PhbSrvGprot.h 247 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 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *  PhbSrvGprot.h
 *
 * Project:
 * --------
 *  MAUI
 *
 * Description:
 * ------------
 *  This file contains external prototypes for phb service layer.
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/
#ifndef PHBSRVGPROT_H
#define PHBSRVGPROT_H

#include "custom_phb_config.h"
#include "MMIDataType.h"
#ifdef __MMI_DIALER_SEARCH__
#include "CallLogSrvGprot.h"
#endif

#include "MMI_features.h"
#include "mmi_res_range_def.h"
#include "kal_general_types.h"
#include "customer_email_num.h"
#include "ps_public_enum.h"
#include "ps_public_struct.h"
#include "custom_calllog.h"
#include "l4c_common_enum.h"
#ifdef __VCARD_CLOUD_SUPPORT__
#include "CloudSrvGprot.h"
#endif

#ifdef __cplusplus
extern "C"
{
#endif

#if !defined(LOW_COST_SUPPORT) || defined(__OP01__) || defined(__OP02__)
#define __MMI_PHB_SLIM_EXTRA_DEFEATURE__
#else
#undef __MMI_PHB_SLIM_EXTRA_DEFEATURE__
#endif

#if !defined(LOW_COST_SUPPORT) || defined(__MMI_PHB_STARTUP_COPY_SIM__) || defined(__OP01__)|| defined(__OP02__)||\
    defined(__TOPWELL_MMI_REMOTE_CONTROL__) || defined(__TOPWELL_MMI_PHB_SLIM_SETTING_MESS_OPERATION__)
#define __MMI_PHB_SLIM_SETTING_MESS_OPERATION__
#else
#undef __MMI_PHB_SLIM_SETTING_MESS_OPERATION__
#endif

#ifndef __ULC_AT__
#ifndef __MMI_PHB_ATCMD_SUPPORT__
#define __MMI_PHB_ATCMD_SUPPORT__
#endif 
#endif

#define SRV_PHB_SEARCH_LENGTH           ((MMI_PHB_NAME_LENGTH > MMI_PHB_NUMBER_LENGTH) ? MMI_PHB_NAME_LENGTH : MMI_PHB_NUMBER_LENGTH)/* max search length */

#ifndef SRV_FMGR_PATH_MAX_LEN
#define SRV_FMGR_PATH_MAX_LEN           (259)
#endif

/* PHB error result */
#define SRV_PHB_SIM_PARTIAL_ERROR       10        /* sim partial fail */
#define SRV_PHB_RES_ALL_ERROR           9         /* image & video write error */
#define SRV_PHB_IMAGE_RING_ERROR        7         /* image & ringtone write error */
#define SRV_PHB_RING_VIDEO_ERROR        6         /* ringtone & video write error */
#define SRV_PHB_IMAGE_VIDEO_ERROR       5         /* image & video write error */
#define SRV_PHB_RING_ERROR              4         /* ringtone write error */
#define SRV_PHB_IMAGE_ERROR             3         /* image write error */
#define SRV_PHB_VIDEO_ERROR             2         /* video write error */
#define SRV_PHB_NAME_MODIFIED           1         /* name have been truncated due to lengeth exceed SIM MAX name length */
#define SRV_PHB_NO_ERROR                0         /* Success */
#define SRV_PHB_ERROR                   -1        /* fail */
#define SRV_PHB_NOT_READY               -2        /* phonebook not ready */
#define SRV_PHB_NUM_NOT_READY           -3        /* phonebook number search not ready */
#define SRV_PHB_NOT_SUPPORT             -4        /* phonebook not support */
#define SRV_PHB_NOT_FOUND               -5        /* not found the contact */
#define SRV_PHB_DATAMGR_BUSY            -6        /* phonebook is busy, write operation fail due to other write operation is working */
#define SRV_PHB_STORAGE_FULL            -7        /* storage is full */
#define SRV_PHB_STORAGE_EMPTY           -8        /* storage is empty */
#define SRV_PHB_NO_SIM_CARD             -9       /* No SIM card */
#define SRV_PHB_ADN_FORBID              -10       /* SIM card contact can't access */
#define SRV_PHB_OUT_OF_INDEX            -11       /* invalid index */
#define SRV_PHB_NAME_NUM_EMPTY          -12       /* SIM card contact can't access */
#define SRV_PHB_NUMBER_TOO_LONG         -13       /* number too long */
#define SRV_PHB_BIRTHDAY_ERROR          -14       /* birthday error */
#define SRV_PHB_GROUP_NAME_EMPTY        -15       /* group name empty */
#define SRV_PHB_GROUP_NAME_DUP          -16       /* group name duplicate */
#define SRV_PHB_GROUP_FULL              -17       /* group full */
#define SRV_PHB_HALF_MARTCHED           -18       /* half matched */
#define SRV_PHB_SIM_ERROR               -19       /* SIM fail */
#define SRV_PHB_VCARD_INVALID           -20       /* vCard is invalid*/
#define SRV_PHB_TCARD_NOT_AVAILABLE     -21       /* memory card not available*/
#define SRV_PHB_CLOUD_NO_DATA           -22       /* SRV_CLD_NODATA*/
#define SRV_PHB_CLOUD_NO_MEMORY         -23       /* SRV_CLD_NO_MEMORY*/
#define SRV_PHB_CLOUD_FS_ERROR          -24       /* SRV_CLD_FS_ERROR*/
#define SRV_PHB_CLOUD_NETWORK_ERROR     -25       /* SRV_CLD_NWK_ERROR*/
#define SRV_PHB_CLOUD_LOGOUT            -26       /* SRV_CLD_LOGOUT*/
#define SRV_PHB_CLOUD_NO_NEED_SYNC      -27       /* SRV_CLD_NO_NEED_SYNC*/
#define SRV_PHB_CLOUD_NO_STORAGE        -28       /* SRV_CLD_NO_STORAGE*/
#define SRV_PHB_CLOUD_ACCOUNT_ERROR     -29       /* SRV_CLD_ACCT_ERROR*/
#define SRV_PHB_CLOUD_BUSY              -30       /* SRV_CLD_BUSY*/
#define SRV_PHB_CLOUD_UID_ERROR         -31       /* SRV_CLD_GET_UID_ERROR*/
#define SRV_PHB_CLOUD_ERROR             -32       /* SRV_CLD_ERROR */
#define SRV_PHB_CLOUD_DISK_FULL         -33       /* SRV_CLD_DISK_FULL*/
#define SRV_PHB_TCARD_ERROR             -34       /* memory card write error*/
#define SRV_PHB_GROUP_CANCEL_OP         -35       /* group cancel op */


/* PHB field type */
#define SRV_PHB_ENTRY_FIELD_NAME                0x00000001      /* phonebook name field */
#define SRV_PHB_ENTRY_FIELD_NICK                0x00000002      /* phonebook name field */
#define SRV_PHB_ENTRY_FIELD_NUMBER              0x00000004      /* phonebook mobile number field */
#define SRV_PHB_ENTRY_FIELD_OPT_NUM_1           0x00000008      /* phonebook home number field */
#define SRV_PHB_ENTRY_FIELD_OPT_NUM_2           0x00000010      /* phonebook office number field */
#define SRV_PHB_ENTRY_FIELD_OPT_NUM_3           0x00000020      /* phonebook fax number field */
#define SRV_PHB_ENTRY_FIELD_HOME                0x00000008      /* phonebook home number field */
#define SRV_PHB_ENTRY_FIELD_OFFICE              0x00000010      /* phonebook office number field */
#define SRV_PHB_ENTRY_FIELD_FAX                 0x00000020      /* phonebook fax number field */
#define SRV_PHB_ENTRY_FIELD_EMAIL1              0x00000040      /* phonebook email1 address field */
#define SRV_PHB_ENTRY_FIELD_EMAIL2              0x00000080      /* phonebook email2 address field */
#define SRV_PHB_ENTRY_FIELD_COMPANY             0x00000100      /* phonebook company name field */
#define SRV_PHB_ENTRY_FIELD_P0BOX               0x00000200      /* phonebook pobox field */
#define SRV_PHB_ENTRY_FIELD_EXTENSION           0x00000400      /* phonebook extension field */
#define SRV_PHB_ENTRY_FIELD_STREET              0x00000800      /* phonebook street field */
#define SRV_PHB_ENTRY_FIELD_CITY                0x00001000      /* phonebook city field */
#define SRV_PHB_ENTRY_FIELD_STATE               0x00002000      /* phonebook state field */
#define SRV_PHB_ENTRY_FIELD_POSTALCODE          0x00004000      /* phonebook postalcode field */
#define SRV_PHB_ENTRY_FIELD_COUNTRY             0x00008000      /* phonebook country field */
#define SRV_PHB_ENTRY_FIELD_VOIP                0x00010000      /* phonebook voip number field */
#define SRV_PHB_ENTRY_FIELD_IMPS                0x00020000      /* phonebook imps field */
#define SRV_PHB_ENTRY_FIELD_TITLE               0x00040000      /* phonebook title field */
#define SRV_PHB_ENTRY_FIELD_URL                 0x00080000      /* phonebook url field */
#define SRV_PHB_ENTRY_FIELD_NOTE                0x00100000      /* phonebook note field */
#define SRV_PHB_ENTRY_FIELD_GROUP               0x00200000      /* phonebook caller group field */
#define SRV_PHB_ENTRY_FIELD_BDAY                0x00400000      /* phonebook birthday field */
#define SRV_PHB_ENTRY_FIELD_RING                0x00800000      /* phonebook caller ringtione field */
#define SRV_PHB_ENTRY_FIELD_PIC                 0x01000000      /* phonebook caller video field */
#define SRV_PHB_ENTRY_FIELD_VIDEO               0x02000000      /* phonebook caller pic field */
#define SRV_PHB_ENTRY_FIELD_DEF                 0x04000000      /* phonebook default number field */
#define SRV_PHB_ENTRY_FIELD_ALL                 0xFFFFFFFF      /* phonebook ALL field */

#define SRV_PHB_ENTRY_FIELD_SIM                 (SRV_PHB_ENTRY_FIELD_NAME | SRV_PHB_ENTRY_FIELD_NUMBER)    /* phonebook SIM fields */
#define SRV_PHB_ENTRY_FIELD_OPTIONAL_NUM        (SRV_PHB_ENTRY_FIELD_OPT_NUM_1 | SRV_PHB_ENTRY_FIELD_OPT_NUM_2 | SRV_PHB_ENTRY_FIELD_OPT_NUM_3) /* phonebook optional number fields */
#define SRV_PHB_ENTRY_FIELD_OPTIONAL            (SRV_PHB_ENTRY_FIELD_OPTIONAL_NUM | SRV_PHB_ENTRY_FIELD_EMAIL | SRV_PHB_ENTRY_FIELD_COMPANY) /* phonebook optional fields */
#define SRV_PHB_ENTRY_FIELD_ADDRESS             (SRV_PHB_ENTRY_FIELD_P0BOX | SRV_PHB_ENTRY_FIELD_EXTENSION | SRV_PHB_ENTRY_FIELD_STREET | SRV_PHB_ENTRY_FIELD_CITY | SRV_PHB_ENTRY_FIELD_STATE | SRV_PHB_ENTRY_FIELD_POSTALCODE | SRV_PHB_ENTRY_FIELD_COUNTRY)
#define SRV_PHB_ENTRY_FIELD_INFO                (SRV_PHB_ENTRY_FIELD_ADDRESS | SRV_PHB_ENTRY_FIELD_TITLE | SRV_PHB_ENTRY_FIELD_URL | SRV_PHB_ENTRY_FIELD_NOTE)    /* phonebook info fields */
#define SRV_PHB_ENTRY_FIELD_RES                 (SRV_PHB_ENTRY_FIELD_RING | SRV_PHB_ENTRY_FIELD_PIC | SRV_PHB_ENTRY_FIELD_VIDEO)    /* phonebook res fields */

#define SRV_PHB_ENTRY_FIELD_GSM_NUM             (SRV_PHB_ENTRY_FIELD_NUMBER | SRV_PHB_ENTRY_FIELD_OPTIONAL_NUM)    /* phonebook gsm number fields */
#define SRV_PHB_ENTRY_FIELD_ALL_NUM             (SRV_PHB_ENTRY_FIELD_GSM_NUM | SRV_PHB_ENTRY_FIELD_VOIP)    /* phonebook all number fields */
#define SRV_PHB_ENTRY_FIELD_EMAIL               (SRV_PHB_ENTRY_FIELD_EMAIL1 | SRV_PHB_ENTRY_FIELD_EMAIL2)   /* phonebook all email fields */
#define SRV_PHB_ENTRY_FIELD_MMS                 (SRV_PHB_ENTRY_FIELD_GSM_NUM | SRV_PHB_ENTRY_FIELD_EMAIL)   /* phonebook gsm number & email fields */
#define SRV_PHB_ENTRY_FIELD_MMS_PHB             (SRV_PHB_ENTRY_FIELD_NUMBER | SRV_PHB_ENTRY_FIELD_EMAIL)    /* phonebook mobile number & email fields */

#define SRV_PHB_ENTRY_FIELD_VCARD               (SRV_PHB_ENTRY_FIELD_SIM | SRV_PHB_ENTRY_FIELD_OPTIONAL | SRV_PHB_ENTRY_FIELD_INFO | SRV_PHB_ENTRY_FIELD_GROUP | SRV_PHB_ENTRY_FIELD_BDAY | SRV_PHB_ENTRY_FIELD_PIC) /* vcard support fields */
#define SRV_PHB_ENTRY_FIELD_VENDOR              (SRV_PHB_ENTRY_FIELD_SIM | SRV_PHB_ENTRY_FIELD_OPTIONAL | SRV_PHB_ENTRY_FIELD_INFO | SRV_PHB_ENTRY_FIELD_GROUP | SRV_PHB_ENTRY_FIELD_BDAY) /* vendor support fields */

#define SRV_PHB_INVALID_INDEX                   0xFFFF

/* caller resource type */
#define  SRV_PHB_RES_TYPE_RING_ID               0x0001
#define  SRV_PHB_RES_TYPE_IMAGE_ID              0x0002
#define  SRV_PHB_RES_TYPE_VIDEO_ID              0x0004
#define  SRV_PHB_RES_TYPE_AUDIO_RING_FILE       0x0008
#define  SRV_PHB_RES_TYPE_VIDEO_RING_FILE       0x0010
#define  SRV_PHB_RES_TYPE_IMAGE_FILE            0x0020
#define  SRV_PHB_RES_TYPE_VIDEO_FILE            0x0040
#define  SRV_PHB_RES_TYPE_VIDEO_SOUND_ON        0x0080

#define  SRV_PHB_RES_TYPE_RING_FILE             (SRV_PHB_RES_TYPE_AUDIO_RING_FILE | SRV_PHB_RES_TYPE_VIDEO_RING_FILE)

#define  SRV_PHB_RES_TYPE_RING                  (SRV_PHB_RES_TYPE_RING_ID | SRV_PHB_RES_TYPE_RING_FILE)
#define  SRV_PHB_RES_TYPE_IMAGE                 (SRV_PHB_RES_TYPE_IMAGE_ID | SRV_PHB_RES_TYPE_IMAGE_FILE)
#define  SRV_PHB_RES_TYPE_VIDEO                 (SRV_PHB_RES_TYPE_VIDEO_ID | SRV_PHB_RES_TYPE_VIDEO_FILE | SRV_PHB_RES_TYPE_VIDEO_SOUND_ON)

#define  SRV_PHB_RES_TYPE_VISUAL                (SRV_PHB_RES_TYPE_IMAGE | SRV_PHB_RES_TYPE_VIDEO | SRV_PHB_RES_TYPE_VIDEO_RING_FILE)

#if defined(DEBUG_KAL) && defined(DEBUG_BUF2)
#define srv_phb_mem_malloc(size, type)          srv_phb_mem_malloc_ext(size, type, __FILE__, __LINE__)
#define srv_phb_mem_free(memblock)              srv_phb_mem_free_ext(memblock, __FILE__, __LINE__)
#else /* defined(DEBUG_KAL) && defined(DEBUG_BUF2) */ 
#define srv_phb_mem_malloc(size, type)          srv_phb_mem_malloc_ext(size, type, "", __LINE__)
#define srv_phb_mem_free(memblock)              srv_phb_mem_free_ext(memblock, "", __LINE__)
#endif /* defined(DEBUG_KAL) && defined(DEBUG_BUF2) */


/***************************************************************************** 
 * Typedef 
 *****************************************************************************/

/****************************************************/
/*                                                  */
/*               Enum                               */
/*                                                  */
/****************************************************/

typedef enum
{
    EVT_ID_PHB_ADD_CONTACT = SRV_PHB_BASE + 1,
    EVT_ID_PHB_UPD_CONTACT,
    EVT_ID_PHB_DEL_CONTACT,
    EVT_ID_PHB_READY,                           /* srv_phb_startup_evt_struct */
    EVT_ID_PHB_AT_NOTIFY,                       /* srv_phb_at_notify_evt_struct */
    EVT_ID_PHB_OWNER_NUMBER_CHANGED,            /* srv_phb_owner_number_changed_evt_struct */
    EVT_ID_PHB_OP_GROUP,
    EVT_ID_PHB_MULTI_OP_STATUS,
    EVT_ID_PHB_STORAGE_CHANGE,
    EVT_ID_PHB_NAME_SEQUENCE_CHANGE,
    EVT_ID_PHB_BACKUP_RESTORE_NCENTER,
    EVT_ID_PHB_FIELD_TYPE_CHNAGED_IND,
    EVT_ID_PHB_PRE_UPDATE_CONTACT,
    EVT_ID_PHB_MULTI_OP_DONE,
    #ifdef __SRV_PHB_TCARD_STORAGE_SUPPORT__
    EVT_ID_PHB_TCARD_READY,
    #endif
    EVT_ID_PHB_PBAPC_NOTIFY,
    EVT_ID_PBAP_NOTIFY,
    EVT_ID_PHB_MAX
} srv_phb_event_enum;


typedef enum
{
    SRV_PHB_NAME_DISPLAY_TYPE_NONE,
    SRV_PHB_NAME_DISPLAY_TYPE_1,                /* last name first name */
    SRV_PHB_NAME_DISPLAY_TYPE_2,                /* last name,first name */
    SRV_PHB_NAME_DISPLAY_TYPE_3,                /* first name last name */
    SRV_PHB_NAME_DISPLAY_TYPE_4,                /* first name,last name */
    SRV_PHB_NAME_DISPLAY_TYPE_TOTAL
} srv_phb_name_display_type_enum;


/* phonebook search type enmu */
typedef enum
{
    SRV_PHB_SEARCH_TYPE_NAME,                   /* search name */
    SRV_PHB_SEARCH_TYPE_NUM,                    /* search number */
    SRV_PHB_SEARCH_TYPE_TOTAL                   /* enum total */
} srv_phb_search_type_enum;


/* phonebook memory type enmu */
typedef enum
{
    SRV_PHB_MEMORY_TYPE_CTR,                    /* control buffer */
    SRV_PHB_MEMORY_TYPE_ADM,                    /* phb ADM buffer */
    SRV_PHB_MEMORY_TYPE_TOTAL                   /* enum total */
} srv_phb_memory_type_enum;


/* phonebook check storage type enmu */
typedef enum
{
    SRV_PHB_CHECK_STORAGE_EMPTY,
    SRV_PHB_CHECK_STORAGE_FULL,
    SRV_PHB_CHECK_STORAGE_FULL_OR_EMPTY,
    SRV_PHB_CHECK_STORAGE_TYPE_TOTAL
} srv_phb_check_storage_type_enum;


typedef enum
{
    SRV_PHB_AT_OP_TYPE_ADD,
    SRV_PHB_AT_OP_TYPE_EDIT,
    SRV_PHB_AT_OP_TYPE_DELETE,
    SRV_PHB_AT_OP_TYPE_DELETE_ALL,
    SRV_PHB_AT_OP_TYPE_TOTAL
} srv_phb_at_op_type_enum;


typedef enum
{
    SRV_PHB_GROUP_OP_TYPE_ADD,
    SRV_PHB_GROUP_OP_TYPE_UPD,
    SRV_PHB_GROUP_OP_TYPE_DEL,
    SRV_PHB_GROUP_OP_TYPE_ADD_MEMBER,
    SRV_PHB_GROUP_OP_TYPE_REMOVE_MEMBER,

    SRV_PHB_GROUP_OP_TYPE_TOTAL
} srv_phb_group_op_type_enum;

typedef enum
{
    SRV_PHB_NUMBER_OP_TYPE_DIAL = 0x0F,
    SRV_PHB_NUMBER_OP_TYPE_MESSAGE = 0xF0,
    SRV_PHB_NUMBER_OP_TYPE_ALL = 0xFF,
    SRV_PHB_NUMBER_OP_TYPE_TOTAL
} srv_phb_number_op_type_enum;


/****************************************************/
/*                                                  */
/*               Struct                             */
/*                                                  */
/****************************************************/


/* phonebook contact field data struct */
typedef struct
{
    U16* name;                                              /* WCS name field point */
    U16* l_name;                                            /* WCS last name field point */
    U16* n_name;                                            /* WCS nick name field point */
    U16* number;                                            /* WCS mobile number field point */
    mmi_phb_wcs_num_struct* opt_num[MMI_PHB_OPT_NUM_COUNT]; /* optional number field point array */
    U8* opt_order;
    
    /* to be remove begin */
    U16* home_number;                                       /* WCS home number field point */
    U16* office_number;                                     /* WCS office number field point */
    U16* fax_number;                                        /* WCS fax number field point */
    /* to be remove end */
    
    U16* company_name;                                      /* WCS company name field point */
    U16* email_address;                                     /* WCS eamil address field point */
    U16* email_address2;                                    /* WCS eamil address field point */
    U16 b_year;                                             /* birthday year field */
    U8 b_month;                                             /* birthday month field */
    U8 b_day;                                               /* birthday day field */
    U16* title;                                             /* WCS title field point */
    U16* url;                                               /* WCS url field point */
    U16* pobox;                                             /* WCS pobox field point */
    U16* extension;                                         /* WCS extension field point */
    U16* street;                                            /* WCS street field point */
    U16* city;                                              /* WCS city field point */
    U16* state;                                             /* WCS state field point */
    U16* postalcode;                                        /* WCS postal code field point */
    U16* country;                                           /* WCS country field point */
    U16* note;                                              /* WCS note field point */
    U32 group_mask;                                         /* group mask field */
    U16* ringtone_path;                                     /* WCS caller ringtone path point */
    U16* image_path;                                        /* WCS caller pic path point */
    U16* video_path;                                        /* WCS caller video path point */
    U16 ringtone_id;                                        /* caller ringtone id */
    U16 image_id;                                           /* caller pic id */
    U16 video_id;                                           /* caller video id */
    U16 res_type;                                           /* caller res type */
    U8 default_number;                                      /* default number field point */
    U16* imps;                                              /* WCS imps field point */
    U16* voip;                                              /* WCS voip field point */
} srv_phb_contact_data_struct;


/* phonebook contact info struct */
typedef struct
{
    U32 field_mask;                             /* contain field mask */
    srv_phb_contact_data_struct field_data;     /* contact's field data */
} srv_phb_contact_info_struct;


/* phonebook group_filter struct */
typedef struct
{
    U32 group_mask;                             /* group mask */
    MMI_BOOL is_equal;                          /* MMI_TRUE: filter all contacts in the group, else filter all contacts not in the group */
} srv_phb_group_filter_struct;


/* phonebook qsearch filter struct */
typedef struct
{
    U16* key_word;                              /* input key word */
    U16 key_len;
    U16 input_mode;                             /* input mode */
} srv_phb_qsearch_filter_struct;


/* phonebook qsearch filter struct */
typedef struct
{
    U16* key_word;                              /* input key word */
    U16 key_len;
} srv_phb_name_filter_struct;


/* phonebook filter struct */
typedef struct
{
    U8 storage;                                 /* storage filter */
    U32 field_filter;                           /* field filter */
    srv_phb_name_filter_struct* name_filter;    /* name filter */
    srv_phb_qsearch_filter_struct* qsearch_filter;  /* quick search filter */
    srv_phb_group_filter_struct* group_filter;  /* group filter */
} srv_phb_filter_struct;


/* phonebook contact position struct */
typedef struct
{
    U16 index;                                  /* index: 1 - MAX index */
    U8 storage;                                 /* storage: SIM, PHONE, SIM2 */
} srv_phb_contact_pos_struct;


/* PHB ready event struct */
typedef struct
{
    MMI_EVT_PARAM_HEADER
    MMI_BOOL phb_ready;                         /* PHB ready or not */
    MMI_BOOL sim_refresh;                       /* SAT SIM refresh or not */
    U8 storage;                                 /* PHB storage is available only if SAT SIM refresh is TRUE */
} srv_phb_startup_evt_struct;


/* AT notify event struct */
typedef struct
{
    MMI_EVT_PARAM_HEADER
    srv_phb_at_op_type_enum op_type;
} srv_phb_at_notify_evt_struct;


/* Owner number changed event struct */
typedef struct
{
    MMI_EVT_PARAM_HEADER
    U8 sim_interface;                           /* SIM1/SIM2 */
    U16 index;                                  /* LINE1(0)/LINE2(1) */
} srv_phb_owner_number_changed_evt_struct;


typedef struct
{
    MMI_EVT_PARAM_HEADER
    srv_phb_group_op_type_enum op_type;
    U8 group_id;                                /* group_id */
    mmi_phb_group_info_struct* group_info;      /* group info */
} srv_phb_group_op_evt_struct;


typedef struct
{
    MMI_EVT_PARAM_HEADER
    U16 old_storage_mask;                        /* old prefer storage mask */
    U16 new_storage_mask;                        /* new prefer storage mask */
} srv_phb_storage_change_evt_struct;


typedef struct
{
    MMI_EVT_PARAM_HEADER
    U8 old_name_sequence;                        /* old name show sequence */
    U8 new_name_sequence;                        /* new name show sequence */
} srv_phb_name_sequence_change_evt_struct;


typedef struct
{
    MMI_EVT_PARAM_HEADER
    U16 success_count;                           /* success count */
    U16 total_count;                             /* total count */
} srv_phb_backup_restore_evt_struct;


typedef struct
{
    MMI_EVT_PARAM_HEADER
    U16 finish_count;                           /* finish count */
    U16 fail_count;                             /* fail count */
    U16 total_count;                            /* total count */
} srv_phb_multi_op_status_evt_struct;

typedef struct
{
    MMI_EVT_PARAM_HEADER
    U16 finish_count;                           /* finish count */
    U16 fail_count;                             /* fail count */
    U16 total_count;                            /* total count */
    U8 type;                                    /*srv_phb_op_cb_type_enum*/
} srv_phb_multi_op_done_evt_struct;

/* field type changed */
typedef struct
{
    MMI_EVT_PARAM_HEADER

    U32 field_type;
    U32 field_sub_type;
    MMI_BOOL is_delete;
    MMI_BOOL result;
} srv_phb_field_type_changed_ind_struct;

#ifdef __SRV_PHB_TCARD_STORAGE_SUPPORT__
typedef struct
{
    MMI_EVT_PARAM_HEADER
        
    MMI_BOOL is_ready;
} srv_phb_tcard_ready_evt_struct;
#endif

/****************************************************/
/*                                                  */
/*          Struct for vendor                       */
/*                                                  */
/****************************************************/


/* phonebook contact info struct for SDK */
typedef struct
{
    srv_phb_contact_pos_struct pos;                         /* contact position */
    U16 name[MMI_PHB_NAME_LENGTH + 1];                      /* contact name field(UCS2) */
    U16 number[MMI_PHB_NUMBER_PLUS_LENGTH + 1];             /* contact mobile number field(UCS2) */
#ifdef __MMI_PHB_OPTIONAL_FIELD__
    U16 home_number[MMI_PHB_NUMBER_PLUS_LENGTH + 1];        /* contact home number field(UCS2) */
    U16 office_number[MMI_PHB_NUMBER_PLUS_LENGTH + 1];      /* contact office number field(UCS2) */
    U16 fax_number[MMI_PHB_NUMBER_PLUS_LENGTH + 1];         /* contact fax number field(UCS2) */
    mmi_phb_wcs_num_struct opt_num[3];
    U16 email_address[MMI_PHB_EMAIL_LENGTH + 1];            /* contact email field(UCS2) */
#ifdef __MMI_PHB_OPTIONAL_FIELDS_2ND_EMAIL__
    U16 email_address2[MMI_PHB_EMAIL_LENGTH + 1];           /* contact email2 field(UCS2) */
#endif /* __MMI_PHB_OPTIONAL_FIELDS_2ND_EMAIL__ */
    U16 company_name[MMI_PHB_COMPANY_LENGTH + 1];           /* contact company name field(UCS2) */
#endif /* __MMI_PHB_OPTIONAL_FIELD__ */
#if defined(__MMI_PHB_BIRTHDAY_FIELD__)
    U8 birth_day;                                           /* contact birthday-day field */
    U8 birth_mon;                                           /* contact birthday-month field */
    U16 birth_year;                                         /* contact birthday-year field */
#endif	/* __MMI_PHB_BIRTHDAY_FIELD__ */
#if defined(__MMI_PHB_INFO_FIELD__)
    U16 title[MMI_PHB_TITLE_LENGTH + 1];                    /* contact title field(UCS2) */
    U16 url[MMI_PHB_URL_LENGTH + 1];                        /* contact url field(UCS2) */
    U16 adr_pobox[MMI_PHB_ADDRESS_LENGTH + 1];              /* contact address-pobox field(UCS2) */
    U16 adr_extension[MMI_PHB_ADDRESS_LENGTH + 1];          /* contact address-extention field(UCS2) */
    U16 adr_street[MMI_PHB_ADDRESS_LENGTH + 1];             /* contact address-street field(UCS2) */
    U16 adr_city[MMI_PHB_ADDRESS_LENGTH + 1];               /* contact address-city field(UCS2) */
    U16 adr_state[MMI_PHB_ADDRESS_LENGTH + 1];              /* contact address-state field(UCS2) */
    U16 adr_postal_code[MMI_PHB_ADDRESS_LENGTH + 1];        /* contact address-state field(UCS2) */
    U16 adr_country[MMI_PHB_ADDRESS_LENGTH + 1];            /* contact address-postal code field(UCS2) */
    U16 note[MMI_PHB_NOTE_LENGTH + 1];                      /* contact note field(UCS2) */
#endif /* __MMI_PHB_INFO_FIELD__ */
    U32 group_mask;                                         /* contact group field(bitmask) */
} srv_phb_sdk_contact_struct;


/* add contact req struct for SDK */
typedef struct {
    phb_storage_enum storage;                   /* storage */
    srv_phb_sdk_contact_struct* contact_ptr;    /* contact info point */
} srv_phb_sdk_add_req_struct;


/* update contact req struct for SDK */
typedef struct
{
    srv_phb_contact_pos_struct pos;             /* contact position */
    srv_phb_sdk_contact_struct* contact_ptr;    /* contact info point */
} srv_phb_sdk_update_req_struct;


/* delete contact req struct for SDK */
typedef struct
{
   srv_phb_contact_pos_struct pos;              /* contact position */
} srv_phb_sdk_delete_req_struct;


/* get contact req struct for SDK */
typedef struct
{
    srv_phb_contact_pos_struct pos;             /* contact position */
    srv_phb_sdk_contact_struct* contact_ptr;    /* contact info point */
} srv_phb_sdk_get_req_struct;


/* search contact req struct for SDK */
typedef struct
{
    U16  pattern_ucs2[SRV_PHB_SEARCH_LENGTH];   /* search pattern(UCS2) */
    srv_phb_search_type_enum search_type;       /* search type */
    srv_phb_sdk_contact_struct* contact_ptr;    /* contact info point */
} srv_phb_sdk_search_req_struct;


/****************************************************/
/*                                                  */
/*          OP_LIB CB                               */
/*                                                  */
/****************************************************/

/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_async_func_type
 * DESCRIPTION
 *  Definition of callback for async event interface
 * PARAMETERS
 *  user_data:          [IN]        User data
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_async_func_type) (void *user_data);


/*****************************************************************************
 * <Query CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_query_async_func_type
 * DESCRIPTION
 *  Definition of callback for query callback interface
 * PARAMETERS
 *  user_data:          [IN]        User data
 * RETURNS
 *  void
 *****************************************************************************/


typedef struct
{
    S32 result;
    void *user_data;
} srv_phb_query_async_cb_result_struct;


typedef void (*srv_phb_query_async_func_type) (srv_phb_query_async_cb_result_struct *ret);

typedef void * ( *srv_phb_query_mem_alloc_func_type)(U32 len, void *user_data);

typedef void ( *srv_phb_query_mem_free_func_type)(void *ptr, void *user_data);

/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_op_callback_type
 * DESCRIPTION
 *  callback function type for phb op
 * PARAMETERS
 *  result            :    [IN]     result
 *  id                :    [IN]     contact's store_index
 *  user_data:        :    [IN]     user data
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_op_callback_type)(S32 result, mmi_phb_contact_id id, void* user_data);


/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_op_all_callback_type
 * DESCRIPTION
 *  callback function type for copy/move/delete all
 * PARAMETERS
 *  finish_count        :   [IN]    finish count
 *  total_count         :   [IN]    total count
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_op_all_callback_type)(U16 finish_count, U16 total_count, void* user_data);


/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_op_several_callback_type
 * DESCRIPTION
 *  callback function type for phb multi op
 * PARAMETERS
 *  entry_array         :   [IN]    store index array
 *  finish_count        :   [IN]    finish count
 *  total_count         :   [IN]    total count
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_op_several_callback_type)(U16* entry_array, U16 finish_count, U16 total_count, void* user_data);


/****************************************************/
/*                                                  */
/*          CB for vendor                           */
/*                                                  */
/****************************************************/


/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_sdk_callback_type
 * DESCRIPTION
 *  callback function type for SDK operation
 * PARAMETERS
 *  result              :   [IN]    result
 *  contact_ptr         :   [IN]    contact info point
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_sdk_callback_type)(S32 result, srv_phb_sdk_contact_struct* contact_ptr);


/***************************************************************************** 
 * Global Function 
 *****************************************************************************/


/****************************************************/
/*                                                  */
/*          API for vendor                          */
/*                                                  */
/****************************************************/


/*****************************************************************************
 * FUNCTION
 *  srv_phb_sdk_is_phb_ready
 * DESCRIPTION
 *  check phonebook is ready
 * PARAMETERS
 *  void
 * RETURNS
 *  MMI_BOOL
 * RETURN VALUES
 *  MMI_TRUE            :           phonebook ready
 *  MMI_FALSE           :           phonebook not ready
 *****************************************************************************/
extern MMI_BOOL srv_phb_sdk_is_phb_ready(void);


/*****************************************************************************
 * FUNCTION
 *  mmi_phb_sdk_add_contact
 * DESCRIPTION
 *  add contact API for SDK
 * PARAMETERS
 *  req_info            :   [IN]    add contact req_info
 *  cb                  :   [IN]    callback function
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_sdk_add_contact(srv_phb_sdk_add_req_struct* req_info, srv_phb_sdk_callback_type cb);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_sdk_update_contact
 * DESCRIPTION
 *  update contact API for SDK
 * PARAMETERS
 *  req_info            :   [IN]    update contact req_info
 *  cb                  :   [IN]    callback function
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_sdk_update_contact(srv_phb_sdk_update_req_struct* req_info, srv_phb_sdk_callback_type cb);


/*****************************************************************************
 * FUNCTION
 *  mmi_phb_sdk_delete_contact
 * DESCRIPTION
 *  delete contact API for SDK
 * PARAMETERS
 *  req_info            :   [IN]    delete contact req_info
 *  cb                  :   [IN]    callback function
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_sdk_delete_contact(srv_phb_sdk_delete_req_struct* req_info, srv_phb_sdk_callback_type cb);


/*****************************************************************************
 * FUNCTION
 *  mmi_phb_sdk_get_contact 
 * DESCRIPTION
 *  get contact API for SDK
 * PARAMETERS
 *  req_info            :   [IN]    get contact req_info
 * RETURNS
 *  result
 *****************************************************************************/
extern S32 srv_phb_sdk_get_contact(srv_phb_sdk_get_req_struct* req_info);


/*****************************************************************************
 * FUNCTION
 *  mmi_phb_sdk_search_contact 
 * DESCRIPTION
 *  search contact API for SDK
 * PARAMETERS
 *  req_info            :   [IN]    search contact req_info
 * RETURNS
 *  result
 *****************************************************************************/
extern S32 srv_phb_sdk_search_contact(srv_phb_sdk_search_req_struct* req_info);


/*****************************************************************************
 * FUNCTION
 *  mmi_phb_sdk_get_total_contacts   
 * DESCRIPTION
 *  get total contacts of phonebook
 * PARAMETERS
 *  storage             :   [IN]    storage
 * RETURNS
 *  S32
 * RETURN VALUES
 *  < 0                 :           error result
 *  >0                  :           total contacts count
 *****************************************************************************/
extern S32 srv_phb_sdk_get_total_contacts(phb_storage_enum storage);


/*****************************************************************************
 * FUNCTION
 *  mmi_phb_sdk_get_used_contacts   
 * DESCRIPTION
 *  store data to phonebook
 * PARAMETERS
 *  pos_array           :   [OUT]   used contact position array ordered by name, no need set it as NULL
 *  storage             :   [IN]    storage
 * RETURNS
 *  S32
 * RETURN VALUES
 *  < 0                 :           error result
 *  >0                  :           used contacts count
 *****************************************************************************/
extern S32 srv_phb_sdk_get_used_contacts(srv_phb_contact_pos_struct* pos_array, phb_storage_enum storage);


/****************************************************/
/*                                                  */
/*      Internal API, for PB AP only                */
/*                                                  */
/****************************************************/

/*****************************************************************************
 * FUNCTION
 *  srv_phb_mem_malloc_ext
 * DESCRIPTION
 *  memory malloc function
 * PARAMETERS
 *  size                :   [IN]    buffer size to malloc
 *  type                :   [IN]    memory type
 *  file                :   [IN]    file
 *  line                :   [IN]    line
 * RETURNS
 *  void*
 * RETURN VALUES
 *  NULL                :           malloc fail
 *  other               :           buffer point
 *****************************************************************************/
extern void* srv_phb_mem_malloc_ext(S32 size, srv_phb_memory_type_enum type, const char* file, int line);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_mem_free_ext
 * DESCRIPTION
 *  memory free function
 * PARAMETERS
 *  memblock            :   [IN]    buffer point
 *  file                :   [IN]    file
 *  line                :   [IN]    line
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_mem_free_ext(void* memblock, const char* file, int line);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_build_contact_list
 * DESCRIPTION
 *  build contact store_index array by filter
 * PARAMETERS
 *  filter              :   [IN]    build list filter
 *  entry_array         :   [OUT]   output store_index array
 *  max_count           :   [IN]    max count of store_index array
 * RETURNS
 *  S32
 * RETURN VALUES
 *  >=0                 :           matched contact's count
 *  <0                  :           refer phb error result
 *****************************************************************************/
extern S32 srv_phb_oplib_build_contact_list(srv_phb_filter_struct* filter, U16* entry_array, U32 max_count);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_build_alpha_jump_table
 * DESCRIPTION
 *  build alpha jump table
 * PARAMETERS
 *  entry_array         :   [IN]    list contact's store_index array
 *  entry_count         :   [IN]    list contact's count
 * RETURNS
 *  void
 *****************************************************************************/
extern S32 srv_phb_oplib_build_alpha_jump_table(U16* entry_array, U16 entry_count);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_get_alpha_index
 * DESCRIPTION
 *  get alpha jump index
 * PARAMETERS
 *  input_char          :   [IN]    input char
 * RETURNS
 *  U16
 * RETURN VALUES
 *  index               :           jump index
 *****************************************************************************/
extern U16 srv_phb_oplib_get_alpha_index(U16 input_char);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_search
 * DESCRIPTION
 *  search a contact by name or number
 * PARAMETERS
 *  pattern_ucs2        :   [IN]    search patern
 *  search_type         :   [IN]    search type, refer srv_phb_search_type_enum
 * RETURNS
 *  S32
 * RETURN VALUES
 *  >=0                 :           matched contact's store_index
 *  <0                  :           refer phb error result
 *****************************************************************************/
extern S32 srv_phb_oplib_search(U16* pattern_ucs2, srv_phb_search_type_enum search_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_get_contact_info
 * DESCRIPTION
 *  get contact's info by store_index
 * PARAMETERS
 *  store_index         :   [IN]    contact's store_index
 *  contact_info        :   [OUT]   contact's info
 * RETURNS
 *  S32
 * RETURN VALUES
 *  SRV_PHB_NO_ERROR    :           get contact info success
 *  Others              :           refer phb error result
 *****************************************************************************/
extern S32 srv_phb_oplib_get_contact_info(U16 store_index, srv_phb_contact_info_struct* contact_info);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_add_contact
 * DESCRIPTION
 *  add a phonebook contact
 * PARAMETERS
 *  storage             :   [IN]    storage to add, refer phb_storage_enum
 *  record_index        :   [IN]    record index to add, start at 1
 *  contact_info        :   [IN]    contact's info
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_add_contact(U8 storage, U16 record_index, srv_phb_contact_info_struct* contact_info, srv_phb_op_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_update_contact
 * DESCRIPTION
 *  edit a phonebook contact
 * PARAMETERS
 *  store_index         :   [IN]    contact's store_index
 *  contact_info        :   [IN]    contact's info
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_update_contact(U16 store_index, srv_phb_contact_info_struct* contact_info, srv_phb_op_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_delete_contact
 * DESCRIPTION
 *  delete a phonebook contact
 * PARAMETERS
 *  store_index         :   [IN]    contact's store_index
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_delete_contact(U16 store_index, srv_phb_op_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_copy_contact
 * DESCRIPTION
 *  copy a phonebook contact
 * PARAMETERS
 *  dst_storage         :   [IN]    dest storage
 *  store_index         :   [IN]    source contact's store_index
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_copy_contact(U8 dst_storage, U16 store_index, srv_phb_op_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_move_contact
 * DESCRIPTION
 *  move a phonebook contact
 * PARAMETERS
 *  dst_storage         :   [IN]    dest storage
 *  store_index         :   [IN]    source contact's store_index
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_move_contact(U8 dst_storage, U16 store_index, srv_phb_op_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_delete_all_contact
 * DESCRIPTION
 *  delete all contacst of a storage
 * PARAMETERS
 *  storage             :   [IN]    storage
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_delete_all_contact(U8 storage, srv_phb_op_all_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_build_contact_list
 * DESCRIPTION
 *  build contact store_index array by filter
 * PARAMETERS
 *  filter              :   [IN]    build list filter
 *  entry_array         :   [OUT]   output store_index array
 * RETURNS
 *  S32
 * RETURN VALUES
 *  >=0                 :           matched contact's count
 *  <0                  :           refer phb error result
 *****************************************************************************/
extern void srv_phb_oplib_cancel_multi_op(void);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_copy_all_contact
 * DESCRIPTION
 *  copy all contacst of a storage
 * PARAMETERS
 *  src_storage         :   [IN]    source storage
 *  dst_storage         :   [IN]    dest storage
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_copy_all_contact(U8 src_storage, U8 dst_storage, srv_phb_op_all_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_move_all_contact
 * DESCRIPTION
 *  move all contacst of a storage
 * PARAMETERS
 *  src_storage         :   [IN]    source storage
 *  dst_storage         :   [IN]    dest storage
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_move_all_contact(U8 src_storage, U8 dst_storage, srv_phb_op_all_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_delete_several_contact
 * DESCRIPTION
 *  delete several contacts to a storage
 * PARAMETERS
 *  entry_array         :   [IN]    source store_index array
 *  entry_count         :   [IN]    source store_index count
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_delete_several_contact(U16* entry_array, U16 entry_count, srv_phb_op_several_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_copy_several_contact
 * DESCRIPTION
 *  copy several contacts to a storage
 * PARAMETERS
 *  entry_array         :   [IN]    source store_index array
 *  entry_count         :   [IN]    source store_index count
 *  dst_storage         :   [IN]    dest storage
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_copy_several_contact(U16* entry_array, U16 entry_count, U8 dst_storage, srv_phb_op_several_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_oplib_move_several_contact
 * DESCRIPTION
 *  move several contacts to a storage
 * PARAMETERS
 *  entry_array         :   [IN]    source store_index array
 *  entry_count         :   [IN]    source store_index count
 *  dst_storage         :   [IN]    dest storage
 *  cb                  :   [IN]    call back function
 *  user_data           :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_oplib_move_several_contact(U16* entry_array, U16 entry_count, U8 dst_storage, srv_phb_op_several_callback_type cb, void* user_data);

typedef void (*srv_phb_group_callback_type)(S32 result, void* user_data);

/* group info interface struct */
typedef struct
{
    U16 group_name[MMI_PHB_GROUP_NAME_LENGTH + 1];
    U16 res_type;
    U16 image_id;
    U16 image_path[SRV_FMGR_PATH_MAX_LEN + 1];
    U16 ringtone_id;
    U16 ringtone_path[SRV_FMGR_PATH_MAX_LEN + 1];
    #ifdef __MMI_PHB_CALLER_VIDEO__
    U16 video_id;
    U16 video_path[SRV_FMGR_PATH_MAX_LEN + 1];
    #endif
    phb_storage_enum storage;
    srv_phb_group_callback_type cb;
    void *user_data;
} srv_phb_group_info_struct;

/*****************************************************************************
 * FUNCTION
 *  srv_phb_datamgr_get_group_list
 * DESCRIPTION
 *  get group id list ordered by group name
 * PARAMETERS
 *  group_array         :   [OUT]   group id array
 *  group_name          :   [IN]    group name
 * RETURNS
 *  U8
 * RETURN VALUES
 *  count               :           group count
 ****************************************************************************/
extern U8 srv_phb_datamgr_get_group_list(U8* group_array, U16* group_name);

#if defined(__MMI_VIDEO_TELEPHONY__)
/*****************************************************************************
 * FUNCTION
 *  srv_phb_set_vt_call
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  
 *****************************************************************************/
extern void srv_phb_set_vt_call(mmi_phb_contact_id id, MMI_BOOL is_vt);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_is_vt_call
 * DESCRIPTION
 *  
 * PARAMETERS
 * 
 * RETURNS
 *  
 *****************************************************************************/
extern MMI_BOOL srv_phb_is_vt_call(mmi_phb_contact_id id);
#endif /* defined(__MMI_VIDEO_TELEPHONY__) */


#define IN_PHBSTARTUPSRV_C

/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_is_phb_ready
 * DESCRIPTION
 *  This function is used to query if phonebook is ready or not.
 * PARAMETERS
 *  void
 * RETURN VALUES
 *  MMI_TRUE:           PHB ready
 *  MMI_FALSE:          PHB not ready
 *****************************************************************************/
MMI_BOOL srv_phb_startup_is_phb_ready(void);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_is_phb_support
 * DESCRIPTION
 *  This function is used to query if phonebook is support or not.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN/PHB_PHONEBOOK
 * RETURN VALUES
 *  MMI_TRUE:           PHB support
 *  MMI_FALSE:          PHB not support
 *****************************************************************************/
MMI_BOOL srv_phb_startup_is_phb_support(U8 sim_interface, U8 phb_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_get_alpha_length
 * DESCRIPTION
 *  This function is used to get phonebook alpha length.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_PHONEBOOK
 * RETURNS
 *  PHB alpha length
 *****************************************************************************/
U8 srv_phb_startup_get_alpha_length(U8 sim_interface, U8 phb_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_get_fdn_total
 * DESCRIPTION
 *  This function is used to get FDN total records.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 * RETURNS
 *  FDN total No.
 *****************************************************************************/
U16 srv_phb_startup_get_fdn_total(U8 sim_interface);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_get_bdn_total
 * DESCRIPTION
 *  This function is used to get BDN total records.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 * RETURNS
 *  BDN total No.
 *****************************************************************************/
U16 srv_phb_startup_get_bdn_total(U8 sim_interface);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_get_msisdn_total
 * DESCRIPTION
 *  This function is used to get MSISDN total records.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 * RETURNS
 *  MSISDN total No.
 *****************************************************************************/
U16 srv_phb_startup_get_msisdn_total(U8 sim_interface);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_startup_sat_hdlr
 * DESCRIPTION
 *  This function is used to process Phonebook scenario when SIM refresh happens.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_startup_sat_hdlr(U8 sim_interface);

#ifdef __SRV_PHB_TCARD_STORAGE_SUPPORT__
/*****************************************************************************
 * FUNCTION
 *  srv_phb_tcard_is_ready
 * DESCRIPTION
 *  is tcard ready or not
 * PARAMETERS
 *  void        
 * RETURNS
 *  void
 *****************************************************************************/
MMI_BOOL srv_phb_tcard_is_ready(void);
#endif

#define IN_PHBXMGNTSRV_C

/* phb extra# MAX entires count */
#define SRV_PHB_XMGNT_SIM_ENTRIES               20

/* phb extra# MAX owner number entires count */
#define SRV_PHB_XMGNT_OWNER_NUMBERS             4

/* phb extra# MAX sos entires count */
#define SRV_PHB_XMGNT_SOS_ENTRIES               5

#ifdef __MMI_DIALER_SEARCH__

/* ds home number index */
#define MMI_PHB_DS_HOMENUMBER                   0

/* ds office number index */
#define MMI_PHB_DS_OFFICENUMBER                 1

/* ds fax number index */
#define MMI_PHB_DS_FAXNUMBER                    2

#endif /* __MMI_DIALER_SEARCH__ */

/* phb extra# result enum */
typedef enum
{
    SRV_PHB_XMGNT_RESULT_OK,                    /* Successful */
    SRV_PHB_XMGNT_RESULT_FAIL,                  /* Failed */
    SRV_PHB_XMGNT_RESULT_EF_FULL                /* EFext# full */
} srv_phb_xmgnt_result_enum;

/* phb extra# handle */
typedef void*   SRV_PHB_XMGNT_HANDLE;

/* phb extra# name struct */
typedef struct
{
    U8 name_length;                             /* Name Length */
    U8 name_dcs;                                /* Name Data Coding Scheme */
    U16 name[MMI_PHB_NAME_LENGTH + 1];          /* UCS2 name field */
} srv_phb_xmgnt_name_struct;

/* phb extra# number struct */
typedef struct
{
    U8 type;                                    /* Number type */
    U8 length;                                  /* Number length */
    U16 number[MMI_PHB_NUMBER_PLUS_LENGTH + 1]; /* UCS2 number field */
} srv_phb_xmgnt_number_struct;

/* phb extra# entry struct */
typedef struct
{
    U8 storage;                                 /* Phb storage */
    U8 type;                                    /* Phb type */
    U16 index;                                  /* Phb entry index */
    U16 record_index;                           /* Phb record index */
    srv_phb_xmgnt_number_struct tel;            /* extra# number field */
    srv_phb_xmgnt_name_struct alpha_id;         /* extra# name field */
} srv_phb_xmgnt_entry_struct;


/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_xmgnt_callback_type
 * DESCRIPTION
 *  Definition of callback for extra# management (get sim list)
 * PARAMETERS
 *  result:             [IN]        result code
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_xmgnt_callback_type) (U16 result);


/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_xmgnt_callback_type_ex
 * DESCRIPTION
 *  Definition of callback for extra# management (get sim entry)
 * PARAMETERS
 *  result:             [IN]        result code
 *  sim_entry:          [IN]        extra# entry
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_xmgnt_callback_type_ex) (U16 result, l4c_phb_entry_struct *sim_entry);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_list_count
 * DESCRIPTION
 *  This function is used to get extra# list count.
 * PARAMETERS
 *  handle:             [IN]        extra# handle
 * RETURNS
 *  extra# list count
 *****************************************************************************/
extern U16 srv_phb_xmgnt_get_list_count(SRV_PHB_XMGNT_HANDLE handle);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_entry_index
 * DESCRIPTION
 *  This function is used to get entry index by hilight index.
 * PARAMETERS
 *  handle:             [IN]        extra# handle
 *  index:              [IN]        hilight index
 * RETURNS
 *  entry index
 *****************************************************************************/
extern U16 srv_phb_xmgnt_get_entry_index(SRV_PHB_XMGNT_HANDLE handle, U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_entry_name
 * DESCRIPTION
 *  This function is used to get extra# name by hilight index.
 * PARAMETERS
 *  handle:             [IN]        extra# handle
 *  index:              [IN]        hilight index
 * RETURNS
 *  extra# name
 *****************************************************************************/
extern U16 *srv_phb_xmgnt_get_entry_name(SRV_PHB_XMGNT_HANDLE handle, U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_entry_number
 * DESCRIPTION
 *  This function is used to get extra# number by hilight index.
 * PARAMETERS
 *  handle:             [IN]        extra# handle
 *  index:              [IN]        hilight index
 * RETURNS
 *  extra# number
 *****************************************************************************/
extern U16 *srv_phb_xmgnt_get_entry_number(SRV_PHB_XMGNT_HANDLE handle, U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_entry_number_length
 * DESCRIPTION
 *  This function is used to get extra# number length by hilight index.
 * PARAMETERS
 *  handle:             [IN]        extra# handle
 *  index:              [IN]        hilight index
 * RETURNS
 *  extra# number length
 *****************************************************************************/
extern U8 srv_phb_xmgnt_get_entry_number_length(SRV_PHB_XMGNT_HANDLE handle, U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_list
 * DESCRIPTION
 *  This function is used to get extra# list.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  list_cb:            [IN]        Get extra# list callback
 * RETURNS
 *  extra# handle
 *****************************************************************************/
extern SRV_PHB_XMGNT_HANDLE srv_phb_xmgnt_get_list(
                                U8 sim_interface,
                                U8 phb_type,
                                srv_phb_xmgnt_callback_type list_cb);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_entry
 * DESCRIPTION
 *  This function is used to get extra# entry by entry index.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  record_index:       [IN]        PHB record index
 *  entry_cb:           [IN]        Get extra# entry callback
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_xmgnt_get_entry(
                    U8 sim_interface,
                    U8 phb_type,
                    U16 record_index,
                    srv_phb_xmgnt_callback_type_ex entry_cb);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_set_entry
 * DESCRIPTION
 *  This function is used to add/edit extra# entry.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  index:              [IN]        PHB entry index
 *  record_index:       [IN]        PHB record index
 *  name:               [IN]        extra# name
 *  number:             [IN]        extra# number
 *  set_cb:             [IN]        Add/Edit extra# entry callback
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_xmgnt_set_entry(
                    U8 sim_interface,
                    U8 phb_type,
                    U16 index,
                    U16 record_index,
                    U16 *name,
                    U16 *number,
                    srv_phb_xmgnt_callback_type set_cb);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_delete_entry
 * DESCRIPTION
 *  This function is used to delete extra# entry.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  index:              [IN]        PHB entry index
 *  record_index:       [IN]        PHB record index
 *  del_cb:             [IN]        Delete extra# entry callback
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_xmgnt_delete_entry(
                    U8 sim_interface,
                    U8 phb_type,
                    U16 index,
                    U16 record_index,
                    srv_phb_xmgnt_callback_type del_cb);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_query_dial_mode
 * DESCRIPTION
 *  This function is used to query FDN/BDN dial mode.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_FDN/PHB_BDN
 * RETURNS
 *  FDN/BDN dial mode (0: off, 1: on, 0xFF: query failed)
 *****************************************************************************/
extern U8 srv_phb_xmgnt_query_dial_mode(U8 sim_interface, U8 phb_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_toggle_dial_mode
 * DESCRIPTION
 *  This function is used to toggle FDN/BDN dial mode.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_FDN/PHB_BDN
 *  toggle_cb:          [IN]        Toggle FDN/BDN dial mode callback
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_xmgnt_toggle_dial_mode(
                    U8 sim_interface,
                    U8 phb_type,
                    srv_phb_xmgnt_callback_type toggle_cb);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_search_fdn_by_number
 * DESCRIPTION
 *  This function is used to search FDN name (SIM1 or SIM2) by number.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  number:             [IN]        Number to dial
 *  name:               [OUT]       Name to match the number
 * RETURNS
 *  PHB entry index
 *****************************************************************************/
extern U16 srv_phb_xmgnt_search_fdn_by_number(U8 sim_interface, U16 *number, U16 *name);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_approve_fdn
 * DESCRIPTION
 *  This is phb_approve function of PHB fdn
 * PARAMETERS
 *  tel_number                   [IN]  BCD number to approve 
 *  num_length                  [IN]  BCD
 *  sim_id                         [IN]   sim id please refer to mmi_sim_enum
 * RETURNS
 *  MMI_BOOL
 *****************************************************************************/
extern MMI_BOOL srv_phb_xmgnt_approve_fdn(
                    kal_uint8 *tel_number,
                    kal_uint8 num_length,
                    kal_uint8 sim_id,
                    l4c_operation_type_enum l4c_op,
                    kal_uint16 *cause);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_owner_number_parse_msisdn_info
 * DESCRIPTION
 *  This function is used to parse MSISDN information.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  no_msisdn:          [IN]        No. of MSISDN
 *  msisdn:             [IN]        MSISDN data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_owner_number_parse_msisdn_info(U8 sim_interface, U8 no_msisdn, l4csmu_addr_struct *msisdn);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_owner_number_set_name_number
 * DESCRIPTION
 *  This function is used to set MSISDN name & number by index.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  index:              [IN]        LINE1(0)/LINE2(1)
 *  name:               [IN]        MSISDN name
 *  number:             [IN]        MSISDN number
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_owner_number_set_name_number(U8 sim_interface, U16 index, U16 *name, U16 *number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_owner_number_get_name
 * DESCRIPTION
 *  This function is used to get MSISDN name by index.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  index:              [IN]        LINE1(0)/LINE2(1)
 * RETURNS
 *  MSISDN name
 *****************************************************************************/
extern U16 *srv_phb_owner_number_get_name(U8 sim_interface, U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_owner_number_get_number
 * DESCRIPTION
 *  This function is used to get MSISDN number by index.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  index:              [IN]        LINE1(0)/LINE2(1)
 * RETURNS
 *  MSISDN number
 *****************************************************************************/
extern U16 *srv_phb_owner_number_get_number(U8 sim_interface, U16 index);


#define IN_PHBSRV_C

/* PHB storage status enum */
typedef enum
{
    SRV_PHB_STORAGE_STATUS_EMPTY,               /* storage is empty */
    SRV_PHB_STORAGE_STATUS_FULL,                /* storage is full */
    SRV_PHB_STORAGE_STATUS_OTHERS               /* others status */
} srv_phb_storage_status_enum;


/* SyncML action type enmu */
typedef enum
{
    SRV_PHB_VCARD_READ,                         /* read action */
    SRV_PHB_VCARD_ADD,                          /* write action */
    SRV_PHB_VCARD_UPDATE,                       /* update action */
    SRV_PHB_VCARD_DELETE                        /* delete action */
} srv_phb_sync_vcard_enum;


/* SyncML error result enmu */
typedef enum
{
    SRV_PHB_SYNC_SUCCESS,                       /* sync success */
    SRV_PHB_SYNC_ERROR,                         /* sync fail */
    SRV_PHB_SYNC_NOT_SUPPORT,                   /* not support */
    SRV_PHB_SYNC_INVALID_PARAM,                 /* invalid parameter */
    SRV_PHB_SYNC_NOT_READY,                     /* phonebook not ready */
    SRV_PHB_SYNC_STORAGE_FULL,                  /* storage full */
    SRV_PHB_SYNC_NOT_FOUND                      /* not found */
} srv_phb_sync_error_enum;


/* cm number struct */
typedef struct
{
    U16 *number;                                /* number to search(UCS2) */
    MMI_BOOL is_mo_call;                        /* is mo call */
    MMI_BOOL is_voip_call;                      /* is voip call */
    U8 sim_interface;                           /* SIM interface */
    U8 call_type;                               /* refer ecc_call_type_enum */
    void *user_data;                            /* user data */
} srv_phb_cm_number_struct;


/* caller info struct */
typedef struct
{
    U16 name[MMI_PHB_NAME_LENGTH + 1];          /* caller name(UCS2) */
    SRV_PHB_ID phb_id;
    mmi_phb_num_type_enum number_type;          /* number type */
    U16 ringtone_id;                            /* caller ringtone id */
    U16 image_id;                               /* caller image id */
    U16 video_id;                               /* caller video id */
    U16 res_type;
} srv_phb_caller_info_struct;


/* caller res id struct */
typedef struct
{
    U32  call_type;                              /* call type */
    U16 image_id;                               /* image id */
    U16 video_id;                               /* video id */
    U16 ringtone_id;
    U16 res_type;
} srv_phb_caller_res_id_struct;


/* caller res info struct */
typedef struct
{
    U16 pic_id;                                 /* image id */
    U16 pic_path[SRV_FMGR_PATH_MAX_LEN + 1];    /* image path */
#ifdef __MMI_PHB_CALLER_VIDEO__
    U16 video_id;                               /* video id */
    U16 video_path[SRV_FMGR_PATH_MAX_LEN + 1];  /* video path */
#endif
    U16 ringtone_id;
    U16 ringtone_path[SRV_FMGR_PATH_MAX_LEN + 1];
    U16 res_type;                               /* res type */
} srv_phb_caller_res_info_struct;


#ifdef __MMI_DIALER_SEARCH__

/* ds find entry phonebook record struct */
typedef struct
{
    U16 store_index;                            /* phb store index */
    union
    {
        U8 first;
        U8 num_index;
    } u;                                        /* if name match, first match location; if number match, number type */
    U8 count;                                   /* if name match, the count = 1; if number match, show count of number type */
    U8 mask[(MMI_PHB_NAME_LENGTH + 7) / 8];     /* match location of every name match, for underline */
} srv_phb_ds_phb_entry_struct;


typedef struct
{
    srv_phb_ds_phb_entry_struct entry[MMI_PHB_ENTRIES];
    SRV_CLOG_ID calllog_id[SRV_CLOG_LOG_MAX_NUM];
    U16 key_len;
    U16 name_count;                             /* the count of phb name matched */
    U16 number_count;                           /* the count of phb number matched */
    U16 callog_count;
} srv_phb_ds_list_cntx_struct;


typedef struct
{
    WCHAR* key_word;                            /* input key word */
    U8 * key_int;
    U8 * key_bcd;
    U16 key_len;
} srv_phb_ds_input_struct;

#endif /* __MMI_DIALER_SEARCH__ */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_storage
 * DESCRIPTION
 *  This function is used to get PHB storage by store index. If store index is not in a valid range,
 *  it will return 0xFF.
 * PARAMETERS
 *  id:        [IN]        Store index
 * RETURN VALUES
 *  PHB_STORAGE_NVRAM:      Phone storage
 *  PHB_STORAGE_SIM:        SIM storage
 *  PHB_STORAGE_SIM2:       SIM2 storage
 *****************************************************************************/
extern U8 srv_phb_get_storage(mmi_phb_contact_id id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_store_index_in_storage
 * DESCRIPTION
 *  This function is used to check if store index is in the range of the specified storage.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  storage:            [IN]        PHB storage
 * RETURN VALUES
 *  MMI_TRUE:           In range
 *  MMI_FALSE:          Out of range
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_store_index_in_storage(U16 store_index, U8 storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_storage_status
 * DESCRIPTION
 *  This function is used to check the status of the specified storage.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 * RETURN VALUES
 *  SRV_PHB_STORAGE_STATUS_EMPTY:   Storage is empty
 *  SRV_PHB_STORAGE_STATUS_FULL:    Storage is full
 *  SRV_PHB_STORAGE_STATUS_OTHERS:  Others status
 *****************************************************************************/
extern U8 srv_phb_check_storage_status(U8 storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_storage_accessible
 * DESCRIPTION
 *  This function is used to check if the specified storage is accessible.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 * RETURN VALUES
 *  MMI_TRUE:           Storage is accessible
 *  MMI_FALSE:          Don't allow to access it
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_storage_accessible(U8 storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_total_contact
 * DESCRIPTION
 *  This function is used to get PHB total records by PHB storage.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 * RETURNS
 *  PHB total No.
 *****************************************************************************/
extern U16 srv_phb_get_total_contact(U8 storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_used_contact
 * DESCRIPTION
 *  This function is used to get PHB used records by PHB storage.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 * RETURNS
 *  PHB used No.
 *****************************************************************************/
extern U16 srv_phb_get_used_contact(U8 storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_store_index_to_sort_index
 * DESCRIPTION
 *  This function is used to convert store index to sort index.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 *  store_index:        [IN]        Store index
 * RETURNS
 *  Sort index
 *****************************************************************************/
extern U16 srv_phb_store_index_to_sort_index(U8 storage, U16 store_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_sort_index_to_store_index
 * DESCRIPTION
 *  This function is used to convert sort index to store index.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 *  sort_index:         [IN]        Sort index
 * RETURNS
 *  Store index
 *****************************************************************************/
mmi_phb_contact_id srv_phb_sort_index_to_store_index(U8 storage, U16 sort_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_store_index_to_record_index
 * DESCRIPTION
 *  This function is used to convert store index to record index.
 * PARAMETERS
 *  id:        [IN]        Store index
 *  storage:            [OUT]       PHB storage
 *  record_index:       [OUT]       Record index
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_store_index_to_record_index(mmi_phb_contact_id id, U8 *storage, U16 *record_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_record_index_to_store_index
 * DESCRIPTION
 *  This function is used to convert record index to store index.
 * PARAMETERS
 *  storage:            [IN]        PHB storage
 *  id:       [IN]        Record index
 *  store_index:        [OUT]       Store index
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_record_index_to_store_index(U8 storage, U16 record_index, mmi_phb_contact_id *id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_entry_exist
 * DESCRIPTION
 *  This function is used to check if PHB entry exists in PHB conatcts or not.
 * PARAMETERS
 *  id:        [IN]        Store index
 * RETURN VALUES
 *  MMI_TRUE:           Entry exist
 *  MMI_FALSE:          Doesn't exist
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_entry_exist(mmi_phb_contact_id id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_number_exist
 * DESCRIPTION
 *  This function is used to check if the given number exists in PHB list or not.
 * PARAMETERS
 *  number:             [IN]        Number to check
 * RETURN VALUES
 *  MMI_TRUE:           Number exist
 *  MMI_FALSE:          Doesn't exist
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_number_exist(U16 *number);


#ifdef __SYNCML_SUPPORT__

/*****************************************************************************
 * FUNCTION
 *  srv_phb_sync_get_index_array
 * DESCRIPTION
 *  This function is used to get PHB store index array.
 * PARAMETERS
 *  index_array:            [IN/OUT]    Store index array
 *  max_index_count:        [IN]        Index array size
 * RETURNS
 *  No. of contacts in Phone storage
 *****************************************************************************/
extern U16 srv_phb_sync_get_index_array(U16 *index_array, U16 max_index_count);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_sync_vcard
 * DESCRIPTION
 *  This function is used to sync data from/to PHB to/from SyncML server.
 * PARAMETERS
 *  action:                 [IN]        SyncML action type
 *  file_path:              [IN]        vCard file path
 *  store_index:            [IN]        Store index
 *  charset:                [IN]        Default charset to parse vCard
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_sync_vcard(U8 action, U16 *file_path, U16 store_index, U8 charset);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_sync_get_record_size
 * DESCRIPTION
 *  This function is used to get PHB record size which SyncML can support.
 * PARAMETERS
 *  void
 * RETURNS
 *  PHB record size
 *****************************************************************************/
extern U16 srv_phb_sync_get_record_size(void);

#endif /* __SYNCML_SUPPORT__ */


#if defined(__MMI_IMPS__) && defined(IMPS_WV13_ENHANCEMENT)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__MMI_IMPS__) && defined(IMPS_WV13_ENHANCEMENT) */


#if defined(__MMI_VCARD__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_pbap_build_vcard
 * DESCRIPTION
 *  This function is used to build vCard for PBAP.
 * PARAMETERS
 *  file_path:          [IN]        vCard file path
 *  store_index:        [IN]        Store index
 *  is_append:          [IN]        write file from tail or not
 *  vcard_format:       [IN]        vcard version
 * RETURNS
 *  S32                             write result
 *****************************************************************************/
extern S32 srv_phb_build_vcard(U16 *file_path, U16 store_index, MMI_BOOL is_append, U8 vcard_format);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_pbap_build_vcard
 * DESCRIPTION
 *  This function is used to build vCard for PBAP.
 * PARAMETERS
 *  file_path:          [IN]        vCard file path
 *  store_index:        [IN]        Store index
 *  is_append:          [IN]        write file from tail or not
 *  vcard_format:       [IN]        vcard version
 * RETURNS
 *  S32                             write result
 *****************************************************************************/
extern S32 srv_contact_build_vcard(U16 *file_path, U16 store_index, MMI_BOOL is_append, U8 vcard_format);

#endif /* defined(__MMI_VCARD__) */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_name_by_number
 * DESCRIPTION
 *  This function is used to get PHB name by the given number. It will call SSE API to search
 *  the number.
 *  If the search ok, but name is empty, or if the search fails, we will fill in name[out] with '\0'.
 * PARAMETERS
 *  number:             [IN]        Number to search
 *  name:               [OUT]       Name to store the search result
 *  len:                [IN]        Name length
 * RETURN VALUES
 *  MMI_TRUE:           Number found
 *  MMI_FALSE:          Number not found
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_name_by_number(U16 *number, U16 *name, U16 len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_store_index_by_number
 * DESCRIPTION
 *  This function is used to get store index by the given number. It will call SSE API to search
 *  the number. Then you can use store index to get PHB name.
 * PARAMETERS
 *  number:             [IN]        Number to search
 *  store_index:        [OUT]       Store index to store the search result
 * RETURN VALUES
 *  MMI_TRUE:           Number found
 *  MMI_FALSE:          Number not found
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_store_index_by_number(U16 *number, U16 *store_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_set_invalid_number_id
 * DESCRIPTION
 *  This function is used to set number id as invalid value
 * PARAMETERS
 *  phb_id:             [IN]        phb number id to set
 * RETURNS
 *  Number id
 *****************************************************************************/
extern void srv_phb_set_invalid_number_id(SRV_PHB_ID* phb_id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_number_id
 * DESCRIPTION
 *  This function is used to check a number's id is valid
 * PARAMETERS
 *  phb_id:             [IN]        phb number id to check
 * RETURNS
 *  MMI_TRUE:           valid
 *  MMI_FALSE:          invalid
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_number_id(SRV_PHB_ID phb_id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_number_id
 * DESCRIPTION
 *  This function is used to create a number's id
 * PARAMETERS
 *  storage_type:       [IN]        PHB_FDN or PHB_PHONEBOOK, refer phb_type_enum
 *  store_index:        [IN]        contact store_index
 *  number_index:       [IN]        SRV_PHB_ENTRY_FIELD_NUMBER or SRV_PHB_ENTRY_FIELD_OPT_NUM_1 or
 *                                  SRV_PHB_ENTRY_FIELD_OPT_NUM_2 SRV_PHB_ENTRY_FIELD_OPT_NUM_3
 * RETURNS
 *  Number id
 *****************************************************************************/
extern SRV_PHB_ID srv_phb_create_number_id(U8 storage_type, U16 store_index, U8 number_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_name_by_number_id
 * DESCRIPTION
 *  This function is used to get contact's store_index by number id
 * PARAMETERS
 *  number_id:          [IN]        number id
 * RETURNS
 *  store_index
 *****************************************************************************/
extern U16 srv_phb_get_store_index_by_number_id(SRV_PHB_ID number_id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_name_by_number_id
 * DESCRIPTION
 *  This function is used to get contact's name by number id
 * PARAMETERS
 *  name:               [OUT]       name data
 *  number_id:          [IN]        number id
 *  max_len:            [IN]        max Name length
 * RETURN VALUES
 *  MMI_TRUE:           Got name
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_name_by_number_id(U16 *name, SRV_PHB_ID number_id, U16 max_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_number_by_number_id
 * DESCRIPTION
 *  This function is used to get contact's number by number id
 * PARAMETERS
 *  number:             [OUT]       number data
 *  number_id:          [IN]        number id
 *  max_len:            [IN]        max number length
 * RETURN VALUES
 *  MMI_TRUE:           Got number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_number_by_number_id(U16 *number, SRV_PHB_ID number_id, U16 max_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_cm_user_data_ex
 * DESCRIPTION
 *  This function is used to create cm user data before making call.
 * PARAMETERS
 *  name:               [IN]        Caller name
 *  number:             [IN]        Caller number
 * RETURNS
 *  App user data
 *****************************************************************************/
extern void *srv_phb_create_cm_user_data_ex(U16 *name, U16 *number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_cm_user_data
 * DESCRIPTION
 *  This function is used to create cm user data before making call.
 *  App must set name or store index to this data so that PHB will search the right name.
 *  App must keep this pointer until call disconnected.
 * PARAMETERS
 *  name:               [IN]        Caller name
 *  number_index:       [IN]        Caller number index
 *  store_index:        [IN]        Caller store index
 * RETURNS
 *  App user data
 *****************************************************************************/
extern void *srv_phb_create_cm_user_data(U16 *name, U32 number_index, U16 store_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_cm_user_data_by_sub_id
 * DESCRIPTION
 *  This function is used to create cm user data before making call.
 *  App must set name or store index to this data so that PHB will search the right name.
 *  App must keep this pointer until call disconnected.
 * PARAMETERS
 *  name:               [IN]        Caller name
 *  number_sub_id:      [IN]        Caller number index
 *  store_index:        [IN]        Caller store index
 * RETURNS
 *  App user data
 *****************************************************************************/
extern void *srv_phb_create_cm_user_data_by_sub_id(U16 *name, U32 number_sub_id, U16 store_index);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_cm_user_data_by_id
 * DESCRIPTION
 *  This function is used to create cm user data before making call.
 *  App must set phb id to this data so that PHB will search the right name.
 *  App must keep this pointer until call disconnected.
 * PARAMETERS
 *  phb_id:             [IN]        phb id
 * RETURNS
 *  App user data
 *****************************************************************************/
extern void *srv_phb_create_cm_user_data_by_id(SRV_PHB_ID phb_id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_hold_cm_user_data
 * DESCRIPTION
 *  This function is used to hold on cm user data.
 * PARAMETERS
 *  user_data:          [IN]        App user data
 * RETURN VALUES
 *  MMI_TRUE:           Hold on
 *  MMI_FALSE:          Fails
 *****************************************************************************/
extern MMI_BOOL srv_phb_hold_cm_user_data(void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_destory_cm_user_data
 * DESCRIPTION
 *  This function is used to destroy cm user data after call disconnected.
 * PARAMETERS
 *  user_data:          [IN]        App user data
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_destory_cm_user_data(void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_caller_info_by_number
 * DESCRIPTION
 *  This function is used to get caller info by number. As general, it is called by CM
 *  to show in-call screen with PHB name.
 * PARAMETERS
 *  cm_param:           [IN]        Number input by CM
 *  phb_info:           [OUT]       Caller info output by PHB
 * RETURN VALUES
 *  MMI_TRUE:           Number found
 *  MMI_FALSE:          Number not found
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_caller_info_by_number(
                    srv_phb_cm_number_struct *cm_param,
                    srv_phb_caller_info_struct *phb_info);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_caller_res_info_by_id
 * DESCRIPTION
 *  This function is used to get caller res info by id. As general, it is called by CM
 *  to show in-call screen with image or video from PHB.
 * PARAMETERS
 *  res_id:             [IN]        Caller res id input by CM
 *  res_info:           [OUT]       Caller res info output by PHB
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_get_caller_res_info_by_id(
                srv_phb_caller_res_id_struct *res_id,
                srv_phb_caller_res_info_struct *res_info);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_field
 * DESCRIPTION
 *  This function is used to get PHB field by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  field:              [OUT]       PHB field
 * RETURN VALUES
 *  MMI_TRUE:           Got field
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_field(U16 store_index, U32 *field);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_name
 * DESCRIPTION
 *  This function is used to get PHB name by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  name:               [OUT]       PHB name
 *  len:                [IN]        Name length
 * RETURN VALUES
 *  MMI_TRUE:           Got name
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_name(U16 store_index, U16 *name, U16 len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_number
 * DESCRIPTION
 *  This function is used to get PHB mobile number by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  number:             [OUT]       PHB mobile number
 *  len:                [IN]        Mobile number length
 * RETURN VALUES
 *  MMI_TRUE:           Got number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_number(U16 store_index, U16 *number, U16 len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_number_ex
 * DESCRIPTION
 *  This function is used to get PHB mobile number by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  number:             [OUT]       PHB mobile number
 *  len:                [IN]        Mobile number length
 * RETURN VALUES
 *  MMI_TRUE:           Got number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
MMI_BOOL srv_phb_get_number_ex(U16 store_index, U8 num_index, WCHAR *number, U8* type, U16 len);


#if defined(__MMI_PHB_BIRTHDAY_FIELD__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_birthday
 * DESCRIPTION
 *  This function is used to get PHB birthday by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  year:               [OUT]       Birthday year
 *  month:              [OUT]       Birthday month
 *  day:                [OUT]       Birthday day 
 * RETURN VALUES
 *  MMI_TRUE:           Got birthday
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_birthday(U16 store_index, U16 *year, U8 *month, U8 *day);

#endif /* defined(__MMI_PHB_BIRTHDAY_FIELD__) */


#ifdef __MMI_PHB_OPTIONAL_FIELD__

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_optional_number
 * DESCRIPTION
 *  This function is used to get PHB home number by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  field_flag:         [IN]        option number field flag
 *  number:             [OUT]       number data
 *  type:               [OUT]       number type
 *  len:                [IN]        max number length
 * RETURN VALUES
 *  MMI_TRUE:           Got home number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_optional_number(U16 store_index, U32 field_flag, WCHAR* number, mmi_phb_num_type_enum *type, U16 len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_optional_number_order
 * DESCRIPTION
 *  This function is used to get number order by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  number_order:       [OUT]       Number order
 * RETURN VALUES
 *  MMI_TRUE:           Got home number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_optional_number_order(U16 store_index, U8* number_order);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_email_address
 * DESCRIPTION
 *  This function is used to get PHB email address by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  email:              [OUT]       PHB email address
 *  len:                [IN]        Email address length
 * RETURN VALUES
 *  MMI_TRUE:           Got email address
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_email_address(U16 store_index, U16 *email, U16 len);


#ifdef __MMI_PHB_OPTIONAL_FIELDS_2ND_EMAIL__

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_email_address2
 * DESCRIPTION
 *  This function is used to get PHB email address2 by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  email:              [OUT]       PHB email address2
 *  len:                [IN]        Email address2 length
 * RETURN VALUES
 *  MMI_TRUE:           Got email address2
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_email_address2(U16 store_index, U16 *email, U16 len);

#endif /* __MMI_PHB_OPTIONAL_FIELDS_2ND_EMAIL__ */

#endif /* __MMI_PHB_OPTIONAL_FIELD__ */


#if defined(__MMI_PHB_INFO_FIELD__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_url
 * DESCRIPTION
 *  This function is used to get URL number by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  url:                [OUT]       PHB URL number
 *  len:                [IN]        URL number length
 * RETURN VALUES
 *  MMI_TRUE:           Got URL number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_url(U16 store_index, U16 *url, U16 len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_address
 * DESCRIPTION
 *  This function is used to get PHB address.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  pobox:              [OUT]       PHB pobox
 *  extension:          [OUT]       PHB extension
 *  street:             [OUT]       PHB street
 *  city:               [OUT]       PHB city
 *  state:              [OUT]       PHB state
 *  postalcode:         [OUT]       PHB postalcode
 *  country:            [OUT]       PHB country
 * RETURN VALUES
 *  MMI_TRUE:           Success
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_address(
                    U16 store_index,
                    U16 *pobox,
                    U16 *extension,
                    U16 *street,
                    U16 *city,
                    U16 *state,
                    U16 *postalcode,
                    U16 *country);

#endif /* defined(__MMI_PHB_INFO_FIELD__) */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_image
 * DESCRIPTION
 *  This function is used to get PHB image id & path by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  image_id:           [OUT]       PHB image id
 *  image_path:         [OUT]       PHB image path
 *  res_type:           [OUT]       PHB image resource type
 * RETURN VALUES
 *  MMI_TRUE:           Got image id
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_image(U16 store_index, U16* image_id, U16 *image_path, U16* res_type);


#if defined(__MMI_PHB_CALLER_VIDEO__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_video
 * DESCRIPTION
 *  This function is used to get PHB video id & path by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  video_id:           [OUT]       PHB video id
 *  video_path:         [OUT]       PHB video path
 *  res_type:           [OUT]       PHB video resource type
 * RETURN VALUES
 *  MMI_TRUE:           Got video id
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_video(U16 store_index, U16 *video_id, U16* video_path, U16* res_type);
#endif /* defined(__MMI_PHB_CALLER_VIDEO__) */


#ifdef __MMI_PHB_DEFAULT_NUMBER__

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_default_number_id
 * DESCRIPTION
 *  This function is used to get PHB default number id by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  id:                 [OUT]       PHB default number id
 * RETURN VALUES
 *  MMI_TRUE:           Got default number id
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_default_number_id(U16 store_index, U8 *id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_default_number
 * DESCRIPTION
 *  This function is used to get PHB default number by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  number:             [OUT]       PHB default number
 *  type:               [OUT]       Number type
 *  len:                [IN]        Default number length
 * RETURN VALUES
 *  MMI_TRUE:           Got default number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_default_number(U16 store_index, WCHAR *number, mmi_phb_num_type_enum *type, U16 len);

#endif /* __MMI_PHB_DEFAULT_NUMBER__ */


#if defined(__MMI_IMPS__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__MMI_IMPS__) */


#if defined(__MMI_VOIP__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_voip_number
 * DESCRIPTION
 *  This function is used to get VOIP number by store index.
 * PARAMETERS
 *  store_index:        [IN]        Store index
 *  voip:               [OUT]       PHB VOIP number
 *  len:                [IN]        VOIP number length
 * RETURN VALUES
 *  MMI_TRUE:           Got VOIP number
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_voip_number(U16 store_index, U16 *voip, U16 len);

#endif /* defined(__MMI_VOIP__) */


#ifdef __MMI_PHB_CALLER_GROUP__
/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_group_name
 * DESCRIPTION
 *  This function is used to get group name by group index.
 * PARAMETERS
 *  group_id:           [IN]        group index
 *  group_name:         [OUT]       group name
 *  len:                [IN]        group name length
 * RETURN VALUES
 *  MMI_TRUE:           Got group name
 *  MMI_FALSE:          Didn't get it
 *****************************************************************************/
extern MMI_BOOL srv_phb_get_group_name(U8 group_id, U16 *group_name, U16 len);
#endif /* __MMI_PHB_CALLER_GROUP__ */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_truncate_name
 * DESCRIPTION
 *  This function is used to truncate PHB name by storage.
 * PARAMETERS
 *  name:               [IN/OUT]    Name to truncate
 *  storage:            [IN]        PHB storage
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_truncate_name(U16 *name, U8 storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_truncate_name_ex
 * DESCRIPTION
 *  This function is used to truncate PHB name by storage.
 * PARAMETERS
 *  name:               [IN/OUT]    Name to truncate
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN/PHB_PHONEBOOK
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_truncate_name_ex(U16 *name, U8 sim_interface, U8 phb_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_truncate_number
 * DESCRIPTION
 *  This function is used to truncate PHB number.
 * PARAMETERS
 *  number:             [IN/OUT]    Number to truncate
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_truncate_number(U16 *number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_compare_number
 * DESCRIPTION
 *  This function is used to compare two PHB numbers.
 * PARAMETERS
 *  number1:            [IN]        First number
 *  number2:            [IN]        Second number
 * RETURN VALUES
 *  MMI_TRUE:           Equal
 *  MMI_FALSE:          Not equal
 *****************************************************************************/
extern MMI_BOOL srv_phb_compare_number(U16 *number1, U16 *number2);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_read_compare_length
 * DESCRIPTION
 *  This function is used to read compare length from NVRAM.
 * PARAMETERS
 *  void
 * RETURNS
 *  U8
 *****************************************************************************/
extern U8 srv_phb_read_compare_length(void);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_number_to_int
 * DESCRIPTION
 *  Converts the last n characters of a phone number to interger.
 * PARAMETERS
 *  number:             [IN]        Input number
 * RETURNS
 *  interger of input number
 *****************************************************************************/
extern U32 srv_phb_convert_number_to_int(U16 *number);


#ifndef __MTK_TARGET__
#define SRV_PHB_INVALID_INT64_NUMBER        0x4000000000000000I64
#else
#define SRV_PHB_INVALID_INT64_NUMBER        0x4000000000000000LL
#endif


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_number_to_int64
 * DESCRIPTION
 *  Converts the last n characters of a phone number to interger 64.
 * PARAMETERS
 *  number:             [IN]        Input number
 * RETURNS
 *  interger of input number
 *****************************************************************************/
extern __int64 srv_phb_convert_number_to_int64(U16 *number);


#define IN_PHBUTILSRV_C
/*****************************************************************************
 * FUNCTION
 *  srv_phb_towupper
 * DESCRIPTION
 *  This function is used to convert lowercase letter to uppercase letter.
 * PARAMETERS
 *  wc:                 [IN]        Wide character
 * RETURNS
 *  Wild character
 *****************************************************************************/
extern U16 srv_phb_towupper(U16 wc);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_compare_wchar
 * DESCRIPTION
 *  This function is used to compare two wild characters.
 * PARAMETERS
 *  char1:              [IN]        First character
 *  char2:              [IN]        Second character
 * RETURNS
 *  >0:                 First is greater than second
 *  =0:                 First is identical to second
 *  <0:                 First is less than second
 *****************************************************************************/
extern S32 srv_phb_compare_wchar(U16 char1, U16 char2);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_compare_ucs2_string
 * DESCRIPTION
 *  This function is used to compare two ucs2 strings.
 * PARAMETERS
 *  string1:            [IN]        First string
 *  string2:            [IN]        Second string
 * RETURNS
 *  >0:                 First is greater than second
 *  =0:                 First is identical to second
 *  <0:                 First is less than second
 *****************************************************************************/
extern S32 srv_phb_compare_ucs2_string(U16 *string1, U16 *string2);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_compare_pinyin_string
 * DESCRIPTION
 *  This function is used to compare two pinyin strings.
 * PARAMETERS
 *  string1:            [IN]        First string
 *  string2:            [IN]        Second string
 * RETURNS
 *  >0:                 First is greater than second
 *  =0:                 First is identical to second
 *  <0:                 First is less than second
 *****************************************************************************/
extern S32 srv_phb_compare_pinyin_string(U16 *string1, U16 *string2);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_gsm_extended_count
 * DESCRIPTION
 *  This function is used to calculate GSM extended characters' count.
 * PARAMETERS
 *  buffer:             [IN]        Input buffer
 *  max_buffer_len:     [IN]        Max length of buffer
 * RETURNS
 *  GSM extended characters' count
 *****************************************************************************/
extern U32 srv_phb_gsm_extended_count(U16 *buffer, U32 max_buffer_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_ucs2_character
 * DESCRIPTION
 *  This function is used to check if UCS2 character (such as Chinese) exists or not.
 * PARAMETERS
 *  buffer:             [IN]        Input buffer
 * RETURN VALUES
 *  MMI_TRUE:           Include a UCS2 character
 *  MMI_FALSE:          Didn't include it
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_ucs2_character(U16 *buffer);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_international_number
 * DESCRIPTION
 *  This function is used to check if it is an international number or not.
 * PARAMETERS
 *  type:               [IN]        TON
 * RETURNS
 *  MMI_TRUE:           International number
 *  MMI_FALSE:          Others number
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_international_number(U8 type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_valid_number
 * DESCRIPTION
 *  This function is used to check if it is a valid number or not.
 * PARAMETERS
 *  number:             [IN]        Number to check
 * RETURN VALUES
 *  MMI_TRUE:           Valid number
 *  MMI_FALSE:          Invalid number
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_valid_number(U16 *number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_valid_number_ex
 * DESCRIPTION
 *  This function is used to check if it is a valid number or not.
 * PARAMETERS
 *  number:             [IN]        Number to check
 *  is_sim:             [IN]        Number comes from SIM or not
 * RETURN VALUES
 *  MMI_TRUE:           Valid number
 *  MMI_FALSE:          Invalid number
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_valid_number_ex(U16 *number, MMI_BOOL is_sim);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_check_valid_url
 * DESCRIPTION
 *  This function is used to check if it is a valid URL or not.
 * PARAMETERS
 *  url:                [IN]        URL to check
 * RETURN VALUES
 *  MMI_TRUE:           Valid URL
 *  MMI_FALSE:          Invalid URL
 *****************************************************************************/
extern MMI_BOOL srv_phb_check_valid_url(U16 *url);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_bcd
 * DESCRIPTION
 *  This function is used to convert ASCII string to BCD.
 * PARAMETERS
 *  dest:               [OUT]       BCD encoding string
 *  source:             [IN]        ASCII encoding string
 *  max_dest_len:       [IN]        Max length of dest buffer
 * RETURNS
 *  No. of bytes converted
 *****************************************************************************/
extern U32 srv_phb_convert_to_bcd(U8 *dest, U8 *source, U32 max_dest_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_digit
 * DESCRIPTION
 *  This function is used to convert BCD string to ASCII. (0x0D will be converted to '?')
 * PARAMETERS
 *  dest:               [OUT]       ASCII encoding string
 *  source:             [IN]        BCD encoding string
 *  max_dest_len:       [IN]        Max length of dest buffer
 * RETURNS
 *  No. of bytes converted
 *****************************************************************************/
extern U32 srv_phb_convert_to_digit(U8 *dest, U8 *source, U32 max_dest_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_digit_ex
 * DESCRIPTION
 *  This function is used to convert BCD string to ASCII. (0x0D will be converted to '?'
 *  if is_sim MMI_TRUE, otherwise it will be 'w')
 *  It will be removed when MMI callog revise.
 * PARAMETERS
 *  dest:               [OUT]       ASCII encoding string
 *  source:             [IN]        BCD encoding string
 *  max_dest_len:       [IN]        Max length of dest buffer
 *  is_sim:             [IN]        Number comes from SIM or not
 * RETURNS
 *  No. of bytes converted
 *****************************************************************************/
extern U32 srv_phb_convert_to_digit_ex(U8 *dest, U8 *source, U32 max_dest_len, MMI_BOOL is_sim);


#if defined(__PHB_0x81_SUPPORT__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_0x81
 * DESCRIPTION
 *  This function is used to convert UCS2 string (such as PHB name) to 0x81 encoding.
 *  We will copy the convert result to input buffer when is_convert is assigned as MMI_TRUE.
 * PARAMETERS
 *  name:               [IN/OUT]    PHB name
 *  is_convert:         [IN]        Copy the convert result or not
 * RETURNS
 *  No. of bytes converted
 *****************************************************************************/
extern U32 srv_phb_convert_to_0x81(U16 *name, MMI_BOOL is_convert);

#endif /* defined(__PHB_0x81_SUPPORT__) */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_name
 * DESCRIPTION
 *  This function is used to compine PHB first and last name.
 * PARAMETERS
 *  name:               [OUT]       PHB name
 *  f_name:             [IN]        First name
 *  l_name:             [IN]        Last name
 *  max_name_len:       [IN]        Max length of PHB name
 * RETURNS
 *  No. of characters converted
 *****************************************************************************/
extern void srv_phb_convert_to_name(U16 *name, U16 *f_name, U16 *l_name, U32 max_name_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_spelling
 * DESCRIPTION
 *  This function is used to convert to spelling. (ex. Chinese 'Ò»' can be converted to 'Y', 'i').
 * PARAMETERS
 *  input_mode:         [IN]        Input method mode
 *  input_char:         [IN]        Input character
 *  output_char:        [OUT]       Output characters
 *  out_len:            [IN]        Output buffer length
 * RETURNS
 *  No. of characters converted
 *****************************************************************************/
extern U16 srv_phb_convert_to_spelling(U16 input_mode, U16 input_char, U16 *output_char, U16 out_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_pinyin
 * DESCRIPTION
 *  This function is used to convert to pinyin. (ex. Chinese 'Ò»¸ö' can be converted to 'Y', 'i', 'G', 'e').
 * PARAMETERS
 *  input_string:       [IN]        Input strings
 *  output_string:      [OUT]       Output strings
 *  out_len:            [IN]        Output buffer length
 * RETURNS
 *  No. of characters converted
 *****************************************************************************/
extern U16 srv_phb_convert_to_pinyin(U16 *input_string, U16 *output_string, U16 out_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_initial
 * DESCRIPTION
 *  This function is used to convert to initial. (ex. Chinese 'Ò»¸ö' can be converted to 'Y', 'G').
 * PARAMETERS
 *  input_string:       [IN]        Input strings
 *  output_string:      [OUT]       Output strings
 *  out_len:            [IN]        Output buffer length
 * RETURNS
 *  No. of characters converted
 *****************************************************************************/
extern void srv_phb_convert_to_initial(U16 *input_string, U16 *output_string, U16 out_len);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_remove_invalid_name
 * DESCRIPTION
 *  This function is used to remove invalid characters.
 * PARAMETERS
 *  name:               [IN/OUT]    PHB name
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_remove_invalid_name(U16 *name);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_remove_invalid_number_ex
 * DESCRIPTION
 *  This function is used to remove invalid characters.
 * PARAMETERS
 *  number:             [IN/OUT]    PHB number
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_remove_invalid_number_ex(U16 *number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_remove_invalid_number
 * DESCRIPTION
 *  This function is used to remove invalid characters.
 * PARAMETERS
 *  number:             [IN/OUT]    PHB number
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_remove_invalid_number(U16 *number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_number_asc_to_wcs
 * DESCRIPTION
 *  This function is used to convert PHB number from ascii to wcs.
 * PARAMETERS
 *  dest:               [OUT]       Desitination number
 *  src:                [IN]        Source number
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_number_asc_to_wcs(mmi_phb_wcs_num_struct* dest, mmi_phb_asc_num_struct* src);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_number_wcs_to_asc
 * DESCRIPTION
 *  This function is used to convert PHB number from wcs to ascii.
 * PARAMETERS
 *  dest:               [OUT]       Desitination number
 *  src:                [IN]        Source number
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_number_wcs_to_asc(mmi_phb_asc_num_struct* dest, mmi_phb_wcs_num_struct* src);


#ifdef __MMI_DIALER_SEARCH__
#if defined(__MMI_PHB_OPTIONAL_FIELD__) && defined(__MMI_PHB_DS_SEARCH_OP_NUMBER__)
/*****************************************************************************
 * FUNCTION
 *  srv_phb_ds_compare_halfbyte
 * DESCRIPTION
 *  compare two strings according to ds compare algorithm
 * PARAMETERS
 *  a:                  [IN]        one ds number
 *  b:                  [IN]        another ds number
 *  length:             [IN]        compare length
 * RETURNS
 *  s32                 0 for equal and another value for non-equal
 *****************************************************************************/
extern S32 srv_phb_ds_compare_halfbyte(void *a, void *b, U32 length);

#endif /* defined(__MMI_PHB_OPTIONAL_FIELD__) && defined(__MMI_PHB_DS_SEARCH_OP_NUMBER__) */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_ds_search_entry
 * DESCRIPTION
 *  search phonebook & call log entry by key word
 * PARAMETERS
 *  key_word:           [IN]        key word
 *  output:             [OUT]       search result
 * RETURNS
 *  S32
 *****************************************************************************/
extern S32 srv_phb_ds_search_entry(WCHAR* key_word, srv_phb_ds_list_cntx_struct* output);
#endif /* __MMI_DIALER_SEARCH__ */

#include "PhbSrvIprot.h"


#define PHB_NEW_FTO_SRV

#define MMI_PHB_INVALID_CONTACT_ID      0xFFFF
#define MMI_PHB_INVALID_GROUP_ID        0xFF
#define MMI_PHB_SUB_ID_NEW              0xFFFF

#define SRV_PHB_QUERY_PATTERN_LEN       ((MMI_PHB_NAME_LENGTH > MMI_PHB_NUMBER_PLUS_LENGTH) ? MMI_PHB_NAME_LENGTH : MMI_PHB_NUMBER_PLUS_LENGTH)

/***************************************************************************** 
 * Typedef 
 *****************************************************************************/
typedef void* srv_phb_handle;
typedef void* srv_phb_query_handle;


typedef void* srv_phb_field_filter;
typedef void* srv_phb_contact_filter;
typedef void* srv_phb_contact;
typedef U32 srv_phb_iterator;

#define SRV_PHB_STORAGE_MASK_PHONE       (1 << PHB_STORAGE_NVRAM)
#define SRV_PHB_STORAGE_MASK_SIM         (1 << PHB_STORAGE_SIM)
#define SRV_PHB_STORAGE_MASK_SIM2        (1 << PHB_STORAGE_SIM2)
#define SRV_PHB_STORAGE_MASK_SIM3        (1 << PHB_STORAGE_SIM3)
#define SRV_PHB_STORAGE_MASK_SIM4        (1 << PHB_STORAGE_SIM4)

#ifdef __SRV_PHB_TCARD_STORAGE_SUPPORT__
#define SRV_PHB_STORAGE_MASK_TCARD       (1 << PHB_STORAGE_TCARD)
#else
#define SRV_PHB_STORAGE_MASK_TCARD       0
#endif

#define SRV_PHB_STORAGE_MASK_ALL         (SRV_PHB_STORAGE_MASK_SIM | SRV_PHB_STORAGE_MASK_SIM2 | SRV_PHB_STORAGE_MASK_SIM3 | SRV_PHB_STORAGE_MASK_SIM4 | SRV_PHB_STORAGE_MASK_PHONE | SRV_PHB_STORAGE_MASK_TCARD)

/****************************************************/
/*                                                  */
/*               enum                               */
/*                                                  */
/****************************************************/


/****************************************************/
/*                                                  */
/*               async op                           */
/*                                                  */
/****************************************************/
typedef enum
{
    SRV_PHB_OP_CB_TYPE_ADD,
    SRV_PHB_OP_CB_TYPE_UPD,
    SRV_PHB_OP_CB_TYPE_DEL,
    SRV_PHB_OP_CB_TYPE_COPY,
    SRV_PHB_OP_CB_TYPE_MOVE,
    SRV_PHB_OP_CB_TYPE_COPY_ALL,
    SRV_PHB_OP_CB_TYPE_MOVE_ALL,
    SRV_PHB_OP_CB_TYPE_DELETE_ALL,
    SRV_PHB_OP_CB_TYPE_MULTI_COPY,
    SRV_PHB_OP_CB_TYPE_MULTI_MOVE,
    SRV_PHB_OP_CB_TYPE_MULTI_DELETE,
    SRV_PHB_OP_CB_TYPE_UPDATE_STATUS,
    SRV_PHB_OP_CB_TYPE_BACKUP,
    SRV_PHB_OP_CB_TYPE_RESTORE,
    SRV_PHB_OP_CB_TYPE_SYNC,
    SRV_PHB_OP_CB_TYPE_TOTAL
} srv_phb_op_cb_type_enum;


typedef enum
{
    SRV_PHB_UPDATE_MODE_REPLACE,  /* remove all old data */
    SRV_PHB_UPDATE_MODE_IMPORT,   /* import from sync or AT, use save index to update  */
    SRV_PHB_UPDATE_MODE_TOTAL
} srv_phb_update_mode_enum;


/****************************************************/
/*                                                  */
/*              Phb contact filter                  */
/*                                                  */
/****************************************************/
typedef enum
{
    SRV_PHB_QUERY_TYPE_PARTIAL,
    SRV_PHB_QUERY_TYPE_FULL,
#ifdef __MMI_DIALER_SEARCH__
    SRV_PHB_QUERY_TYPE_DS,
#endif
    SRV_PHB_QUERY_TYPE_TOTAL
} srv_phb_query_type_enum;

/****************************************************/
/*                                                  */
/*              Phb backup restore mode         */
/*                                                  */
/****************************************************/
typedef enum
{
    SRV_PHB_BACKUP_RESTORE_MODE_T_CARD,
    SRV_PHB_BACKUP_RESTORE_MODE_CLOUD,
    SRV_PHB_BACKUP_RESTORE_MODE_TOTAL
} srv_phb_backup_restore_mode_enum;



/****************************************************/
/*                                                  */
/*               Struct                             */
/*                                                  */
/****************************************************/


/****************************************************/
/*                                                  */
/*              contact                             */
/*                                                  */
/****************************************************/


/* srv phb caller res struct */
typedef struct
{
    MMI_BOOL flag;                                              /* only use for caller video, MMI_TRUE mean video sound on*/
    U16 res_id;                                                 /* res id field, judge it only when path is empty string */
    WCHAR res_path[SRV_FMGR_PATH_MAX_LEN + 1];                  /* res path field */
} srv_phb_res_struct;


/* srv phb group struct */
typedef struct
{
    U8 group_id[MMI_PHB_GROUP_COUNT];                      /* group id array */
    U16 group_count;                                       /* group count */
} srv_phb_group_struct;


/* srv phb birthday struct */
typedef mmi_phb_bday_struct srv_phb_bday_struct;


/* srv phb number struct */
typedef struct
{
    mmi_phb_sub_id sub_id;                                 /* number id field, set as MMI_PHB_SUB_ID_NEW, 
                                                           srv will assign a id after add/update it */
    U8 index;                                              /* store index */
    U8 type;                                               /* number type field, refer: mmi_phb_num_type_enum */
    U8 last_used_sim;                                      /*preferred sim, high 4 bits for sms, low 4 bits for call */
    WCHAR number[MMI_PHB_NUMBER_PLUS_LENGTH + 1];          /* number data field */
    WCHAR label[MMI_PHB_FIELD_LABEL_LENGTH + 1];           /* number label field */
    MMI_BOOL is_default;                                   /* is default number flag */
} srv_phb_number_struct;


/* srv phb email struct */
typedef struct
{
    mmi_phb_sub_id sub_id;                          /* email id field, same as number id */
    U8 index;                                       /* store index */
    U8 type;                                        /* email type field, refer: mmi_phb_email_type_enum */
    WCHAR email[MMI_PHB_EMAIL_LENGTH + 1];          /* email data field */
    WCHAR label[MMI_PHB_FIELD_LABEL_LENGTH + 1];    /* email label field */
} srv_phb_email_struct;


/* srv phb address struct */
typedef struct
{
    mmi_phb_sub_id sub_id;                         /* address id field, same as number id */
    U8 index;                                      /* store index */
    U8 type;                                       /* address type field */
    mmi_phb_address_struct address;                /* address data field */
} srv_phb_address_struct;


/* srv phb url struct */
typedef struct
{
    mmi_phb_sub_id sub_id;                         /* url id field, same as number id */
    U8 index;                                      /* store index */
    U8 type;                                       /* url type field */
    WCHAR url[MMI_PHB_URL_LENGTH + 1];             /* url data field */
} srv_phb_url_struct;


/* srv phb note struct */
typedef struct
{
    mmi_phb_sub_id sub_id;                         /* note id field, same as number id */
    U8 index;                                      /* store index */
    U8 type;                                       /* note type field */
    WCHAR note[MMI_PHB_NOTE_LENGTH + 1];           /* note data field */
} srv_phb_note_struct;



/****************************************************/
/*                                                  */
/*               async op                           */
/*                                                  */
/****************************************************/

/* srv phb op event struct */
typedef struct
{
    MMI_EVT_PARAM_HEADER
    U16 store_index;                            /* contact store_index */
    mmi_phb_contact_id id;                      /* contact id */
    U32 update_field;                           /* updated field */
    srv_phb_contact contact;                    /* updated field info */
} srv_phb_op_evt_struct;

/* srv phb async op cb parameter common struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;       /* op type */
    srv_phb_handle handle;              /* op handle */
    void* user_data;                    /* user data */
} srv_phb_async_op_cb_struct;


/*****************************************************************************
 * <GROUP CallBackFunctions>
 *
 * FUNCTION
 *  srv_phb_async_op_callback_type
 * DESCRIPTION
 *  async op common call back type
 * PARAMETERS
 *  info:             [IN]        cb info
 * RETURNS
 *  void
 *****************************************************************************/
typedef void (*srv_phb_async_op_callback_type)(srv_phb_async_op_cb_struct* info);


/* srv phb add req struct */
typedef struct
{
    U16 record_index;                       /* set the new contact id(base on the storage, 1st),
                                            let's srv find empty id set as MMI_PHB_INVALID_CONTACT_ID */
    srv_phb_update_mode_enum mode;      /* update mode */
    phb_storage_enum storage;               /* storage to add contact */
    srv_phb_contact contact;                /* contact data to add */
    srv_phb_async_op_callback_type cb;      /* cb */
    void* user_data;                        /* user data */
} srv_phb_add_req_struct;

/* srv phb add cb parameter struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;           /* op type */
    srv_phb_handle handle;                  /* op handle */
    void* user_data;                        /* user data */
    S32 result;                             /* result */
    mmi_phb_contact_id id;                  /* contact id */
} srv_phb_add_cb_struct;


/* srv phb update req struct */
typedef struct
{
    mmi_phb_contact_id id;              /* contact id */
    srv_phb_update_mode_enum mode;      /* update mode */
    U32 update_field;                   /* update field mask */
    srv_phb_contact contact;            /* contact data to updata */
    srv_phb_async_op_callback_type cb;  /* cb */
    void* user_data;                    /* user data */
} srv_phb_update_req_struct;

/* srv phb update cb parameter struct */
typedef srv_phb_add_cb_struct srv_phb_update_cb_struct;


/* srv phb delete req struct */
typedef struct
{
    mmi_phb_contact_id id;                  /* contact id */
    srv_phb_async_op_callback_type cb;      /* cb */
    void* user_data;                        /* user data */
} srv_phb_delete_req_struct;

/* srv phb delete cb parameter struct */
typedef srv_phb_add_cb_struct srv_phb_delete_cb_struct;


/* srv phb copy req struct */
typedef struct
{
    mmi_phb_contact_id id;
    phb_storage_enum dest_storage;
    srv_phb_async_op_callback_type cb;
    void* user_data;
} srv_phb_copy_req_struct;

/* srv phb copy cb parameter struct */
typedef srv_phb_add_cb_struct srv_phb_copy_cb_struct;


/* srv phb move req struct */
typedef srv_phb_copy_req_struct srv_phb_move_req_struct;

/* srv phb move cb parameter struct */
typedef srv_phb_add_cb_struct srv_phb_move_cb_struct;

/* srv phb copy all req struct */
typedef struct
{
    phb_storage_enum src_storage;       /* src storage */
    phb_storage_enum dest_storage;      /* dest storage */
    srv_phb_async_op_callback_type cb;  /* cb */
    void* user_data;                    /* user data */
} srv_phb_copy_all_req_struct;

/* srv phb copy all cb parameter struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;  /* op type */
    srv_phb_handle handle;         /* op handle */
    void* user_data;               /* user data */
    U16 finish_count;              /* finished count */
    U16 total_count;               /* total count */
    U16 fail_count;                /* failed count*/
    S32 result;                    /* result of operation*/
} srv_phb_copy_all_cb_struct;


/* srv phb move all req struct */
typedef srv_phb_copy_all_req_struct srv_phb_move_all_req_struct;

/* srv phb move all cb parameter struct */
typedef srv_phb_copy_all_cb_struct srv_phb_move_all_cb_struct;

/* srv phb delete all req struct */
typedef struct
{
    phb_storage_enum storage;
    srv_phb_async_op_callback_type cb;
    void* user_data;
} srv_phb_delete_all_req_struct;

/* srv phb delete all cb parameter struct */
typedef srv_phb_copy_all_cb_struct srv_phb_delete_all_cb_struct;


/* srv phb multi copy req struct */
typedef struct
{
    U16 contact_count;                  /* total count */
    mmi_phb_contact_id* id_array;       /* contact id array */
    phb_storage_enum dest_storage;      /* dest storage */
    srv_phb_async_op_callback_type cb;  /* cb */
    void* user_data;                    /* user data */
} srv_phb_multi_copy_req_struct;


/* srv phb multi copy cb parameter struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;   /* op type */
    srv_phb_handle handle;          /* op handle */
    void* user_data;                /* user data */
    U16 finish_count;               /* finished count */
    U16 total_count;                /* total count */
    U16 fail_count;                 /* failed count*/
    S32 result;                     /* operation result*/
    mmi_phb_contact_id* id_array;   /* failed contact id array */
} srv_phb_multi_copy_cb_struct;


/* srv phb multi move req struct */
typedef srv_phb_multi_copy_req_struct srv_phb_multi_move_req_struct;

/* srv phb multi move cb parameter struct */
typedef srv_phb_multi_copy_cb_struct srv_phb_multi_move_cb_struct;


/* srv phb multi delete req struct */
typedef struct
{
    U16 contact_count;
    mmi_phb_contact_id* id_array;
    srv_phb_async_op_callback_type cb;
    void* user_data;
} srv_phb_multi_delete_req_struct;


/* srv phb multi delete cb parameter struct */
typedef srv_phb_multi_copy_cb_struct srv_phb_multi_delete_cb_struct;


/* srv phb backup req struct */
typedef struct
{
    srv_phb_async_op_callback_type cb;      /* cb */
    void* user_data;                        /* user data */
    WCHAR path[SRV_FMGR_PATH_MAX_LEN + 1];  /* path */
    phb_storage_enum storage;               /* storage */
    #ifdef __VCARD_CLOUD_SUPPORT__
    srv_phb_backup_restore_mode_enum mode;  /* backup mode */
    U32 provider;                           /* provider id need by cloud*/
    U8 account;                             /* account id need by cloud*/
    srv_cloud_mem_alloc malloc_func;
    srv_cloud_mem_free free_func;
    #endif
} srv_phb_backup_req_struct;

typedef srv_phb_copy_all_cb_struct srv_phb_backup_cb_struct;


/* srv phb restore req struct */
typedef struct
{
    srv_phb_async_op_callback_type cb;      /* cb */
    void* user_data;                        /* user data */
    WCHAR path[SRV_FMGR_PATH_MAX_LEN + 1];  /* path */
    #ifdef __VCARD_CLOUD_SUPPORT__
    srv_phb_backup_restore_mode_enum mode;  /* restore mode */
    U32 provider;                           /* provider id need by cloud*/
    U8 account;                             /* account id need by cloud*/
    srv_cloud_mem_alloc malloc_func;
    srv_cloud_mem_free free_func;
    #endif
} srv_phb_restore_req_struct;

typedef srv_phb_copy_all_cb_struct srv_phb_restore_cb_struct;


/* srv phb backup update cb parameter struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;     /* cb type*/
    srv_phb_handle handle;            /* op handle */
    void* user_data;                  /* user data */
    S32 result;                       /* finished count */
    S32 error_code;                   /* error code */
    U16 event_id;                     /* cancel or continue event id */
} srv_phb_backup_update_cb_struct;


/* srv phb backup update cb parameter struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;     /* cb type*/
    srv_phb_handle handle;            /* op handle */
    void* user_data;                  /* user data */
    S32 result;                       /* success or fail */
    S32 error_code;                   /* error code */
    U16 event_id;                     /* cancel or continue event id */
    U16 percentage;                   /* record process process 0 ~ 100 */
} srv_phb_restore_update_cb_struct;


/* srv phb multi op status update cb parameter struct */
typedef struct
{
    srv_phb_op_cb_type_enum type;     /* cb type*/
    srv_phb_handle handle;            /* op handle */
    void* user_data;                  /* user data */
    U16 finish_count;                 /* finished count */
    U16 fail_count;                   /* failed count */
    U16 total_count;                  /* total count */
} srv_phb_multi_op_status_cb_struct;

/*set preferred sim request struct*/
typedef struct
{
    U16 *number;
    mmi_phb_contact_id id;
    mmi_sim_enum sim_id;
    srv_phb_number_op_type_enum op_type;
    srv_phb_async_op_callback_type cb;      /* cb */
    void* user_data;                        /* user data */
} srv_phb_set_preferred_sim_req;


/****************************************************/
/*                                                  */
/*               query                              */
/*                                                  */
/****************************************************/

/* srv phb query req struct */
typedef struct
{
    MMI_BOOL alpha_table;     /* MMI_TRUE: build alpha table */
    MMI_BOOL item_order;      /* MMI_TRUE: match item ordered first by match field, second by name */
    U32 align_field;          /* output item align field; name or number or number & email */
    srv_phb_contact_filter filter;  /* contact filter */
} srv_phb_query_req_struct;


/* srv phb query match info struct */
typedef struct
{
    mmi_phb_contact_field_id_enum matched_field;                             /* matched field type*/
    MMI_BOOL is_sequence;                         /* is_sequence flag */
    U8 sequence_start;                            /* use it when is_sequence is MMI_TRUE */
    U8 sequence_len;                              /* use it when is_sequence is MMI_TRUE */
    U8 mask[(SRV_PHB_QUERY_PATTERN_LEN + 7) / 8]; /* use it when is_sequence is MMI_FALSE */
} srv_phb_query_match_info_struct;


/* srv phb aphla info struct */
typedef struct
{
    U16 start_index;            /* start index*/
    U16 count;                  /* total count*/
} srv_phb_alpha_info_struct;

/***************************************************************************** 
 * Global Function
 *****************************************************************************/

    
/****************************************************/
/*                                                  */
/*              contact                             */
/*                                                  */
/****************************************************/


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_contact
 * DESCRIPTION
 *  create a contact container
 * PARAMETERS
 *  contact            : [IN]   src contact, if it's NULL return a empry contact, otherwise copy the src contact
 * RETURNS
 *  void
*****************************************************************************/
extern srv_phb_contact srv_phb_create_contact(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_free_contact
 * DESCRIPTION
 *  free a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  void
*****************************************************************************/
extern void srv_phb_free_contact(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_reset_contact
 * DESCRIPTION
 *  reset all contact values of a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  void
*****************************************************************************/
extern void srv_phb_reset_contact(srv_phb_contact contact, U32 field);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_fname
 * DESCRIPTION
 *  get first name from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_fname(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_fname
 * DESCRIPTION
 *  set first name to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  fname              : [IN]  first name data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_fname(srv_phb_contact contact, const WCHAR* fname);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_lname
 * DESCRIPTION
 *  get last name from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_lname(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_lname
 * DESCRIPTION
 *  set last name to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  lname              : [IN]  last name data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_lname(srv_phb_contact contact, const WCHAR* lname);


/*****************************************************************************
* FUNCTION
*  srv_phb_contact_set_name
* DESCRIPTION
*  set name to a contact handle
* PARAMETERS
*  contact            : [IN]  contact container
*  name              : [IN]  name data
* RETURNS
*  void
*****************************************************************************/
WCHAR* srv_phb_contact_set_name(srv_phb_contact contact, const WCHAR* name);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_lname
 * DESCRIPTION
 *  get full name from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_name(srv_phb_contact contact);


/*****************************************************************************
* FUNCTION
*  srv_phb_contact_get_nick
* DESCRIPTION
*  get nick name from a contact handle
* PARAMETERS
*  void
* RETURNS
*  void
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_nick(srv_phb_contact contact);


/*****************************************************************************
* FUNCTION
*  srv_phb_contact_set_nick
* DESCRIPTION
*  set nick name to a contact handle
* PARAMETERS
*  void
* RETURNS
*  void
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_nick(srv_phb_contact contact, const WCHAR* nick);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_company
 * DESCRIPTION
 *  get company filed from contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_company(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_company
 * DESCRIPTION
 *  set company data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  company            : [IN]  company data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_company(srv_phb_contact contact, const WCHAR* company);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_title
 * DESCRIPTION
 *  get title data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_title(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_title
 * DESCRIPTION
 *  set title data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  title              : [IN]  title data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_title(srv_phb_contact contact, const WCHAR* title);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_bday
 * DESCRIPTION
 *  get bday data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  srv_phb_bday_struct*
*****************************************************************************/
extern srv_phb_bday_struct* srv_phb_contact_get_bday(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_bday
 * DESCRIPTION
 *  set bday data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  bday               : [IN]  bday data
 * RETURNS
 *  srv_phb_bday_struct*
*****************************************************************************/
extern srv_phb_bday_struct* srv_phb_contact_set_bday(srv_phb_contact contact, const srv_phb_bday_struct* bday);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_group
 * DESCRIPTION
 *  get group data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  srv_phb_group_struct*
*****************************************************************************/
extern srv_phb_group_struct* srv_phb_contact_get_group(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_group
 * DESCRIPTION
 *  set group data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  group              : [IN]  group info
 * RETURNS
 *  srv_phb_group_struct*
*****************************************************************************/
extern srv_phb_group_struct* srv_phb_contact_set_group(srv_phb_contact contact, const srv_phb_group_struct* group);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_group_ex
 * DESCRIPTION
 *  set group data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  group_id           : [IN]  group id
 * RETURNS
 *  srv_phb_group_struct*
*****************************************************************************/
extern srv_phb_group_struct* srv_phb_contact_set_group_ex(srv_phb_contact contact, U8 group_id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_ringtone
 * DESCRIPTION
 *  get ringtone data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_get_ringtone(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_ringtone
 * DESCRIPTION
 *  set ringtone data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  ringtone           : [IN]  ringtone info
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_set_ringtone(srv_phb_contact contact, const srv_phb_res_struct* ringtone);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_ringtone_ex
 * DESCRIPTION
 *  set ringtone data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  id                 : [IN]  ringtone id
 *  path               : [IN]  ringtone path
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_set_ringtone_ex(srv_phb_contact contact, U16 id, const WCHAR* path);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_image
 * DESCRIPTION
 *  get image data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_get_image(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_image
 * DESCRIPTION
 *  set image data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  image              : [IN]  image info
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_set_image(srv_phb_contact contact, const srv_phb_res_struct* image);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_image_ex
 * DESCRIPTION
 *  set image data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  id                 : [IN]  image id
 *  path               : [IN]  image path
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_set_image_ex(srv_phb_contact contact, U16 id, const WCHAR* path);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_video
 * DESCRIPTION
 *  get video data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_get_video(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_video
 * DESCRIPTION
 *  set video data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  video              : [IN]  video info
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_set_video(srv_phb_contact contact, const srv_phb_res_struct* video);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_video_ex
 * DESCRIPTION
 *  set video data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  id                 : [IN]  video id
 *  path               : [IN]  video path
 *  video_sound        : [IN]  video sound on or off
 * RETURNS
 *  srv_phb_res_struct*
*****************************************************************************/
extern srv_phb_res_struct* srv_phb_contact_set_video_ex(srv_phb_contact contact, U16 id, const WCHAR* path, MMI_BOOL video_sound);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_imps
 * DESCRIPTION
 *  get imps data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  void
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_imps(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_imps
 * DESCRIPTION
 *  set imps data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  imps               : [IN]  wcs imps data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_imps(srv_phb_contact contact, const WCHAR* imps);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_imps
 * DESCRIPTION
 *  set imps data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  imps               : [IN]  asc imps data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_asc_imps(srv_phb_contact contact, const CHAR* imps);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_voip
 * DESCRIPTION
 *  get voip data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_voip(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_voip
 * DESCRIPTION
 *  set voip data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  voip               : [IN]  wcs voip data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_voip(srv_phb_contact contact, const WCHAR* voip);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_asc_voip
 * DESCRIPTION
 *  set voip data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  voip               : [IN]  asc voip data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_asc_voip(srv_phb_contact contact, const CHAR* voip);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_msn
 * DESCRIPTION
 *  get msn data from a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_get_msn(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_msn
 * DESCRIPTION
 *  set msn data to a contact container
 * PARAMETERS
 *  contact            : [IN]  contact container
 *  msn                : [IN]  wcs msn data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_msn(srv_phb_contact contact, const WCHAR* msn);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_set_asc_msn
 * DESCRIPTION
 *  set msn data to a contact container
 * PARAMETERS
 *  contact                    : [IN]  contact container
 *  msn                        : [IN]  asc msn data
 * RETURNS
 *  WCHAR*
*****************************************************************************/
extern WCHAR* srv_phb_contact_set_asc_msn(srv_phb_contact contact, const CHAR* msn);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_number
 * DESCRIPTION
 *  add a number to contact container
 * PARAMETERS
 *  contact                    : [IN]  contact container
 *  number                     : [IN]  number info
 * RETURNS
 *  srv_phb_number_struct
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_add_number(srv_phb_contact contact, const srv_phb_number_struct* number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_number
 * DESCRIPTION
 *  add a number to contact container
 * PARAMETERS
 *  contact                    : [IN]  contact container
 *  id                         : [IN]  number sub id, new number set as MMI_PHB_SUB_ID_NEW
 *  save_index                 : [IN]  number save index, only for AT, otherwise set as 0
 *  type                       : [IN]  number type, refer mmi_phb_num_type_enum
 *  number                     : [IN]  asc number data
 *  label                      : [IN]  number field label
 *  is_default                 : [IN]  is default number flag
 * RETURNS
 *  srv_phb_number_struct
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_add_asc_number(
                                srv_phb_contact contact,
                                mmi_phb_sub_id id,
                                U8 save_index,
                                U8 type,
                                const CHAR* number,
                                const WCHAR* label,
                                MMI_BOOL is_default);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_number_ex
 * DESCRIPTION
 *  add a number to contact container
 * PARAMETERS
 *  contact                    : [IN]  contact container
 *  id                         : [IN]  number sub id, new number set as MMI_PHB_SUB_ID_NEW
 *  save_index                 : [IN]  number save index, only for AT, otherwise set as 0
 *  type                       : [IN]  number type, refer mmi_phb_num_type_enum
 *  last_used_sim          : [IN] preferred sim for gemini+
 *  number                     : [IN]  asc number data
 *  label                      : [IN]  number field label
 *  is_default                 : [IN]  is default number flag
 * RETURNS
 *  srv_phb_number_struct
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_add_asc_number_ex(
                                srv_phb_contact contact,
                                mmi_phb_sub_id id,
                                U8 save_index,
                                U8 type,
                                U8 last_used_sim,
                                const CHAR* number,
                                const WCHAR* label,
                                MMI_BOOL is_default);



/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_number
 * DESCRIPTION
 *  add a number to contact container
 * PARAMETERS
 *  contact                    : [IN]  contact container
 *  id                         : [IN]  number sub id, new number set as MMI_PHB_SUB_ID_NEW
 *  save_index                 : [IN]  number save index, only for AT, otherwise set as 0
 *  type                       : [IN]  number type, refer mmi_phb_num_type_enum
 *  number                     : [IN]  wcs number data
 *  label                      : [IN]  number field label
 *  is_default                 : [IN]  is default number flag
 * RETURNS
 *  srv_phb_number_struct*
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_add_number_ex(
                                srv_phb_contact contact,
                                mmi_phb_sub_id id,
                                U8 save_index,
                                U8 type,
                                const WCHAR* number,
                                const WCHAR* label,
                                MMI_BOOL is_default);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_number_count
 * DESCRIPTION
 *  get number count of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  U16
*****************************************************************************/
extern U16 srv_phb_contact_get_number_count(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_number_iterator
 * DESCRIPTION
 *  get number iterator from a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_iterator
*****************************************************************************/
extern srv_phb_iterator srv_phb_contact_get_number_iterator(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_number_next
 * DESCRIPTION
 *  get next number data from a contact container by number iterator
 * PARAMETERS
 *  iterator    : [IN]  number iterator
 * RETURNS
 *  srv_phb_number_struct*
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_get_number_next(srv_phb_iterator* iterator);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_number_by_sub_id
 * DESCRIPTION
 *  get number data from a contact container by number sub id
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  number sub id
 * RETURNS
 *  srv_phb_number_struct*
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_get_number_by_sub_id(srv_phb_contact contact, mmi_phb_sub_id id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_number_by_save_index
 * DESCRIPTION
 *  get number data from a contact container by number save index
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  save_index : [IN]  number save index
 * RETURNS
 *  srv_phb_number_struct*
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_get_number_by_save_index(srv_phb_contact contact, U8 save_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_first_number
 * DESCRIPTION
 *  add the first number of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_number_struct*
*****************************************************************************/
extern srv_phb_number_struct* srv_phb_contact_get_first_number(srv_phb_contact contact);

/*****************************************************************************
* FUNCTION
*  srv_phb_contact_find_number
* DESCRIPTION
* 
* PARAMETERS
*  contact    : [IN]  contact infor
*  number    : [IN]  number
*  index       : [OUT] number index in contact
* RETURNS
*  MMI_TRUE  : number exist
*  MMI_FALSE : not found
*****************************************************************************/
extern MMI_BOOL srv_phb_contact_find_number(srv_phb_contact contact, U16 *number, U32 *index);



/*****************************************************************************
* FUNCTION
*  srv_phb_contact_remove_number
* DESCRIPTION
*  remove a number from contact container by sub id
* PARAMETERS
*  contact    : [IN]  contact container
*  sub_id     : [IN]  number id
* RETURNS
*  MMI_BOOL
*****************************************************************************/
extern MMI_BOOL srv_phb_contact_remove_number(srv_phb_contact contact, srv_phb_number_struct* number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_email
 * DESCRIPTION
 *  add a email to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  email      : [IN]  email info
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_add_email(srv_phb_contact contact, const srv_phb_email_struct* email);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_asc_email
 * DESCRIPTION
 *  add a email to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  email sub id
 *  save_index : [IN]  email save index
 *  type       : [IN]  email type
 *  email      : [IN]  asc email data
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_add_asc_email(srv_phb_contact contact, mmi_phb_sub_id id, U8 save_index, U8 type, const CHAR* email, const WCHAR* label);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_email_ex
 * DESCRIPTION
 *  add a email to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  email sub id
 *  save_index : [IN]  email save index
 *  type       : [IN]  email type
 *  email      : [IN]  wcs email data
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_add_email_ex(srv_phb_contact contact, mmi_phb_sub_id id, U8 save_index, U8 type, const WCHAR* email, const WCHAR* label);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_email_count
 * DESCRIPTION
 *  get email count of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  U16
*****************************************************************************/
extern U16 srv_phb_contact_get_email_count(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_email_iterator
 * DESCRIPTION
 *  get email iterator from a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_iterator
*****************************************************************************/
extern srv_phb_iterator srv_phb_contact_get_email_iterator(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_email_next
 * DESCRIPTION
 *  get next email data from a contact container by email iterator
 * PARAMETERS
 *  iterator    : [IN]  email iterator
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_get_email_next(srv_phb_iterator* iterator);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_email_by_sub_id
 * DESCRIPTION
 *  get email data from a contact container by email sub id
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  email sub id
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_get_email_by_sub_id(srv_phb_contact contact, mmi_phb_sub_id id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_email_by_save_index
 * DESCRIPTION
 *  get email data from a contact container by email save index
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  save_index : [IN]  email save index
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_get_email_by_save_index(srv_phb_contact contact, U8 save_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_first_email
 * DESCRIPTION
 *  add the first email of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_email_struct*
*****************************************************************************/
extern srv_phb_email_struct* srv_phb_contact_get_first_email(srv_phb_contact contact);


/*****************************************************************************
* FUNCTION
*  srv_phb_contact_remove_email
* DESCRIPTION
* 
* PARAMETERS
*  void
* RETURNS
*  void
*****************************************************************************/
extern MMI_BOOL srv_phb_contact_remove_email(srv_phb_contact contact, srv_phb_email_struct* email);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_address
 * DESCRIPTION
 *  add a address to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  address    : [IN]  address info
 * RETURNS
 *  srv_phb_address_struct*
*****************************************************************************/
extern srv_phb_address_struct* srv_phb_contact_add_address(srv_phb_contact contact, const srv_phb_address_struct* address);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_address_ex
 * DESCRIPTION
 *  add a address to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  address sub id
 *  type       : [IN]  address type
 *  address    : [IN]  address data
 * RETURNS
 *  srv_phb_address_struct*
*****************************************************************************/
extern srv_phb_address_struct* srv_phb_contact_add_address_ex(srv_phb_contact contact, mmi_phb_sub_id id, U8 type, const mmi_phb_address_struct* address);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_address_count
 * DESCRIPTION
 *  get address count of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  U16
*****************************************************************************/
extern U16 srv_phb_contact_get_address_count(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_address_iterator
 * DESCRIPTION
 *  get address iterator from a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_iterator
*****************************************************************************/
extern srv_phb_iterator srv_phb_contact_get_address_iterator(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_address_next
 * DESCRIPTION
 *  get next address data from a contact container by address iterator
 * PARAMETERS
 *  iterator    : [IN]  address iterator
 * RETURNS
 *  srv_phb_address_struct*
*****************************************************************************/
extern srv_phb_address_struct* srv_phb_contact_get_address_next(srv_phb_iterator* iterator);


/*****************************************************************************
* FUNCTION
 *  srv_phb_contact_get_address_by_sub_id
 * DESCRIPTION
 *  get address data from a contact container by sub id
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  address sub id
 * RETURNS
 *  srv_phb_address_struct*
*****************************************************************************/
extern srv_phb_address_struct* srv_phb_contact_get_address_by_sub_id(srv_phb_contact contact, mmi_phb_sub_id id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_url
 * DESCRIPTION
 *  add a url to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  url        : [IN]  url info
 * RETURNS
 *  srv_phb_url_struct*
*****************************************************************************/
extern srv_phb_url_struct* srv_phb_contact_add_url(srv_phb_contact contact, const srv_phb_url_struct* url);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_url_ex
 * DESCRIPTION
 *  add a url to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  url sub id
 *  type       : [IN]  url type
 *  url        : [IN]  wcs url data
 * RETURNS
 *  srv_phb_url_struct*
*****************************************************************************/
extern srv_phb_url_struct* srv_phb_contact_add_url_ex(srv_phb_contact contact, mmi_phb_sub_id id, U8 type, const WCHAR* url);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_asc_url
 * DESCRIPTION
 *  add a url to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  url sub id
 *  type       : [IN]  url type
 *  url        : [IN]  asc url data
 * RETURNS
 *  srv_phb_url_struct*
*****************************************************************************/
extern srv_phb_url_struct* srv_phb_contact_add_asc_url(srv_phb_contact contact, mmi_phb_sub_id id, U8 type, const CHAR* url);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_url_count
 * DESCRIPTION
 *  get url count of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  U16
*****************************************************************************/
extern U16 srv_phb_contact_get_url_count(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_url_iterator
 * DESCRIPTION
 *  get url iterator from a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_iterator
*****************************************************************************/
extern srv_phb_iterator srv_phb_contact_get_url_iterator(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_url_next
 * DESCRIPTION
 *  get next url data from a contact container by url iterator
 * PARAMETERS
 *  iterator    : [IN]  url iterator
 * RETURNS
 *  srv_phb_url_struct*
*****************************************************************************/
extern srv_phb_url_struct* srv_phb_contact_get_url_next(srv_phb_iterator* iterator);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_url_by_sub_id
 * DESCRIPTION
 *  get url data from a contact container by sub id
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  url sub id
 * RETURNS
 *  srv_phb_url_struct*
*****************************************************************************/
extern srv_phb_url_struct* srv_phb_contact_get_url_by_sub_id(srv_phb_contact contact, mmi_phb_sub_id id);


/*****************************************************************************
* FUNCTION
*  srv_phb_contact_add_note
* DESCRIPTION
*  add a note to a contact container
* PARAMETERS
*  contact    : [IN]  contact container
*  note       : [IN]  note to add
* RETURNS
*  srv_phb_note_struct*
*****************************************************************************/
extern srv_phb_note_struct* srv_phb_contact_add_note(srv_phb_contact contact, const srv_phb_note_struct* note);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_add_note_ex
 * DESCRIPTION
 *  add a note to a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  note sub id
 *  type       : [IN]  note type
 *  note       : [IN]  note data
 * RETURNS
 *  srv_phb_note_struct*
*****************************************************************************/
extern srv_phb_note_struct* srv_phb_contact_add_note_ex(srv_phb_contact contact, mmi_phb_sub_id id, U8 type, const WCHAR* note);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_note_count
 * DESCRIPTION
 *  get note count of a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  U16
*****************************************************************************/
extern U16 srv_phb_contact_get_note_count(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_note_iterator
 * DESCRIPTION
 *  get note iterator from a contact container
 * PARAMETERS
 *  contact    : [IN]  contact container
 * RETURNS
 *  srv_phb_iterator
*****************************************************************************/
extern srv_phb_iterator srv_phb_contact_get_note_iterator(srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_note_next
 * DESCRIPTION
 *  get next note data from a contact container by note iterator
 * PARAMETERS
 *  iterator    : [IN]  note iterator
 * RETURNS
 *  srv_phb_note_struct*
*****************************************************************************/
extern srv_phb_note_struct* srv_phb_contact_get_note_next(srv_phb_iterator* iterator);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_get_note_by_sub_id
 * DESCRIPTION
 *  get note data from a contact container by sub id
 * PARAMETERS
 *  contact    : [IN]  contact container
 *  id         : [IN]  note sub id
 * RETURNS
 *  srv_phb_note_struct*
*****************************************************************************/
extern srv_phb_note_struct* srv_phb_contact_get_note_by_sub_id(srv_phb_contact contact, mmi_phb_sub_id id);


#if 0
/* under construction !*/
/* under construction !*/
#endif


/****************************************************/
/*                                                  */
/*               async op                           */
/*                                                  */
/****************************************************/

/*****************************************************************************
 * FUNCTION
 *  srv_phb_stop_async_op
 * DESCRIPTION
 *  stop a async op
 * PARAMETERS
 *  handle    : [IN]  op handle
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_stop_async_op(srv_phb_handle handle);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_free_handle
 * DESCRIPTION
 *  free op handle. Notice: AP need free each handle once and only once
 * PARAMETERS
 *  handle    : [IN]  op handle
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_free_handle(srv_phb_handle handle);


/* add op */
/*****************************************************************************
 * FUNCTION
 *  srv_phb_add_contact
 * DESCRIPTION
 *  add a contact
 * PARAMETERS
 *  req    : [IN]  add req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_add_contact(srv_phb_add_req_struct* req);


/* update op */
/*****************************************************************************
 * FUNCTION
 *  srv_phb_update_contact
 * DESCRIPTION
 *  update a contact
 * PARAMETERS
 *  req    : [IN]  update req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_update_contact(srv_phb_update_req_struct* req);


/* delete op */
/*****************************************************************************
 * FUNCTION
 *  srv_phb_delete_contact
 * DESCRIPTION
 *  delete a contact
 * PARAMETERS
 *  req    : [IN]  delete req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_delete_contact(srv_phb_delete_req_struct* req);


/* copy op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_copy_contact
 * DESCRIPTION
 *  copy a contact
 * PARAMETERS
 *  req    : [IN]  copy req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_copy_contact(srv_phb_copy_req_struct* req);


/* move op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_move_contact
 * DESCRIPTION
 *  move a contact
 * PARAMETERS
 *  req    : [IN]  move req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_move_contact(srv_phb_move_req_struct* req);


/* copy all op */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_copy_all_contact
 * DESCRIPTION
 *  copy contacts by storage
 * PARAMETERS
 *  req    : [IN]  copy all req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_copy_all_contact(srv_phb_copy_all_req_struct* req);


/* move all op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_move_all_contact
 * DESCRIPTION
 *  move contacts by storage
 * PARAMETERS
 *  req    : [IN]  move all req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_move_all_contact(srv_phb_move_all_req_struct* req);


/* delete all op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_delete_all_contact
 * DESCRIPTION
 *  delete contacts by storage
 * PARAMETERS
 *  req    : [IN]  delete all req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
srv_phb_handle srv_phb_delete_all_contact(srv_phb_delete_all_req_struct* req);


/* multi copy op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_multi_copy_contact
 * DESCRIPTION
 *  copy several contact
 * PARAMETERS
 *  req    : [IN]  multi copy req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_multi_copy_contact(srv_phb_multi_copy_req_struct* req);


/* multi move op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_multi_move_contact
 * DESCRIPTION
 *  move several contact
 * PARAMETERS
 *  req    : [IN]  multi move req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_multi_move_contact(srv_phb_multi_move_req_struct* req);


/* multi delete op */

/*****************************************************************************
 * FUNCTION
 *  srv_phb_multi_delete_contact
 * DESCRIPTION
 *  delete several contact
 * PARAMETERS
 *  req    : [IN]  multi delete req
 * RETURNS
 *  srv_phb_handle
 *****************************************************************************/
extern srv_phb_handle srv_phb_multi_delete_contact(srv_phb_multi_delete_req_struct* req);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_backup_contact
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern srv_phb_handle srv_phb_backup_contact(srv_phb_backup_req_struct* req);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_restore_contact
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern srv_phb_handle srv_phb_restore_contact(srv_phb_restore_req_struct* req);


/****************************************************/
/*                                                  */
/*              Phb filter                          */
/*                                                  */
/****************************************************/

/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_field_filter
 * DESCRIPTION
 *  create a empty field filter
 * PARAMETERS
 *  void
 * RETURNS
 *  srv_phb_field_filter
 *****************************************************************************/
extern srv_phb_field_filter srv_phb_create_field_filter(void);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_field_filter_ext
 * DESCRIPTION
 *  create a field filter with field type filter
 * PARAMETERS
 *  field_type:         [IN]        field mask, such as MMI_PHB_CONTACT_FIELD_NAME
 * RETURNS
 *  srv_phb_field_filter
 *****************************************************************************/
extern srv_phb_field_filter srv_phb_create_field_filter_ext(U32 field_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_field_filter_ext2
 * DESCRIPTION
 *  create a field filter with number type filter
 * PARAMETERS
 *  number_type:        [IN]        number type refer: mmi_phb_num_type_enum
 * RETURNS
 *  srv_phb_field_filter 
 *****************************************************************************/
extern srv_phb_field_filter srv_phb_create_field_filter_ext2(U32 field_type, U8 number_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_free_field_filter
 * DESCRIPTION
 *  free a field filter
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_free_field_filter(srv_phb_field_filter filter);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_filed_filter_set_field
 * DESCRIPTION
 *  set field type filter to a field filter
 * PARAMETERS
 *  filter:             [IN]        field filter
 *  field_type:         [IN]        field mask, such as MMI_PHB_CONTACT_FIELD_NAME
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_filed_filter_set_field(srv_phb_field_filter filter, U32 field_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_set_number_type_filter
 * DESCRIPTION
 *  set number type filter to a field filter
 * PARAMETERS
 *  filter:             [IN]        field filter
 *  number_type:        [IN]        number type refer: mmi_phb_num_type_enum
 * RETURNS
 *  void 
 *****************************************************************************/
extern void srv_phb_filed_filter_set_number_type(srv_phb_field_filter filter, U8 number_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_filed_filter_set_default_number
 * DESCRIPTION
 *  set default number filter to a field filter
 * PARAMETERS
 *  filter:             [IN]        field filter
 *  only_default:       [IN]        MMI_TRUE: only get default number
 * RETURNS
 *  void 
 *****************************************************************************/
extern void srv_phb_filed_filter_set_default_number(srv_phb_field_filter filter, MMI_BOOL only_default);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_read_contact
 * DESCRIPTION
 *  create empty contact filter
 * PARAMETERS
 *  id:             [IN]        contact id
 *  filter:         [IN]        field filter
 *  contact:        [IN]        if set will reuse the contact to get contact info, otherwise will use a new contact to get info
 * RETURNS
 *  srv_phb_contact
 *****************************************************************************/
extern srv_phb_contact srv_phb_read_contact(mmi_phb_contact_id id, srv_phb_field_filter filter, srv_phb_contact contact);


/****************************************************/
/*                                                  */
/*              Phb contact filter                  */
/*                                                  */
/****************************************************/
#define SRV_PHB_QUERY_MAX_TIME                  (50) // query step

/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_contact_filter
 * DESCRIPTION
 *  create empty contact filter
 * PARAMETERS
 *  void
 * RETURNS
 *  srv_phb_contact_filter
 *****************************************************************************/
extern srv_phb_contact_filter srv_phb_create_contact_filter(void);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_contact_filter
 * DESCRIPTION
 *  create contact filter with storage mask
 * PARAMETERS
 *  storage_mask : [IN] refer SRV_PHB_STORAGE_MASK_SIM, SRV_PHB_STORAGE_MASK_PHONE, SRV_PHB_STORAGE_MASK_SIM2, SRV_PHB_STORAGE_MASK_ALL
 * RETURNS
 *  srv_phb_contact_filter
 *****************************************************************************/
extern srv_phb_contact_filter srv_phb_create_contact_filter_by_storage(U8 storage_mask);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_contact_filter_by_filed
 * DESCRIPTION
 *  create a contact filter with field filter
 * PARAMETERS
 *  field_type:             [IN]        fields mask, such as MMI_PHB_CONTACT_FIELD_NAME
 * RETURNS
 *  srv_phb_contact_filter 
 *****************************************************************************/
extern srv_phb_contact_filter srv_phb_create_contact_filter_by_filed(U32 field_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_create_contact_filter
 * DESCRIPTION
 *  free a contact filter
 * PARAMETERS
 *  filter:                 [IN]        contact filter
 * RETURNS
 *  void  
 *****************************************************************************/
extern void srv_phb_free_contact_filter(srv_phb_contact_filter filter);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_free_query_entry
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern void srv_phb_free_query_entry(srv_phb_contact_filter filter, srv_phb_query_handle handle);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_storage
 * DESCRIPTION
 *  set storage filter to a contact filter
 * PARAMETERS
 *  filter:                 [IN]        contact filter
 *  storage_mask:           [IN]        storage mask, such as SRV_PHB_STORAGE_MASK_SIM
 * RETURNS
 *  void 
 *****************************************************************************/
extern void srv_phb_contact_filter_set_storage(srv_phb_contact_filter filter, U8 storage_mask);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_field
 * DESCRIPTION
 *  set field filter to a contact filter
 * PARAMETERS
 *  filter:                 [IN]        contact filter
 *  field_type:             [IN]        fields mask, such as MMI_PHB_CONTACT_FIELD_NAME
 * RETURNS
 *  void 
 *****************************************************************************/
extern void srv_phb_contact_filter_set_field(srv_phb_contact_filter filter, U32 field_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_query
 * DESCRIPTION
 *  set string compare filter to a contact filter
 * PARAMETERS
 *  filter:                 [IN]        contact filter
 *  pattern:                [IN]        string compare pattern
 *  query_field:            [IN]        compare fields
 *  type:                   [IN]        compare type
 * RETURNS
 *  void 
 *****************************************************************************/
extern void srv_phb_contact_filter_set_query(srv_phb_contact_filter filter, WCHAR* pattern, U32 query_field, srv_phb_query_type_enum type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_mem_entry
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern void srv_phb_contact_filter_set_mem_entry(srv_phb_contact_filter filter, srv_phb_query_mem_alloc_func_type alloc_func, 
                        srv_phb_query_mem_free_func_type free_func, void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_query_entry
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern void srv_phb_contact_filter_set_query_entry(srv_phb_contact_filter filter, srv_phb_query_async_func_type callback_func,
                        U16 start_index, U16 query_time, void *user_data);


#ifdef __MMI_PHB_CALLER_GROUP__
/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_group
 * DESCRIPTION
 *  set group filter to a contact filter
 * PARAMETERS
 *  filter:                 [IN]        contact filter
 *  group_ids:              [IN]        group id
 *  is_equal:               [IN]        MMI_TRUE mean want to get all contact in the group,
                                        MMI_FALSE mean want to get all contact not in the group,
 * RETURNS
 *  void 
 *****************************************************************************/
extern void srv_phb_contact_filter_set_group(srv_phb_contact_filter filter, U8 group_id, MMI_BOOL is_equal);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_contact_filter_set_group_ex
 * DESCRIPTION
 *  set group filter to a contact filter
 * PARAMETERS
 *  filter:                 [IN]        contact filter
 *  group_ids:              [IN]        group info
 *  is_equal:               [IN]        MMI_TRUE mean want to get all contact in these groups,
                                        MMI_FALSE mean want to get all contact not in these groups,
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_contact_filter_set_group_ex(srv_phb_contact_filter filter, srv_phb_group_struct* group_ids, MMI_BOOL is_equal);
#endif /* __MMI_PHB_CALLER_GROUP__ */


/****************************************************/
/*                                                  */
/*               query                              */
/*                                                  */
/****************************************************/


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query
 * DESCRIPTION
 *  query contact info from phb, it can be use to get contact list
 * PARAMETERS
 *  req:                 [IN]        query req
 *  handle:              [IN]        set NULL will create new handle, otherwise
                                     will reset exist handle and use it to query
 * RETURNS
 *  srv_phb_query_handle
 *****************************************************************************/
extern srv_phb_query_handle srv_phb_query(srv_phb_query_req_struct* req, srv_phb_query_handle handle);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_contact
 * DESCRIPTION
 *  get a contact's full info from query result by index
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  srv_phb_contact
 *****************************************************************************/
extern srv_phb_contact srv_phb_query_get_contact(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_count
 * DESCRIPTION
 *  get total item count from query result
 * PARAMETERS
 *  handle:             [IN]        query handle
 * RETURNS
 *  U32
 *****************************************************************************/
extern U32 srv_phb_query_get_count(srv_phb_query_handle handle);


#ifdef __MMI_DIALER_SEARCH__
/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_clog_count
 * DESCRIPTION
 *  get total clog item count from query result
 * PARAMETERS
 *  handle:             [IN]        query handle
 * RETURNS
 *  U32
 *****************************************************************************/
extern U32 srv_phb_query_get_clog_count(srv_phb_query_handle handle);
#endif


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_contact_id
 * DESCRIPTION
 *  get a contact id from query result by index
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  mmi_phb_contact_id
 *****************************************************************************/
extern mmi_phb_contact_id srv_phb_query_get_contact_id(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_align_field_type
 * DESCRIPTION
 *  get align field type from query result by index
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 *  field_type:         [OUT]       align field type
 * RETURNS
 *  mmi_phb_contact_field_id_enum
 *****************************************************************************/
extern mmi_phb_contact_field_id_enum srv_phb_query_get_align_field_type(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_align_field
 * DESCRIPTION
 *  get align field from query result by index, the output will be srv_phb_number_struct* or srv_phb_email_struct* depedend the output field_type
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 *  field_type:         [OUT]       align field type
 * RETURNS
 *  void*
 *****************************************************************************/
extern void* srv_phb_query_get_align_field(srv_phb_query_handle handle, U32 index, mmi_phb_contact_field_id_enum* field_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_matched_info
 * DESCRIPTION
 *  get match info from query result by index
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  srv_phb_query_match_info_struct*
 *****************************************************************************/
extern srv_phb_query_match_info_struct* srv_phb_query_get_matched_info(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_alpha_count
 * DESCRIPTION
 *  get alpha count, must call srv_phb_query before
 * PARAMETERS
 *  handle                  : [IN] query handle
 *  alpha_index             : [IN] alpha index 'a' match 1 & 0 for other 
 * RETURNS
 *  alpha count
 *****************************************************************************/
extern srv_phb_alpha_info_struct* srv_phb_query_get_alpha_count(srv_phb_query_handle handle, U16 alpha_index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_name
 * DESCRIPTION
 *  get name filed from query result by index
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  WCHAR*
 *****************************************************************************/
extern WCHAR* srv_phb_query_get_name(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_imgae
 * DESCRIPTION
 *  get image filed from query result by index
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  srv_phb_res_struct*
 *****************************************************************************/
extern srv_phb_res_struct* srv_phb_query_get_imgae(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_number
 * DESCRIPTION
 *  get number filed from query result by index, if align field not number it will return NULL
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  srv_phb_number_struct*
 *****************************************************************************/
extern srv_phb_number_struct* srv_phb_query_get_number(srv_phb_query_handle handle, U32 index, WCHAR* buf);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_query_get_email
 * DESCRIPTION
 *  get email filed from query result by index, if align field not email it will return NULL
 * PARAMETERS
 *  handle:             [IN]        query handle
 *  index:              [IN]        item index
 * RETURNS
 *  srv_phb_email_struct*
 *****************************************************************************/
extern srv_phb_email_struct* srv_phb_query_get_email(srv_phb_query_handle handle, U32 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_free_query_handle
 * DESCRIPTION
 *  free a query handle
 * PARAMETERS
 *  handle:             [IN]        query handle
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_free_query_handle(srv_phb_query_handle handle);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_number_id_check_modify
 * DESCRIPTION
 *  This function is used to check a number id's number is modified
 * PARAMETERS
 *  number:             [IN]        old number data
 *  number_id:          [IN]        contact number's id
 *  id:                 [IN]        modified contact's store_index
 *  contact:            [IN]        modified contact's info
 * RETURN VALUES
 *  MMI_TRUE:           modified
 *  MMI_FALSE:          Not modified
 *****************************************************************************/
extern MMI_BOOL srv_phb_number_id_check_modify(WCHAR *number, SRV_PHB_ID number_id, mmi_phb_contact_id id, srv_phb_contact contact);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_field_filter
 * DESCRIPTION
 *  Convert old phb srv field mask to new field mask. This's API is just for adapted old phb srv.
 * PARAMETERS
 *  field_filter           : [IN]   old field mask such as SRV_PHB_ENTRY_FIELD_NAME
 * RETURNS
 *  U32
 *****************************************************************************/
extern U32 srv_phb_convert_field_filter(U32 field_filter);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_num_count
 * DESCRIPTION
 *  get a contact's exist number count
 * PARAMETERS
 *  id           : [IN]   contact id
 * RETURNS
 *  U32
 *****************************************************************************/
extern U8 srv_phb_get_num_count(mmi_phb_contact_id id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_email_count
 * DESCRIPTION
 *  get a contact's exist email count
 * PARAMETERS
 *  id           : [IN]   contact id
 * RETURNS
 *  U32
 *****************************************************************************/
extern U8 srv_phb_get_email_count(mmi_phb_contact_id id);


#ifdef __MMI_VCARD__
/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_vcard_support_property
 * DESCRIPTION
 * 
 * PARAMETERS
 *  storage           : [IN]   phb_storage_enum
 * RETURNS
 *  U32
 *****************************************************************************/
extern U32 srv_phb_get_vcard_support_property(phb_storage_enum storage);
#endif /* __MMI_VCARD__ */


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_support_field
 * DESCRIPTION
 *  get all support filed's mask
 * PARAMETERS
 *  storage           : [IN]   phb_storage_enum
 * RETURNS
 *  U32
 *****************************************************************************/
extern U32 srv_phb_get_support_field(phb_storage_enum storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_support_field_count
 * DESCRIPTION
 *  get each contact field support count
 * PARAMETERS
 *  storage           : [IN]   storage refer phb_storage_enum
 *  field             : [IN]   contact field
 * RETURNS
 *  U32
 *****************************************************************************/
extern U32 srv_phb_get_support_field_count(U8 storage, mmi_phb_contact_field_id_enum field);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_alpha_field_length
 * DESCRIPTION
 *  get alpha filed's alpha length, such as name, number. For phone storage, the
 *  return value is char count. For sim storage, the return value is the sim 
 *  file's alpha length
 * PARAMETERS
 *  storage           : [IN]   storage refer phb_storage_enum
 *  field             : [IN]   contact field
 * RETURNS
 *  U32
 *****************************************************************************/
U32 srv_phb_get_alpha_field_length(phb_storage_enum storage, mmi_phb_contact_field_id_enum field);


#ifdef __MMI_PHB_USIM_SUPPORT__
/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_usim_field_total
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern U16 srv_phb_get_usim_field_total(phb_storage_enum storage, U8 occr, phb_type_enum type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_usim_field_used
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern U16 srv_phb_get_usim_field_used(phb_storage_enum storage, U8 occr, phb_type_enum type);
#endif


/*****************************************************************************
 * FUNCTION
 *  srv_phb_add_field_type
 * DESCRIPTION
 *  add a new field type
 * PARAMETERS
 *  type_info          :   [IN]    type info
 * RETURNS
 *  S32
 * RETURN VALUES
 *  >=0                 :           type id
 *  -1                  :           error
 *****************************************************************************/
extern S32 srv_phb_add_field_type(WCHAR* type_label, mmi_phb_contact_field_id_enum field);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_delete_field_type
 * DESCRIPTION
 *  delete a field type
 * PARAMETERS
 *  type_id            :   [IN]    type id
 * RETURNS
 *  void
 *****************************************************************************/
extern MMI_BOOL srv_phb_delete_field_type(U8 type_id, mmi_phb_contact_field_id_enum field);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_phone_get_type_list
 * DESCRIPTION
 *  get field type id list ordered by type name
 * PARAMETERS
 *  type_array         :   [OUT]   type id array
 * RETURNS
 *  U8
 * RETURN VALUES
 *  count               :           type count
 ****************************************************************************/
extern U8 srv_phb_get_field_type_list(U8* type_array, mmi_phb_contact_field_id_enum field, phb_storage_enum storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_field_type_label
 * DESCRIPTION
 *  get a field type label by id
 * PARAMETERS
 *  type_id            :   [IN]    type id
 *  field              :   [IN]    field
 * RETURNS
 *  WCHAR*
 *****************************************************************************/
extern WCHAR* srv_phb_get_field_type_label(U8 type_id, mmi_phb_contact_field_id_enum field, phb_storage_enum storage);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_update_field_type
 * DESCRIPTION
 *  update a field type
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
extern S32 srv_phb_update_field_type(U8 type_id, WCHAR* type_label, mmi_phb_contact_field_id_enum field);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_max_field_type
 * DESCRIPTION
 *  get max field type
 * PARAMETERS
 *  type_id            :   [IN]    type id
 * RETURNS
 *  void
 *****************************************************************************/
extern U8 srv_phb_get_max_field_type(phb_storage_enum storage, mmi_phb_contact_field_id_enum field);


/****************************************************/
/*                                                  */
/*               Group op                           */
/*                                                  */
/****************************************************/

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_group_list
 * DESCRIPTION
 *  get group id list ordered by group name
 * PARAMETERS
 *  group_array         :   [IN/OUT]   group id array
 *  group_name         :   [IN/OUT]   group name
 *  storage               :   [IN] phb_storage_enum such as PHB_STOAGE_NVRAM
 * RETURNS
 *  U32
 * RETURN VALUES
 *  count               :           group count
 ****************************************************************************/
U32 srv_phb_get_group_list(U8* group_array, U16* group_name, phb_storage_enum storage);


#ifdef __MMI_PHB_CALLER_GROUP__
typedef struct
{
    mmi_phb_contact_id* id_array;
    U16 entry_count;
    U8 group_id;
    MMI_BOOL is_reset;
    srv_phb_group_callback_type cb;
    void *user_data;
}srv_phb_group_add_members_req;

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_storage_by_group_id
 * DESCRIPTION
 *  get phone book storage by group id
 * PARAMETERS
 *  group_id     :  [IN]  group id
 * RETURNS
 *  phb_storage_enum
 *****************************************************************************/
phb_storage_enum srv_phb_get_storage_by_group_id(U8 group_id);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_add_group_members
 * DESCRIPTION
 *  add contacts to a group
 * PARAMETERS
 *  req                   :   [IN]   srv_phb_group_add_members_req
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_add_group_members(srv_phb_group_add_members_req *req);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_remove_group_member
 * DESCRIPTION
 *  remove a member from a group
 * PARAMETERS
 *  id                  :   [IN]    contact's store_index
 *  group_id            :   [IN]    group id
 *  cb                    :   [IN]    srv_phb_group_callback_type
 * user_data           :   [IN]    user_data
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_remove_group_member(mmi_phb_contact_id id, U8 group_id, srv_phb_group_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_remove_all_group_members
 * DESCRIPTION
 *  remove all members from a group
 * PARAMETERS
 *  group_id            :   [IN]    group id
 *  cb                    :   [IN]    srv_phb_group_callback_type
 *  user_data          :   [IN]    user data
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_remove_all_group_members(U8 group_id, srv_phb_group_callback_type cb, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_add_group
 * DESCRIPTION
 *  add a new group
 * PARAMETERS
 *  group_info          :   [IN]    group info
 * RETURNS
 *  S32
 * RETURN VALUES
 *  >=0                 :           group id
 *  SRV_PHB_ERROR                    :          group info is NULL
 *  SRV_PHB_GROUP_NAME_EMPTY:          group name is NULL
 *  SRV_PHB_GROUP_FULL            :          reach max group numbers
 *  SRV_PHB_GROUP_NAME_DUP    :          there are two same group names in a storage
 *****************************************************************************/
void srv_phb_add_group(srv_phb_group_info_struct* group_info);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_delete_group
 * DESCRIPTION
 *  delete a group
 * PARAMETERS
 *  group_id            :   [IN]    group id
 *  cb                    :   [IN]    srv_phb_group_callback_type
 *  user_data          :   [IN]    user data
 * RETURNS
 *  result
 *****************************************************************************/
void srv_phb_delete_group(U8 group_id, srv_phb_group_callback_type cb, void* user_data);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_group_info
 * DESCRIPTION
 *  get a group's info
 * PARAMETERS
 *  group_id            :   [IN]    group id
 *  group_info          :   [OUT]   group info
 * RETURNS
 *  S32
 * RETURN VALUES
 *  SRV_PHB_NO_ERROR   :           get success
 *  other               :           error result
 *****************************************************************************/
S32 srv_phb_get_group_info(U8 group_id, srv_phb_group_info_struct* group_info);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_update_group_info
 * DESCRIPTION
 *  update a group
 * PARAMETERS
 *  group_id            :   [IN]    group id
 *  group_info          :   [OUT]   group info
 * RETURNS
 *  S32
 * RETURN VALUES
 *  >= 0                :           piggyback group id
 *  other               :           error result
 *****************************************************************************/
void srv_phb_update_group_info(U8 group_id, srv_phb_group_info_struct* group_info);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_pri_group_info
 * DESCRIPTION
 *  
 * PARAMETERS
 *  
 * RETURNS
 *  
 *****************************************************************************/
void srv_phb_group_cancel_operation(srv_phb_group_op_type_enum op_type);

#endif /* __MMI_PHB_CALLER_GROUP__ */

/***************************************************************************** 
 * Typedef
 *****************************************************************************/
/* phb name display */
typedef enum
{
    SRV_CONTACT_NAME_DISPLAY_TYPE_NONE,
    SRV_CONTACT_NAME_DISPLAY_TYPE_1,                    /* last name first name */
    SRV_CONTACT_NAME_DISPLAY_TYPE_2,                    /* last name,first name */
    SRV_CONTACT_NAME_DISPLAY_TYPE_3,                    /* first name last name */
    SRV_CONTACT_NAME_DISPLAY_TYPE_4,                    /* first name,last name */
    SRV_CONTACT_NAME_DISPLAY_TYPE_TOTAL
} SRV_CONTACT_NAME_DISPLAY_TYPE_ENUM;


typedef enum
{
    SRV_CONTACT_SPEAK_NAME_OFF,                         /* don't speak name */
    SRV_CONTACT_SPEAK_NAME_ON                           /* speak contact name when hilite */
} SRV_CONTACT_SPEAK_NAME_ENUM;


typedef enum
{
    SRV_CONTACT_SAVE_CONTACT_NOTIFY_OFF,                /* don't popup save to contact when meet a new number */
    SRV_CONTACT_SAVE_CONTACT_NOTIFY_ON                  /* popup to notify user a new number comes */
} SRV_CONTACT_SAVE_CONTACT_NOTIFY_ENUM;

/***************************************************************************** 
 * Function 
 *****************************************************************************/

/*****************************************************************************
* FUNCTION
*  srv_phb_get_storage_mask
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
U16 srv_phb_get_storage_mask(void);


/*****************************************************************************
* FUNCTION
*  srv_phb_set_storage_mask
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
void srv_phb_set_storage_mask(U16 storage);


/*****************************************************************************
* FUNCTION
*  srv_phb_check_storage_is_hide
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern MMI_BOOL srv_phb_check_storage_is_hide(U8 storage);


/*****************************************************************************
* FUNCTION
*  srv_phb_set_storage_mask
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern SRV_CONTACT_NAME_DISPLAY_TYPE_ENUM srv_phb_get_name_display(void);



/*****************************************************************************
* FUNCTION
*  srv_phb_set_name_display
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern MMI_BOOL srv_phb_set_name_display(SRV_CONTACT_NAME_DISPLAY_TYPE_ENUM type, srv_phb_async_func_type cb);


/*****************************************************************************
* FUNCTION
*  srv_phb_get_save_notify
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern SRV_CONTACT_SAVE_CONTACT_NOTIFY_ENUM srv_phb_get_save_notify(void);


/*****************************************************************************
* FUNCTION
*  srv_phb_set_save_notify
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern void srv_phb_set_save_notify(SRV_CONTACT_SAVE_CONTACT_NOTIFY_ENUM type);


/*****************************************************************************
* FUNCTION
*  srv_phb_get_name_speak
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern SRV_CONTACT_SPEAK_NAME_ENUM srv_phb_get_name_speak(void);


/*****************************************************************************
* FUNCTION
*  srv_phb_set_name_speak
* DESCRIPTION
*  
* PARAMETERS
*  
* RETURNS
*  
*****************************************************************************/
extern void srv_phb_set_name_speak(SRV_CONTACT_SPEAK_NAME_ENUM type);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_get_preferred_sim
 * DESCRIPTION
 *  get last used sim id from a contact
 * PARAMETERS
 *  number    : [IN]    number to search
 *  id           :  [IN]    contact id, if you do not use this param, please set MMI_PHB_INVALID_CONTACT_ID
 *  op_type   : [IN]    please refer to srv_phb_number_op_type_enum
 *  sim_id     : [OUT] mmi_sim_enum
 * RETURNS
 *
 *  SRV_PHB_NO_ERROR             :                   success
 *  SRV_PHB_NOT_FOUND           :                   no number matched
 *  SRV_PHB_NUM_NOT_READY    :                   lookup table not ready
*****************************************************************************/
S32 srv_phb_get_preferred_sim (
            U16 *number,
            mmi_phb_contact_id id,
            srv_phb_number_op_type_enum op_type,
            mmi_sim_enum *sim_id);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_set_preferred_sim
 * DESCRIPTION
 *  set last used sim for a contact
 * PARAMETERS
 *  number    : [IN]  number to set
 *  id           :  [IN]  contact id, if you do not use this param, please set MMI_PHB_INVALID_CONTACT_ID
 *  sim_id     : [IN]  last used sim id
 *  op_type   : [IN]  operater type of this number, refer to srv_phb_number_op_type_enum
 * RETURNS
 *  SRV_PHB_NO_ERROR          :                      success
 *  SRV_PHB_NOT_FOUND        :                      no number matched
 *  SRV_PHB_NUM_NOT_READY    :                   lookup table not ready
*****************************************************************************/
S32 srv_phb_set_preferred_sim (
           U16 *number,
           mmi_phb_contact_id id,
           mmi_sim_enum sim_id,
           srv_phb_number_op_type_enum op_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_set_preferred_sim_ex
 * DESCRIPTION
 *  set last used sim for a contact
 * PARAMETERS
 * req
 * RETURNS
 *  SRV_PHB_NO_ERROR          :                      success
 *  SRV_PHB_NOT_FOUND        :                      no number matched
 *  SRV_PHB_NUM_NOT_READY    :                   lookup table not ready
*****************************************************************************/
S32 srv_phb_set_preferred_sim_ex (srv_phb_set_preferred_sim_req* req);

typedef void (*srv_phb_xdnmgr_callback_type)(U16 result, void* user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xdnmgr_toggle_dial_mode
 * DESCRIPTION
 *  This function is used to toggle FDN/BDN dial mode.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_FDN/PHB_BDN
 *  toggle_cb:          [IN]        Toggle FDN/BDN dial mode callback
 *  user_data:          [IN]        Caller user data
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_xdnmgr_toggle_dial_mode(
        U8 sim_type, 
        phb_type_enum phb_type, 
        srv_phb_xdnmgr_callback_type cb,
        void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xmgnt_get_list
 * DESCRIPTION
 *  This function is used to get extra# list.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  list_cb:            [IN]        Get extra# list callback
 * RETURNS
 *  extra# handle
 *****************************************************************************/
extern SRV_PHB_XMGNT_HANDLE srv_phb_xdnmgr_get_list(
        U8 sim_type,
        phb_type_enum phb_type,
        srv_phb_xdnmgr_callback_type list_cb,
        void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_fdnmgr_set_entry
 * DESCRIPTION
 *  This function is used to add/edit extra# entry.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  index:              [IN]        PHB entry index
 *  record_index:       [IN]        PHB record index
 *  name:               [IN]        extra# name
 *  number:             [IN]        extra# number
 *  set_cb:             [IN]        Add/Edit extra# entry callback
 *  user_data:         [IN]        this pointer
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_fdnmgr_set_entry(
                    U8 sim_interface,
                    U8 phb_type,
                    U16 index,
                    U16 record_index,
                    U16 *name,
                    U16 *number,
                    srv_phb_xdnmgr_callback_type set_cb,
                    SRV_PHB_XMGNT_HANDLE handle,
                    MMI_BOOL is_new,
                    void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_xdnmgr_delete_entry
 * DESCRIPTION
 *  This function is used to delete extra# entry.
 * PARAMETERS
 *  sim_interface:      [IN]        SIM1/SIM2
 *  phb_type:           [IN]        PHB_ECC/PHB_FDN/PHB_BDN/PHB_MSISDN/PHB_SDN
 *  index:              [IN]        PHB entry index
 *  record_index:       [IN]        PHB record index
 *  del_cb:             [IN]        Delete extra# entry callback
 *  user_data:           [IN]      user_data
 * RETURN VALUES
 *  MMI_TRUE:           This request is accepted.
 *  MMI_FALSE:          This request is rejected.
 *****************************************************************************/
extern MMI_BOOL srv_phb_xdnmgr_delete_entry(
                    U8 sim_interface,
                    U8 phb_type,
                    U16 index,
                    U16 record_index,
                    srv_phb_xdnmgr_callback_type del_cb,
                    void *user_data);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_read_my_number
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_read_my_number(mmi_phb_my_number_struct *my_number);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_write_my_number
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_write_my_number(mmi_phb_my_number_struct *my_number);

#if defined(__MMI_OP11_HOMESCREEN_0301__) || defined(__MMI_OP11_HOMESCREEN_0302__) || defined(__MMI_OP11_HOMESCREEN__) || defined (__MMI_VUI_WIDGET_KEY_VIP_CONTACT__)

/*****************************************************************************
 * FUNCTION
 *  srv_phb_update_vip_contact
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 *  store_index     [IN]        
 *  name            [IN]        
 *  number          [IN]        
 *  num_type        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_update_vip_contact(U16 index, U16 store_index, U16 *name, U16 *number, U32 num_type);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_clear_vip_contact
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_clear_vip_contact(U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_clear_all_vip_contact
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_clear_all_vip_contact(void);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_is_sync
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  MMI_TRUE if set
 *****************************************************************************/
MMI_BOOL srv_phb_vip_contact_is_sync(U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_get_store_index
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  VIP contact store index
 *****************************************************************************/
U16 srv_phb_vip_contact_get_store_index(U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_get_name
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  VIP contact name
 *****************************************************************************/
U16 *srv_phb_vip_contact_get_name(U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_get_number
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  VIP contact number
 *****************************************************************************/
U16 *srv_phb_vip_contact_get_number(U16 index);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_get_entry
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  VIP contact entry
 *****************************************************************************/
mmi_phb_vip_contact_struct *srv_phb_vip_contact_get_entry(U16 index);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_get_count
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  
 *****************************************************************************/
U32 srv_phb_vip_contact_get_count(void);

/*****************************************************************************
 * FUNCTION
 *  srv_phb_vip_contact_delete_entry
 * DESCRIPTION
 *  
 * PARAMETERS
 *  index           [IN]        
 * RETURNS
 *  
 *****************************************************************************/
void srv_phb_vip_contact_delete_entry(U32 index);

#endif /* defined(__MMI_OP11_HOMESCREEN_0301__) || defined(__MMI_OP11_HOMESCREEN_0302__) || defined(__MMI_OP11_HOMESCREEN__) */


/****************************************************/
/*                                                                                        */
/*               backup restore                                                   */
/*                                                                                        */
/****************************************************/
#ifdef __MMI_MULTI_VCARD__

#define SRV_PHB_BACKUP_RESTORE_FILE_FOLDER_NAME "BackUpRestore"
#define SRV_PHB_BACKUP_RESTORE_FILE_CONFIG_NAME "~vcardConfigure.txt"
#define SRV_PHB_BACKUP_RESTORE_FILE_NAME "vcard.vcf"


typedef struct
{
    WCHAR year[4 + 1];
    WCHAR month[2 + 1];
    WCHAR day[2 + 1];
}srv_phb_backup_restore_time_struct;


typedef struct
{
    WCHAR is_empty[1 + 1];
    U32   contact_num;
    WCHAR file_path[40 + 1];
    srv_phb_backup_restore_time_struct date; 
}srv_phb_backup_restore_file_config_struct;
#endif

#ifdef __MMI_VCARD__
#include "..\..\vcard\include\vcard_lib.h"

#define SRV_PHB_VCARD_PORT             0x23f4
#define SRV_PHB_VCARD_FILE_PATH        "Received"
#define SRV_PHB_VCARD_FILE_EXT         ".vcf"

/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_vcard_object
 * DESCRIPTION
 *  
 * PARAMETERS
 *  contact       [IN]        
 *  vcard_object    [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void srv_phb_contact_to_vcard_object(srv_phb_contact contact, vcard_object_struct *vcard_object);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_vcard_object_to_contact
 * DESCRIPTION
 *  
 * PARAMETERS
 *  contact       [IN]        
 *  vcard_object    [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
srv_phb_contact srv_phb_vcard_object_to_contact(srv_phb_contact contact, vcard_object_struct *vcard_object);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_to_vcard_object
 * DESCRIPTION
 *  used for PLUTO MMI only and will phase out
 *  convert contact to vcard object
 * PARAMETERS
 *  contact_p       [IN]        
 *  vcard_object    [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_convert_to_vcard_object(srv_phb_contact_info_struct *contact_p, vcard_object_struct *vcard_object);


/*****************************************************************************
 * FUNCTION
 *  srv_phb_convert_from_vcard_object
 * DESCRIPTION
 *  used for PLUTO MMI only and will phase out
 *  convert vcard object to contact
 * PARAMETERS
 *  contact_p       [IN]        
 *  vcard_object    [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
extern void srv_phb_convert_from_vcard_object(srv_phb_contact_info_struct *contact_p, vcard_object_struct *vcard_object);

#endif /* __MMI_VCARD__ */

#if defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC)
#include "App_datetime.h"

#define MMI_PHB_JAVA_SEARCH_LENGTH (MMI_PHB_EMAIL_LENGTH+1)

typedef struct
{
    U16  sort_index; /* sort index or the no. of group member */
    U16  store_index;
    U16 name[MMI_PHB_NAME_LENGTH + 1];

#ifndef __COSMOS_MMI_PACKAGE__
    U16 number[MMI_PHB_NUMBER_LENGTH + 1 + 1];
    mmi_phb_wcs_num_struct opt_num[MMI_PHB_OPT_NUM_COUNT];
    
    /* to be remove begin */
    U16 homeNumber[MMI_PHB_NUMBER_LENGTH + 1 + 1];
    U16 officeNumber[MMI_PHB_NUMBER_LENGTH + 1 + 1];
    U16 faxNumber[MMI_PHB_NUMBER_LENGTH + 1 + 1];
    /* to be remove end */
    
    U16 emailAddress[MMI_PHB_EMAIL_LENGTH + 1];
#ifdef JSR_75_PIM_EXTRA_EMAIL2
    U16 emailAddress2[MMI_PHB_EMAIL_LENGTH + 1];
#endif
#else
    mmi_phb_wcs_num_struct opt_num[MMI_PHB_NUMBER_FIELD_COUNT];
    mmi_phb_wcs_email_struct emailAddresses[MMI_PHB_EMAIL_FIELD_COUNT];
#endif

    U16 companyName[MMI_PHB_COMPANY_LENGTH + 1];
#ifdef JSR_75_PIM_EXTRA_BIRTHDAY
    applib_time_struct bDay;
#endif

#ifdef JSR_75_PIM_EXTRA_INFO
    U16 title[MMI_PHB_TITLE_LENGTH + 1];
    U16 url[MMI_PHB_URL_LENGTH + 1];
    U16 adrPOBox[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 adrExtension[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 adrStreet[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 adrCity[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 adrState[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 adrPostalCode[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 adrCountry[MMI_PHB_ADDRESS_LENGTH + 1];
    U16 note[MMI_PHB_NOTE_LENGTH + 1];
#endif /* JSR_75_PIM_EXTRA_INFO */
#ifdef JSR_75_PIM_EXTRA_IMAGE
    U16 phb_image_path[SRV_FMGR_PATH_MAX_LEN + 1];
#endif /* JSR_75_PIM_EXTRA_IMAGE */

    /* Put these two U8 at the end of structure to prevent 4-bytes alignment problem */
    U32 group_id;  /* 1-based. 0 is no group. 1~MMI_PHB_CALLER_GROUPS in NVRAM; MMI_PHB_CALLER_GROUPS~ in USIM. */
#ifdef JSR_75_PIM_EXTRA_PREFERRED_NUMBER
    U8 preferred_no;
#endif

} mmi_phb_handler_entry_struct;


typedef struct 
{
    U16 group_name[MMI_PHB_GROUP_NAME_LENGTH+1];
    U8 group_id;
    U8 padding; /* reserved 2 bytes alignment*/
} mmi_phb_handler_group_struct;

typedef struct 
{
    U16 list[MMI_PHB_PHONE_ENTRIES];
	U16 count;
} mmi_phb_handler_delete_member_list_struct;


typedef struct
{
    LOCAL_PARA_HDR
//    U8 sort_type;
    U8 storage;
    U16 index; /* physical store_index (0~MAX_PB_ENTRIES-1) for update and delete command */
    mmi_phb_handler_entry_struct *entry_ptr; /* NULL for delete command */
} mmi_phb_handler_set_entry_req_struct;

typedef struct
{
    LOCAL_PARA_HDR 
    U8 result;
//    U16 index;  /* sort index, not physical store index */
    U16 store_index; /* physical store index */
} mmi_phb_handler_set_entry_rsp_struct;

typedef struct
{
    LOCAL_PARA_HDR 
    U8 sort_type;
    U8 storage;
    U8 group;
    U16 index; /* sort index */
    U16 count; /* if count is 0, return the total count */
    mmi_phb_handler_entry_struct *entry_ptr;
} mmi_phb_handler_get_entry_req_struct;

typedef struct
{
    LOCAL_PARA_HDR
    U8 result;
    U16 count;
} mmi_phb_handler_get_entry_rsp_struct;

typedef struct
{
    LOCAL_PARA_HDR
    U16 pattern[MMI_PHB_JAVA_SEARCH_LENGTH];
    U8 sort_type;
    U8 storage;
    U8 search_type;
    U8 group;
    U16 start_index;  /* 0-based, 0 means the first sorted item, 1 means 2nd sorted item */
    mmi_phb_handler_entry_struct *entry_ptr;
} mmi_phb_handler_search_entry_req_struct;

typedef struct
{
    LOCAL_PARA_HDR
    U8 result;
    U16 index; /* sort index if succeess */
} mmi_phb_handler_search_entry_rsp_struct;


typedef struct
{
    LOCAL_PARA_HDR
    U8 max_group;
    U8 storage;
    mmi_phb_handler_group_struct* group_ptr;
} mmi_phb_handler_get_group_info_req_struct;


typedef struct
{
    LOCAL_PARA_HDR
    U8 result;
    U8 count;
} mmi_phb_handler_get_group_info_rsp_struct;


typedef struct
{
    LOCAL_PARA_HDR
    U8 group_id; /* 0-based */
    mmi_phb_handler_group_struct* group_ptr;
    mmi_phb_handler_delete_member_list_struct* delete_list_ptr;
} mmi_phb_handler_set_group_info_req_struct;


typedef struct
{
    LOCAL_PARA_HDR
    U8 result;
} mmi_phb_handler_set_group_info_rsp_struct;


typedef enum
{
    MMI_PHB_NO_SORT,
    MMI_PHB_BY_NAME,
    MMI_PHB_BY_EMAIL,
    MMI_PHB_BY_NUMBER
} mmi_phb_sort_type_enum;

typedef enum
{
    MMI_PHB_JAVA_ERROR,
    MMI_PHB_JAVA_SUCCESS,
    MMI_PHB_JAVA_NOT_READY,
    MMI_PHB_JAVA_NOT_SUPPORT,
    MMI_PHB_JAVA_NOT_FOUND,
    MMI_PHB_JAVA_STORAGE_FULL,
    MMI_PHB_JAVA_NUMBER_TOO_LONG,
    MMI_PHB_JAVA_ADN_FORBID,
    MMI_PHB_JAVA_OUT_OF_INDEX,
    MMI_PHB_JAVA_EMAIL_FULL,
    MMI_PHB_JAVA_ANR_FULL,
    MMI_PHB_JAVA_BIRTHDAY_ERROR,
    MMI_PHB_JAVA_NO_SIM_CARD,
    MMI_PHB_JAVA_IMAGE_ERROR,
    MMI_PHB_JAVA_ERROR_ENUM_TOTAL
} mmi_phb_java_error_enum;
#endif /* defined(SUPPORT_JSR_75_PIM) || defined(SUPPORT_CMCC) */
#if defined(__MMI_PBAP_SUPPORT__) && defined(__MMI_VCARD__)

/* vcard field supported */
#define VCARD_FILTER_VER       0        /* Version (Bit 0) */
#define VCARD_FILTER_FN        1        /* Formatted Name (Bit 1) */
#define VCARD_FILTER_N         2        /* Structured Presentation of Name (Bit 2) */
#define VCARD_FILTER_PHOTO     3        /* Associated Image or Photo (Bit 3) */
#define VCARD_FILTER_BDAY      4        /* Birthday (Bit 4) */
#define VCARD_FILTER_ADR       5        /* Delivery Address (Bit 5) */
#define VCARD_FILTER_LABEL     6        /* Delivery (Bit 6) */
#define VCARD_FILTER_TEL       7        /* Telephone (Bit 7) */
#define VCARD_FILTER_EMAIL     8        /* Electronic Mail Address (Bit 8) */
#define VCARD_FILTER_MAILER    9        /* Electronic Mail (Bit 9) */
#define VCARD_FILTER_TZ        10       /* Time Zone (Bit 10) */
#define VCARD_FILTER_GEO       11       /* Geographic Position (Bit 11) */
#define VCARD_FILTER_TITLE     12       /* Job (Bit 12) */
#define VCARD_FILTER_ROLE      13       /* Role within the Organization (Bit 13) */
#define VCARD_FILTER_LOGO      14       /* Organization Logo (Bit 14) */
#define VCARD_FILTER_AGENT     15       /* vCard of Person Representing (Bit 15) */
#define VCARD_FILTER_ORG       16       /* Name of Organization (Bit 16) */
#define VCARD_FILTER_NOTE      17       /* Comments (Bit 17) */
#define VCARD_FILTER_REV       18       /* Revision (Bit 18) */
#define VCARD_FILTER_SOUND     19       /* Pronunciation of Name (Bit 19) */
#define VCARD_FILTER_URL       20       /* Uniform Resource Locator (Bit 20) */
#define VCARD_FILTER_UID       21       /* Unique ID (Bit 21) */
#define VCARD_FILTER_KEY       22       /* Public Encryption Key (Bit 22) */
#define VCARD_FILTER_NICK      23       /* Nickname (Bit 23) */
#define VCARD_FILTER_CAT       24       /* Categories (Bit 24) */
#define VCARD_FILTER_PRODID    25       /* Product Id (Bit 25) */
#define VCARD_FILTER_CLASS     26       /* Class Information (Bit 26) */
#define VCARD_FILTER_SORT_STR  27       /* Sort string (Bit 27) */
#define VCARD_FILTER_TIMESTAMP 28       /* Time stamp (Bit 28) */
/* Bits 29-38 Reserved for future use */
#define VCARD_FILTER_PROP      39       /* Use of a proprietary filter (Bit 39) */
/* Bits 40-63 Reserved for proprietary filter usage */

#define VCARD_FIELD_MAX        64       /* max count of vcard field */


/* vcard build error */
typedef enum
{
    PHB_VCARD_NO_ERROR,           /* no error */
    PHB_VCARD_IN_USE,             /* vcard to build is using */
    PHB_VCARD_NOT_FOUND,          /* vcard index not found */
    PHB_VCARD_FS_ERROR,           /* FS ERROR */
    PHB_VCARD_ERROR_TOTAL
} mmi_phb_vcard_error_enum;

typedef struct
{
    mmi_phb_vcard_error_enum error_code;
    S32 fs_error;
} mmi_phb_vcard_error_struct;

/* vcard storage */
typedef enum
{
    PHB_STORAGE_NO,
    PHB_STORAGE_NVRAM_PB,
    PHB_STORAGE_NVRAM_OCH,
    PHB_STORAGE_NVRAM_ICH,
    PHB_STORAGE_NVRAM_MCH,
    PHB_STORAGE_NVRAM_CCH,
    PHB_STORAGE_SIM1_PB,
    PHB_STORAGE_SIM1_OCH,
    PHB_STORAGE_SIM1_ICH,
    PHB_STORAGE_SIM1_MCH,
    PHB_STORAGE_SIM1_CCH,
    PHB_STORAGE_TOTAL
}mmi_phb_storage_enum;

/* index sort order */
typedef enum
{
    PHB_SORT_ORDER_NONE,
    PHB_SORT_ORDER_INDEX,           /* sort by vcard index */
    PHB_SORT_ORDER_NAME,            /* sort by name */
    PHB_SORT_ORDER_TOTAL
} mmi_phb_sort_order_enum;


/* vcard object */
typedef struct
{
    U16 index_hdlr;                         /* phonebook store index handler , 0 for owner number */
    U8 vcard_storage;                       /* mmi_phb_storage_enum */
    U8 vcard_filter[VCARD_FIELD_MAX / 8];   /* the bit be set 1 will be built if support */
    U8 vcard_format;                        /* vcard format */
} mmi_vcard_object_struct;

typedef struct
{
    /* Array of 8 bytes for this 64-bit filter value */
    kal_uint8 byte[VCARD_FIELD_MAX / 8];
} mmi_vcard_filter_struct;

typedef struct
{
    U16 index;
    U8 storage;
    U16 *index_array;
    U32 index_array_size;
    CHAR number[(MMI_PHB_NUMBER_LENGTH + 1 + 1) * ENCODING_LENGTH];
    CHAR name[(MMI_PHB_NAME_LENGTH + 1) * ENCODING_LENGTH];
    U16 file_path[(SRV_FMGR_PATH_MAX_LEN + 1) * ENCODING_LENGTH];
} mmi_phb_get_info_struct;

typedef void (*mmi_phb_build_vcard_funcptr_type)(mmi_phb_vcard_error_struct* error_info);
typedef void (*mmi_phb_get_index_array_funcptr_type)(mmi_phb_vcard_error_struct* error_info, U16* array, U16 array_count);
typedef void (*mmi_phb_get_info_by_index_funcptr_type)(mmi_phb_vcard_error_struct* error_info, CHAR* name, CHAR* number);
typedef void (*mmi_phb_get_storage_size_funcptr_type)(mmi_phb_vcard_error_struct* error_info, U16 size);

extern void mmi_phb_build_vcard(
                U16* path,
                mmi_vcard_object_struct* vcard_object,
                MMI_BOOL is_append,
                mmi_phb_build_vcard_funcptr_type build_done_cb);

extern void mmi_phb_get_info_by_index(
                U16 index_hdlr,
                U8 vcard_storage,
                mmi_phb_get_info_by_index_funcptr_type get_info_cb);

extern void mmi_phb_get_new_missed_calls(mmi_phb_get_storage_size_funcptr_type get_size_cb);

extern void mmi_phb_get_index_array(
                U8 vcard_storage,
                U8 sort_order,
                U16* index_array,
                U32 index_array_size,
                mmi_phb_get_index_array_funcptr_type get_index_array_cb);

extern void mmi_phb_get_storage_size(
                U8 vcard_storage,
                mmi_phb_get_storage_size_funcptr_type get_storage_size_cb);

#endif /* __MMI_PBAP_SUPPORT__ */


#ifdef __OP01_FWPBW__
extern MMI_BOOL srv_phb_get_direct_dial(U16 index, U16 *buf);
#endif
#ifdef __cplusplus
}
#endif

#endif /* PHBSRVGPROT_H */