IdleCommon.c 83.3 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
/*****************************************************************************
*  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) 2010
*
*  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:
 * ---------
 *  IdleCommon.c
 *
 * Project:
 * --------
 *  MAUI
 *
 * Description:
 * ------------
 *  This file implements the common part of the idle application.
 *
 * 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!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

/****************************************************************************
 * Include
 ****************************************************************************/
#include "MMI_features.h"
#include "IdleGprot.h"
#include "DialerGprot.h"
#include "ScrLockerGprot.h"
#include "NwInfoSrvGprot.h"
#include "NwNameSrvGprot.h"
#include "SimCtrlSrvGprot.h"
#include "CphsSrvGprot.h"
#include "NetworkSetupGprot.h"
#include "BrowserGprots.h"
#include "browser_api.h"
#include "MiscFunctions.h"
#include "PhbCuiGprot.h"
#include "CallLogGprot.h"
#include "ShortcutsProts.h"
#include "VolumeHandler.h"
#include "CallSetSrvGprot.h"
#include "PhoneSetupGprots.h"
#include "ImeiSrvGprot.h"
#include "netsetsrvgprot.h"
#include "AmGprot.h"
#include "NetworkSetupGProt.h"

#ifdef __MMI_BT_DIALER_SUPPORT__
#include "SettingGprots.h"
#include "UMGProt.h"
#include "AllAppGprot.h"
#ifdef __MMI_CALENDAR__
#include "CalendarGprot.h"
#endif
#include "BTMMIScrGprots.h"
#include "wgui_categories_idlescreen.h"
#endif

#if defined(__MMI_SEARCH_WEB__)
#include "SearchWebGProt.h"
#endif

#if 0
#if defined(__MMI_VRSD__)
/* under construction !*/
#endif
/* under construction !*/
#if defined(__MMI_VRSI__)
/* under construction !*/
#endif
#endif

#if defined (__MMI_CAMERA__) && !defined(__MMI_CAMCORDER__)
#include "MMI_features_camera.h"
#include "CameraApp.h"
#elif defined (__MMI_CAMERA__) && defined(__MMI_CAMCORDER__)
#include "CamcorderGprot.h"
#endif

#if defined(__MMI_ATV_SUPPORT__)
#include "MobileTVPlayerGProt.h"
#endif

#if (MMI_MAX_SIM_NUM >= 3)
#include "SimSpaceGprot.h"
#endif /* (MMI_MAX_SIM_NUM >= 3) */

#include "MMIDataType.h"
#include "wgui_categories_list.h"
#include "IdleMain.h"
#include "IdleObject.h"
#include "kal_public_api.h"
#include "DebugInitDef_Int.h"
#include "kal_general_types.h"
#include "GlobalConstants.h"
#include "mmi_frm_input_gprot.h"
#include "wgui_categories_util.h"
#include "mmi_frm_timer_gprot.h"
#include "TimerEvents.h"
#include "mmi_rp_app_idle_def.h"
#include "GlobalResDef.h"
#include "AlertScreen.h"
#include "mmi_frm_events_gprot.h"
#include "CommonScreensResDef.h"
#include "gui_effect_oem.h"
#include "Unicodexdcl.h"
#include "l4c_nw_cmd.h"
#include "IdleCommon.h"
#include "wgui_inputs.h"

#ifdef __TOPWELL_MMI_QUICK_CAPUTURE_AND_SAVE__
extern void mmi_quick_caputure_and_save(void);
#endif
#if 0
#if defined(__OP01_FWPCOLOR__) || defined(__OP01_FWPBW__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #ifdef __MMI_FM_RADIO__
/* under construction !*/
    #endif
#endif
#endif

#if defined(__TOPWELL_THEME_IDLE_SHORTCUT_BAR__)
extern void DrawIdlescreenShortcutBarRight(void);
extern void DrawIdlescreenShortcutBarLeft(void);
extern void IdlescreenShortcutBarItemEntry(void);
extern void DrawIdlescreenShortcutBarUp(void);
extern void DrawIdlescreenShortcutBarDown(void);
#endif


#if defined(__TOPWELL_HW_KEYMAP_MULTY_FUNCTION__)|| defined(__TOPWELL_MMI_ENTER_OK_KEY__)      
extern void mmi_sndrec_pre_entry_main_screen(void);
extern void mmi_um_entry_main_message_menu(void);
#endif
#if defined(__TOPWELL_MMI_MUSIC_4KEY__)
extern void mmi_audply_entry_main(void);
extern BOOL mmi_audply_is_playing(void);
extern void mmi_audply_pause(void);
extern void mmi_audply_stop_playing(void);
extern void topwell_mmi_audply_goto_next(void);
extern void topwell_mmi_audply_goto_prev(void);
#endif

#ifdef __MMI_FM_RADIO__
extern void mmi_fmrdo_run_app(void);
#endif
#ifdef __MMI_AUDIO_PLAYER__
extern void mmi_audply_entry_main(void);
#endif
#if defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_FUNANDGAME__)
extern void mmi_game_entry_app_screen(void);
#endif
#if defined(__TOPWELL_MMI_DIALING_FULL_SCREEN__)
extern void topwell_mmi_clear_all_dial_character(void);
#endif

#if defined(__MMI_ATV_SUPPORT__)
extern  void mmi_mtv_player_launch(void);
#endif

#if defined(__MMI_SOUND_RECORDER__)
void mmi_sndrec_pre_entry_main_screen(void);
#endif

#if defined(__TOPWELL_MMI_SOS_INTEGRATION__)
extern void mmi_sos_start_launch(void);
#endif

/****************************************************************************
 * Global context
 ****************************************************************************/

typedef struct
{
    U8          flag;
    FuncPtr     right_softkey_hdlr;
    FuncPtr     left_softkey_hdlr;
} mmi_idle_key_cntx_struct;


static mmi_idle_key_cntx_struct g_idle_key_cntx;


/****************************************************************************
 * Define
 ****************************************************************************/

#define MMI_IDLE_KEY_DELAYED_RSK_TIMEOUT_VALUE      (500)


/****************************************************************************
 * Option Flag
 ****************************************************************************/

#define MMI_IDLE_KEY_FLAG_DISABLE_LOCK_BY_END       (1 << 0)


/* Macro: (1) set flag (2) clear flag and (3) check if flag is set. */
#define MMI_IDLE_KEY_SET(_f)       (g_idle_key_cntx.flag |= _f)
#define MMI_IDLE_KEY_CLR(_f)       (g_idle_key_cntx.flag &= ~_f)
#define MMI_IDLE_KEY_HAS(_f)       (((g_idle_key_cntx.flag & _f) == _f))


/****************************************************************************
 * Function
 ****************************************************************************/
#if defined(__TOPWELL_HW_TORCH__) 
#ifdef __TOPWELL_HW_TORCH_SHOW_STATUS_ICON__
extern void show_torch_status_icon(U8 status);
#endif
void mmi_idle_torch_switch(void)
{
#ifdef __MTK_TARGET__
	if (torch_switch())
	{
#ifdef __TOPWELL_HW_TORCH_SHOW_STATUS_ICON__
	show_torch_status_icon(1);	
#endif
		mmi_popup_display_simple_ext(STR_ID_TORCH_ON, MMI_EVENT_INFO,GRP_ID_ROOT,NULL);   
	}
	else
	{
#ifdef __TOPWELL_HW_TORCH_SHOW_STATUS_ICON__
		show_torch_status_icon(0);
#endif
		mmi_popup_display_simple_ext(STR_ID_TORCH_OFF, MMI_EVENT_INFO,GRP_ID_ROOT,NULL);	
	}
#endif
}
#endif    

#ifdef __TOPWELL_HW_KEY_TO_BACKLIGHT_HALF_MODE__
#include "gpiosrvgprot.h"
extern kal_uint8 backlight_half_mode_flag = 0;

extern void mmi_backlight_half_mode_switch(void)
{
    if (backlight_half_mode_flag)
    {
        srv_backlight_set_real_level(SRV_BACKLIGHT_TYPE_MAINLCD, g_phnset_gpio_cntx_p->bl_setting_level);
        srv_backlight_set_hf_time(SRV_BACKLIGHT_SET_TIMER_DEFAULT, g_phnset_gpio_cntx_p->bl_setting_hftime);
      	backlight_half_mode_flag = 0;
    }
    else
    {
        srv_backlight_set_real_level(SRV_BACKLIGHT_TYPE_MAINLCD, 1);
      	srv_backlight_set_hf_time(SRV_BACKLIGHT_SET_TIMER_DEFAULT, 10);
        backlight_half_mode_flag = 1;
    }
}
#endif

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_rsk_hdlr
 * DESCRIPTION
 *  This function sets the right softkey handler.
 * PARAMETERS
 *  hdlr                : [IN]          Key handler
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_rsk_hdlr(FuncPtr hdlr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_idle_obj_struct *obj = mmi_idle_get_obj();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    if (hdlr)
    {
        if (!(obj->capability & ENABLE_SOFT_KEY_AREA))
        {
            //SetKeyHandler(hdlr, KEY_RSK, KEY_EVENT_DOWN);
			SetKeyDownHandler(hdlr, KEY_RSK);
        }
        else
        {
            SetRightSoftkeyFunction(hdlr, KEY_EVENT_UP);
        }
    }
}

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_rsk_view
 * DESCRIPTION
 *  This function sets the right softkey string and image.
 * PARAMETERS
 *  string_id           : [IN]          String ID
 *  image_id            : [IN]          Image ID
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_rsk_view(U16 string_id, U16 image_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_idle_obj_struct *obj = mmi_idle_get_obj();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);
   
    if (obj->capability & ENABLE_SOFT_KEY_AREA)
    {
        ChangeRightSoftkey(string_id, image_id);
    }
}



/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_csk_hdlr
 * DESCRIPTION
 *  This function sets the center softkey handler.
 * PARAMETERS
 *  hdlr                : [IN]          Key handler
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_csk_hdlr(FuncPtr hdlr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_idle_obj_struct *obj = mmi_idle_get_obj();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    if (hdlr)
    {
        if (!(obj->capability & ENABLE_SOFT_KEY_AREA))
        {
            //SetKeyHandler(hdlr, KEY_CSK, KEY_EVENT_DOWN);
			SetKeyDownHandler(hdlr, KEY_CSK);
        }
        else
        {
            SetCenterSoftkeyFunction(hdlr, KEY_EVENT_UP);
        }
    }
}

#ifndef __MMI_WGUI_DISABLE_CSK__

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_csk_view
 * DESCRIPTION
 *  This function sets the center softkey string and image.
 * PARAMETERS
 *  string_id           : [IN]          String ID
 *  image_id            : [IN]          Image ID
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_csk_view(U16 string_id, U16 image_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_idle_obj_struct *obj = mmi_idle_get_obj();

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    if (obj->capability & ENABLE_SOFT_KEY_AREA)
    {
        ChangeCenterSoftkey(string_id, image_id);
    }
}
#endif /*__MMI_WGUI_DISABLE_CSK__*/


#if defined(__MMI_IDLE_CAMERA_KEY_TO_STOP_AUDIOPLAYER__)
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_entry_camera_ex
 * DESCRIPTION
 *  This function entry the camera application. In addition, it will stop the
 *  current audio player.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_entry_camera_ex(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /*
     * Stop playing audio by camera key.
     */
#ifdef __MMI_AUDIO_PLAYER__
    if (mmi_audply_is_playing())
    {
        mmi_audply_do_stop_action(MMI_TRUE);
    }
    else
#endif /* __MMI_AUDIO_PLAYER__ */
#ifdef __MMI_FM_RADIO__
    if (mmi_fmrdo_is_power_on())
    {
        mmi_fmrdo_power_on_check(MMI_FALSE);
    }
    else
#endif /* __MMI_FM_RADIO__ */
#if 0
#ifdef __A8BOX_SUPPORT__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* __A8BOX_SUPPORT__ */
#endif

    /*
     * Launch camera.
     */
#if defined (__MMI_CAMERA__) && !defined(__MMI_CAMCORDER__)
    mmi_camera_lauch();
#elif defined (__MMI_CAMERA__) && defined(__MMI_CAMCORDER__)
    mmi_camco_launch();
#endif /* defined (__MMI_CAMERA__) && !defined(__MMI_CAMCORDER__) */
}
#endif /* defined(__MMI_IDLE_CAMERA_KEY_TO_STOP_AUDIOPLAYER__) */


#if (__MRE_AM__) && defined(__MMI_MRE_APP_OPERA_MINI__)
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_entry_mre_opera
 * DESCRIPTION
 *  This function launches the MRE Opera Mini browser.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_entry_mre_opera(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    mmi_am_start_from_mm(APPID_OPERA);
}
#endif /* (__MRE_AM__) && defined(__MMI_MRE_APP_OPERA_MINI__) */

#if 0
#if defined(__OP12__)
/* 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 !*/
/* 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 !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* __OP12__ */
/* under construction !*/
/* under construction !*/
#if defined(__MMI_OP01_WITH_WAP_KEY__)
#if defined(__OP01_0202__)
/* 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 !*/
/* 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(__OP01_0202__) */
/* 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 !*/
#if defined(__OP01_0202__)
/* under construction !*/
#else
/* under construction !*/
#endif
/* under construction !*/
#endif /* defined(__MMI_OP01_WITH_WAP_KEY__)  */
/* under construction !*/
/* under construction !*/
#if defined(__OP01_FWPCOLOR__) || defined(__OP01_FWPBW__)
/* 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
/* under construction !*/
#if defined(__OP01_FWPBW__)
/* 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 !*/
/* 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 !*/
/* 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
#endif /* 0 */


#ifdef __MMI_BT_DIALER_SUPPORT__

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_show_BT_dialer_popup_screen
 * DESCRIPTION
 *  This function
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_BT_dialer_connect(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    mmi_bt_dialer_show_popup(mmi_frm_group_get_active_id());
}

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_BT_disconnect_notify
 * DESCRIPTION
 *  This function
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/

static void mmi_idle_BT_dialer_disconnect(void)
{
    mmi_bt_dialer_disconnect_notify(mmi_frm_group_get_active_id());
}

#ifndef __MMI_BTD_BOX_UI_STYLE__
static void mmi_idle_set_right_soft_key_hdlr(void);
void mmi_idle_BT_dialer_update_RSK(void)
{
    mmi_idle_set_right_soft_key_hdlr();
}
#endif

#endif

#ifdef __TOPWELL_MMI_IDLE_RIGHT_KEY_TO_IMAGEVIEW__
#include "Mmi_rp_app_camera_def.h"
extern void mmi_imgview_launch(void);
#endif
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_right_soft_key_hdlr
 * DESCRIPTION
 *  This function
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_right_soft_key_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 str_id = 0;
    FuncPtr hdlr = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /*
     * Get the handler and string.
     */
#if 0     
#if defined(__MMI_OP01_DCD__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__MMI_OP01_DCD__) */
#if defined(__OP12__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__OP12__) */
#endif 

#ifdef __MMI_BT_DIALER_SUPPORT__
    {     
        if (GetIdleScreenBTDialerConnectionStatus())  
        {
            str_id = STR_ID_IDLE_BTDIALER_DISCONNECT;
            hdlr = mmi_idle_BT_dialer_disconnect;          
        }
        else
        {
            str_id = STR_ID_IDLE_BTDIALER_CONNECT;          
            hdlr   = mmi_idle_BT_dialer_connect;
        }
    }
#else
    {
    #ifdef __TOPWELL_MMI_IDLE_RIGHT_KEY_TO_IMAGEVIEW__
        str_id = STR_ID_CAMERA_TO_IMGVIEW;
        hdlr   = mmi_imgview_launch;    
    #else
        str_id = STR_ID_IDLE_CONTACT;
        hdlr   = mmi_phb_idle_launch;
    #endif
    }
#endif

    /*
     * Set the handler and string.
     */
 #if defined(__TOPWELL_MMI_IDLE_SOFTKEY_BAR_3ICON__) 
    SetKeyHandler(mmi_phb_idle_launch,KEY_RSK,KEY_EVENT_UP);
    mmi_idle_set_rsk_view(0, 0);
 #else  
    mmi_idle_set_rsk_hdlr(hdlr);
    mmi_idle_set_rsk_view(str_id, 0);
 #endif   
}


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_center_soft_key_hdlr
 * DESCRIPTION
 *  This function
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
#ifdef __TOPWELL_MMI_SPEED_DIAL_FUNCTION__	 
#include "PhoneBookCore.h"
#include "UcmSrvGprot.h"
#include "UcmGProt.h"
//const speed_dial_struct empty_speed_dial_matrix = {0,0,IMG_ID_SPEED_DIAL_ADD,0,0}; 
speed_dial_struct speed_dial_matrix[9] = {0};//{{0,0,IMG_ID_SPEED_DIAL_ADD,0,0},{0,0,IMG_ID_SPEED_DIAL_ADD,0,0},{0,0,IMG_ID_SPEED_DIAL_ADD,0,0}},
											 //{{0,0,IMG_ID_SPEED_DIAL_ADD,0,0},{0,0,IMG_ID_SPEED_DIAL_ADD,0,0},{0,0,IMG_ID_SPEED_DIAL_ADD,0,0}},
											// {{0,0,IMG_ID_SPEED_DIAL_ADD,0,0},{0,0,IMG_ID_SPEED_DIAL_ADD,0,0},{0,0,IMG_ID_SPEED_DIAL_ADD,0,0}}};
extern U8 speed_dial_hight_item;

MMI_ID select_phb_sg_id = 0;
MMI_ID speed_dial_grp_id = 0;

void topwell_mmi_speed_dial_read_record(void)
{
	S16 pError;
	U8 ret;
	/*ret = ReadRecord(NVRAM_EF_TOPWELL_SPEED_DIAL_LID, 
			   NVRAM_TOPWELL_SPEED_DIAL_TOTAL, 
			   (void *)speed_dial_matrix, 
			   NVRAM_TOPWELL_SPEED_DIAL_SIZE, 
			   &pError);*/
    U16 total_size;
	U16 start_id = 0;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    total_size = NVRAM_TOPWELL_SPEED_DIAL_SIZE * NVRAM_TOPWELL_SPEED_DIAL_TOTAL;
    while (start_id < 9)
	{
	    ret = ReadMultiRecord(
	            NVRAM_EF_TOPWELL_SPEED_DIAL_LID,
	            (U16)(start_id + 1),
	            (void*)&speed_dial_matrix[start_id],
	            total_size,
	            (U16) NVRAM_TOPWELL_SPEED_DIAL_TOTAL,
	            &pError);
		start_id++;
	}
}

void topwell_mmi_speed_dial_write_record(void)
{
	S16 pError;
	U8 ret;
	/*ret = WriteRecord(NVRAM_EF_TOPWELL_SPEED_DIAL_LID, 
			    NVRAM_TOPWELL_SPEED_DIAL_TOTAL, 
			    (void *)speed_dial_matrix, 
			    NVRAM_TOPWELL_SPEED_DIAL_SIZE, 
			    &pError);*/
    ret = WriteRecord(
            NVRAM_EF_TOPWELL_SPEED_DIAL_LID,
            (U16) (speed_dial_hight_item + 1),
            (void*)&speed_dial_matrix[speed_dial_hight_item],
            NVRAM_TOPWELL_SPEED_DIAL_SIZE,
            &pError);

}

static mmi_ret topwell_mmi_speed_dial_proc(mmi_event_struct* evt)
{
    cui_phb_select_contact_result_struct *select_result;
    switch (evt->evt_id)
	{
		case EVT_ID_GROUP_GOBACK:
		case EVT_ID_GROUP_GOBACK_IN_END_KEY:
			return MMI_RET_OK;
		
		case EVT_ID_PHB_SELECT_CONTACT:
			memset(speed_dial_matrix[speed_dial_hight_item].name,0x00,(MMI_PHB_NAME_FIELD_LENGTH + 1)*2);
			memset(speed_dial_matrix[speed_dial_hight_item].number,0x00,MMI_PHB_NUMBER_LENGTH + 1 + 1);
			select_result = (cui_phb_select_contact_result_struct*) evt;
			speed_dial_matrix[speed_dial_hight_item].empty_data = 1;
			mmi_ucs2ncpy((CHAR*)(speed_dial_matrix[speed_dial_hight_item].name), (CHAR*)select_result->name, (MMI_PHB_NAME_FIELD_LENGTH + 1)*2);
			mmi_ucs2ncpy((CHAR*)(speed_dial_matrix[speed_dial_hight_item].number), (CHAR*)select_result->select_data, MMI_PHB_NUMBER_LENGTH + 1 + 1);
			topwell_mmi_speed_dial_write_record();
			cui_phb_list_select_contact_close(select_phb_sg_id);
			break;

		case EVT_ID_PHB_SELECT_CONTACT_CANCEL:
			cui_phb_list_select_contact_close(select_phb_sg_id);
			break;
	}

}

static void topwell_mmi_speed_dial_add_from_contacts(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
	U32 filter_type= MMI_PHB_LIST_DFAULT_FILTER; 
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    //sms_send_gid = cui_sms_get_active_send_gid();

    //handle = cui_sms_get_send_handle(sms_send_gid);
	
    select_phb_sg_id = cui_phb_list_select_contact_create(speed_dial_grp_id);

	
    if (select_phb_sg_id != GRP_ID_INVALID)
    {
        cui_phb_list_select_contact_set_field_filter(select_phb_sg_id, filter_type);
        cui_phb_list_select_contact_run(select_phb_sg_id);
    }

}

void topwell_mmi_make_speed_call(void)
{
	/*----------------------------------------------------------------*/
	/* Local Variables												  */
	/*----------------------------------------------------------------*/
	srv_ucm_call_type_enum call_type = SRV_UCM_VOICE_CALL_TYPE;
	mmi_ucm_make_call_para_struct makecall_para;
	U16 ucs2_strNumber[22] = {0};
	/*----------------------------------------------------------------*/
	/* Code Body													  */
	/*----------------------------------------------------------------*/	   
	memcpy(ucs2_strNumber,speed_dial_matrix[speed_dial_hight_item].number,(MMI_PHB_NAME_FIELD_LENGTH + 1)*2);
	call_type = SRV_UCM_VOICE_CALL_TYPE;
	mmi_ucm_init_call_para(&makecall_para);
	makecall_para.dial_type = call_type;
	makecall_para.ucs2_num_uri = (U16*)ucs2_strNumber;
	mmi_ucm_call_launch(0, &makecall_para);
	return;
}


void topwell_mmi_enter_speed_dial_scrn(void)
{
    U8 *guiBuffer;
    MMI_ID gid;
    MMI_BOOL entry_ret;    


    speed_dial_grp_id = mmi_frm_group_create(GRP_ID_ROOT, GRP_ID_TOPWELL_SPEED_DIAL, topwell_mmi_speed_dial_proc, NULL);
    mmi_frm_group_enter(GRP_ID_TOPWELL_SPEED_DIAL, MMI_FRM_NODE_SMART_CLOSE_FLAG );
    
    entry_ret = mmi_frm_scrn_enter(GRP_ID_TOPWELL_SPEED_DIAL, SCR_ID_TOPWELL_SPEED_DIAL, NULL, topwell_mmi_enter_speed_dial_scrn, MMI_FRM_FULL_SCRN);
    if (!entry_ret)
    {
        return;
    }
    topwell_mmi_speed_dial_read_record();
    guiBuffer = mmi_frm_scrn_get_active_gui_buf();



   /* mmi_frm_group_create(GRP_ID_ROOT, GRP_ID_TOPWELL_SPEED_DIAL, NULL, NULL);
    mmi_frm_group_enter(GRP_ID_TOPWELL_SPEED_DIAL, MMI_FRM_NODE_SMART_CLOSE_FLAG);
 
    if(!mmi_frm_scrn_enter(GRP_ID_TOPWELL_SPEED_DIAL,
                       SCR_ID_TOPWELL_SPEED_DIAL,
                       NULL,
                       topwell_mmi_enter_speed_dial_scrn,
                       MMI_FRM_FULL_SCRN))
   {
       return;
   }
	
    guiBuffer = mmi_frm_scrn_get_active_gui_buf();*/
	ShowCategory333MatrixScreen(
	NULL,
	 NULL,
	 (WCHAR*)GetString(STR_GLOBAL_OK),
	 (WCHAR*)GetString(STR_GLOBAL_BACK),
	 9,
	 0,
	 guiBuffer);
	//ShowCategory333MatrixScreen(
							//IMG_ID_SPEED_DIAL_ADD,
							//guiBuffer);
	SetCenterSoftkeyFunction(topwell_mmi_speed_dial_add_from_contacts,KEY_EVENT_UP);
	SetLeftSoftkeyFunction(topwell_mmi_speed_dial_add_from_contacts,KEY_EVENT_UP);
	SetKeyHandler(topwell_mmi_make_speed_call,KEY_SEND,KEY_EVENT_UP);
#ifdef __SENDKEY2_SUPPORT__
	SetKeyHandler(topwell_mmi_make_speed_call, KEY_SEND2,KEY_EVENT_UP);
#endif /* __SENDKEY2_SUPPORT__ */
}
#endif

#ifdef __TOPWELL_MMI_PRIVACY_PROTECTION__
extern void mmi_idle_entry_dialer_by_key(void);
#endif

#ifdef __TOPWELL_MMI_EMERGENCY_SPEED_CALL__
#include "SmsSrvGprot.h"
extern void topwell_mmi_emergency_call(void)
{
	S8 ucs2_addr[20];	
	mmi_asc_n_to_ucs2((S8*)ucs2_addr, (S8*)"112", SRV_SMS_MAX_ADDR_LEN+1);
	MakeCall(ucs2_addr);

}
#endif

static void mmi_idle_set_center_soft_key_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 img_id = 0;
    FuncPtr hdlr = NULL;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /*
     * Get the handler and string.
 	 * for FTE_KEY_ONLY, the UE of CSK is the same as LSK 
	*/

     img_id = IMG_GLOBAL_COMMON_CSK;  

#if defined(__TOPWELL_THEME_IDLE_SHORTCUT_BAR__)     
    hdlr   = IdlescreenShortcutBarItemEntry;  

#elif defined(__TOPWELL_MMI_ENTER_OK_KEY__)    
#if defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_MP3__)
    hdlr   = mmi_audply_entry_main;     
#elif defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_DIALER__)
    hdlr   = mmi_idle_entry_dialer_by_key;
#elif defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_FUNANDGAME__)
    hdlr   = mmi_game_entry_app_screen;
#elif defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_SPEED_DIAL__)
	hdlr   = topwell_mmi_enter_speed_dial_scrn;
#elif defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_ATV__)
#if defined(__MMI_ATV_SUPPORT__)
     hdlr   = mmi_mtv_player_launch;
#endif   
#endif

#else
#if defined(__MMI_BT_DIALER_SUPPORT__) && defined(__MMI_MAINLCD_128X128__)
    img_id = IMG_GLOBAL_COMMON_CSK;     
    hdlr   = EntryMainMenuFromIdleScreen;    
#elif defined(__MMI_FTE_SUPPORT__) && !defined(__MMI_TOUCH_SCREEN__)
	img_id = IMG_GLOBAL_COMMON_CSK;     
    hdlr   = EntryMainMenuFromIdleScreen;    
#elif defined(__MMI_MAINLCD_96X64__)
	img_id = IMG_GLOBAL_COMMON_CSK;    
    hdlr   = mmi_dialer_launch;
#elif defined(__TOPWELL_BASE_BUG__)
	img_id = IMG_GLOBAL_COMMON_CSK;     
    hdlr   = EntryMainMenuFromIdleScreen;      
#else
	img_id = IMG_GLOBAL_DIAL_PAD_CSK;    
    hdlr   = mmi_dialer_launch;    
#endif
#endif
    /*
     * Set the handler and string.
     */
    mmi_idle_set_csk_hdlr(hdlr);
#ifndef __MMI_WGUI_DISABLE_CSK__
    mmi_idle_set_csk_view(0, img_id);
#endif /*__MMI_WGUI_DISABLE_CSK__*/

#if defined(__TOPWELL_MMI_ENTER_OK_KEY__)      
#if defined(__TOPWELL_MMI_ENTER_OK_LONG_KEY_TO_ATV__)  
    SetKeyHandler(EntryMainMenuFromIdleScreen, KEY_ENTER, KEY_EVENT_UP);
#if defined(__MMI_ATV_SUPPORT__)
    ClearKeyHandler(KEY_ENTER, KEY_LONG_PRESS);
    SetKeyHandler(mmi_mtv_player_launch, KEY_ENTER, KEY_LONG_PRESS);
#endif    
#endif

#if defined(__TOPWELL_MMI_ENTER_OK_KEY_TO_SOUND_RECORD__)  
    SetKeyHandler(EntryMainMenuFromIdleScreen, KEY_ENTER, KEY_EVENT_UP);
    ClearKeyHandler(KEY_ENTER, KEY_LONG_PRESS);
    SetKeyHandler(mmi_sndrec_pre_entry_main_screen, KEY_ENTER, KEY_LONG_PRESS);
#endif
#endif

#if defined(__TOPWELL_MMI_SOS_INTEGRATION__)
    SetKeyHandler(EntryMainMenuFromIdleScreen, KEY_ENTER, KEY_EVENT_UP);
	ClearKeyHandler(KEY_ENTER, KEY_LONG_PRESS);
	SetKeyHandler(mmi_sos_start_launch, KEY_ENTER, KEY_LONG_PRESS);
#endif

}



/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_send_key_hdlr
 * DESCRIPTION
 *  This function sets the send key handler.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_send_key_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#if !defined(__SENDKEY2_SUPPORT__)
    //SetKeyHandler(mmi_clog_sendkey_launch, KEY_SEND, KEY_EVENT_DOWN);
    SetKeyDownHandler(mmi_clog_sendkey_launch, KEY_SEND);
#else
    //SetKeyHandler(mmi_clog_sendkey_launch, KEY_SEND1, KEY_EVENT_DOWN);
    //SetKeyHandler(mmi_clog_sendkey_launch, KEY_SEND2, KEY_EVENT_DOWN);
    SetKeyDownHandler(mmi_clog_sendkey_launch, KEY_SEND1);
    SetKeyDownHandler(mmi_clog_sendkey_launch, KEY_SEND2);
#endif /* __SENDKEY2_SUPPORT__ */
}


extern void mmi_btdialer_launch_func(void);

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_navigation_key_hdlr
 * DESCRIPTION
 *  This function sets the navigation key handler.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_navigation_key_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#if 0    
#if defined(__MMI_OP01_DCD__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__MMI_OP01_DCD__) */
#endif

    {
#ifdef __TOPWELL_THEME_IDLE_SHORTCUT_BAR__
        SetKeyHandler(DrawIdlescreenShortcutBarUp, KEY_UP_ARROW, KEY_EVENT_DOWN);
        SetKeyHandler(DrawIdlescreenShortcutBarDown, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
        SetKeyHandler(DrawIdlescreenShortcutBarLeft, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
        SetKeyHandler(DrawIdlescreenShortcutBarRight, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
#else
    #ifdef __MMI_BT_DIALER_SUPPORT__
    #if !defined(__DISABLE_SHORTCUTS_MENU__)
        //SetKeyHandler(EntryShctInIdle, KEY_UP_ARROW, KEY_EVENT_DOWN);
        SetKeyDownHandler(EntryShctInIdle, KEY_UP_ARROW);
    #endif
        //SetKeyHandler(mmi_phb_entry_main_menu, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
        //SetKeyHandler(mmi_btdialer_launch_func, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
        //SetKeyHandler(mmi_clndr_entry_main_menu, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
        SetKeyDownHandler(mmi_phb_entry_main_menu, KEY_DOWN_ARROW);
        SetKeyDownHandler(mmi_btdialer_launch_func, KEY_RIGHT_ARROW);
    #ifdef __MMI_CALENDAR__
        SetKeyDownHandler(mmi_clndr_entry_main_menu, KEY_LEFT_ARROW);
    #endif
	#else
    #if defined(__MMI_DEDICATED_KEY_SHORTCUTS__)
        RegisterDedicatedKeyHandlers();
    #else
    #if !defined(__DISABLE_SHORTCUTS_MENU__)
        //SetKeyHandler(EntryShctInIdle, KEY_UP_ARROW, KEY_EVENT_DOWN);
        SetKeyDownHandler(EntryShctInIdle, KEY_UP_ARROW);
    #if (__MRE_AM__) && defined(__MMI_MRE_APP_OPERA_MINI__)
        //SetKeyHandler(mmi_idle_entry_mre_opera, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
        SetKeyDownHandler(mmi_idle_entry_mre_opera, KEY_RIGHT_ARROW);
    #endif
    #if (MMI_MAX_SIM_NUM >= 3)
        //SetKeyHandler(mmi_sim_space_launch, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
        SetKeyDownHandler(mmi_sim_space_launch, KEY_LEFT_ARROW);
    #endif /* (MMI_MAX_SIM_NUM >= 3) */
    #endif /* !defined(__DISABLE_SHORTCUTS_MENU__) */
    #endif /* defined(__MMI_DEDICATED_KEY_SHORTCUTS__) */
#endif

    // google search handler is the highest priority
    #if defined(__MMI_SEARCH_WEB__)
        if (mmi_search_web_hot_key_is_enabled(MMI_SEARCH_WEB_HOT_KEY_DOWN_KEY))
        {
            //SetKeyHandler(mmi_search_web_trigger_by_down_key, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
            SetKeyDownHandler(mmi_search_web_trigger_by_down_key, KEY_DOWN_ARROW);
        }
    #endif /* defined(__MMI_SEARCH_WEB__) */
	#endif /*__BT_DIALER_PACKAGE__*/
    }
}


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_disable_lock_by_end_key
 * DESCRIPTION
 *  This function turns off the availability to lock the keypad by END key. When
 *  the unit testing is running using the tool, e.g., MSC composer, it sometimes
 *  needs to emit some END key events to make sure the handset is in the idle
 *  screen. If the "Lock keypad?" confirm screen is shown, the unit test case
 *  might fail since the handset is not in the idle screen.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_idle_disable_lock_by_end_key(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_IDLE_KEY_SET(MMI_IDLE_KEY_FLAG_DISABLE_LOCK_BY_END);

    mmi_popup_display_simple(
        (WCHAR *)get_string(STR_GLOBAL_DONE),
        MMI_EVENT_SUCCESS,
        GRP_ID_ROOT,
        NULL);
}


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_lock_keypad_confirm_evt_hdlr
 * DESCRIPTION
 *  This function handles the event of the lock keypad confirm screen.
 * PARAMETERS
 *  event               : [IN]              Event
 * RETURNS
 *  mmi_ret
 *****************************************************************************/
static mmi_ret mmi_idle_lock_keypad_confirm_evt_hdlr(mmi_event_struct *event)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_alert_result_evt_struct *evt = (mmi_alert_result_evt_struct *)event;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(evt);

    if (evt->evt_id == EVT_ID_ALERT_QUIT && evt->result == MMI_ALERT_CNFM_YES)
    {
        mmi_idle_display();
        mmi_scr_locker_launch();
    }

    return MMI_RET_OK;
}

#if 0
/* 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

#if defined(__MMI_QWERTY_KEYPAD_SUPPORT__)
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_entry_dialer_by_translate_key
 * DESCRIPTION
 *  This function is the translate key handler if APP wants to launch dialer by
 *  the tranlate key.
 * PARAMETERS
 *  key_code                : [IN]      Key code
 *  key_type                : [IN]      Key type
 *  ucs2_value              : [IN]      UCS2 value
 *  key_flag                : [IN]      Key flag
 * RETURNS
 *  void
 *****************************************************************************/
static MMI_BOOL mmi_idle_entry_dialer_by_translate_key(
    S16 key_code,
    S16 key_type,
    U16 ucs2_value,
    U32 key_flag)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* Skip non-dialer key. */
    if ((!wgui_inputs_dialer_is_dialer_keys(key_code)) ||
        (key_type != KEY_EVENT_DOWN))
    {
        return MMI_FALSE; /* continue the key routing. */
    }

    /* set SSE effect */
    gui_sse_setup_scenario(GUI_SSE_SCENARIO_FROM_IDLE);

	mmi_frm_send_incomplete_key_event_to_new_screen(MMI_TRUE);

    /* Show the dial pad. */
    mmi_dialer_launch_by_translate_key(key_code, key_type, ucs2_value, key_flag);

    return MMI_TRUE; /* stop the key routing. */
}
#else /* defined(__MMI_QWERTY_KEYPAD_SUPPORT__) */
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_entry_dialer_by_key
 * DESCRIPTION
 *  This function is the digital key handler if APP wants to launch dialer by
 *  the digital key.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
 #ifdef __TOPWELL_MMI_PRIVACY_PROTECTION__
static void mmi_idle_entry_dialer_by_key_ext(void)
#else
static void mmi_idle_entry_dialer_by_key(void)
#endif
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 key_code, key_type;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    GetkeyInfo(&key_code, &key_type);
#if defined(__TOPWELL_MMI_DIALING_FULL_SCREEN__)
     topwell_mmi_clear_all_dial_character();
#endif

	mmi_frm_send_incomplete_key_event_to_new_screen(MMI_TRUE);
    /* set SSE effect */
    gui_sse_setup_scenario(GUI_SSE_SCENARIO_FROM_IDLE);

    //mmi_dialer_launch_by_key(key_code);
    mmi_dialer_launch_by_key_ex(CUI_DIALER_TYPE_UNSPECIFIED, key_code);
}
#ifdef __TOPWELL_MMI_PRIVACY_PROTECTION__
#include "PhoneSetup.h"
void mmi_idle_entry_dialer_by_key(void)
{
#if defined(__MMI_DIALER_SEARCH__)
    if(cui_dialer_search_is_enable())  
        mmi_privacy_protection_launch(PRIVACY_PHONEBOOK, mmi_idle_entry_dialer_by_key_ext);    
    else
#endif
        mmi_idle_entry_dialer_by_key_ext();
}
#endif
#endif /* defined(__MMI_QWERTY_KEYPAD_SUPPORT__) */


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_dial_pad_hdlr
 * DESCRIPTION
 *  This function sets the dial pad handler.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_dial_pad_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    mmi_frm_set_dial_key_tone_type(MMI_DIALER_KEY_TONE_DTMF);
#if defined(__MMI_QWERTY_KEYPAD_SUPPORT__)
    mmi_frm_set_app_translate_key_handler(mmi_idle_entry_dialer_by_translate_key);

    /*
     * On QWERTY phone, the DTMF tones are played when the user wants to dial
     * calls; otherwise, normal key tone is played, e.g. in the editor. Enable
     * the DTMF tone here.
     *
     * PS. Our non-QWERTY phone will always play DTMF tone no matter in the dial
     *     pad or editor.
     */
#else
    SetGroupKeyHandler(
        mmi_idle_entry_dialer_by_key,
        (PU16)PresentAllDialerKeys,
        TOTAL_DIALER_KEYS,
        KEY_EVENT_DOWN);
#if defined(__TOPWELL_HW_TORCH__) 
#ifdef __TOPWELL_HW_TORCH_IDLE_KEY_0_EXT__	
	ClearKeyHandler(KEY_0, KEY_EVENT_DOWN);
	SetKeyHandler(mmi_idle_torch_switch, KEY_0, KEY_EVENT_LONG_PRESS); 
	SetKeyHandler(mmi_idle_entry_dialer_by_key , KEY_0, KEY_EVENT_UP);
#endif
#endif

#ifdef __TOPWELL_MMI_QUICK_CAPUTURE_AND_SAVE__
#if defined(__TOPWELL_MMI_QUICK_CAPUTURE_AND_SAVE_KEY_9__)
    ClearKeyHandler(KEY_9, KEY_EVENT_DOWN);
    SetKeyLongpressHandler(mmi_quick_caputure_and_save, KEY_9);
    SetKeyUpHandler(mmi_idle_entry_dialer_by_key , KEY_9);
#endif    
#endif
#if defined(__TOPWELL_MMI_UNLOCK_STAR_KEY__) && defined(__TOPWELL_MMI_DIALING_FULL_SCREEN__)
	ClearKeyHandler(KEY_STAR, KEY_EVENT_DOWN);
	SetKeyHandler(mmi_scr_locker_launch, KEY_STAR, KEY_EVENT_LONG_PRESS); 
	SetKeyHandler(mmi_idle_entry_dialer_by_key , KEY_STAR, KEY_EVENT_UP);
#endif
#endif /* __MMI_QWERTY_KEYPAD_SUPPORT__ */
}

#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#if defined(__MMI_VRSD__) || defined(__MMI_VRSI__)
/* 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 !*/
#if defined(__MMI_VRSD__)
/* under construction !*/
#elif defined(__MMI_VRSI__)
/* under construction !*/
#else
/* under construction !*/
#endif
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__MMI_VRSD__) || defined(__MMI_VRSI__) */
#endif


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_camera_hdlr
 * DESCRIPTION
 *  This function sets the camera key handler.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
#if defined (__MMI_CAMERA__)
static void mmi_idle_set_camera_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#if defined (__MMI_CAMERA__) && !defined(__MMI_CAMCORDER__)
    /*
     * Not support camcoder
     */
#if defined(__MMI_IDLE_CAMERA_KEY_TO_STOP_AUDIOPLAYER__)
    //SetKeyHandler(mmi_idle_entry_camera_ex, CAMERA_SHORTCUT_KEY, KEY_EVENT_UP);
    SetKeyUpHandler(mmi_idle_entry_camera_ex, CAMERA_SHORTCUT_KEY);
#else
    //SetKeyHandler(mmi_camera_lauch, CAMERA_SHORTCUT_KEY, KEY_EVENT_DOWN);
    SetKeyDownHandler(mmi_camera_lauch, CAMERA_SHORTCUT_KEY);
#endif /* defined(__MMI_IDLE_CAMERA_KEY_TO_STOP_AUDIOPLAYER__) */
#elif defined (__MMI_CAMERA__) && defined(__MMI_CAMCORDER__)
    /*
     * Support camcoder
     */
#if defined(__MMI_IDLE_CAMERA_KEY_TO_STOP_AUDIOPLAYER__)
    //SetKeyHandler(mmi_idle_entry_camera_ex, CAMERA_SHORTCUT_KEY, KEY_EVENT_UP);
    SetKeyUpHandler(mmi_idle_entry_camera_ex, CAMERA_SHORTCUT_KEY);
#else
    //SetKeyHandler(mmi_camco_launch, KEY_CAMERA, KEY_EVENT_DOWN);
    SetKeyDownHandler(mmi_camco_launch, KEY_CAMERA);
#endif /* defined(__MMI_IDLE_CAMERA_KEY_TO_STOP_AUDIOPLAYER__) */
#endif /* defined (__MMI_CAMERA__) && !defined(__MMI_CAMCORDER__) */
}
#endif/*defined (__MMI_CAMERA__)*/

#if 0
#if defined(__MMI_OP01_DCD__) || defined(__MMI_OP01_WITH_WAP_KEY__) || defined(__MMI_OP02_WITH_WAP_KEY__)
/* 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 !*/
        #ifndef __MMI_WGUI_DISABLE_CSK__
/* under construction !*/
        #endif
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /*defined(__MMI_OP01_DCD__) || defined(__MMI_OP01_WITH_WAP_KEY__) || defined(__MMI_OP02_WITH_WAP_KEY__)*/
#endif /*0*/

/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_browser_hdlr
 * DESCRIPTION
 *  This function sets up the wap key handler.
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_idle_set_wap_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
#if 0
#if defined(__MMI_OP01_DCD__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #if defined(__MMI_OP01_WITH_WAP_KEY__)
/* under construction !*/
    #endif
/* under construction !*/
/* under construction !*/
#endif /* defined(__MMI_OP01_DCD__) */
/* under construction !*/
    #if defined(__MMI_OP01_WITH_WAP_KEY__)
        #if defined(__OP01_3G__) && defined(__MMI_REDUCED_KEYPAD__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
        #else /* defined(__OP01_3G__) && defined(__MMI_REDUCED_KEYPAD__) */
/* under construction !*/
/* under construction !*/
/* under construction !*/
        #endif /* defined(__OP01_3G__) && defined(__MMI_REDUCED_KEYPAD__) */
    #elif defined(__MMI_OP02_WITH_WAP_KEY__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #elif defined(BROWSER_SUPPORT) && defined(__MMI_WITH_WAP_KEY__)
/* under construction !*/
    #endif
/* under construction !*/
#else /*0*/
    #if defined(BROWSER_SUPPORT) && defined(__MMI_WITH_WAP_KEY__)
        //SetKeyHandler(wap_internet_key_hdlr, KEY_WAP, KEY_LONG_PRESS);
        SetKeyLongpressHandler(wap_internet_key_hdlr, KEY_WAP);
    #endif
#endif /* 0 */

}

#if 0
#if defined(__OP01_FWPCOLOR__) || defined(__OP01_FWPBW__)
/* 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 !*/
#if defined(__OP01_FWPCOLOR__)
/* under construction !*/
/* under construction !*/
#endif
/* under construction !*/
#if defined(__OP01_FWPBW__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #ifdef __MMI_FM_RADIO__
/* under construction !*/
    #endif
#endif
/* under construction !*/
/* under construction !*/
#endif /* defined(__OP01_FWPCOLOR__) || defined(__OP01_FWPBW__)*/
#endif

#ifdef __TOPWELL_IDLE_SHOUTCUT_KEY_0_TO_SOUNDRECORD__
extern void mmi_sndrec_entry_record_from_idle_shortcut_key(void);
#endif

#if defined(__TOPWELL_HW_BATTERY_CHARGER__) 
#include "CharBatSrvGprot.h"
extern kal_uint8 battery_charger_flag;
extern kal_uint8 battery_charger_switch(void);

static void mmi_idle_battery_charger_switch(void)
{
    if ((srv_charbat_get_battery_level() == SRV_CHARBAT_BATTERY_LEVEL_0)||(srv_charbat_get_battery_level() == SRV_CHARBAT_BATTERY_LOW_WARNING))
    {
        mmi_popup_display_simple_ext(
        	STR_ID_BATTERY_CHARGER_0,
        	MMI_EVENT_SUCCESS,
        	GRP_ID_ROOT,
        	NULL);
        battery_charger_flag = 0;	
        return;
    }

    if (battery_charger_switch())
    {
        mmi_popup_display_simple_ext(STR_ID_BATTERY_CHARGER_ON, MMI_EVENT_INFO,GRP_ID_ROOT,NULL); 
    }
    else
    {
        mmi_popup_display_simple_ext(STR_ID_BATTERY_CHARGER_OFF, MMI_EVENT_INFO,GRP_ID_ROOT,NULL);    
    }
}
#endif 


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_set_handler
 * DESCRIPTION
 *  This function sets the default handler according to the capability of the
 *  idle object.
 * PARAMETERS
 *  obj           : [IN]        Idle object
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_idle_set_handler(mmi_idle_obj_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U32 capability; 

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    capability = obj->capability;
   
#ifdef __MMI_IDLE_CLASSIC_AND_MAINMENU_SUPPORT__
    if (capability & ENABLE_LEFT_SOFT_KEY)
    {
        if (!(obj->capability & ENABLE_SOFT_KEY_AREA))
        {
            //SetKeyHandler(EntryMainMenuFromIdleScreen, KEY_LSK, KEY_EVENT_DOWN);
            SetKeyDownHandler(EntryMainMenuFromIdleScreen, KEY_LSK);            
        }
        else
        {
   #if defined(__TOPWELL_MMI_IDLE_SOFTKEY_BAR_3ICON__)
            SetKeyHandler(mmi_clog_launch,KEY_LSK,KEY_EVENT_UP);
            ChangeLeftSoftkey(0, 0);
  #else
            SetLeftSoftkeyFunction(EntryMainMenuFromIdleScreen, KEY_EVENT_UP);
            ChangeLeftSoftkey(STR_ID_IDLE_MAIN_MENU, 0);
  #endif

        }
    }
#endif /*__MMI_IDLE_CLASSIC_AND_MAINMENU_SUPPORT__*/

#ifndef __MMI_BTD_BOX_UI_STYLE__
    if (capability & ENABLE_RIGHT_SOFT_KEY)
    {
        mmi_idle_set_right_soft_key_hdlr();
    }
#else
  SetKeyHandler(mmi_scr_locker_launch, KEY_RSK, KEY_EVENT_UP);
#endif
    if (capability & ENABLE_CENTER_SOFT_KEY)
    {
        mmi_idle_set_center_soft_key_hdlr();
    }
    if (capability & ENABLE_SEND_KEY)
    {
        mmi_idle_set_send_key_hdlr();
    }

    if (capability & ENABLE_NAVIGATION_KEY)
    {
        mmi_idle_set_navigation_key_hdlr();
    }

#ifndef __MMI_BTD_BOX_UI_STYLE__
    if (capability & ENABLE_END_KEY)
    {
    #if defined(__TOPWELL_MMI_SCREEN_LOCK_END__)
		SetKeyHandler(mmi_scr_locker_launch, KEY_END, KEY_EVENT_UP);
	#elif defined(__TOPWELL_MMI_SCREEN_LOCK_STAR__) 
		//do nothing
	#elif defined(__TOPWELL_MMI_SCREEN_LOCK_POUND__)
		SetKeyHandler(mmi_scr_locker_launch, KEY_STAR, KEY_LONG_PRESS);
	#else
        //SetKeyHandler(mmi_idle_entry_lock_keypad_confirm, KEY_END, KEY_EVENT_UP);
        //SetKeyHandler(mmi_scr_locker_launch, KEY_END, KEY_EVENT_UP);
        SetKeyUpHandler(mmi_scr_locker_launch, KEY_END);
	#endif	
    }
#endif
    if (capability & ENABLE_DIALER)
    {
        mmi_idle_set_dial_pad_hdlr();
    }
    if (capability & ENABLE_VOLUME_CONTROL)
    {
    #if defined(__TOPWELL_MMI_NOT_VOLUMN_KEY__)
        //none
    #else
        SetDefaultVolumeKeyHandlers();
    #endif
    }
#if 0
#if defined(__MMI_VRSD__) || defined(__MMI_VRSI__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
#endif

#if defined (__MMI_CAMERA__)
    if (capability & ENABLE_CAMERA)
    {
        mmi_idle_set_camera_hdlr();
    }
#endif

    if (capability & ENABLE_WAP)
    {
        mmi_idle_set_wap_hdlr();
    }

#if defined(__MMI_MAPBAR_GIS__)
    if (capability & ENABLE_GIS)
    {
        //SetKeyHandler(mmi_gis_enter_app_check_conform, KEY_EXTRA_2, KEY_EVENT_UP);   
        SetKeyUpHandler(mmi_gis_enter_app_check_conform, KEY_EXTRA_2);
    }
#endif

#if defined(__MMI_ATV_SUPPORT__)
    if (capability & ENABLE_MTV)
    {        
        //SetKeyHandler(mmi_mtv_player_launch, KEY_EXTRA_1, KEY_EVENT_DOWN);    
        SetKeyDownHandler(mmi_mtv_player_launch, KEY_EXTRA_1);
    }
#endif

#if 0
#if defined(__OP01_FWPCOLOR__) || defined(__OP01_FWPBW__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
#endif

#if defined(__TOPWELL_HW_TORCH__)      
#if defined(__TOPWELL_HW_TORCH_IDLE_KEY_OK__)  
    ClearKeyHandler(KEY_ENTER, KEY_LONG_PRESS);
    SetKeyHandler(mmi_idle_torch_switch, KEY_ENTER, KEY_LONG_PRESS);
#endif
#ifdef __TOPWELL_HW_TORCH_IDLE_KEY_0_EXT__		
	SetKeyHandler(mmi_idle_torch_switch, KEY_0, KEY_EVENT_LONG_PRESS);
#endif
#ifdef __TOPWELL_HW_TORCH_DIALER_KEY_DOWN_ARROW__		
	SetKeyHandler(mmi_idle_torch_switch, KEY_DOWN_ARROW, KEY_EVENT_DOWN);
#endif
#endif

#if defined(__TOPWELL_MMI_ENTER_0_KEY__)
#ifdef __TOPWELL_IDLE_SHOUTCUT_KEY_0_TO_FMRADIO__		
	SetKeyHandler(mmi_fmrdo_run_app, KEY_0, KEY_EVENT_LONG_PRESS);
#endif

#ifdef __TOPWELL_IDLE_SHOUTCUT_KEY_0_TO_SOUNDRECORD__		
	SetKeyHandler(mmi_sndrec_entry_record_from_idle_shortcut_key, KEY_0, KEY_EVENT_LONG_PRESS);
#endif
#endif

#if defined(__TOPWELL_HW_KEYMAP_EXT1_FUNCTION__)
#if defined(__TOPWELL_HW_KEYMAP_EXT1_FUNCTION_FOR_FMR__)
    SetKeyDownHandler(mmi_fmrdo_run_app, KEY_EXTRA_1);
#elif defined(__TOPWELL_HW_KEYMAP_EXT1_FUNCTION_FOR_MP3__)
    SetKeyDownHandler(mmi_audply_entry_main, KEY_EXTRA_1);
#elif defined(__TOPWELL_HW_KEYMAP_EXT1_FUNCTION_FOR_CAM__)
    SetKeyDownHandler(mmi_camera_lauch, KEY_EXTRA_1);
#elif defined(__TOPWELL_HW_KEYMAP_EXT1_FUNCTION_FOR_TORCH__)
#if defined(__TOPWELL_HW_TORCH__) 
    SetKeyDownHandler(mmi_idle_torch_switch, KEY_EXTRA_1);
#endif
#elif defined(__TOPWELL_HW_KEYMAP_EXT1_FUNCTION_FOR_SREC__)
#if defined(__MMI_SOUND_RECORDER__)
     SetKeyDownHandler(mmi_sndrec_pre_entry_main_screen, KEY_EXTRA_1);
#endif
#endif
#endif

#if defined(__TOPWELL_HW_KEYMAP_EXT2_FUNCTION__)
#if defined(__TOPWELL_HW_KEYMAP_EXT2_FUNCTION_FOR_FMR__)
    SetKeyDownHandler(mmi_fmrdo_run_app, KEY_EXTRA_2);
#elif defined(__TOPWELL_HW_KEYMAP_EXT2_FUNCTION_FOR_MP3__)
    SetKeyDownHandler(mmi_audply_entry_main, KEY_EXTRA_2);
#elif defined(__TOPWELL_HW_KEYMAP_EXT2_FUNCTION_FOR_CAM__)
    SetKeyDownHandler(mmi_camera_lauch, KEY_EXTRA_2);
#elif defined(__TOPWELL_HW_KEYMAP_EXT2_FUNCTION_FOR_TORCH__)
#if defined(__TOPWELL_HW_TORCH__) 
    SetKeyDownHandler(mmi_idle_torch_switch, KEY_EXTRA_2);
#endif
#elif defined(__TOPWELL_HW_KEYMAP_EXT2_FUNCTION_FOR_SREC__)
#if defined(__MMI_SOUND_RECORDER__)
     SetKeyDownHandler(mmi_sndrec_pre_entry_main_screen, KEY_EXTRA_2);
#endif
#endif
#endif

#if defined(__TOPWELL_HW_KEYMAP_EXT3_FUNCTION__)
#if defined(__TOPWELL_HW_KEYMAP_EXT3_FUNCTION_FOR_FMR__)
    SetKeyDownHandler(mmi_fmrdo_run_app, KEY_EXTRA_A);
#elif defined(__TOPWELL_HW_KEYMAP_EXT3_FUNCTION_FOR_MP3__)
    SetKeyDownHandler(mmi_audply_entry_main, KEY_EXTRA_A);
#elif defined(__TOPWELL_HW_KEYMAP_EXT3_FUNCTION_FOR_CAM__)
    SetKeyDownHandler(mmi_camera_lauch, KEY_EXTRA_A);
#elif defined(__TOPWELL_HW_KEYMAP_EXT3_FUNCTION_FOR_TORCH__)
#if defined(__TOPWELL_HW_TORCH__) 
    SetKeyDownHandler(mmi_idle_torch_switch, KEY_EXTRA_A);
#endif
#elif defined(__TOPWELL_HW_KEYMAP_EXT3_FUNCTION_FOR_SREC__)
#if defined(__MMI_SOUND_RECORDER__)
     SetKeyDownHandler(mmi_sndrec_pre_entry_main_screen, KEY_EXTRA_A);
#endif
#endif
#endif

#if defined(__TOPWELL_HW_KEYMAP_EXT4_FUNCTION__)
#if defined(__TOPWELL_HW_KEYMAP_EXT4_FUNCTION_FOR_FMR__)
    SetKeyDownHandler(mmi_fmrdo_run_app, KEY_EXTRA_B);
#elif defined(__TOPWELL_HW_KEYMAP_EXT4_FUNCTION_FOR_MP3__)
    SetKeyDownHandler(mmi_audply_entry_main, KEY_EXTRA_B);
#elif defined(__TOPWELL_HW_KEYMAP_EXT4_FUNCTION_FOR_CAM__)
    SetKeyDownHandler(mmi_camera_lauch, KEY_EXTRA_B);
#elif defined(__TOPWELL_HW_KEYMAP_EXT4_FUNCTION_FOR_TORCH__)
#if defined(__TOPWELL_HW_TORCH__) 
    SetKeyDownHandler(mmi_idle_torch_switch, KEY_EXTRA_B);
#endif
#elif defined(__TOPWELL_HW_KEYMAP_EXT4_FUNCTION_FOR_SREC__)
#if defined(__MMI_SOUND_RECORDER__)
     SetKeyDownHandler(mmi_sndrec_pre_entry_main_screen, KEY_EXTRA_B);
#endif
#endif
#endif

#ifdef __TOPWELL_MMI_EMERGENCY_SPEED_CALL__
    SetKeyHandler(topwell_mmi_emergency_call, KEY_ENTER, KEY_LONG_PRESS);
	//SetKeyHandler(mmi_idle_entry_dialer_by_key , KEY_ENTER, KEY_EVENT_UP);
#endif

#ifdef __TOPWELL_THEME_IDLE_SHORTCUT_4ICON__
    mmi_register_shortcut_handler();
#endif

#if defined(__TOPWELL_HW_KEYMAP_MULTY_FUNCTION__)
    SetKeyDownHandler(mmi_camera_lauch, KEY_F1);
    SetKeyDownHandler(mmi_sndrec_pre_entry_main_screen, KEY_F2);
    SetKeyDownHandler(mmi_idle_torch_switch, KEY_F3);
    SetKeyDownHandler(mmi_phb_entry_main_menu,KEY_F4);
    SetKeyDownHandler(mmi_um_entry_main_message_menu,KEY_F5);    
    
#if defined (__TOPWELL_HW_KEY_TO_BACKLIGHT_HALF_MODE__)
    SetKeyDownHandler(mmi_backlight_half_mode_switch,KEY_F6);
#elif defined(__TOPWELL_HW_BATTERY_CHARGER__) 
    SetKeyDownHandler(mmi_idle_battery_charger_switch,KEY_F6);   
#endif   
#endif

#ifdef __TOPWELL_MMI_MUSIC_4KEY__
    if(mmi_audply_is_playing())
    {
    	SetKeyDownHandler(mmi_audply_stop_playing, KEY_EXTRA_A);
    	SetKeyUpHandler(mmi_audply_entry_main, KEY_EXTRA_A);
    	SetKeyDownHandler(topwell_mmi_audply_goto_prev, KEY_FWD);
    	SetKeyDownHandler(topwell_mmi_audply_goto_next, KEY_BACK);
    	SetKeyDownHandler(mmi_audply_pause, KEY_PLAY_STOP);
    	SetKeyUpHandler(mmi_audply_entry_main, KEY_PLAY_STOP);
    }
    else
    {
    	SetKeyDownHandler(mmi_audply_entry_main, KEY_EXTRA_A);
    	SetKeyDownHandler(mmi_audply_entry_main, KEY_FWD);
    	SetKeyDownHandler(mmi_audply_entry_main, KEY_BACK);
    	SetKeyDownHandler(mmi_audply_entry_main, KEY_PLAY_STOP);
    }
#endif


}





#if defined(__HOMEZONE_SUPPORT__ )
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_get_homezone_string
 * DESCRIPTION
 *  This function prepares the service string in the homezone situation.
 * PARAMETERS
 *  sim                     : [IN]            SIM ID
 *  service_indication      : [OUT]           mmi_idle_service_indication_struct
 * RETURNS
 *  In homezone, return MMI_TRUE; otherwise, return MMI_FALSE.
 *****************************************************************************/
static MMI_BOOL mmi_idle_get_homezone_string(
    mmi_sim_enum sim,
    mmi_idle_service_indication_struct *service_indication)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_nw_info_homezone_info_struct homezone;
    MMI_BOOL ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    ret = srv_nw_info_get_homezone_info(sim, &homezone);
    if (!ret || !homezone.is_in_homezone)
    {
        return MMI_FALSE; /* It's not in home zone. */
    }

    mmi_wcsncpy(service_indication->line2, homezone.tag, MMI_IDLE_NW_NAME_MAX_STR_LEN);

    return MMI_TRUE;
}
#endif /* defined(__HOMEZONE_SUPPORT__ ) */

#if 0
#if defined(__OP12__) && defined(__NBR_CELL_INFO__)
/* 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 !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__OP12__) && defined(__NBR_CELL_INFO__) */
#endif /*0*/


#if defined(__MMI_IDLE_SCREEN_OWNER_NUMBER__)
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_get_msisdn_type
 * DESCRIPTION
 *  This function gets the MSISDN type.
 * PARAMETERS
 *  sim             : [IN]              SIM id
 * RETURNS
 *  srv_cphs_msisdn_type_enum
 *****************************************************************************/
static srv_cphs_msisdn_type_enum mmi_idle_get_msisdn_type(mmi_sim_enum sim)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_callset_line_id_enum line_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    line_id = srv_callset_line_switch_get_id(sim);

    return line_id == SRV_CALLSET_LINE2 ?
           SRV_CPHS_MSISDN_TYPE_LINE2 : SRV_CPHS_MSISDN_TYPE_LINE1;
}
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_get_owner_number_string
 * DESCRIPTION
 *  This function gets the owner number string.
 * PARAMETERS
 *  sim                     : [IN]            SIM ID
 *  service_indication      : [OUT]           mmi_idle_service_indication_struct
 * RETURNS
 *  On available, return MMI_TRUE; otherwise, return MMI_FALSE.
 *****************************************************************************/
static MMI_BOOL mmi_idle_get_owner_number_string(
    mmi_sim_enum sim,
    mmi_idle_service_indication_struct *service_indication)

{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_cphs_msisdn_type_enum msisdn_type;
    const WCHAR *string;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (mmi_phnset_show_owner_number_is_on(sim) &&
        srv_sim_ctrl_is_available(sim))
    {
        /*
         * Priority: owner name > owner number.
         */
        msisdn_type = mmi_idle_get_msisdn_type(sim);

        string = srv_cphs_get_msisdn_name(msisdn_type, sim);
        if (!string || !mmi_wcslen(string))
        {
            string = srv_cphs_get_msisdn_number(msisdn_type, sim);
        }

        if (string && mmi_wcslen(string))
        {
            mmi_wcsncpy(service_indication->line2, string, SRV_NW_NAME_MAX_STR_LEN);
            return MMI_TRUE;
        }
    }

    return MMI_FALSE;
}
#endif /* defined(__MMI_IDLE_SCREEN_OWNER_NUMBER__) */


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_get_extra_indication_for_line2_string
 * DESCRIPTION
 *  This function gets the extra infomation string instead of spn for specific UE.
 * PARAMETERS
 *  sim                     : [IN]            SIM ID
 *  service_indication      : [OUT]           mmi_idle_service_indication_struct
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_idle_get_extra_indication_for_line2_string(
    mmi_sim_enum sim,
    mmi_idle_service_indication_struct *service_indication)

{
 /*----------------------------------------------------------------*/
 /* Local Variables                                                */
 /*----------------------------------------------------------------*/

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

    /*
      * Override 2nd line if there is other information required.
      */
#if 0
#if defined(__OP12__) && defined(__NBR_CELL_INFO__)
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif /* defined(__OP12__) */
#endif

#if defined(__HOMEZONE_SUPPORT__ )
     if (mmi_idle_get_homezone_string(sim,service_indication))
     {
         return;
     }
#endif /* defined(__HOMEZONE_SUPPORT__ ) */

#if defined(__MMI_IDLE_SCREEN_OWNER_NUMBER__)
     if (mmi_idle_get_owner_number_string(sim,service_indication))
     {
         return;
     }
#endif /* defined(__MMI_IDLE_SCREEN_OWNER_NUMBER__) */
}


#ifdef __MMI_TELEPHONY_SUPPORT__
/*****************************************************************************
 * FUNCTION
 *  mmi_idle_get_service_indication_string
 * DESCRIPTION
 *  This function gets the service indication string of the specified SIM in the idle.
 *  include special info , like homezone, cell info, owner number
 * PARAMETERS
 *  sim                     : [IN]            SIM ID
 *  service_indication      : [OUT]           mmi_idle_service_indication_struct
 * RETURNS

 *  void
 *****************************************************************************/
void mmi_idle_get_service_indication_string(
    mmi_sim_enum sim,
    mmi_idle_service_indication_struct *service_indication)

{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_nw_name_service_indication_struct tmp_indication;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    srv_nw_name_get_service_indication_string(sim, &tmp_indication);

    mmi_wcsncpy(service_indication->line1, tmp_indication.line1, MMI_IDLE_NW_NAME_MAX_STR_LEN);
    mmi_wcsncpy(service_indication->line2, tmp_indication.line2, MMI_IDLE_NW_NAME_MAX_STR_LEN);

    /*
     * Override 2nd line if there is other information required.
     */
    mmi_idle_get_extra_indication_for_line2_string(sim, service_indication);
}


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_update_service_indication_context
 * DESCRIPTION
 *  This function updates service indication of idle context
 * PARAMETERS
 *  obj             : [IN]              Object
 * RETURNS
 *  void
 *****************************************************************************/
void mmi_idle_update_service_indication_context(mmi_idle_obj_struct *obj)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_idle_service_indication_struct *service_indication;
    S32 i;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_ASSERT(obj);

    for (i = 0; i < MMI_SIM_TOTAL; i++)
    {
        service_indication = mmi_idle_get_service_indication_context(obj, mmi_frm_index_to_sim(i));
        mmi_idle_get_service_indication_string(mmi_frm_index_to_sim(i), service_indication);
    }
}
#endif


/*****************************************************************************
 * FUNCTION
 *  mmi_idle_get_service_indication_context
 * DESCRIPTION
 *  This function gets the context of the service string.
 * PARAMETERS
 *  obj                 : [IN]              Object
 *  sim                 : [IN]              SIM ID
 * RETURNS
 *  void
 *****************************************************************************/
mmi_idle_service_indication_struct *mmi_idle_get_service_indication_context(
    mmi_idle_obj_struct *obj,
    mmi_sim_enum sim)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    return &(obj->service_indication[mmi_frm_sim_to_index(sim)]);
}