GCallSrvCmInterface.c 117 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 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573
/*****************************************************************************
*  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).
*
*****************************************************************************/
/*******************************************************************************
 *  Modification Notice:
 *  --------------------------
 *  This software is modified by MediaTek Inc. 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) 2001
 *
 *******************************************************************************/

 /*******************************************************************************
 * Filename:
 * ---------
 *   GCallSrvCmInterface.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *  GSM / 3G call service
 *  Interfaces for UCM service 
 *
 * 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!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#include "MMI_features.h"
#ifdef __MMI_TELEPHONY_SUPPORT__

#include "Custom_events_notify.h" /* mmi_get_event_based_image, mmi_get_int_event_based_sound */

#include "CphsSrvGprot.h"

#include "Resource_audio.h" /* TONE_BUSY_CALL_GSM */

#include "ProfilesSrvGprot.h" /* srv_prof_get_current_profile_value */

#include "custom_phb_config.h" /* MMI_PHB_NAME_LENGTH */

#include "Mdi_audio.h" /* MDI_AUDIO_SPEECH_APP_ID_ENUM */

#include "UcmSrvGprot.h"
#include "..\UcmSrv\UCMSrvIntProt.h"

#include "GCallSrvProt.h"

#include "MMIDataType.h"
#include "GCallSrvDef.h"
#include "MMI_common_app_trc.h"
#include "DebugInitDef_Int.h"
#include "kal_trace.h"
#include "l3_inc_enums.h"
#include "string.h"
#include "kal_non_specific_general_types.h"
#include "kal_release.h"
#include "MMI_features.h"
#include "mmi_rp_srv_gcall_def.h"
#include "GlobalResDef.h"
#include "csmcc_common_enums.h"
#include "wgui_categories_util.h"
#include "Unicodexdcl.h"
#include "GlobalConstants.h"
#include "PhbSrvGprot.h"
#include "mmi_msg_struct.h"
#include "l4c_aux_struct.h"
#include "mmi_frm_mem_gprot.h"
#include "app_buff_alloc.h"
#include "CustDataRes.h"
#include "mmi_frm_events_gprot.h"
#include "wgui_categories_list.h"
#include "l4c2abm_struct.h"
#include "mmi_cb_mgr_gprot.h"
#include "mmi_frm_utility_gprot.h"
#include "UcmSrvProt.h"

/*****************************************************************************
 * FUNCTION
 *  srv_gcall_is_invalid_call_type
 * DESCRIPTION
 *  check call type
 * PARAMETERS
 *
 * RETURNS
 *  void
 *****************************************************************************/
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)
extern void srv_ucm_int_indication(srv_ucm_call_type_enum call_type, srv_ucm_int_ind_opcode_enum op_code, void *ind_data);
#endif
static MMI_BOOL srv_gcall_is_invalid_call_type(srv_ucm_call_type_enum call_type)
{
    if (srv_gcall_get_interface_with_ucm_call_type(call_type) == MMI_SIM_NONE)
    {
        return MMI_TRUE;
    }
    return MMI_FALSE;
}
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_act_req
 * DESCRIPTION
 *  UCM action request handler
 * PARAMETERS
 *
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_cmhdlr_act_req(srv_ucm_call_type_enum call_type, srv_ucm_int_act_opcode_enum act_op, void *ptr, srv_ucm_int_at_info_struct *at_info, void *user_data, srv_ucm_int_act_rsp_callback_func_ptr rsp_callback)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 result = SRV_GCALL_RESULT_OK;
    srv_gcall_cm_event_enum event = SRV_GCALL_CM_EVENT_INVALID;
    srv_gcall_ucm_info_struct prev_ucm_info;
    mmi_sim_enum interface;
#ifdef WIN32
    srv_ucm_int_at_info_struct *at_info_ext;
#endif
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (srv_gcall_is_invalid_call_type(call_type))
    {
        return;
    }
  #ifdef WIN32
    if(at_info==NULL)
    {
	at_info_ext = (srv_ucm_int_at_info_struct *)OslMalloc(sizeof(srv_ucm_int_at_info_struct));
	memset(at_info_ext,0,sizeof(srv_ucm_int_at_info_struct));
       at_info = at_info_ext;
	OslMfree(at_info_ext);
    }
  #endif
    if (srv_gcall_cntxt_is_locked())
    {
        MMI_ASSERT(srv_gcall_post_act_evt(call_type, act_op, ptr, at_info, user_data, rsp_callback));
        return;
    }
    else
    {
        MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_ACT_REQ, call_type, act_op);

        srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(call_type));

        /* backup ucm_info */
        memcpy(&prev_ucm_info, &(cm_p->ucm_info), sizeof(srv_gcall_ucm_info_struct));
        interface = cm_p->interface;

        /* set call type for dial prmt */
        cm_p->ucm_info.call_type = call_type;

        /* permit check */
        result = srv_gcall_prmt((srv_ucm_int_prmt_opcode_enum)act_op, ptr);

    }

    /* re-assign ucm_info */
    /* if it is not background op (auto reject), overwrite the previous ucm info */
    if (act_op != SRV_UCM_INT_AUTO_REJECT_ACT)
    {
        srv_gcall_reset_ucm_info_except_bg_op();
    }
    cm_p->ucm_info.call_type = call_type;
    if (srv_gcall_util_op_need_rsp(act_op))
    {
        cm_p->ucm_info.op = act_op;
        cm_p->ucm_info.rsp_cb = rsp_callback;
        cm_p->ucm_info.user_data = user_data;
    }

    if (result != SRV_GCALL_RESULT_OK)
    {
        if (srv_gcall_util_op_need_rsp(act_op))
        {
            /* don't send notify_ind to ucm */
            srv_gcall_ucm_error(cm_p->ucm_info.call_type, result);
        }

        /* restore ucm info */
        srv_gcall_cntxt_reset_ptr();
        srv_gcall_cntxt_set_ptr(interface);
        memcpy(&(cm_p->ucm_info), &prev_ucm_info, sizeof(srv_gcall_ucm_info_struct));
        srv_gcall_cntxt_reset_ptr();

        return;
    }

    if ((srv_gcall_util_op_need_rsp(act_op))
        && (prev_ucm_info.op != SRV_UCM_INT_NO_ACT))
    {
        /* overwrite the previous op, ex. end processing calls */
        /* clear the waiting event handlr since the op has been overwritten
         * don't care the rsp since UCM srv guarentees all the processing calls is released
         */
        srv_gcall_reset_ps_event_handler(cm_p->ps_info.rsp_event);
        cm_p->ps_info.rsp_event = 0;
    }
    srv_gcall_set_l4c_source((U8)(at_info->l4c_source));

    /* do action */
    switch (act_op)
    {
        case SRV_UCM_INT_DIAL_ACT:
            switch (((srv_ucm_dial_act_req_struct*)ptr)->module_id)
            {
            #ifdef __SAT__
                case SRV_UCM_MODULE_ORIGIN_SAT:
                    event = SRV_GCALL_CM_EVENT_DIAL_SAT;
                    break;
            #endif /* __SAT__ */

            #ifdef __CCBS_SUPPORT__
                case SRV_UCM_MODULE_ORIGIN_CCBS:
                    if (cm_p->ccbs_info.state == SRV_GCALL_CCBS_STATE_ACCEPTED)
                    {
                        event = SRV_GCALL_CM_EVENT_DIAL_CCBS;
                    }
                    break;
            #endif /* __CCBS_SUPPORT__ */ 

                default:
                    event = SRV_GCALL_CM_EVENT_DIAL_NORMAL;
                    break;
            }
            break;

        case SRV_UCM_INT_ACCEPT_ACT:
            event = SRV_GCALL_CM_EVENT_ACCEPT;
            break;

        case SRV_UCM_INT_HOLD_ACT:
        case SRV_UCM_INT_RETRIEVE_ACT:
        case SRV_UCM_INT_SWAP_ACT:
            event = SRV_GCALL_CM_EVENT_SWAP;
            break;

        case SRV_UCM_INT_CONFERENCE_ACT:
            event = SRV_GCALL_CM_EVENT_CONF;
            break;

        case SRV_UCM_INT_SPLIT_ACT:
            event = SRV_GCALL_CM_EVENT_SPLIT;
            break;

    #ifdef __MMI_UCM_ECT__
        case SRV_UCM_INT_EXPLICIT_CALL_TRANSFER_ACT:
            event = SRV_GCALL_CM_EVENT_ECT;
            break;
    #endif /* __MMI_UCM_ECT__ */

    #ifdef __MMI_UCM_DEFLECT__
        case SRV_UCM_INT_DEFLECT_ACT:
            event = SRV_GCALL_CM_EVENT_DEFLECT;
            break;
    #endif /* __MMI_UCM_DEFLECT__ */

        case SRV_UCM_INT_END_SINGLE_ACT:
            event = SRV_GCALL_CM_EVENT_END_SINGLE;
            break;

        case SRV_UCM_INT_END_CONFERENCE_ACT:
            event = SRV_GCALL_CM_EVENT_END_CONF;

            if (prev_ucm_info.op == SRV_UCM_INT_CONFERENCE_ACT
                || prev_ucm_info.op == SRV_UCM_INT_SPLIT_ACT
                || prev_ucm_info.op == SRV_UCM_INT_HOLD_ACT
                || prev_ucm_info.op == SRV_UCM_INT_RETRIEVE_ACT
                || prev_ucm_info.op == SRV_UCM_INT_SWAP_ACT)
            {
                /* conflict *//* the conf call is active or held? */
                event = SRV_GCALL_CM_EVENT_END_ALL;
            }
            break;

        case SRV_UCM_INT_END_ALL_ACT:
            event = SRV_GCALL_CM_EVENT_END_ALL;
            break;

        case SRV_UCM_INT_FORCE_RELEASE_ACT:
            /* abort the previous op (don't wait for rsp anymore) */
            srv_gcall_reset_ps_event_handler(cm_p->ps_info.rsp_event);
            cm_p->ps_info.rsp_event = 0;

            event = SRV_GCALL_CM_EVENT_FORCE_RELEASE;
            break;

        case SRV_UCM_INT_AUTO_REJECT_ACT:
            cm_p->ucm_info.bg_op = SRV_UCM_INT_AUTO_REJECT_ACT;
            event = SRV_GCALL_CM_EVENT_AUTO_REJECT;
            break;

        case SRV_UCM_INT_START_DTMF_ACT:
            event = SRV_GCALL_CM_EVENT_START_DTMF;
            break;

        case SRV_UCM_INT_STOP_DTMF_ACT:
            event = SRV_GCALL_CM_EVENT_STOP_DTMF;
            break;

    #if (defined(__OP01__) && defined(__MMI_VIDEO_TELEPHONY__))
        case SRV_UCM_INT_VT_FALLTO_VOICE_ACT:
            event = SRV_GCALL_CM_EVENT_VT_FALLTO_VOICE_ACT;
            break;
    #endif /* defined(__OP01__) && defined(__MMI_VIDEO_TELEPHONY__) */

        default:
            break;
    }

    srv_gcall_proc_cm_event(event, ptr);

    srv_gcall_cntxt_reset_ptr();

}

/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_prmt
 * DESCRIPTION
 *  permit function for UCM srv
 * PARAMETERS
 *
 * RETURNS
 *  
 *****************************************************************************/
srv_ucm_result_enum srv_gcall_cmhdlr_prmt(srv_ucm_call_type_enum call_type, srv_ucm_int_prmt_opcode_enum prmt_type, void *ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 gcall_result;
    mmi_sim_enum ori_sim = MMI_SIM_NONE;
    srv_ucm_call_type_enum ori_call_type = SRV_UCM_CALL_TYPE_END_OF_ENUM;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (srv_gcall_is_invalid_call_type(call_type))
    {
        return SRV_UCM_RESULT_UNSPECIFIED_ERROR;
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_PRMT, call_type, prmt_type);

    if (srv_gcall_cntxt_is_locked())
    {
        /* allow permit when cntxt is locked since permit function doesn't modify the context */
        /* backup interface and call type */
        ori_sim = cm_p->interface;
        ori_call_type = cm_p->ucm_info.call_type; /* reuse ucm_info.call_type for call type available and dial permit */
        srv_gcall_cntxt_reset_ptr();
    }

    /* allow bitwised call type */
    /* convert bitwised call type to single call type */
    call_type = srv_gcall_util_get_ucm_single_call_type(call_type);

    srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(call_type));

    cm_p->ucm_info.call_type = call_type; /* reuse ucm_info.call_type for dial permit */
    gcall_result = srv_gcall_prmt(prmt_type, ptr);
    cm_p->ucm_info.call_type = SRV_UCM_CALL_TYPE_END_OF_ENUM;

    srv_gcall_cntxt_reset_ptr();

    if (ori_sim != MMI_SIM_NONE)
    {
        /* restore cntxt */
        srv_gcall_cntxt_set_ptr(ori_sim);
        cm_p->ucm_info.call_type = ori_call_type; /* reuse ucm_info.call_type for call type available and dial permit */
    }

    return srv_gcall_util_get_ucm_result(gcall_result);

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_query
 * DESCRIPTION
 *  function which is called by UCM
 * PARAMETERS
 *
 * RETURNS
 *  
 *****************************************************************************/
MMI_BOOL srv_gcall_cmhdlr_query(srv_ucm_call_type_enum call_type, srv_ucm_int_query_enum query_type, void *ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    MMI_BOOL result = MMI_FALSE;
    mmi_sim_enum ori_sim = MMI_SIM_NONE;
    srv_ucm_call_type_enum ori_call_type = SRV_UCM_CALL_TYPE_END_OF_ENUM;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (srv_gcall_is_invalid_call_type(call_type))
    {
        return MMI_FALSE;
    }

    if (srv_gcall_cntxt_is_locked())
    {
        /* allow query when cntxt is locked since query function doesn't modify the context */
        /* backup interface and call type */
        ori_sim = cm_p->interface;
        ori_call_type = cm_p->ucm_info.call_type; /* reuse ucm_info.call_type for call type available */
        srv_gcall_cntxt_reset_ptr();
    }

    srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(call_type));

    cm_p->ucm_info.call_type = call_type; /* reuse ucm_info.call_type for call type available */

    if (cm_p->interface != MMI_SIM_NONE)
    {
        switch (query_type)
        {
            case SRV_UCM_INT_NUMBER:
                result = srv_gcall_util_is_valid_number(cm_p->interface, 
                            ((srv_ucm_int_query_number_struct*)ptr)->num_uri,
                            (((srv_ucm_int_query_number_struct*)ptr)->module == SRV_UCM_MODULE_ORIGIN_SAT) ? SRV_GCALL_DIR_MO_STK : SRV_GCALL_DIR_MO);
                break;

            case SRV_UCM_INT_ECC_NUMBER:
                result = srv_gcall_util_is_valid_ecc(cm_p->interface, 
                            ((srv_ucm_int_query_number_struct*)ptr)->num_uri,
                            (((srv_ucm_int_query_number_struct*)ptr)->module == SRV_UCM_MODULE_ORIGIN_SAT) ? SRV_GCALL_DIR_MO_STK : SRV_GCALL_DIR_MO);
                break;

            case SRV_UCM_INT_DTMF_DIGIT:
                result = srv_gcall_util_is_valid_dtmf(((srv_ucm_dtmf_struct*)ptr)->digit);
                break;

            case SRV_UCM_INT_CALL_SRV_AVAILABLE:
                result = srv_gcall_util_type_available(call_type, MMI_TRUE);
                break;

            case SRV_UCM_INT_CALL_SRV_TMP_UNAVAILABLE:
                result = srv_gcall_is_tmp_not_available();
                break;

            case SRV_UCM_INT_CALLER_RES:
                result = srv_gcall_get_caller_res_info(ptr);
                break;

            default:
                break;
        }
    }

    cm_p->ucm_info.call_type = SRV_UCM_CALL_TYPE_END_OF_ENUM;

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_QUERY, call_type, query_type, result);

    srv_gcall_cntxt_reset_ptr();

    if (ori_sim != MMI_SIM_NONE)
    {
        /* restore cntxt */
        srv_gcall_cntxt_set_ptr(ori_sim);
        cm_p->ucm_info.call_type = ori_call_type; /* reuse ucm_info.call_type for call type available */
    }

    return result;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_cnf
 * DESCRIPTION
 *  
 * PARAMETERS
 *  call_type
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_cmhdlr_cnf(srv_ucm_call_type_enum call_type, srv_ucm_int_cnf_opcode_enum cnf_type, void *ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (srv_gcall_cntxt_is_locked())
    {
        if (!srv_gcall_post_cnf_evt(call_type, cnf_type, ptr, srv_gcall_cmhdlr_cnf))
        {
            /* the result code is reserved */
        }
        return;
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF, call_type, cnf_type);

    srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(call_type));

    switch (cnf_type)
    {
        case SRV_UCM_INT_QUERY_CNF:
            break;

        case SRV_UCM_INT_DIAL_CNF:
            srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_DIAL_CNF, ptr);
            break;

        case SRV_UCM_INT_CALL_PRESENT_CNF:
            srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_MT_PRESENT_CNF, ptr);
            break;

        default:
            /* ignore */
            break;    
    }

    srv_gcall_cntxt_reset_ptr();

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_cnf_auto_dtmf
 * DESCRIPTION
 *  This function is called by the state machine function
 *  to dial CCBS call
 * PARAMETERS
 *  info            [?]         
 *  any(?)          [IN]        Information associated with ccbs
 *  result(?)       [OUT]       Of execution of function which may be success or failure
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_cmhdlr_cnf_auto_dtmf(srv_ucm_call_type_enum ucm_call_type, srv_ucm_int_cnf_opcode_enum cnf_type, void *ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_query_cnf_struct *cnf = (srv_ucm_int_query_cnf_struct*)ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    MMI_ASSERT(cnf_type == SRV_UCM_INT_QUERY_CNF);

    if (srv_gcall_cntxt_is_locked())
    {
        if (!srv_gcall_post_cnf_evt(ucm_call_type, cnf_type, ptr, srv_gcall_cmhdlr_cnf_auto_dtmf))
        {
            /* the result code is reserved */
        }
        return;
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF_AUTO_DTMF, ucm_call_type);

    srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(ucm_call_type));

    if (cm_p->auto_dtmf_info.call_id == SRV_GCALL_INVALID_ID)
    {
        /* ignore, normal case. 
         * The user presses the key almost at the same time as the call is released.
         *     (release_ind is handled before the key event))
         */
        MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF_AUTO_DTMF_IGNORE);
        srv_gcall_cntxt_reset_ptr();
        return;
    }

    if (cnf->result != SRV_UCM_QUERY_CNF_YES)
    {
        srv_gcall_reset_auto_dtmf_info();
    }
    else
    {
        srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_AUTO_DTMF, NULL);
    }

    srv_gcall_cntxt_reset_ptr();
}

#ifdef __MMI_CALLSET_AUTO_REDIAL__
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_abort_auto_redial
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_cmhdlr_abort_auto_redial(mmi_sim_enum sim)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_sim_enum ori_sim = MMI_SIM_NONE;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    MMI_ASSERT(sim);

    if (cm_p)
    {
        ori_sim = cm_p->interface;
        srv_gcall_cntxt_reset_ptr();
    }

    srv_gcall_cntxt_set_ptr(sim);
    srv_gcall_reset_redial_info();
    srv_gcall_cntxt_reset_ptr();

    if (ori_sim != MMI_SIM_NONE)
    {
        srv_gcall_cntxt_set_ptr(ori_sim);
    }
}
#endif /* __MMI_CALLSET_AUTO_REDIAL__ */

#ifdef __CCBS_SUPPORT__
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_cnf_ccbs_recall
 * DESCRIPTION
 *  This function is called by the state machine function
 *  to dial CCBS call
 * PARAMETERS
 *  info            [?]         
 *  any(?)          [IN]        Information associated with ccbs
 *  result(?)       [OUT]       Of execution of function which may be success or failure
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_cmhdlr_cnf_ccbs_recall(srv_ucm_call_type_enum ucm_call_type, srv_ucm_int_cnf_opcode_enum cnf_type, void *ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_query_cnf_struct *cnf = (srv_ucm_int_query_cnf_struct*)ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    MMI_ASSERT(cnf_type == SRV_UCM_INT_QUERY_CNF);

    if (srv_gcall_cntxt_is_locked())
    {
        if (!srv_gcall_post_cnf_evt(ucm_call_type, cnf_type, ptr, srv_gcall_cmhdlr_cnf_ccbs_recall))
        {
            /* the result code is reserved */
        }
        return;
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF_CCBS_RECALL, ucm_call_type);

    srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(ucm_call_type));

    if (cm_p->ccbs_info.state != SRV_GCALL_CCBS_STATE_RECALL)
    {
        /* ignore, normal case. 
         * The user presses the key almost at the same time as the ccbs recall is released.
         *     (release_ind is handled before the key event))
         */
        MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF_CCBS_RECALL_IGNORE, cm_p->ccbs_info.state);
        srv_gcall_cntxt_reset_ptr();
        return;
    }

    if (cnf->result != SRV_UCM_QUERY_CNF_YES)
    {
        srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_CCBS_RECALL_REJECT, NULL);
    }
    else
    {
        srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_CCBS_RECALL_ACCEPT, NULL);
    }

    srv_gcall_cntxt_reset_ptr();
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_cmhdlr_cnf_ccbs_activate
 * DESCRIPTION
 *  This function is called by the state machine function
 *  to dial CCBS call
 * PARAMETERS
 *  info            [?]         
 *  any(?)          [IN]        Information associated with ccbs
 *  result(?)       [OUT]       Of execution of function which may be success or failure
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_cmhdlr_cnf_ccbs_activate(srv_ucm_call_type_enum ucm_call_type, srv_ucm_int_cnf_opcode_enum cnf_type, void *ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_query_cnf_struct *cnf = (srv_ucm_int_query_cnf_struct*)ptr;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    MMI_ASSERT(cnf_type == SRV_UCM_INT_QUERY_CNF);

    if (srv_gcall_cntxt_is_locked())
    {
        if (!srv_gcall_post_cnf_evt(ucm_call_type, cnf_type, ptr, srv_gcall_cmhdlr_cnf_ccbs_activate))
        {
            /* the result code is reserved */
        }
        return;
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF_CCBS_ACTIVATE, ucm_call_type);

    srv_gcall_cntxt_set_ptr(srv_gcall_get_interface_with_ucm_call_type(ucm_call_type));

    if (cm_p->ccbs_info.state != SRV_GCALL_CCBS_STATE_ACTIVATE_CNF)
    {
        /* ignore, normal case. 
         * The user presses the key almost at the same time as the call is released.
         *     (release_ind is handled before the key event))
         */
        MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_CMHDLR_CNF_CCBS_ACTIVATE_IGNORE, cm_p->ccbs_info.state);
        srv_gcall_cntxt_reset_ptr();
        return;
    }

    if (cnf->result != SRV_UCM_QUERY_CNF_YES)
    {
        srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_CCBS_IGNORE, NULL);
    }
    else
    {
        srv_gcall_proc_cm_event(SRV_GCALL_CM_EVENT_CCBS_ACTIVATE, NULL);
    }

    srv_gcall_cntxt_reset_ptr();

}

#endif /* __CCBS_SUPPORT__ */



/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_error
 * DESCRIPTION
 *  deside tone_id and error_cause; send rsp to UCM according to ucm_op
 *  error response or notification
 * PARAMETERS
 *  cause       [IN]        
 *  call_type   [IN]    may need different info for different call_type
 * RETURNS
 *  pBOOL(?)
 *****************************************************************************/
void srv_gcall_ucm_error(srv_ucm_call_type_enum ucm_call_type, U16 result)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 msg_id = STR_ID_GCALL_OP_FAIL;
    U16 img_id = IMG_GLOBAL_FAIL;
    U16 tone_id = ERROR_TONE_IN_CALL;
    srv_gcall_type_enum call_type = srv_gcall_util_get_internal_call_type(ucm_call_type);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

#ifdef __MMI_UCM_DETAIL_ERROR_MSG__
    switch (result)
    {
        case SRV_GCALL_RESULT_UNASSIGNED_NUM:
            tone_id = NUM_UNOBTAIN_TONE;
        case SRV_GCALL_RESULT_INVALID_NUMBER_FORMAT:
            msg_id = STR_ID_GCALL_UNRECOGNIZED_NUMBER;
            break;

        case SRV_GCALL_RESULT_SWITCH_EQUIPMENT_CONGESTION:
            tone_id = CONGESTION_TONE;
            break;

        case SRV_GCALL_RESULT_CALL_REJECTED:
            tone_id= AUTH_FAIL_TONE;
            break;

        case SRV_GCALL_RESULT_CHANNEL_UN_ACCP:
        case SRV_GCALL_RESULT_NETWORK_OUT_OF_ORDER:
        case SRV_GCALL_RESULT_QOS_UNAVAIL:
        case SRV_GCALL_RESULT_INVALID_TRANSIT_NW_SEL:
        case SRV_GCALL_RESULT_CSMCC_NO_RESPONSE_FROM_NW:
        case SRV_GCALL_RESULT_NETWORK_FAILURE:
    #if !(defined(__OP01__) && defined(__MMI_VIDEO_TELEPHONY__))
        case SRV_GCALL_RESULT_CM_MM_RR_CONN_RELEASE:
    #endif /* !(defined(__OP01__) && defined(__MMI_VIDEO_TELEPHONY__)) */
        case SRV_GCALL_RESULT_IMSI_UNKNOWN_IN_VLR:
            msg_id = STR_ID_GCALL_NETWORK_FAIL;
            break;

        case SRV_GCALL_RESULT_ACCESS_CLASS_BARRED:
        case SRV_GCALL_RESULT_CM_MM_ACCESS_BARRED:
            msg_id = STR_ID_GCALL_BUSY_NETWORK_TRY_LATER;
            break;

        case SRV_GCALL_RESULT_USER_BUSY:
            /* voice call shows user busy, csd call shows network busy */
            if (call_type == CSMCC_VOICE_CALL)
            {
                msg_id = STR_ID_GCALL_USER_BUSY;
                tone_id = TONE_BUSY_CALL_GSM;
            }
            else
            {
                msg_id = STR_ID_GCALL_NETWORK_BUSY;
            }
            break;

        case SRV_GCALL_RESULT_NO_CIRCUIT_CHANNEL_AVAIL:
        case SRV_GCALL_RESULT_REQUESTED_CKT_CHANEL_NOT_AVIL:
        case SRV_GCALL_RESULT_RESOURCE_UNAVAIL_UNSPECIFIED:
            msg_id = STR_ID_GCALL_NETWORK_BUSY;
            break;

        case SRV_GCALL_RESULT_NO_USER_RESPONDING:
            msg_id = STR_ID_GCALL_NOT_RESPONDING;
            break;

        case SRV_GCALL_RESULT_NO_ANSWER_ON_ALERT:
            msg_id = STR_ID_GCALL_NO_ANSWER;
            break;

        case SRV_GCALL_RESULT_ACM_EXCEEDED:
            msg_id = STR_ID_GCALL_ACM_EXCEEDED;
            break;

        case SRV_GCALL_RESULT_REQ_FACILITY_UNAVAIL:
        case SRV_GCALL_RESULT_IE_NOT_IMPLEMENTED:
        case SRV_GCALL_RESULT_CONDITIONAL_MM_IE_ERROR:
        case SRV_GCALL_RESULT_CM_MM_ASSIGNMENT_REJECT:
            msg_id = STR_ID_GCALL_UNAVAILABLE;
            break;

        case SRV_GCALL_RESULT_CSMCC_ILLEGAL_DTMF_TONE:
        case SRV_GCALL_RESULT_CSMCC_CALL_ACCEPT_NOT_ALLOW:
        case SRV_GCALL_RESULT_MS_ID_NOT_DERIVED_BY_NW:
        case SRV_GCALL_RESULT_IMPLICIT_DETACH:
        case SRV_GCALL_RESULT_MSG_NOT_COMPAT_WITH_PROTO_STATE:
        case SRV_GCALL_RESULT_PROTO_ERROR_UNSPECIFIED:
            msg_id = STR_ID_GCALL_UNEXPECTED_ERROR;
            break;
/*
        case SRV_GCALL_RESULT_IMEI_NOT_ACCEPTED:
            msg_id = STR_ID_GCALL_IMEI_ERROR;
            break;
*/
        case SRV_GCALL_RESULT_GPRS_NOT_ALLOWED:
        case SRV_GCALL_RESULT_GPRS_NON_GPRS_NOT_ALLOWED:
            msg_id = STR_ID_GCALL_GPRS_NOT_ALLOWED;
            break;

        case SRV_GCALL_RESULT_MT_DATA_CALL_FAIL:
            msg_id = STR_ID_GCALL_MT_DATA_CALL_FAIL;
            break;

        case SRV_GCALL_RESULT_REQ_FAC_NOT_SUBS:
        case SRV_GCALL_RESULT_PLMN_NOT_ALLOWED:
        case SRV_GCALL_RESULT_LOCATION_AREA_NOT_ALLOWED:
        case SRV_GCALL_RESULT_ROAMING_AREA_NOT_ALLOWED:
        case SRV_GCALL_RESULT_GPRS_NOT_ALLOWED_IN_PLMN:
        case SRV_GCALL_RESULT_NO_SUITABLE_CELLS_IN_LA:
        case SRV_GCALL_RESULT_MSC_TEMP_NOT_REACHABLE:
        case SRV_GCALL_RESULT_CM_MM_ABORT_BY_NW:
        case SRV_GCALL_RESULT_BEARER_CAP_NOT_AUTHORISED:
        case SRV_GCALL_RESULT_SERV_OPTION_TEMP_OUT_OF_ORDER:
            msg_id = STR_ID_GCALL_NETWORK_NOT_ALLOWED;
            break;

        case SRV_GCALL_RESULT_CSMCC_CMD_NOT_ALLOW:
        case SRV_GCALL_RESULT_SERV_OPTION_NOT_SUPPORTED:
        case SRV_GCALL_RESULT_REQ_SERV_OPTION_NOT_SUBSCRIBED:
        case SRV_GCALL_RESULT_CALL_CANNOT_BE_IDENTIFIED:
            msg_id = STR_ID_GCALL_COMMAND_NOT_SUPPORTED;
            break;

        case SRV_GCALL_RESULT_NO_PDP_CONTEXT_ACTIVATED:
        case SRV_GCALL_RESULT_SEMANTICALLY_INCORRECT_MSG:
        case SRV_GCALL_RESULT_INVALID_MM_MAND_INFO:
            msg_id = STR_ID_GCALL_DATA_ERROR;
            break;

        case SRV_GCALL_RESULT_MSG_TYPE_NON_EXISTENT:
        case SRV_GCALL_RESULT_MSG_TYPE_INCOMPAT_WITH_PROTO_STATE:
            msg_id = STR_ID_GCALL_MESSAGE_TYPE_ERROR;
            break;

        case SRV_GCALL_RESULT_CM_MM_RANDOM_ACCES_FAILURE:
            msg_id = STR_ID_GCALL_ACCESS_FAIL;
            break;

        case SRV_GCALL_RESULT_CM_MM_CONN_TIMEOUT:
            msg_id = STR_ID_GCALL_TIMER_EXPIRED;
            break;

        case SRV_GCALL_RESULT_L4C_FDN_FAIL:
            msg_id = STR_ID_GCALL_FDN_FAIL;
            break;

        case SRV_GCALL_RESULT_L4C_LOCAL_DISCONNECT_CSD:
            msg_id = STR_ID_GCALL_CSD_DISCONNECTING;
            break;

        case SRV_GCALL_RESULT_DISALLOW_MORE_CALL:
            msg_id = STR_ID_GCALL_INVALID_COMMAND;
            break;

        default:
            break;
    }   /* End of Switch */
#else /* __MMI_UCM_DETAIL_ERROR_MSG__ */
    switch (result)
    {
        case SRV_GCALL_RESULT_L4C_FDN_FAIL:
            msg_id = STR_ID_GCALL_FDN_FAIL;
            break;

        default:
            break;
    }   /* End of Switch */
#endif /* __MMI_UCM_DETAIL_ERROR_MSG__ */

    switch (cm_p->ucm_info.op)
    {
        case SRV_UCM_INT_DIAL_ACT:
            if (call_type != CSMCC_CSD_CALL)
            {
                srv_gcall_ucm_dial_rsp(result, (PU8)get_string(msg_id));
            }
            else
            {
                srv_gcall_ucm_dial_ind(result, (PU8)get_string(msg_id));
            }
            break;
            
        case SRV_UCM_INT_NO_ACT:
            srv_gcall_ucm_notify_ind(call_type, (PU8)get_string(msg_id), img_id, tone_id);
            break;
            
        default:
            srv_gcall_ucm_act_rsp(result, (PU8)get_string(msg_id));
            break;
    }
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_dial_rsp
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_dial_rsp(U16 result, U8 *error_msg)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_dial_act_rsp_struct rsp;
    srv_gcall_call_info_struct *call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_STATE, (U8)SRV_GCALL_STATE_OUTGOING);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&rsp, 0, sizeof(srv_ucm_int_dial_act_rsp_struct));

    /* call list */
    rsp.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    /* Be sure to clear outgoing call info before ucm_dial_rsp */
    srv_gcall_get_ucm_call_list(rsp.call_list);

    rsp.result_info.result = srv_gcall_util_get_ucm_result(result);
    if (error_msg)
    {
        mmi_ucs2ncpy((CHAR *)rsp.result_info.error_msg, (CHAR *)error_msg, SRV_UCM_MAX_ERR_MSG_LEN);
    }

    if ((result == SRV_GCALL_RESULT_OK)
        && (call_info))
    {
        /* uid info */
        rsp.uid_info.call_id = call_info->call_id;
        rsp.uid_info.group_id = call_info->group_id;
        rsp.uid_info.call_type = cm_p->ucm_info.call_type;

        /* remote info */
        strncpy((CHAR *)rsp.remote_info.num_uri,
            (CHAR *)call_info->num2,
            SRV_UCM_MAX_NUM_URI_LEN);

        srv_gcall_derive_display_name(call_info, (PU8)rsp.remote_info.disp_name, SRV_UCM_MAX_DISP_NAME_LEN);
        mmi_ucs2ncpy((CHAR *)rsp.remote_info.log_name, (CHAR *)srv_gcall_get_call_log_name(call_info), MMI_PHB_NAME_LENGTH);

        srv_gcall_set_remote_line_icon(call_info, &rsp.remote_info);

    #ifdef __MMI_UCM_NUMBER_TYPE__
        rsp.remote_info.number_type = call_info->number_type;
        rsp.remote_info.num_type_icon = srv_gcall_derive_number_type_icon(call_info->number_type);
    #endif /* __MMI_UCM_NUMBER_TYPE__ */

        rsp.remote_info.phb_id = cm_p->phb_data.phb_id;

        /* display info */
        /* Not allow caller video for outgoing call */
                    
    #ifdef __IP_NUMBER__
        if (cm_p->mo.is_ip_dial)
        {
            srv_gcall_util_get_curr_ip_number_ucs2(cm_p->interface, (WCHAR*)(rsp.display_info.ip_num));
        }
    #endif /* __IP_NUMBER__ */ 
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_DIAL_RSP_INFO,
        rsp.result_info.result, 
        rsp.remote_info.num_uri[0], rsp.remote_info.num_uri[1], rsp.remote_info.num_uri[2],
        rsp.remote_info.num_uri[3], rsp.remote_info.num_uri[4]);

    (*(cm_p->ucm_info.rsp_cb))(rsp.uid_info.call_type, SRV_UCM_INT_DIAL_ACT, &rsp, cm_p->ucm_info.user_data);

    srv_gcall_reset_ucm_info_except_bg_op();
    
    srv_ucm_int_mfree(rsp.call_list);

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_act_rsp
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_act_rsp(U16 result, U8 *error_msg)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_act_rsp_struct rsp;
#ifdef __MMI_VIDEO_TELEPHONY__
    srv_gcall_call_info_struct *call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_STATE, (U8)SRV_GCALL_STATE_ACTIVE);
#endif /* __MMI_VIDEO_TELEPHONY__ */
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    MMI_ASSERT(cm_p->ucm_info.op != SRV_UCM_INT_NO_ACT);

    memset(&rsp, 0, sizeof(srv_ucm_int_act_rsp_struct));

    rsp.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(rsp.call_list);

    rsp.result_info.result = srv_gcall_util_get_ucm_result(result);
    if (error_msg)
    {
        mmi_ucs2ncpy((CHAR *)rsp.result_info.error_msg, (CHAR *)error_msg, SRV_UCM_MAX_ERR_MSG_LEN);
    }

#ifdef __MMI_VIDEO_TELEPHONY__
    /* Turn on speech */
    if (call_info && call_info->call_type == CSMCC_VIDEO_CALL)
    {
        rsp.no_counter = MMI_TRUE;
    }
#endif /* __MMI_VIDEO_TELEPHONY__ */

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_ACT_RSP_INFO,
    cm_p->ucm_info.op,
    rsp.result_info.result);

    (*(cm_p->ucm_info.rsp_cb))(cm_p->ucm_info.call_type, cm_p->ucm_info.op, (void*)&rsp, cm_p->ucm_info.user_data);

    srv_gcall_reset_ucm_info_except_bg_op();

    srv_ucm_int_mfree(rsp.call_list);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_call_present_cnf_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_call_present_cnf_ind(void *info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_cc_call_present_ind_struct *msg = (mmi_cc_call_present_ind_struct*)info;
    srv_ucm_int_call_present_cnf_ind_struct cnf_ind;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&cnf_ind, 0, sizeof(srv_ucm_int_call_present_cnf_ind_struct));

    /* uid info */
    srv_gcall_set_uid_info(&cnf_ind.uid_info, msg->call_id, SRV_UCM_INVALID_ID, (srv_gcall_type_enum)msg->call_type);

    strncpy((CHAR *)cnf_ind.num_uri, (CHAR *)msg->num.number, SRV_UCM_MAX_NUM_URI_LEN);

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_CALL_PRESENT_CNF_IND_INFO,
    msg->call_id,
    msg->call_type,
    msg->num.number[0], msg->num.number[1], msg->num.number[2],
    msg->num.number[3], msg->num.number[4]);

	srv_ucm_call_present_cnf_ind(cnf_ind.uid_info.call_type, (void*)&cnf_ind, srv_gcall_cmhdlr_cnf);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_ring_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_ring_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_ring_ind_struct ring_ind;
    srv_gcall_call_info_struct *call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_STATE, (U8)SRV_GCALL_STATE_INCOMING);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    MMI_ASSERT(call_info);

    memset(&ring_ind, 0, sizeof(srv_ucm_int_ring_ind_struct));

    /* uid info */
    srv_gcall_set_uid_info(&ring_ind.uid_info, call_info->call_id, call_info->group_id, call_info->call_type);
    
    /* at info */
    ring_ind.at_info.l4c_type = call_info->call_type;
    memcpy(&ring_ind.at_info.l4c_number, &cm_p->mt.l4c_number, sizeof(l4c_number_struct));

    /* display info */
    ring_ind.display_info.alert_type = cm_p->mt.alert_type;
    ring_ind.display_info.light_id = cm_p->mt.backlight_pattern_id;

    /* remote info*/
    srv_gcall_derive_display_name(call_info, (PU8)ring_ind.remote_info.disp_name, SRV_UCM_MAX_DISP_NAME_LEN);
#ifdef __MMI_UCM_DISPLAY_CAUSE_OF_NO_CLI__
    if (cm_p->mt.no_cli_cuase != CSMCC_INVALID_NO_CLI_CAUSE)
    {
        U8 length = (SRV_UCM_MAX_DISP_NAME_LEN - mmi_ucs2strlen((CHAR *)ring_ind.remote_info.disp_name)) * ENCODING_LENGTH;
        PU8 no_cli_msg = NULL;

        no_cli_msg = OslMalloc(length);
        memset(no_cli_msg, 0, length);
        srv_gcall_util_get_no_cli_display_text(cm_p->mt.no_cli_cuase, no_cli_msg);
        mmi_ucs2cat((CHAR *)ring_ind.remote_info.disp_name, GetString(STR_ID_GCALL_LEFT_PARENTHESIS));
        mmi_ucs2ncat((CHAR *)ring_ind.remote_info.disp_name, (CHAR *)no_cli_msg, mmi_ucs2strlen((CHAR *)no_cli_msg));
        mmi_ucs2cat((CHAR *)ring_ind.remote_info.disp_name, GetString(STR_ID_GCALL_RIGHT_PARENTHESIS));
        OslMfree(no_cli_msg);
    }
#endif /* __MMI_UCM_DISPLAY_CAUSE_OF_NO_CLI__ */

    mmi_ucs2ncpy((CHAR *)ring_ind.remote_info.log_name, (CHAR *)srv_gcall_get_call_log_name(call_info), MMI_PHB_NAME_LENGTH);
    strncpy((CHAR *)ring_ind.remote_info.num_uri, (CHAR *)srv_gcall_get_call_log_number(call_info), SRV_UCM_MAX_NUM_URI_LEN);

    srv_gcall_set_remote_line_icon(call_info, &ring_ind.remote_info);

#ifdef __MMI_UCM_NUMBER_TYPE__
    ring_ind.remote_info.number_type = call_info->number_type;
    ring_ind.remote_info.num_type_icon = srv_gcall_derive_number_type_icon(call_info->number_type);
#endif /* __MMI_UCM_NUMBER_TYPE__ */

    ring_ind.remote_info.phb_id = cm_p->phb_data.phb_id;

    /*call list*/
    ring_ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(ring_ind.call_list);

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_RING_IND_REMOTE_INFO,
        call_info->call_id,
        ring_ind.remote_info.disp_name[0], ring_ind.remote_info.disp_name[1],
        ring_ind.remote_info.disp_name[2], ring_ind.remote_info.disp_name[3],
        ring_ind.remote_info.disp_name[4],
        ring_ind.remote_info.log_name[0], ring_ind.remote_info.log_name[1],
        ring_ind.remote_info.log_name[2], ring_ind.remote_info.log_name[3], 
        ring_ind.remote_info.log_name[4],
        ring_ind.remote_info.num_uri[0], ring_ind.remote_info.num_uri[1],
        ring_ind.remote_info.num_uri[2], ring_ind.remote_info.num_uri[3],
        ring_ind.remote_info.num_uri[4]);
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
		srv_ucm_int_indication(ring_ind.uid_info.call_type, SRV_UCM_INT_RING_IND, (void*)&ring_ind);
#else
		srv_ucm_ring_ind((void*)&ring_ind);
#endif
    srv_ucm_int_mfree(ring_ind.call_list);

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_dial_cnf_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_dial_cnf_ind(srv_gcall_type_enum call_type, U8* number)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_dial_cnf_ind_struct cnf_ind;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&cnf_ind, 0, sizeof(srv_ucm_int_dial_cnf_ind_struct));

    strncpy((CHAR *)cnf_ind.num_uri, (CHAR *)number, SRV_UCM_MAX_NUM_URI_LEN);

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_DIAL_CNF_IND, 
        cnf_ind.num_uri[0], cnf_ind.num_uri[1], cnf_ind.num_uri[2],
        cnf_ind.num_uri[3], cnf_ind.num_uri[4]);

	srv_ucm_dial_cnf_ind(srv_gcall_get_ucm_call_type(call_type), (void*)&cnf_ind, srv_gcall_cmhdlr_cnf);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_dial_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_dial_ind(U16 result, U8 *error_msg)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_dial_ind_struct ind;
    srv_gcall_call_info_struct *call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_STATE, (U8)SRV_GCALL_STATE_OUTGOING);

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    /* similar procedure as ucm_dial_rsp */

    memset(&ind, 0, sizeof(srv_ucm_int_dial_ind_struct));

    /* result info */
    ind.result_info.result = srv_gcall_util_get_ucm_result(result);
    if (error_msg)
    {
        mmi_ucs2ncpy((CHAR *)ind.result_info.error_msg, (CHAR *)error_msg, SRV_UCM_MAX_ERR_MSG_LEN);
    }

    /* call list */
    ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(ind.call_list);
    
    if ((result == SRV_GCALL_RESULT_OK)
        && (call_info))
    {
        /* uid info */
        srv_gcall_set_uid_info(&ind.uid_info, call_info->call_id, call_info->group_id, call_info->call_type);

        /* remote info */
        strncpy((CHAR *)ind.remote_info.num_uri,
            (CHAR *)call_info->num2,
            SRV_UCM_MAX_NUM_URI_LEN);

        srv_gcall_derive_display_name(call_info, (PU8)ind.remote_info.disp_name, SRV_UCM_MAX_DISP_NAME_LEN);
        mmi_ucs2ncpy((CHAR *)ind.remote_info.log_name, (CHAR *)srv_gcall_get_call_log_name(call_info), MMI_PHB_NAME_LENGTH);

        srv_gcall_set_remote_line_icon(call_info, &ind.remote_info);

    #ifdef __MMI_UCM_NUMBER_TYPE__
        ind.remote_info.number_type = call_info->number_type;
        ind.remote_info.num_type_icon = srv_gcall_derive_number_type_icon(call_info->number_type);
    #endif /* __MMI_UCM_NUMBER_TYPE__ */

        ind.remote_info.phb_id = cm_p->phb_data.phb_id;

        /* display info */
    #ifdef __IP_NUMBER__
        if (cm_p->mo.is_ip_dial)
        {
            srv_gcall_util_get_curr_ip_number_ucs2(cm_p->interface, (WCHAR*)ind.display_info.ip_num);
        }
    #endif /* __IP_NUMBER__ */ 
    }

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_DIAL_IND,
        ind.result_info.result,
        ind.remote_info.disp_name[0], ind.remote_info.disp_name[1],
        ind.remote_info.disp_name[2], ind.remote_info.disp_name[3],
        ind.remote_info.disp_name[4],
        ind.remote_info.log_name[0], ind.remote_info.log_name[1],
        ind.remote_info.log_name[2], ind.remote_info.log_name[3], 
        ind.remote_info.log_name[4],
        ind.remote_info.num_uri[0], ind.remote_info.num_uri[1],
        ind.remote_info.num_uri[2], ind.remote_info.num_uri[3],
        ind.remote_info.num_uri[4]);
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
		srv_ucm_int_indication(ind.uid_info.call_type, SRV_UCM_INT_DIAL_IND, (void*)&ind);
#else
		srv_ucm_dial_ind((void*)&ind);
#endif    
    srv_gcall_reset_ucm_info_except_bg_op();

    srv_ucm_int_mfree(ind.call_list);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_notify_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_notify_ind(srv_gcall_type_enum call_type, PU8 error_msg, U16 image_id, U16 tone_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_notify_ind_struct notify;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&notify, 0, sizeof(srv_ucm_int_notify_ind_struct));

    notify.call_type = srv_gcall_get_ucm_call_type(call_type);

    /*display*/
    if (image_id)
    {
        /* error */
        notify.image_id = image_id;
        notify.tone_id = tone_id;
    }
    else
    {
        /* information */
        notify.image_id = mmi_get_event_based_image(MMI_EVENT_INFO);
        notify.tone_id = (U16)mmi_get_event_based_sound(MMI_EVENT_INFO);
    }

    if (error_msg)
    {
        mmi_ucs2ncpy((CHAR *)notify.disp_msg, (CHAR *)error_msg, SRV_UCM_MAX_DISP_MSG_LEN);
    }

    /*call list*/
    notify.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(notify.call_list);

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_NOTIFY_IND);
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
		srv_ucm_int_indication(notify.call_type, SRV_UCM_INT_NOTIFY_IND, &notify);
#else
		srv_ucm_notify_ind((void*)&notify);
#endif
    srv_ucm_int_mfree(notify.call_list);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_connect_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_connect_ind(srv_gcall_call_info_struct *call_info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_connect_ind_struct ind;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&ind, 0, sizeof(srv_ucm_int_connect_ind_struct));

    /*uid info*/
    srv_gcall_set_uid_info(&ind.uid_info, call_info->call_id, call_info->group_id, call_info->call_type);

    /*remote info*/
    srv_gcall_derive_display_name(call_info, (PU8)ind.remote_info.disp_name, SRV_UCM_MAX_DISP_NAME_LEN);    
    mmi_ucs2ncpy((CHAR *)ind.remote_info.log_name, (CHAR *)srv_gcall_get_call_log_name(call_info), MMI_PHB_NAME_LENGTH);
    strncpy((CHAR *)ind.remote_info.num_uri, (CHAR *)srv_gcall_get_call_log_number(call_info), SRV_UCM_MAX_NUM_URI_LEN);

    srv_gcall_set_remote_line_icon(call_info, &ind.remote_info);

#ifdef __MMI_UCM_NUMBER_TYPE__
    ind.remote_info.number_type = call_info->number_type;
    ind.remote_info.num_type_icon = srv_gcall_derive_number_type_icon(call_info->number_type);
#endif /* __MMI_UCM_NUMBER_TYPE__ */

    ind.remote_info.phb_id = cm_p->phb_data.phb_id;

    /*call list*/
    ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(ind.call_list);

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_UCM_CONNECT_IND,
        call_info->call_id,
        ind.remote_info.disp_name[0], ind.remote_info.disp_name[1],
        ind.remote_info.disp_name[2], ind.remote_info.disp_name[3],
        ind.remote_info.disp_name[4],
        ind.remote_info.log_name[0], ind.remote_info.log_name[1],
        ind.remote_info.log_name[2], ind.remote_info.log_name[3], 
        ind.remote_info.log_name[4],
        ind.remote_info.num_uri[0], ind.remote_info.num_uri[1],
        ind.remote_info.num_uri[2], ind.remote_info.num_uri[3],
        ind.remote_info.num_uri[4]);

#ifdef __MMI_VIDEO_TELEPHONY__
    /* Turn on speech */
    if (call_info->call_type == CSMCC_VIDEO_CALL)
    {
        srv_gcall_ucm_speech_ind(MMI_TRUE, (U8)MDI_AUDIO_SPEECH_APP_ID_3G324M, CSMCC_VIDEO_CALL);
        ind.no_counter = MMI_TRUE;
    }
#endif /* __MMI_VIDEO_TELEPHONY__ */
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
		srv_ucm_int_indication(ind.uid_info.call_type, SRV_UCM_INT_CONNECT_IND, &ind);
#else
		srv_ucm_connect_ind((void*)&ind);
#endif
    srv_ucm_int_mfree(ind.call_list);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_speech_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_speech_ind(MMI_BOOL turn_on, U8 rat, srv_gcall_type_enum call_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_speech_ind_struct speech_ind;
    srv_ucm_int_session_ind_struct session_ind;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&speech_ind, 0, sizeof(srv_ucm_int_speech_ind_struct));
    memset(&session_ind, 0, sizeof(srv_ucm_int_session_ind_struct));

    /*call type*/
    speech_ind.call_type = srv_gcall_get_ucm_call_type(call_type);

    /*session type*/
    speech_ind.session_type = rat;
    session_ind.session_type = rat;
    
    /*switch*/
    speech_ind.local_switch = turn_on;
    speech_ind.remote_switch = turn_on;
    session_ind.session_switch = turn_on;

    /*call list*/
    speech_ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(speech_ind.call_list);

    session_ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(session_ind.call_list);
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
		if (turn_on == MMI_TRUE)
		{
			/* start session */
			srv_ucm_int_indication(speech_ind.call_type, SRV_UCM_INT_SESSION_IND, &session_ind);
			srv_ucm_int_mfree(session_ind.call_list);
	
			/* turn on codec */
			srv_ucm_int_indication(speech_ind.call_type, SRV_UCM_INT_SPEECH_IND, &speech_ind);
			srv_ucm_int_mfree(speech_ind.call_list);
		}
		else
		{
			/* turn off codec */
			srv_ucm_int_indication(speech_ind.call_type, SRV_UCM_INT_SPEECH_IND, &speech_ind);
			srv_ucm_int_mfree(speech_ind.call_list);
	
			/* stop session */
			srv_ucm_int_indication(speech_ind.call_type, SRV_UCM_INT_SESSION_IND, &session_ind);
			srv_ucm_int_mfree(session_ind.call_list);
		}
#else
    if (turn_on == MMI_TRUE)
    {
        /* start session */
        srv_ucm_session_ind((void*)&session_ind);
        srv_ucm_int_mfree(session_ind.call_list);

        /* turn on codec */
        srv_ucm_speech_ind((void*)&speech_ind);
        srv_ucm_int_mfree(speech_ind.call_list);
    }
    else
    {
        /* turn off codec */
        srv_ucm_speech_ind((void*)&speech_ind);
        srv_ucm_int_mfree(speech_ind.call_list);

        /* stop session */
        srv_ucm_session_ind((void*)&session_ind);
        srv_ucm_int_mfree(session_ind.call_list);
    }
#endif
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_cancel_query_cnf_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_cancel_query_cnf_ind(srv_gcall_type_enum call_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
		srv_ucm_int_indication(srv_gcall_get_ucm_call_type(call_type),SRV_UCM_INT_CANCEL_QUERY_IND, NULL);
#else
	srv_ucm_cancel_query_ind(srv_gcall_get_ucm_call_type(call_type));
#endif
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_cancel_query_ind_by_call_id
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_cancel_query_ind_by_call_id(U8 call_id, srv_gcall_type_enum call_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (call_id == cm_p->auto_dtmf_info.call_id)
    {
        /* cancel auto dtmf */
        srv_gcall_ucm_cancel_query_cnf_ind(call_type);
        srv_gcall_reset_auto_dtmf_info();
    }
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_release_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_release_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_release_ind_struct release_ind; 
    PU8 disp_msg;
#ifdef __OP21__
    U8 tmp_str[10];
    WCHAR ucs2_tmp_str[10];
#endif /* __OP21__ */

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&release_ind, 0, sizeof(srv_ucm_int_release_ind_struct));

    /* uid info */
    srv_gcall_set_uid_info(&release_ind.uid_info, cm_p->release_call_info.call_id, cm_p->release_call_info.group_id, cm_p->release_call_info.call_type);

    /* post action */
    if (cm_p->release_call_info.post_action)
    {
        release_ind.post_action.action = cm_p->release_call_info.post_action;
    #ifdef __IP_NUMBER__
        release_ind.post_action.is_ip_dial = cm_p->mo.is_ip_dial;
    #endif /* __IP_NUMBER__ */
    #ifdef __MMI_CALLSET_AUTO_REDIAL__
        release_ind.post_action.phb_data = cm_p->redial_info.phb_data;
    #endif /* __MMI_CALLSET_AUTO_REDIAL__ */
    }

    /*display info*/
    release_ind.image_id = IMG_GLOBAL_FAIL;
    release_ind.tone_id = CALL_DROP_TONE;
    disp_msg = (PU8)GetString(STR_ID_GCALL_CALL_ENDED);  /*default error message*/

    switch (cm_p->release_call_info.cause)
    {
    #ifdef __MMI_UCM_DETAIL_ERROR_MSG__
        case SRV_GCALL_RESULT_UNASSIGNED_NUM:
            release_ind.tone_id = NUM_UNOBTAIN_TONE;
        case SRV_GCALL_RESULT_INVALID_NUMBER_FORMAT:
    #ifdef __OP21__
        case SRV_GCALL_RESULT_NUMBER_CHANGED:
            disp_msg = (PU8)GetString(STR_ID_GCALL_NUMBER_NOT_AVAILABLE);
    #else /* __OP21__ */
            disp_msg = (PU8)GetString(STR_ID_GCALL_UNRECOGNIZED_NUMBER);
    #endif /* __OP21__ */
            break;

    #ifndef __OP21__
        case SRV_GCALL_RESULT_SWITCH_EQUIPMENT_CONGESTION:
            release_ind.tone_id = CONGESTION_TONE;

        case SRV_GCALL_RESULT_CHANNEL_UN_ACCP:
        case SRV_GCALL_RESULT_NETWORK_OUT_OF_ORDER:
        case SRV_GCALL_RESULT_QOS_UNAVAIL:
        case SRV_GCALL_RESULT_INVALID_TRANSIT_NW_SEL:
    #endif /* __OP21__ */
        case SRV_GCALL_RESULT_CSMCC_NO_RESPONSE_FROM_NW:
        case SRV_GCALL_RESULT_NETWORK_FAILURE:
    #if !(defined(__OP01__) && defined(__MMI_VIDEO_TELEPHONY__))
        case SRV_GCALL_RESULT_CM_MM_RR_CONN_RELEASE:
    #endif /* !(defined(__OP01__) && defined(__MMI_VIDEO_TELEPHONY__)) */
        case SRV_GCALL_RESULT_IMSI_UNKNOWN_IN_VLR:
            disp_msg = (PU8)GetString(STR_ID_GCALL_NETWORK_FAIL);
            break;

    #ifndef __OP21__
        case SRV_GCALL_RESULT_NO_CIRCUIT_CHANNEL_AVAIL:
        case SRV_GCALL_RESULT_REQUESTED_CKT_CHANEL_NOT_AVIL:
        case SRV_GCALL_RESULT_RESOURCE_UNAVAIL_UNSPECIFIED:
            disp_msg = (PU8)GetString(STR_ID_GCALL_NETWORK_BUSY);
            break;
    #endif /* __OP21__ */

        case SRV_GCALL_RESULT_ACCESS_CLASS_BARRED:
        case SRV_GCALL_RESULT_CM_MM_ACCESS_BARRED:
            disp_msg = (PU8)GetString(STR_ID_GCALL_BUSY_NETWORK_TRY_LATER);
            break;

        case SRV_GCALL_RESULT_CALL_REJECTED:
            release_ind.tone_id= AUTH_FAIL_TONE;
    #ifdef __OP21__
        case SRV_GCALL_RESULT_DEST_OUT_OF_ORDER:
            disp_msg = (PU8)GetString(STR_ID_GCALL_NOT_AVAILABLE_USER);
    #endif /* __OP21__ */
            break;

    #ifndef __OP21__
        case SRV_GCALL_RESULT_IC_BAR_CUG:
        case SRV_GCALL_RESULT_BEARER_CAP_NOT_AVAIL:
    #endif /* __OP21__ */
        case SRV_GCALL_RESULT_OPR_DTR_BARRING:
        case SRV_GCALL_RESULT_CALL_BARRED:
    #ifdef __OP21__
            disp_msg = (PU8)GetString(STR_ID_GCALL_NOT_AVAILABLE_USER);
    #else /* __OP21__ */
            disp_msg = (PU8)GetString(STR_ID_GCALL_BARRED_CALL);
    #endif /* __OP21__ */
            break;
        
        case SRV_GCALL_RESULT_NO_USER_RESPONDING:
    #ifndef __OP21__
            disp_msg = (PU8)GetString(STR_ID_GCALL_NOT_RESPONDING);
            break;
    #endif /* __OP21__ */

        case SRV_GCALL_RESULT_NO_ANSWER_ON_ALERT:
    #ifdef __OP21__
            disp_msg = (PU8)GetString(STR_ID_GCALL_NOT_ANSWER_FROM_USER);
    #else /* __OP21__ */
            disp_msg = (PU8)GetString(STR_ID_GCALL_NO_ANSWER);
    #endif /* __OP21__ */
            break;
        
    #ifndef __OP21__
        case SRV_GCALL_RESULT_REQ_FACILITY_UNAVAIL:
    #endif /* __OP21__ */
        case SRV_GCALL_RESULT_IE_NOT_IMPLEMENTED:
        case SRV_GCALL_RESULT_CONDITIONAL_MM_IE_ERROR:
        case SRV_GCALL_RESULT_CM_MM_ASSIGNMENT_REJECT:
            disp_msg = (PU8)GetString(STR_ID_GCALL_UNAVAILABLE);
            break;
        
        case SRV_GCALL_RESULT_IMSI_UNKNOWN_IN_HLR:
        case SRV_GCALL_RESULT_CM_MM_IMSI_DETACH:
        case SRV_GCALL_RESULT_CM_MM_AUTH_FAILURE:
        case SRV_GCALL_RESULT_CM_MM_STATE_NOT_ALLOWED_CM:
            disp_msg = (PU8)GetString(STR_GLOBAL_FAILED);
            break;
/*        
        case SRV_GCALL_RESULT_IMEI_NOT_ACCEPTED:
            disp_msg = (PU8)GetString(STR_ID_GCALL_IMEI_ERROR);
            break;
*/        
    #ifndef __OP21__
        case SRV_GCALL_RESULT_REQ_FAC_NOT_SUBS:
        case SRV_GCALL_RESULT_BEARER_CAP_NOT_AUTHORISED:
    #endif /* __OP21__ */
        case SRV_GCALL_RESULT_PLMN_NOT_ALLOWED:
        case SRV_GCALL_RESULT_LOCATION_AREA_NOT_ALLOWED:
        case SRV_GCALL_RESULT_ROAMING_AREA_NOT_ALLOWED:
        case SRV_GCALL_RESULT_GPRS_NOT_ALLOWED_IN_PLMN:
        case SRV_GCALL_RESULT_NO_SUITABLE_CELLS_IN_LA:
        case SRV_GCALL_RESULT_MSC_TEMP_NOT_REACHABLE:
        case SRV_GCALL_RESULT_CM_MM_ABORT_BY_NW:
        case SRV_GCALL_RESULT_SERV_OPTION_TEMP_OUT_OF_ORDER:
            disp_msg = (PU8)GetString(STR_ID_GCALL_NETWORK_NOT_ALLOWED);
            break;
        
        case SRV_GCALL_RESULT_SERV_OPTION_NOT_SUPPORTED:
        case SRV_GCALL_RESULT_REQ_SERV_OPTION_NOT_SUBSCRIBED:
        case SRV_GCALL_RESULT_CALL_CANNOT_BE_IDENTIFIED:
            disp_msg = (PU8)GetString(STR_ID_GCALL_COMMAND_NOT_SUPPORTED);
            break;
        
    #ifndef __OP21__
        case SRV_GCALL_RESULT_ACM_EXCEEDED:
            disp_msg = (PU8)GetString(STR_ID_GCALL_ACM_EXCEEDED);
            break;
    #endif /* __OP21__ */
        
        case SRV_GCALL_RESULT_USER_BUSY:
    #ifdef __OP21__
            disp_msg = (PU8)GetString(STR_ID_GCALL_BUSY_NUMBER);
    #else /* __OP21__ */
            disp_msg = (PU8)GetString(STR_ID_GCALL_USER_BUSY);
    #endif /* __OP21__ */
            release_ind.tone_id = TONE_BUSY_CALL_GSM;
            break;

    #ifdef __OP21__
        case SRV_GCALL_RESULT_NO_ROUTE_TO_DESTINATION:
            disp_msg = (PU8)GetString(STR_ID_GCALL_CALLER_USER_NOT_AVAILABLE);
            break;
    #endif /* __OP21__ */
    #endif /* __MMI_UCM_DETAIL_ERROR_MSG__ */
    
        case SRV_GCALL_RESULT_L4C_FDN_FAIL:
            disp_msg = (PU8)GetString(STR_ID_GCALL_FDN_FAIL);
            break;

        default:
            if (MMI_FALSE)
            {
            }
    #ifndef __OP21__
            /* mo fail */
            else if ((cm_p->release_call_info.state == SRV_GCALL_STATE_OUTGOING) &&
                        !(cm_p->release_call_info.is_abort))
            {
                disp_msg = (PU8)GetString(STR_ID_GCALL_UNABLE_TO_CONNECT);
            }
    #endif /* __OP21__ */
            /* normal call end */
            else
            {
                disp_msg = (PU8)GetString(STR_ID_GCALL_CALL_ENDED); 
            }
            release_ind.image_id = IMG_ID_GCALL_CALL_ENDED;
            break;
    }

    /* take as normal call clearing */
    if (cm_p->release_call_info.is_abort)
    {
        cm_p->release_call_info.cause = SRV_GCALL_RESULT_NORMAL_CALL_CLR;
        if (cm_p->release_call_info.state != SRV_GCALL_STATE_OUTGOING)
        {
            disp_msg = (PU8)GetString(STR_ID_GCALL_CALL_ENDED); 
        }
        else
        {
            disp_msg = (PU8)GetString(STR_ID_GCALL_CALL_ABORTED);
            release_ind.error_cause = SRV_UCM_RESULT_USER_ABORT;
        }
        release_ind.image_id = IMG_ID_GCALL_CALL_ENDED;
    }

    mmi_ucs2ncpy((CHAR *)release_ind.disp_msg, (CHAR *)disp_msg, SRV_UCM_MAX_ERR_MSG_LEN);

#ifdef __OP21__
    if (cm_p->release_call_info.cause &&
        cm_p->release_call_info.cause != SRV_GCALL_RESULT_NORMAL_CALL_CLR &&
        cm_p->release_call_info.cause != SRV_GCALL_RESULT_USER_BUSY &&
        cm_p->release_call_info.cause < 10000)
    {
        memset(tmp_str, 0, sizeof(tmp_str));
        memset(ucs2_tmp_str, 0, sizeof(ucs2_tmp_str));
        sprintf((CHAR *)tmp_str, " -%02d-", cm_p->release_call_info.cause);
        mmi_asc_to_ucs2((CHAR *)ucs2_tmp_str, (CHAR *)tmp_str);
        mmi_ucs2ncat((CHAR *)release_ind.disp_msg, (CHAR *)ucs2_tmp_str, SRV_UCM_MAX_ERR_MSG_LEN - mmi_ucs2strlen((CHAR *)release_ind.disp_msg));
    }
#endif /* __OP21__ */

    if (release_ind.error_cause != SRV_UCM_RESULT_USER_ABORT)
    {
        release_ind.error_cause = srv_gcall_util_get_ucm_result(cm_p->release_call_info.cause);
    }

    if (srv_gcall_get_call_count(MMI_TRUE, SRV_GCALL_STATE_TOTAL, (srv_gcall_type_enum)0)
        || srv_gcall_util_is_data_csd(cm_p->release_call_info.call_type))
    {
        release_ind.tone_id = 0;
    }

    /*call list*/
    release_ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(release_ind.call_list);

    /* do not reset cntxt ptr (not allow ucm to to other request in ind handler) */

	srv_ucm_release_ind((void*)&release_ind);

    srv_ucm_int_mfree(release_ind.call_list);
}

#ifdef __MMI_CALLSET_AUTO_REDIAL__
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_auto_redial_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_auto_redial_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_auto_redial_ind_struct ind;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&ind, 0, sizeof(srv_ucm_int_auto_redial_ind_struct));

    ind.call_type = srv_gcall_get_ucm_call_type(cm_p->release_call_info.call_type);
    mmi_ucs2ncpy((CHAR *)ind.display_msg, (CHAR *)cm_p->redial_info.msg, SRV_UCM_MAX_AUTO_REDIAL_MSG_LEN);
    strncpy((CHAR *)ind.num_uri, (CHAR *)cm_p->mo.num, SRV_UCM_MAX_NUM_URI_LEN);

#ifdef __IP_NUMBER__
     ind.is_ip_dial = cm_p->mo.is_ip_dial;
#endif /* __IP_NUMBER__ */

    ind.attempt = cm_p->redial_info.curr_attempt; 
    ind.time = cm_p->redial_info.timer;
    ind.abort_hdlr = srv_gcall_cmhdlr_abort_auto_redial;
    ind.phb_data = cm_p->redial_info.phb_data;

	srv_ucm_auto_redial_ind((void*)&ind);
}
#endif /* __MMI_CALLSET_AUTO_REDIAL__ */

/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_disconnecting_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_disconnecting_ind(srv_gcall_call_info_struct *call_info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_disconnecting_ind_struct ind;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&ind, 0, sizeof(srv_ucm_int_disconnecting_ind_struct));

    /* uid */
    srv_gcall_set_uid_info(&ind.uid_info, call_info->call_id, call_info->group_id, call_info->call_type);

    /* call list */
    ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(ind.call_list);

	srv_ucm_disconnecting_ind((void*)&ind);

    srv_ucm_int_mfree(ind.call_list);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_sync_call_list_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_sync_call_list_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_sync_call_list_ind_struct ind;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    /* call list */
    ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(ind.call_list);

	srv_ucm_sync_call_list(ind.call_list);

    srv_ucm_int_mfree(ind.call_list);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_alert_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_alert_ind(srv_gcall_call_info_struct *call_info, U8 gen_tone)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_alert_ind_struct alert_ind;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&alert_ind, 0, sizeof(srv_ucm_int_alert_ind_struct));

    /* uid */
    srv_gcall_set_uid_info(&alert_ind.uid_info, call_info->call_id, call_info->group_id, call_info->call_type);

    /* generate tone or not */
    alert_ind.local_gen = gen_tone;

    /* call list */
    alert_ind.call_list = srv_ucm_int_malloc(sizeof(srv_ucm_int_call_list_struct));
    srv_gcall_get_ucm_call_list(alert_ind.call_list);

	srv_ucm_alert_ind((void*)&alert_ind);

    srv_ucm_int_mfree(alert_ind.call_list);

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_auto_dtmf_cnf_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_auto_dtmf_cnf_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_query_cnf_ind_struct cnf_ind;
    U8 tmp_buf[SRV_GCALL_MAX_DTMF_DIGITS * ENCODING_LENGTH + 40];    

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&cnf_ind, 0, sizeof(srv_ucm_int_query_cnf_ind_struct));
    memset(tmp_buf, 0, sizeof(tmp_buf));

    /* content */
    mmi_ucs2cpy((CHAR *)tmp_buf, GetString(STR_ID_GCALL_DTMF_CONFIRMATION));
    mmi_asc_to_ucs2((CHAR *)tmp_buf + (mmi_ucs2strlen((CHAR *)tmp_buf) * ENCODING_LENGTH), (CHAR *)cm_p->auto_dtmf_info.buf);

    mmi_ucs2ncpy((CHAR *)cnf_ind.content, (CHAR *)tmp_buf, SRV_UCM_MAX_DISP_MSG_LEN);
    cnf_ind.disp_condition = SRV_UCM_DISP_ECC; /* Auto DTMF is also available for ECC */

	srv_ucm_query_cnf_ind(srv_gcall_get_ucm_call_type(CSMCC_VOICE_CALL), (void*)&cnf_ind, srv_gcall_cmhdlr_cnf_auto_dtmf);
}


#ifdef __AOC_SUPPORT__
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_call_cost_ind
 * DESCRIPTION
 *  This function is called by the state machine function in
 *  to make call to protocol stack to get call list to sync with MMI
 * PARAMETERS
 *  info        [?]     
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_call_cost_ind(void *info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_cc_ccm_ind_struct *msg = (mmi_cc_ccm_ind_struct*)info;
    srv_ucm_int_call_cost_ind_struct ind;

    srv_gcall_call_info_struct *call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_CALL_ID, msg->call_id);
    /* ccm_ind is ignored if there is no such call */

    U8 currency[4];
    U8 currency2[4 * ENCODING_LENGTH];

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&ind, 0, sizeof(srv_ucm_int_call_cost_ind_struct));

    /* uid info */
    srv_gcall_set_uid_info(&ind.uid_info, call_info->call_id, call_info->group_id, call_info->call_type);

    /* currency symbol */
    memset(currency, 0, 4 * sizeof(U8));
    memset(currency2, 0, 4 * ENCODING_LENGTH * sizeof(U8));
    memcpy(currency, msg->currency, 3 * sizeof(U8));
    mmi_asc_to_ucs2((CHAR *)currency2, (CHAR *)currency);
    ind.currency_symbol = currency2;

    ind.cost_unit = msg->ccm;

    ind.total_cost_unit = msg->total_ccm;

    ind.price_per_unit = (U32)msg->ppu;

    ind.warning = (MMI_BOOL)msg->warning;

    srv_ucm_call_cost_ind((void*)&ind);
}
#endif /* __AOC_SUPPORT__ */


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_make_voice_call
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
U16 srv_gcall_ucm_make_voice_call(CHAR *number, U8 module_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_dial_act_req_struct dial_req;
    srv_ucm_call_type_enum ucm_call_type = srv_gcall_get_ucm_call_type(CSMCC_VOICE_CALL);
    srv_ucm_hold_and_dial_act_req_struct hold_and_dial_req;
    S32 active_grp_indx[SRV_UCM_MAX_GROUP];
    srv_ucm_group_info_struct active_grp;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    /* use ucm service external api */

    /* dial */
    memset(&dial_req, 0, sizeof(srv_ucm_dial_act_req_struct));
    dial_req.call_type = ucm_call_type;
#ifdef __IP_NUMBER__
    dial_req.is_ip_dial = MMI_FALSE;
#endif /* __IP_NUMBER__ */
    dial_req.module_id = (srv_ucm_module_origin_enum)module_id;
    mmi_ucs2ncpy((CHAR *)dial_req.num_uri, number, SRV_UCM_MAX_NUM_URI_LEN);

    if (srv_ucm_query_act_permit(SRV_UCM_DIAL_ACT, &dial_req) == SRV_UCM_RESULT_OK)
    {
        srv_ucm_act_request(SRV_UCM_DIAL_ACT, &dial_req, NULL, NULL);
        
        return SRV_GCALL_RESULT_OK;
    }

    /* hold and dial */
    if (srv_ucm_query_group_count(SRV_UCM_ACTIVE_STATE, (srv_ucm_call_type_enum)SRV_UCM_CALL_TYPE_ALL, MMI_FALSE, active_grp_indx) > 0)
    {
        MMI_ASSERT(srv_ucm_query_group_data(active_grp_indx[0], &active_grp) > 0);
 
        memset(&hold_and_dial_req, 0, sizeof(srv_ucm_hold_and_dial_act_req_struct));
        hold_and_dial_req.active_call_type = active_grp.call_type;
        hold_and_dial_req.active_group = active_grp.group_id;
        hold_and_dial_req.dial_call_type = ucm_call_type;
    #ifdef __IP_NUMBER__
        hold_and_dial_req.is_ip_dial = MMI_FALSE;
    #endif /* __IP_NUMBER__ */
        hold_and_dial_req.module_id = (srv_ucm_module_origin_enum)module_id;
        mmi_asc_n_to_ucs2((CHAR *)hold_and_dial_req.num_uri, number, SRV_UCM_MAX_NUM_URI_LEN);

        if (srv_ucm_query_act_permit(SRV_UCM_HOLD_AND_DIAL_ACT, &hold_and_dial_req) == SRV_UCM_RESULT_OK)
        {
            srv_ucm_act_request(SRV_UCM_HOLD_AND_DIAL_ACT, &hold_and_dial_req, NULL, NULL);

            return SRV_GCALL_RESULT_OK;
        }

    }

    return SRV_GCALL_RESULT_UNSPECIFIED_ERR;

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_replace_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_replace_ind(srv_gcall_call_info_struct *call_info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_replace_ind_struct ind;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&ind, 0, sizeof(srv_ucm_int_replace_ind_struct));

    /* old uid info */
    srv_gcall_set_uid_info(&ind.old_uid_info, call_info->call_id, call_info->group_id, call_info->call_type);

    memcpy(&ind.new_uid_info, &ind.old_uid_info, sizeof(srv_ucm_id_info_struct));

    ind.call_origin = srv_gcall_util_get_ucm_origin(call_info->dir);
    
    /*remote info*/
    srv_gcall_derive_display_name(call_info, (PU8)ind.remote_info.disp_name, SRV_UCM_MAX_DISP_NAME_LEN);    
    mmi_ucs2ncpy((CHAR *)ind.remote_info.log_name, (CHAR *)srv_gcall_get_call_log_name(call_info), MMI_PHB_NAME_LENGTH);
    strncpy((CHAR *)ind.remote_info.num_uri, (CHAR *)srv_gcall_get_call_log_number(call_info), SRV_UCM_MAX_NUM_URI_LEN);

    srv_gcall_set_remote_line_icon(call_info, &ind.remote_info);

#ifdef __MMI_UCM_NUMBER_TYPE__
    ind.remote_info.number_type = call_info->number_type;
    ind.remote_info.num_type_icon = srv_gcall_derive_number_type_icon(call_info->number_type);
#endif /* __MMI_UCM_NUMBER_TYPE__ */

    ind.remote_info.phb_id = cm_p->phb_data.phb_id;

	srv_ucm_replace_ind((void*)&ind);	
}


#ifdef __CCBS_SUPPORT__
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_ccbs_recall_cnf_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_ccbs_recall_cnf_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_query_cnf_ind_struct cnf_ind;
    U8 temp_str[(SRV_GCALL_MAX_NUMBER + 6) * ENCODING_LENGTH];
    U8 temp_str_2[SRV_GCALL_MAX_NUMBER * ENCODING_LENGTH];

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&cnf_ind, 0, sizeof(srv_ucm_int_query_cnf_ind_struct));

    mmi_ucs2cpy((CHAR *)temp_str, (CHAR *)L"Dial ");
    mmi_asc_to_ucs2((CHAR *)temp_str_2, (CHAR *)cm_p->ccbs_info.number);
    mmi_ucs2cat((CHAR *)temp_str, (CHAR *)temp_str_2);
    mmi_ucs2cat((CHAR *)temp_str, (CHAR *)L"?");

    mmi_ucs2ncpy((CHAR *)cnf_ind.content, (CHAR *)temp_str, SRV_UCM_MAX_DISP_MSG_LEN);
    cnf_ind.disp_condition = (srv_ucm_int_disp_condition_enum)0;

	srv_ucm_query_cnf_ind(srv_gcall_get_ucm_call_type(CSMCC_VOICE_CALL), 
		(void*)&cnf_ind, srv_gcall_cmhdlr_cnf_ccbs_recall);
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_ccbs_activation_cnf_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_ccbs_activation_cnf_ind(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_ucm_int_query_cnf_ind_struct ccbs_activation_conf;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&ccbs_activation_conf, 0, sizeof(srv_ucm_int_query_cnf_ind_struct));

    mmi_ucs2ncpy((CHAR *)ccbs_activation_conf.content, (CHAR *)get_string(STR_ID_GCALL_CCBS_NFY), SRV_UCM_MAX_DISP_MSG_LEN);
    ccbs_activation_conf.disp_condition = SRV_UCM_DISP_OUTGOING; /*show confirm popup in outgoing call screen*/

	srv_ucm_query_cnf_ind(srv_gcall_get_ucm_call_type(CSMCC_VOICE_CALL),
		(void*)&ccbs_activation_conf, srv_gcall_cmhdlr_cnf_ccbs_activate);
}
#endif /* __CCBS_SUPPORT__ */


#ifdef __MMI_VIDEO_TELEPHONY__
/*****************************************************************************
 * FUNCTION
 *  srv_gcall_ucm_start_count_ind
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_ucm_start_count_ind(srv_gcall_call_info_struct *call_info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

	srv_ucm_start_count_ind(NULL);
}
#endif /* __MMI_VIDEO_TELEPHONY__ */


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_sat_notify_mo_number_change
 * DESCRIPTION
 *  This function displays number change notification
 * PARAMETERS
 *  newNumber               [IN]        
 *  ptrDisplayString        [OUT]       
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_sat_notify_mo_number_change(U8 *number, U8 *disp_str)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 index = 0;
    srv_gcall_call_info_struct *call_info;
    mmi_sim_enum sim_id[] = {MMI_SIM1, MMI_SIM2, MMI_SIM3, MMI_SIM4};

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    for (index = 0; index < MMI_SIM_TOTAL; index++)
    {
        srv_gcall_cntxt_set_ptr(sim_id[index]);
        call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_STATE, (U8)SRV_GCALL_STATE_OUTGOING);
        if (!call_info)
        {
            srv_gcall_cntxt_reset_ptr();
        }
        else
        {
            break;
        }
    }

    if (!call_info)
    {
        /* no outgoing call, ignore */
        return;
    }

    if (disp_str && mmi_ucs2strlen((CHAR *)disp_str))
    {
        /* Case1: alpha_id is present and not empty, display alpha_id */
        mmi_ucs2_n_to_asc((CHAR *)(call_info->num2), (CHAR *)number, (SRV_GCALL_MAX_NUMBER - 1) * ENCODING_LENGTH);
        mmi_ucs2ncpy((CHAR *)call_info->name, (CHAR *)disp_str, SRV_GCALL_MAX_NAME - 1);
        srv_gcall_ucm_notify_ind(call_info->call_type, disp_str, 0, 0);
        srv_gcall_ucm_replace_ind(call_info);

        /* don't update display name after connect_ind */
        call_info->dir = SRV_GCALL_DIR_MO_STK;
    }
    else if (disp_str && !mmi_ucs2strlen((CHAR *)disp_str))
    {
        /* Case2: alpha_id is present but empty, don't modify the display name */

        if (!mmi_ucs2strlen((CHAR *)call_info->name))
        {
            /* if there is no name, use original number as the name in case the number is changed in connect_ind */
            /* hide *31#, #31# prefix string  */
            if ((strncmp((CHAR *)call_info->num, "*31#", 4) == 0) ||
                (strncmp((CHAR *)call_info->num, "#31#", 4) == 0))
            {
                mmi_asc_n_to_ucs2((CHAR *)call_info->name, (CHAR *)&(call_info->num[4]), (U32)SRV_GCALL_MAX_NAME);
            }
            else
            {
                mmi_asc_n_to_ucs2((CHAR *)call_info->name, (CHAR *)call_info->num, (U32)SRV_GCALL_MAX_NAME);
            }
        }

        /* don't update display name after connect_ind */
        call_info->dir = SRV_GCALL_DIR_MO_STK;
    }
    /* Case3: alpha_id is not present, ignore all call control by sim attributes, take as normal MO call  */

    srv_gcall_cntxt_reset_ptr();

}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_sat_notify_mo_fail
 * DESCRIPTION
 *  Removes outgoing call screen
 * PARAMETERS
 *  void
 *  Number(?)       [IN]        To show on screen
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_sat_notify_mo_fail(U16 cause)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 i;
    srv_gcall_call_info_struct *call_info;
    mmi_sim_enum sim_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    for (i = 0, sim_id = MMI_SIM1; i < MMI_SIM_TOTAL; i++, sim_id <<= 1)
    {
        srv_gcall_cntxt_set_ptr(sim_id);
        call_info = srv_gcall_get_call_info(SRV_GCALL_CALL_INFO_BY_STATE, (U8)SRV_GCALL_STATE_OUTGOING);
        if (!call_info)
        {
            srv_gcall_cntxt_reset_ptr();
        }
        else
        {
            break;
        }
    }

    if (!call_info)
    {
        /* no outgoing call, ignore */
        return;
    }

    srv_gcall_phdlr_set_release_call_info(call_info, cause);
    
    srv_gcall_proc_ps_event(SRV_GCALL_PS_EVENT_REL_OUTGOING, call_info);
    srv_gcall_cntxt_reset_ptr();
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_post_act_evt
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  result
 *****************************************************************************/
MMI_BOOL srv_gcall_post_act_evt(srv_ucm_call_type_enum call_type, srv_ucm_int_act_opcode_enum act_op, void *ptr, srv_ucm_int_at_info_struct *at_info, void *user_data, srv_ucm_int_act_rsp_callback_func_ptr rsp_callback)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_gcall_act_evt_struct evt;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&evt, 0, sizeof(srv_gcall_act_evt_struct));

    MMI_FRM_INIT_EVENT(&evt, EVT_ID_SRV_GCALL_ACT);
    evt.call_type = call_type;
    evt.act_op = act_op;
    evt.ptr = srv_gcall_post_copy_act_data(act_op, ptr);
    evt.at_info = OslMalloc(sizeof(srv_ucm_int_at_info_struct));
    memcpy(evt.at_info, at_info, sizeof(srv_ucm_int_at_info_struct));
    evt.int_user_data = user_data;
    evt.rsp_callback = rsp_callback;
    
    MMI_FRM_CB_EMIT_POST_EVENT(&evt);

    return MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_post_cnf_evt
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  result
 *****************************************************************************/
MMI_BOOL srv_gcall_post_cnf_evt(srv_ucm_call_type_enum call_type, srv_ucm_int_cnf_opcode_enum cnf_type, void *ptr, srv_ucm_int_cnf_callback_func_ptr cb)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_gcall_cnf_evt_struct evt;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(&evt, 0, sizeof(srv_gcall_cnf_evt_struct));

    MMI_FRM_INIT_EVENT(&evt, EVT_ID_SRV_GCALL_CNF);
    evt.cb = cb;
    evt.call_type = call_type;
    evt.cnf_type = cnf_type;
    evt.ptr = srv_gcall_post_copy_cnf_data(cnf_type, ptr);
    
    MMI_FRM_CB_EMIT_POST_EVENT(&evt);

    return MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_post_copy_act_data
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  data pointer
 *****************************************************************************/
void* srv_gcall_post_copy_act_data(srv_ucm_int_act_opcode_enum act_op, void *from)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    void *to = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (!from)
    {
        return NULL;
    }

    switch (act_op)
    {
        case SRV_UCM_INT_DIAL_ACT:
            to = OslMalloc(sizeof(srv_ucm_dial_act_req_struct));
            memcpy(to, from, sizeof(srv_ucm_dial_act_req_struct));
            break;

        case SRV_UCM_INT_ACCEPT_ACT:
        case SRV_UCM_INT_SPLIT_ACT:
        case SRV_UCM_INT_END_SINGLE_ACT:
        case SRV_UCM_INT_FORCE_RELEASE_ACT:
        case SRV_UCM_INT_AUTO_REJECT_ACT:
            to = OslMalloc(sizeof(srv_ucm_single_call_act_req_struct));
            memcpy(to, from, sizeof(srv_ucm_single_call_act_req_struct));
            break;

        case SRV_UCM_INT_HOLD_ACT:
        case SRV_UCM_INT_RETRIEVE_ACT:
        case SRV_UCM_INT_SWAP_ACT:
        case SRV_UCM_INT_END_CONFERENCE_ACT:
            to = OslMalloc(sizeof(srv_ucm_single_group_act_req_struct));
            memcpy(to, from, sizeof(srv_ucm_single_group_act_req_struct));
            break;

        case SRV_UCM_INT_CONFERENCE_ACT:
            to = OslMalloc(sizeof(srv_ucm_multiple_group_act_req_struct));
            memcpy(to, from, sizeof(srv_ucm_multiple_group_act_req_struct));
            break;

    #ifdef __MMI_UCM_DEFLECT__
        case SRV_UCM_INT_DEFLECT_ACT:
            to = OslMalloc(sizeof(srv_ucm_cd_or_ct_act_req_struct));
            memcpy(to, from, sizeof(srv_ucm_cd_or_ct_act_req_struct));            
            break;
    #endif /* __MMI_UCM_DEFLECT__ */

        case SRV_UCM_INT_END_ALL_ACT:
            break;

    #ifdef __MMI_UCM_ECT__
        case SRV_UCM_INT_EXPLICIT_CALL_TRANSFER_ACT:
            to = OslMalloc(sizeof(srv_ucm_ect_act_req_struct));
            memcpy(to, from, sizeof(srv_ucm_ect_act_req_struct));    
            break;
    #endif /* __MMI_UCM_ECT__ */

        case SRV_UCM_INT_START_DTMF_ACT:
            to = OslMalloc(sizeof(srv_ucm_dtmf_struct));
            memcpy(to, from, sizeof(srv_ucm_dtmf_struct)); 
            break;

        default:
             break;
    }

    MMI_ASSERT(to); /* get buffer fails or op is not supported */
    
    return to;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_post_copy_cnf_data
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  data pointer
 *****************************************************************************/
void* srv_gcall_post_copy_cnf_data(srv_ucm_int_cnf_opcode_enum cnf_type, void *from)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    void *to = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (!from)
    {
        return NULL;
    }

    switch (cnf_type)
    {
        case SRV_UCM_INT_QUERY_CNF:
            to = OslMalloc(sizeof(srv_ucm_int_query_cnf_struct));
            memcpy(to, from, sizeof(srv_ucm_int_query_cnf_struct));
            break;

        case SRV_UCM_INT_DIAL_CNF:
            to = OslMalloc(sizeof(srv_ucm_int_dial_cnf_struct));
            memcpy(to, from, sizeof(srv_ucm_int_dial_cnf_struct));
            break;

        case SRV_UCM_INT_CALL_PRESENT_CNF:
            to = OslMalloc(sizeof(srv_ucm_int_call_present_cnf_struct));
            memcpy(to, from, sizeof(srv_ucm_int_call_present_cnf_struct));
            break;

        default:
             break;
    }

    MMI_ASSERT(to); /* get buffer fails or op is not supported */
    
    return to;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_post_act_evt_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
mmi_ret srv_gcall_post_act_evt_hdlr(mmi_event_struct* para)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_gcall_act_evt_struct *info = (srv_gcall_act_evt_struct*)para;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/    

    srv_gcall_cmhdlr_act_req(info->call_type, info->act_op, 
        info->ptr, info->at_info, info->int_user_data, info->rsp_callback);

    if (info->ptr)
    {
        OslMfree(info->ptr);
    }
    if (info->at_info)
    {
        OslMfree(info->at_info);
    }

    return MMI_RET_OK;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_post_cnf_evt_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
mmi_ret srv_gcall_post_cnf_evt_hdlr(mmi_event_struct* para)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_gcall_cnf_evt_struct *info = (srv_gcall_cnf_evt_struct*)para;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/    

    (*(info->cb))(info->call_type, info->cnf_type, 
        info->ptr);

    OslMfree(info->ptr);

    return MMI_RET_OK;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_get_interface_with_ucm_call_type
 * DESCRIPTION
 *  
 * PARAMETERS
 *  call_type   [IN]    ucm call type
 * RETURNS
 *  sim interface
 *****************************************************************************/
mmi_sim_enum srv_gcall_get_interface_with_ucm_call_type(srv_ucm_call_type_enum call_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (call_type & SRV_UCM_SIM1_CALL_TYPE_ALL)
    {
        return MMI_SIM1;
    }
#if (MMI_MAX_SIM_NUM >= 2)
    else if (call_type & SRV_UCM_SIM2_CALL_TYPE_ALL)
    {
        return MMI_SIM2;
    }
#if (MMI_MAX_SIM_NUM >= 3)
    else if (call_type & SRV_UCM_SIM3_CALL_TYPE_ALL)
    {
        return MMI_SIM3;
    }
#if (MMI_MAX_SIM_NUM == 4)
    else if (call_type & SRV_UCM_SIM4_CALL_TYPE_ALL)
    {
        return MMI_SIM4;
    }
#endif /* (MMI_MAX_SIM_NUM == 4) */
#endif /* (MMI_MAX_SIM_NUM >= 3) */
#endif /* (MMI_MAX_SIM_NUM >= 2) */

    MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_GET_INTERFACE_WITH_UCM_CALL_TYPE_NOT_SUPPORT, call_type);
    return MMI_SIM_NONE;
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #if (MMI_MAX_SIM_NUM >= 2)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #if (MMI_MAX_SIM_NUM >= 3)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #if (MMI_MAX_SIM_NUM == 4)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #endif /* (MMI_MAX_SIM_NUM == 4) */
    #endif /* (MMI_MAX_SIM_NUM >= 3) */
    #endif /* (MMI_MAX_SIM_NUM >= 2) */
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_get_ucm_call_list
 * DESCRIPTION
 *  Gets GSM call list for UCM
 * PARAMETERS
 *        
 * RETURNS
 * 
 *****************************************************************************/
void srv_gcall_get_ucm_call_list(srv_ucm_int_call_list_struct *call_list)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U8 count;
    srv_gcall_call_info_struct *from;
    srv_ucm_int_call_list_entry_info_struct *to;
#ifdef __MMI_UCM_DISPLAY_CAUSE_OF_NO_CLI__
    PU8 no_cli_msg;
    U16 length;
#endif /* __MMI_UCM_DISPLAY_CAUSE_OF_NO_CLI__ */

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    memset(call_list, 0, sizeof(srv_ucm_int_call_list_struct));

    /* call type */
    switch (cm_p->interface)
    {
        case MMI_SIM1:
            call_list->call_type = (srv_ucm_call_type_enum)SRV_UCM_SIM1_CALL_TYPE_ALL;
            break;
    #if (MMI_MAX_SIM_NUM >= 2)
        case MMI_SIM2:
            call_list->call_type = (srv_ucm_call_type_enum)SRV_UCM_SIM2_CALL_TYPE_ALL;
            break;
    #if (MMI_MAX_SIM_NUM >= 3)
        case MMI_SIM3:
            call_list->call_type = (srv_ucm_call_type_enum)SRV_UCM_SIM3_CALL_TYPE_ALL;
            break;
    #if (MMI_MAX_SIM_NUM == 4)
        case MMI_SIM4:
            call_list->call_type = (srv_ucm_call_type_enum)SRV_UCM_SIM4_CALL_TYPE_ALL;
            break;
    #endif /* (MMI_MAX_SIM_NUM == 4) */
    #endif /* (MMI_MAX_SIM_NUM >= 3) */
    #endif /* (MMI_MAX_SIM_NUM >= 2) */
        default:
            MMI_ASSERT(0);
            break;
    }
    
    for (count = 0; count < SRV_GCALL_MAX_CALL; count++)
    {
        from = &(cm_p->call_list[count]);
        to = &(call_list->call_info[call_list->total_num]);

        if (from->call_id == SRV_GCALL_INVALID_ID)
        {
            /* ignore unused call info */
            continue;
        }

        if ((cm_p->ucm_info.bg_op == SRV_UCM_INT_AUTO_REJECT_ACT)
                && (cm_p->auto_reject_call_id == from->call_id))
        {
            /* UCM has already auto rejected the call, so don't let her know. */
            MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_GET_UCM_CALL_LIST_IGNORE, from->call_id);
            continue;
        }

        /* REMOTE INFO */
        strncpy((CHAR *)to->remote_info.num_uri, (CHAR *)from->num, SRV_UCM_MAX_NUM_URI_LEN);

        srv_gcall_derive_display_name(from, (PU8)to->remote_info.disp_name, SRV_UCM_MAX_DISP_NAME_LEN);
        
        mmi_ucs2ncpy((CHAR *)to->remote_info.log_name,
                    (CHAR *)srv_gcall_get_call_log_name(from),
                    MMI_PHB_NAME_LENGTH);
        
        srv_gcall_set_remote_line_icon(from, &to->remote_info);

    #ifdef __MMI_UCM_NUMBER_TYPE__
        to->remote_info.number_type = from->number_type;
        to->remote_info.num_type_icon = srv_gcall_derive_number_type_icon(from->number_type);
    #endif /* __MMI_UCM_NUMBER_TYPE__ */

        to->remote_info.phb_id = cm_p->phb_data.phb_id;

    #ifdef __MMI_UCM_DISPLAY_CAUSE_OF_NO_CLI__
        length = (SRV_UCM_MAX_DISP_NAME_LEN - mmi_ucs2strlen((CHAR *)to->remote_info.disp_name)) * ENCODING_LENGTH;

        if ((from->curr_state == SRV_GCALL_STATE_INCOMING)
            && (cm_p->mt.no_cli_cuase != CSMCC_INVALID_NO_CLI_CAUSE))
        {
            no_cli_msg = OslMalloc(length);
            memset(no_cli_msg, 0, length);
            srv_gcall_util_get_no_cli_display_text(cm_p->mt.no_cli_cuase, no_cli_msg);
            mmi_ucs2cat((CHAR *)to->remote_info.disp_name, GetString(STR_ID_GCALL_LEFT_PARENTHESIS));
            mmi_ucs2ncat((CHAR *)to->remote_info.disp_name, (CHAR *)no_cli_msg, mmi_ucs2strlen((CHAR *)no_cli_msg));
            mmi_ucs2cat((CHAR *)to->remote_info.disp_name, GetString(STR_ID_GCALL_RIGHT_PARENTHESIS));
            OslMfree(no_cli_msg);
        }
    #endif /* __MMI_UCM_DISPLAY_CAUSE_OF_NO_CLI__ */

        /*UID info*/
        srv_gcall_set_uid_info(&to->uid_info, from->call_id, from->group_id, from->call_type);
        
        /*STATE info*/
        to->call_state = srv_gcall_util_get_ucm_call_state(from->curr_state);
        
        /*print info*/
        if (from->call_id != SRV_GCALL_INVALID_ID)
        {
            MMI_TRACE(MMI_COMMON_TRC_G5_CALL, TRC_SRV_GCALL_GET_UCM_CALL_LIST_INFO,
            call_list->total_num, 
            to->uid_info.group_id,
            to->uid_info.call_id,
            to->uid_info.call_type,
            to->call_state);
        }
        
        call_list->total_num++;
    }
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_get_ucm_call_type
 * DESCRIPTION
 *  
 * PARAMETERS
 *  call_type
 * RETURNS
 *  void
 *****************************************************************************/
srv_ucm_call_type_enum srv_gcall_get_ucm_call_type(srv_gcall_type_enum call_type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (cm_p->interface == MMI_SIM1)
    {
        switch (call_type)
        {
            case CSMCC_VOICE_CALL:
            case CSMCC_AUX_VOICE_CALL:
                return SRV_UCM_VOICE_CALL_TYPE;
                 
            case CSMCC_DATA_CALL:
            case CSMCC_FAX_CALL:
            case CSMCC_SAT_DATA_CALL:            
                return SRV_UCM_DATA_CALL_TYPE;

            case CSMCC_CSD_CALL:
                return SRV_UCM_CSD_CALL_TYPE;
            
            case CSMCC_VIDEO_CALL:
                return SRV_UCM_VIDEO_CALL_TYPE;
                 
            default:
                break;
        }
    }
#if (MMI_MAX_SIM_NUM >= 2)    
    else if (cm_p->interface == MMI_SIM2)
    {
        switch (call_type)
        {
            case CSMCC_VOICE_CALL:
            case CSMCC_AUX_VOICE_CALL:
                return SRV_UCM_VOICE_CALL_TYPE_SIM2;
                 
            case CSMCC_DATA_CALL:
            case CSMCC_FAX_CALL:
            case CSMCC_SAT_DATA_CALL:            
                return SRV_UCM_DATA_CALL_TYPE_SIM2;

            case CSMCC_CSD_CALL:
                return SRV_UCM_CSD_CALL_TYPE_SIM2;

            case CSMCC_VIDEO_CALL:
                return SRV_UCM_VIDEO_CALL_TYPE_SIM2;
                 
            default: /* doesn't support video call */
                break;
        }
    }
#if (MMI_MAX_SIM_NUM >= 3)
    else if (cm_p->interface == MMI_SIM3)
    {
        switch (call_type)
        {
            case CSMCC_VOICE_CALL:
            case CSMCC_AUX_VOICE_CALL:
                return SRV_UCM_VOICE_CALL_TYPE_SIM3;
                 
            case CSMCC_DATA_CALL:
            case CSMCC_FAX_CALL:
            case CSMCC_SAT_DATA_CALL:            
                return SRV_UCM_DATA_CALL_TYPE_SIM3;

            case CSMCC_CSD_CALL:
                return SRV_UCM_CSD_CALL_TYPE_SIM3;
                 
            default: /* doesn't support video call */
                break;
        }
    }
#if (MMI_MAX_SIM_NUM == 4)    
    else if (cm_p->interface == MMI_SIM4)
    {
        switch (call_type)
        {
            case CSMCC_VOICE_CALL:
            case CSMCC_AUX_VOICE_CALL:
                return SRV_UCM_VOICE_CALL_TYPE_SIM4;
                 
            case CSMCC_DATA_CALL:
            case CSMCC_FAX_CALL:
            case CSMCC_SAT_DATA_CALL:            
                return SRV_UCM_DATA_CALL_TYPE_SIM4;

            case CSMCC_CSD_CALL:
                return SRV_UCM_CSD_CALL_TYPE_SIM4;
                 
            default: /* doesn't support video call */
                break;
        }
    }
#endif /* (MMI_MAX_SIM_NUM == 4) */
#endif /* (MMI_MAX_SIM_NUM >= 3) */
#endif /* (MMI_MAX_SIM_NUM >= 2) */

    MMI_ASSERT(0);

    return SRV_UCM_CALL_TYPE_END_OF_ENUM;
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_set_remote_line_icon
 * DESCRIPTION
 *  
 * PARAMETERS
 *  call_type
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_set_remote_line_icon(srv_gcall_call_info_struct *from, srv_ucm_remote_info_struct *remote_info)
{
    remote_info->line_icon = 0;
    if (!srv_gcall_util_is_reset_csp_group_service(cm_p->interface, SRV_CPHS_GROUP_CPHS_TELESERVICES, SRV_CPHS_SERVICE_ALS))
    {
    #if defined(__COSMOS_MMI_PACKAGE__) || !defined(__MMI_UCM_SLIM__)
        if (from->call_type == CSMCC_AUX_VOICE_CALL)
        {
            remote_info->line_icon = IMG_ID_GCALL_LINE2;
        }
        else if (from->call_type == CSMCC_VOICE_CALL)
        {
            remote_info->line_icon = IMG_ID_GCALL_LINE1;
        }
    #endif /*defined(__COSMOS_MMI_PACKAGE__) || !defined(__MMI_UCM_SLIM__) */
    }
}


/*****************************************************************************
 * FUNCTION
 *  srv_gcall_set_uid_info
 * DESCRIPTION
 *  
 * PARAMETERS
 *  call_type
 * RETURNS
 *  void
 *****************************************************************************/
void srv_gcall_set_uid_info(srv_ucm_id_info_struct *uid_info, U8 call_id, U8 group_id, srv_gcall_type_enum call_type)
{
    uid_info->call_id = call_id;
    uid_info->group_id = group_id;
    uid_info->call_type = srv_gcall_get_ucm_call_type(call_type);
}


#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))

#include "UcmSrvProt.h"

void srv_ucm_int_indication(srv_ucm_call_type_enum call_type, srv_ucm_int_ind_opcode_enum op_code, void *ind_data)
{
	
#if (defined __GBC_LOAD_APP_SWITCH_ON__ && defined __MTK_TARGET__)||(defined(__GBC_DEV_MODIS__))
	{
		extern BOOL GBC_ivr_run_handle(srv_ucm_int_ind_opcode_enum eDialStatusCb);

		kal_prompt_trace(MOD_XDM,"lzh------call_type %d , op_code %d , line : %d \n ",call_type,op_code,__LINE__);
		
		if (GBC_ivr_run_handle(op_code) == 1)	
		{		
			return;
		}
	}
#endif

	switch (op_code)
	{
		case SRV_UCM_INT_RING_IND:
			srv_ucm_ring_ind(ind_data);
			break;
		case SRV_UCM_INT_DIAL_IND:
			srv_ucm_dial_ind(ind_data);
			break;
		case SRV_UCM_INT_NOTIFY_IND:            
			srv_ucm_notify_ind(ind_data);
			break;
		case SRV_UCM_INT_CONNECT_IND:
			srv_ucm_connect_ind(ind_data);
			break;
		case SRV_UCM_INT_SESSION_IND:
			srv_ucm_session_ind(ind_data);
			break;
		case SRV_UCM_INT_SPEECH_IND:           
			srv_ucm_speech_ind(ind_data);
			break;
		case SRV_UCM_INT_CANCEL_QUERY_IND:
			srv_ucm_cancel_query_ind(call_type);
			break;
		case SRV_UCM_INT_RELEASE_IND:            
			srv_ucm_release_ind(ind_data);
			break;
		case SRV_UCM_INT_AUTO_REDIAL_IND:
			srv_ucm_auto_redial_ind(ind_data);
			break;
		case SRV_UCM_INT_DISCONNECTING_IND:
			srv_ucm_disconnecting_ind(ind_data);
			break;
		case SRV_UCM_INT_SYNC_CALL_LIST_IND:
			srv_ucm_sync_call_list(((srv_ucm_int_sync_call_list_ind_struct *)ind_data)->call_list);
			break;
		case SRV_UCM_INT_ALERT_IND:
			srv_ucm_alert_ind(ind_data);
			break;
	#ifdef __AOC_SUPPORT__
		case SRV_UCM_INT_CALL_COST_IND:
			srv_ucm_call_cost_ind(ind_data);
			break;
	#endif
		case SRV_UCM_INT_REPLACE_IND:
			srv_ucm_replace_ind(ind_data);
			break;
	#ifdef __MMI_VIDEO_TELEPHONY__
		case SRV_UCM_INT_START_COUNT_IND:
			srv_ucm_start_count_ind(ind_data);
			break;
	#endif
		default:
			MMI_ASSERT(0); /* not valid indication op_code */
			break;
		}
}
#endif


#endif /* __MMI_TELEPHONY_SUPPORT__ */