FileMgrInstance.c 102 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
 *
 * Filename:
 * ---------
 *
 *
 * Project:
 * --------
 *  MAUI
 *
 * Description:
 * ------------
 *
 *
 * Author:
 * -------
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * 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!!
 *============================================================================
 ****************************************************************************/
#define _FMGR_INTERNAL_SOURCE_C_
/****************************************************************************
* Include Files                                                                
*****************************************************************************/
#include "MMI_features.h"

#if defined (__MMI_FILE_MANAGER__)
#include "FileMgrGProt.h"
#include "FileMgrProt.h"
#include "FileMgrInstance.h"

#include "FileMgrResDef.h"

#include "FileMgrMain.h"
#include "FileMgrService.h"
#include "FileMgrFSData.h"
#include "FileMgrGUI.h"

#ifdef __DRM_SUPPORT__                
#include "RightsMgrGProt.h"
#endif

#include "USBSrvGprot.h"

#include "Conversions.h"
#include "PhoneSetupGprots.h"

#ifdef __MMI_VUI_MEDIAWALL__
#include "MediaWall\vadp_mediawall.h"
#endif /* __MMI_VUI_MEDIAWALL__ */

#include "MMIDataType.h"
#include "kal_general_types.h"
#include "string.h"
#include "MMI_common_app_trc.h"
#include "DebugInitDef_Int.h"
#include "kal_trace.h"
#include "mmi_common_app_trc.h"
#include "kal_public_api.h"
#include "mmi_res_range_def.h"
#include "mmi_frm_scenario_gprot.h"
#include "mmi_frm_mem_gprot.h"
#include "wgui_categories_fmgr.h"
#include "mmi_rp_file_type_def.h"
#include "mmi_rp_app_filemanager_def.h"
#include "fs_errcode.h"
#include "Unicodexdcl.h"
#include "FileMgrSrvGProt.h"
#include "gui_typedef.h"
#include "wgui_include.h"
#include "wgui_categories_util.h"
#include "GlobalResDef.h"
#include "wgui_touch_screen.h"
#include "wgui_categories.h"
#include "mmi_frm_history_gprot.h"
#include "fs_type.h"
#include "GlobalConstants.h"
#include "mmi_frm_input_gprot.h"
#include "mmi_frm_events_gprot.h"
#include "CommonScreensResDef.h"
#include "wgui_categories_list.h"
#include "fs_func.h"
#include "mmi_rp_srv_filemanager_def.h"
#include "FileMgrType.h"
#include "AlertScreen.h"
#include "ScreenRotationGprot.h"
#include "CustDataRes.h"
#include "gui_data_types.h"
#ifdef __MMI_NCENTER_SUPPORT__
#include "vapp_ncenter_gprot.h"
#endif
/****************************************************************************
* Define
*****************************************************************************/

/****************************************************************************
* Global Variable
*****************************************************************************/

extern mmi_fmgr_context_struct* fmgr_p;

extern const mmi_fmgri_instance_callback_table_struct cui_storage_selector_handler_table;
extern const mmi_fmgri_instance_callback_table_struct cui_file_selector_handler_table;
extern const mmi_fmgri_instance_callback_table_struct cui_folder_selector_handler_table;
extern const mmi_fmgri_instance_callback_table_struct cui_folder_browser_handler_table;
#ifdef __FMGR_FILE_OPTION_CUI__
extern const mmi_fmgri_instance_callback_table_struct cui_file_option_handler_table;
#endif
/****************************************************************************
* Static Variable
*****************************************************************************/

const static mmi_fmgri_instance_callback_table_struct* fmgr_instance_type_table[MMI_FMGR_TYPE_NUM] = 
{
    NULL
    ,&mmi_fmgri_main_table
#ifdef __FMGR_STORAGE_SELECTOR_CUI__
    ,&cui_storage_selector_handler_table
#endif
    ,&cui_file_selector_handler_table
    ,&cui_folder_selector_handler_table
    ,&cui_folder_browser_handler_table
#ifdef __FMGR_FILE_OPTION_CUI__
    ,&cui_file_option_handler_table
#endif
#ifdef __DRM_V02__
    ,&mmi_fmgri_serv_archive_table      /* Archive viewer */
#endif /* __DRM_V02__ */
#ifdef __MMI_FMGR_MULTI_SELECT_SUPPORT__
    ,&mmi_fmgri_serv_multi_select_table /* Multi select */
#endif /* __MMI_FMGR_MULTI_SELECT_SUPPORT__ */

};

/****************************************************************************
* Function Forward Declaration
*****************************************************************************/

static mmi_ret fmgr_explorer_group_proc(mmi_event_struct *param);

static void fmgr_general_highlight_hdlr(S32 index);
static MMI_BOOL fmgr_general_notify_event_hdlr(mmi_fmgr_instance_struct *instance, S32 event, U32 data);
static void fmgr_general_register_key_hdlr(mmi_fmgr_instance_struct *instance);
static void fmgr_general_refresh(mmi_fmgr_instance_struct* instance, S32 new_index);

static S32  fmgr_general_find_file_index(mmi_fmgr_instance_struct* instance, S8* filename);

static void fmgr_general_entry_explorer_internel(mmi_fmgr_instance_struct *instance, U8 *guiBuffer, BOOL small_screen);

#define END_OF_FUNCTION_DECLARATION

/****************************************************************************
* Function Body
*****************************************************************************/

void mmi_fmgri_instance_init(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    fmgr_p->instance_num = 0;
    memset(&(fmgr_p->instance_list), 0, sizeof(fmgr_p->instance_list));
#if defined(__DRM_V02__) || defined __MMI_FMGR_MULTI_SELECT_SUPPORT__ 
    fmgr_p->id_mark_counter = 0;
#endif
}

mmi_fmgr_instance_struct* mmi_fmgri_instance_create(mmi_id owner, mmi_fmgri_type_enum type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgri_instance_notify_creation_struct notify;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    /* notify created */
    notify.owner = owner;
    notify.type = type;
    mmi_fmgri_instance_notify_all(FMGRI_EVENT_INSTANCE_CREATING, (U32)&notify);
    return mmi_fmgri_instance_create_ex(owner, type);
}

mmi_fmgr_instance_struct* mmi_fmgri_instance_create_ex(mmi_id owner, mmi_fmgri_type_enum type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 i;
    mmi_id grp_id;

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

    if(fmgr_p->instance_num == MMI_FMGR_INSTANCE_MAX_NUM)
    {
        FMGR_TRACE0(TRC_MMI_FMGR_E01C58A093D94C22AAA53DE8B8272472, "Fmgr > Instance > Create fail, no free slot!\n");
        // no more instance
#if (MMI_FMGR_INSTANCE_MAX_NUM == 1)
        /* if MAX == 1, means re-entry is not suppoted 
         *  Can re-entry not supported in NEW design????
         */
        // TODO: If re-entry is not suppored, maybe we need to remove previous FMGR
        return NULL;
#else
        return NULL;
#endif
    }

    for(i=0; i<MMI_FMGR_INSTANCE_MAX_NUM; i++)
    {
        if(fmgr_p->instance_list[i].id == 0)
        {
            break;
        }
    }

    if(i == MMI_FMGR_INSTANCE_MAX_NUM)
    {
        FMGR_ASSERT(0);  // Instance list & num are out of sync.
        return NULL;
    }
#if defined(__DRM_V02__) || defined __MMI_FMGR_MULTI_SELECT_SUPPORT__ 
    fmgr_p->instance_id_mark[i] = fmgr_p->id_mark_counter+1;
    fmgr_p->id_mark_counter++;
    if(fmgr_p->id_mark_counter == 0)
        fmgr_p->id_mark_counter++;
#endif

    memset(&(fmgr_p->instance_list[i]), 0, sizeof(fmgr_p->instance_list[i]));
    fmgr_p->instance_list[i].id = i+1;
    fmgr_p->instance_list[i].type = type;
    fmgr_p->instance_list[i].app_id = APP_FILEMANAGER;
    fmgr_p->instance_num++;
#if defined(__DRM_V02__) || defined __MMI_FMGR_MULTI_SELECT_SUPPORT__
    FMGR_TRACE3(TRC_MMI_FMGR_715EFB6379E54817B0A39935A997767C, "Fmgr > Instance > Create ok, id=%d(%d), type=%d\n", i+1, fmgr_p->instance_id_mark[i], type);
#else
    FMGR_TRACE3(TRC_MMI_FMGR_715EFB6379E54817B0A39935A997767C, "Fmgr > Instance > Create ok, id=%d(%d), type=%d\n", i+1, 0, type);
#endif
    /* create group here */
    grp_id = mmi_fmgri_instance_get_screen_id((U8)(i+1));
    ASSERT(!mmi_frm_group_is_present(grp_id) && mmi_frm_group_get_active_id() != grp_id);
    
    grp_id = mmi_frm_group_create(owner, grp_id, 
        fmgr_explorer_group_proc, (void*)&(fmgr_p->instance_list[i]));

    /* set caller automatically */
    mmi_frm_group_set_caller(grp_id, owner);

    return &(fmgr_p->instance_list[i]);
}

void mmi_fmgri_instance_release(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    if(!instance || 
        instance->id == 0 ||
        instance->id > MMI_FMGR_INSTANCE_MAX_NUM ||
        instance != &(fmgr_p->instance_list[instance->id-1]))
    {
        FMGR_ASSERT(0);
    }

    // clean up
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
    if(instance->delay_event)
    {
        OslMfree(instance->delay_event);
        instance->delay_event = NULL;
    }

    if(fmgr_p->search_instance_id == instance->id)
    {
        SET_UCS2STR_EMPTY(fmgr_p->search_filename);
        fmgr_p->search_instance_id = 0;
    }

    FMGR_TRACE2(TRC_MMI_FMGR_B0655D893877438081E6058B30DC76FC, "Fmgr > Instance > Release ok, id=%d, type=%d\n", instance->id, instance->type);
#if defined(__DRM_V02__) || defined __MMI_FMGR_MULTI_SELECT_SUPPORT__
    fmgr_p->instance_id_mark[instance->id-1] = 0;
#endif
    instance->id = 0;
    fmgr_p->instance_num--;
    
}

MMI_BOOL mmi_fmgri_is_instance_id_valid(U8 id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if ((id == 0) || 
        (id > MMI_FMGR_INSTANCE_MAX_NUM) ||
        (fmgr_p->instance_list[id-1].id == 0))
    {
        return MMI_FALSE;
    }
    return MMI_TRUE;
}

MMI_BOOL mmi_fmgri_is_screen_id_valid(U16 screen_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    if (screen_id < SCR_ID_FMGR_EXPLORER_BASE || screen_id > SCR_ID_FMGR_EXPLORER_END)
    {
        return MMI_FALSE;
    }
    return mmi_fmgri_is_instance_id_valid((U8)(screen_id + 1 - SCR_ID_FMGR_EXPLORER_BASE));
}

static mmi_fmgr_instance_struct* fmgr_get_instance_by_id(S32 id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    FMGR_ASSERT(mmi_fmgri_is_instance_id_valid((U8)id));
    return &(fmgr_p->instance_list[id-1]);
}

void mmi_fmgri_instance_get_filepath_and_filter(U8 instance_id, S8 **filepath_pp, FMGR_FILTER *filter_p)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;

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

    instance = fmgr_get_instance_by_id(instance_id);

    if (filepath_pp)
    {
        *filepath_pp = instance->file_path;
    }

    if (filter_p)
    {
        *filter_p = instance->filter_type;
    }
}

#ifndef __MMI_SLIM_FILE_MANAGER__
U8 mmi_fmgri_instance_get_arrow_type(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = fmgr_get_instance_by_id(instance_id);
    return instance->arrow_type;
}
#endif
S32  mmi_fmgri_instance_get_cur_index(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    return fmgr_get_instance_by_id(instance_id)->cur_index;
}

BOOL mmi_fmgri_instance_get_title_info(U8 instance_id, U16* string_id, U16* icon_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;

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

    /* Default value */
    if (string_id)
    {
        *string_id = 0;
    }

    if (icon_id)
    {
        *icon_id = 0;
    }

    instance = fmgr_get_instance_by_id(instance_id);

    /* Use (app_id) setting */
    mmi_fmgr_get_app_title_info(instance->app_id, string_id, icon_id, instance->file_path);

    /* Use (special) setting */
#ifdef __FMGR_CUSTOM_ROOT_SUPPORT__
    if (instance->flag & FMGR_IFLAG_CUSTOM_ROOT)
    {
        mmi_fmgr_get_app_title_info(APP_MYFAVORITE, string_id, icon_id, instance->file_path);
    }
#endif /* __FMGR_CUSTOM_ROOT_SUPPORT__ */

#ifdef FMGR_TAB_SUPPORT
    if (instance->tab_id && string_id)
    {
        *string_id = mmi_fmgri_table_tab_get_title(instance->tab_id, 
        mmi_fmgri_table_tab_get_index(instance->tab_id, (WCHAR*)instance->file_path));
    }
#endif /* FMGR_TAB_SUPPORT */

    /* Use (instance) setting */
    if (string_id && instance->title_str_id)
    {
        *string_id = instance->title_str_id;
    }

    if (icon_id && instance->title_icon_id)
    {
        *icon_id = instance->title_icon_id;
    }

    /* Final default value */
    if (string_id && *string_id == 0)
    {
        *string_id = STR_FMGR_TITLE;
    }    

    return MMI_FALSE;
}

U16  mmi_fmgri_instance_get_list_style(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = fmgr_get_instance_by_id(instance_id);

    return instance->display_type;
}

U16  mmi_fmgri_instance_get_screen_id(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    return SCR_ID_FMGR_EXPLORER_BASE + instance_id-1;
}

#ifndef __MMI_ULTRA_SLIM_FILE_MANAGER__
S32  mmi_fmgri_instance_get_display_str(U8 instance_id, S8 *display_str_buff, S32 buff_len)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;
    S8* filename;
    S32 len;
    FMGR_FILE_INFO_STRUCT   file_info;
    S8                      do_chset;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = mmi_fmgri_get_instance_by_id(instance_id);

    display_str_buff[0] = display_str_buff[1] = 0;

    /* hardcode: Only FMGR has display string */
    if(instance->type != MMI_FMGR_TYPE_APP)
        return FS_INVALID_FILENAME;
    
    if(mmi_ucs2strlen(instance->file_path)==3)
    {
        srv_fmgr_drv_get_name(instance->file_path[0], (WCHAR*)display_str_buff, (U8)buff_len);
    }
    else
    {
        filename = (S8*)srv_fmgr_path_get_filename_ptr((WCHAR*)instance->file_path);
        if(filename)
        {
            /* check if this is short name */
            do_chset = FALSE;
            len = mmi_ucs2strlen(filename);
            if(len <= 12)
            {
                mmi_fmgr_get_file_info_by_path(instance->file_path, &file_info);
                if(file_info.is_short)
                    do_chset = TRUE;
            }

            if(do_chset)
            {
                memset(display_str_buff, 0, buff_len * ENCODING_LENGTH);
                mmi_chset_mixed_text_to_ucs2_str(
                    (U8*) display_str_buff,
                    (S16)((buff_len - 1) * ENCODING_LENGTH),
                    (U8*) filename,
                    (mmi_chset_enum)PhnsetGetDefEncodingType());                
            }
            else
            {
                mmi_ucs2ncpy(display_str_buff, filename, (U32)buff_len);
            }
            
            len = mmi_ucs2strlen(display_str_buff) - 1;
            if(display_str_buff[len*ENCODING_LENGTH] == '\\' &&
                display_str_buff[len*ENCODING_LENGTH+1] == 0)
            {
                display_str_buff[len*ENCODING_LENGTH] = 0;
            }
        }        
        else
            return FS_INVALID_FILENAME;
    }
    
    return FS_NO_ERROR;
}
#endif  /* __MMI_ULTRA_SLIM_FILE_MANAGER__ */
#ifndef __MMI_ULTRA_SLIM_FILE_MANAGER__
MMI_BOOL mmi_fmgri_instance_accept_empty_folder()
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    return MMI_TRUE;
}
#endif
U8 mmi_fmgri_get_active_instance_id(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* i;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    i = mmi_fmgri_get_active_instance();
    if (i)
    {
        return i->id;
    }
    return 0;
}

mmi_fmgr_instance_struct* mmi_fmgri_get_active_instance(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_id grp_id;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    grp_id = mmi_frm_group_get_active_id();
    FMGR_ASSERT(mmi_fmgri_is_screen_id_valid(grp_id));
    
    return (mmi_fmgr_instance_struct*)mmi_frm_group_get_user_data(grp_id);
}

mmi_fmgr_instance_struct* mmi_fmgri_get_instance_by_id(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    return fmgr_get_instance_by_id(instance_id);
}


#if defined(__DRM_V02__) || defined __MMI_FMGR_MULTI_SELECT_SUPPORT__
U32 mmi_fmgri_instance_get_export_id(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    FMGR_ASSERT(fmgr_p->instance_id_mark[instance->id-1]);

    return ((U32)fmgr_p->instance_id_mark[instance->id-1] << 8) | (U32)instance->id;
}

//mick todo
mmi_fmgr_instance_struct* mmi_fmgri_instance_get_instance_by_export_id(U32 exported_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U32 id, mark;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    id = exported_id & 0xFF;
    mark = (exported_id >> 8) & 0xFFFF;
    if (mmi_fmgri_is_instance_id_valid((U8)id) && mark == fmgr_p->instance_id_mark[id-1])
    {
        return fmgr_get_instance_by_id(id);
    }
    return NULL;
}
#endif     /* #if defined(__DRM_V02__) || defined __MMI_FMGR_MULTI_SELECT_SUPPORT__ */


#ifdef __FMGR_HYPERLINK_SUPPORT__
S32  mmi_fmgri_instance_get_hyperlink_count(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;
    S32 count;

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

    if (instance_id == 0)
    {
        return 0;
    }

    instance = fmgr_get_instance_by_id(instance_id);

    if ((fmgr_instance_type_table[instance->type]) &&
        (fmgr_instance_type_table[instance->type]->hyperlink_cb) &&
        (fmgr_instance_type_table[instance->type]->hyperlink_cb(instance, FMGR_HYPERLINK_GET_COUNT, 0, &count)))
    {
        return count;
    }
    else
    {
        return 0;
    }
}

MMI_BOOL mmi_fmgri_instance_get_hyperlink_info(U8 instance_id, S32 index, mmi_fmgr_hyperlink_info_struct* info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;

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

    if (instance_id == 0)
    {
        return MMI_FALSE;
    }

    instance = fmgr_get_instance_by_id(instance_id);

    if ((fmgr_instance_type_table[instance->type]) &&
        (fmgr_instance_type_table[instance->type]->hyperlink_cb) &&
        (fmgr_instance_type_table[instance->type]->hyperlink_cb(instance, FMGR_HYPERLINK_GET_INFO, index, (S32*)info)))
    {
        return MMI_TRUE;
    }
    else
    {
        return MMI_FALSE;
    }
}

void mmi_fmgri_instance_prepare_hyperlink(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;

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

    if(instance_id == 0)
        return;
    instance = fmgr_get_instance_by_id(instance_id);

    if(fmgr_instance_type_table[instance->type] &&
        fmgr_instance_type_table[instance->type]->hyperlink_cb)
    {
        fmgr_instance_type_table[instance->type]->hyperlink_cb(instance, FMGR_HYPERLINK_PREPARE, 0, NULL);
    }

}
#endif

mmi_ret mmi_fmgr_notify_hdlr(mmi_event_struct *param)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgri_instance_notify_app_info_struct app_notify;

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

    if (param->evt_id == EVT_ID_SRV_FMGR_NOTIFICATION_ADV_ACTION)
    {
        app_notify.notify_flag = param->evt_id;
        app_notify.notify_data = param;
        if (!mmi_fmgri_instance_notify_all(FMGRI_EVENT_APP_NOTIFY, (U32)&app_notify))
        {
            return MMI_RET_ERR;
        }
    }
    else if (param->evt_id == EVT_ID_SRV_FMGR_NOTIFICATION_DEV_PLUG_OUT)
    {
        mmi_fmgri_instance_notify_all(FMGRI_EVENT_DRIVE_UNMOUNT, (U32)param);
    }
    else if (param->evt_id == EVT_ID_SRV_FMGR_NOTIFICATION_DEV_PLUG_IN)
    {
        mmi_fmgri_instance_notify_all(FMGRI_EVENT_DRIVE_MOUNT, (U32)param);
    }

    return MMI_RET_OK;
}

MMI_BOOL mmi_fmgri_instance_notify_all(mmi_fmgri_instance_notify_event_enum event, U32 data)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 i;
    MMI_BOOL b_ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    b_ret = MMI_TRUE;
    for (i = 0; i < MMI_FMGR_INSTANCE_MAX_NUM; i++)
    {
        if (fmgr_p->instance_list[i].id)
        {
            if (fmgr_general_notify_event_hdlr(&(fmgr_p->instance_list[i]), (S32)event, data) == MMI_FALSE)
            {
                b_ret = MMI_FALSE;
            }
        }
    }
    return b_ret;
}

extern MMI_BOOL mmi_fmgri_instance_execute_command(U8 instance_id, S32 cmd, S32 para, void* data)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct    *instance;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = mmi_fmgri_get_instance_by_id(instance_id);

    if (fmgr_instance_type_table[instance->type] &&
        fmgr_instance_type_table[instance->type]->cust_cmd_cb)
    {
        return (MMI_BOOL)fmgr_instance_type_table[instance->type]->cust_cmd_cb(instance, cmd, para, data);
    }
    return MMI_FALSE;
}

#define GENERAL_API

static void fmgr_general_highlight_hdlr(S32 index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_id grp_id;    
    mmi_fmgr_instance_struct    *instance;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    /* First we need to know which instance we are at. */
    grp_id = mmi_frm_group_get_active_id();
    if (mmi_fmgri_is_screen_id_valid(grp_id))
    {
        instance = mmi_fmgri_get_active_instance();

        /* Change current index */
        instance->cur_index = index;

        if(fmgr_instance_type_table[instance->type] &&
            fmgr_instance_type_table[instance->type]->highlight_cb)
        {
            fmgr_instance_type_table[instance->type]->highlight_cb(instance, index);
        }
#ifndef __MMI_WGUI_DISABLE_CSK__
#ifdef __FMGR_KEY_RULE__
        if (!(instance->key_binding & MMI_FMGRI_KEY_CSK) &&
            !get_softkey_label(MMI_CENTER_SOFTKEY) &&
            !get_softkey_icon(MMI_CENTER_SOFTKEY) &&
            get_softkey_label(MMI_LEFT_SOFTKEY))
        {
            ChangeCenterSoftkey(0, IMG_GLOBAL_COMMON_CSK);
        }
#endif /* __FMGR_KEY_RULE__ */
#endif

        /* Re-register keys */
        fmgr_general_register_key_hdlr(instance);
    }
}

static void fmgr_general_key_event_hdlr(mmi_fmgr_instance_struct *instance, S32 event, S32 param)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 translated_event;
    mmi_ret result;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    translated_event = event;
    
    switch(event)
    {
#ifdef __MMI_TOUCH_SCREEN__
    case FMGRI_EVENT_TOUCH_CLICK:
        if(instance->key_binding & MMI_FMGRI_KEY_TOUCH) /* no translate */
            break;
        
#ifdef __FMGR_FTE_MENU_INTERACT_SUPPORT__
        if(param == ENUM_TAP_ON_HIGHLIGHTED_ITEM)
            translated_event = FMGRI_EVENT_DEF_CMD;
        else
            return;
#else
        translated_event = FMGRI_EVENT_LSK;
#endif
        break;
#endif

    case FMGRI_EVENT_CSK:
        if(instance->key_binding & MMI_FMGRI_KEY_CSK)   /* no translate */
            break;

#ifdef __FMGR_KEY_RULE__
        translated_event = FMGRI_EVENT_DEF_CMD;
#else
        translated_event = FMGRI_EVENT_LSK;
#endif
        break;
    }
    
    switch(translated_event)
    {
    case FMGRI_EVENT_LSK:
    case FMGRI_EVENT_LEFT_ARROW:
        /* if LSK has no label, means the keys is auto-disabled */
        if(!get_softkey_label(MMI_LEFT_SOFTKEY))
        {
            return;
        }
        break;
    }

    FMGR_TRACE2(TRC_MMI_FMGR_BF071504A65643039188C76B4FF45EE8, "Fmgr > General > Key > id=%d, ev=0x%08X\n", instance->id, translated_event);
    
    if(fmgr_instance_type_table[instance->type] &&
        fmgr_instance_type_table[instance->type]->key_event_cb)
    {
        FMGR_PERF_START(fmgr_general_key_event_hdlr, translated_event);
        result = fmgr_instance_type_table[instance->type]->key_event_cb(instance, translated_event);
        FMGR_PERF_END(fmgr_general_key_event_hdlr);

#ifdef __FMGR_FTE_MENU_INTERACT_SUPPORT__
        if( result != MMI_RET_OK && 
            event == FMGRI_EVENT_TOUCH_CLICK && 
            translated_event == FMGRI_EVENT_DEF_CMD && 
            wgui_category_if_pop_option_menu())
        {
            /* special case, for FTE intuitive cmd is disabled, display options instead */
            fmgr_general_key_event_hdlr(instance, FMGRI_EVENT_LSK, 0);
        }
#endif        
#ifdef __FMGR_KEY_RULE__
        if (result != MMI_RET_OK && 
            event == FMGRI_EVENT_CSK && 
            translated_event == FMGRI_EVENT_DEF_CMD)
        {
            fmgr_general_key_event_hdlr(instance, FMGRI_EVENT_LSK, 0);
        }
#endif
    }
    
}

static MMI_BOOL fmgr_general_notify_event_hdlr(mmi_fmgr_instance_struct *instance, S32 event, U32 data)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
	MMI_BOOL									end_is_slash = MMI_FALSE;
    mmi_fmgri_instance_notify_app_info_struct   *app_notify;
    srv_fmgr_notification_adv_action_event_struct *srv_fmgr_event;
    srv_fmgr_notification_action_enum           action;
    const S8                                    *path;
    S32                                         pathlen;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    FMGR_TRACE3(TRC_MMI_FMGR_1AD330868A114A5D8B608F66C9F7A6A3, 
        "Fmgr > General > Notify > id=%d, ev=0x%08X, data=%d\n", instance->id, event, data);

    switch (event)
    {
        case FMGRI_EVENT_SCREEN_DELETING:
            /* The API will be phased out by FW team, so to remove it here */
            break;

        case FMGRI_EVENT_APP_NOTIFY:
            /* MMI_FMGR_NOTIFY_PRE_MOVE and MMI_FMGR_NOTIFY_PRE_DELETE are removed */
#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 !*/
#endif            
            app_notify = (mmi_fmgri_instance_notify_app_info_struct*)data;
            if (app_notify->notify_flag == EVT_ID_SRV_FMGR_NOTIFICATION_ADV_ACTION)
            {
                srv_fmgr_event = (srv_fmgr_notification_adv_action_event_struct*)app_notify->notify_data;
                action = srv_fmgr_event->action;                
                if (srv_fmgr_event->state == SRV_FMGR_NOTIFICATION_STATE_QUERY &&
                    action != SRV_FMGR_NOTIFICATION_ACTION_COPY &&
                    action != SRV_FMGR_NOTIFICATION_ACTION_CREATE_FOLDER)
                {
                    path = (const S8*)srv_fmgr_event->src_filepath;
                    pathlen = mmi_ucs2strlen(path);
                    if ((path[(pathlen-1)*ENCODING_LENGTH] == '\\') &&
                        (path[(pathlen-1)*ENCODING_LENGTH+1] == 0))
                    {
						end_is_slash = MMI_TRUE;
                        pathlen--;
                    }

                    if (action == SRV_FMGR_NOTIFICATION_ACTION_DELETE_ALL)
                    {
                        if ((mmi_ucs2ncmp(instance->file_path, path, pathlen) == 0) &&
                            (instance->file_path[pathlen*ENCODING_LENGTH] == '\\') &&
                            (instance->file_path[pathlen*ENCODING_LENGTH+1] == 0))
                        {
                            if (end_is_slash)
							{
								pathlen++;
								end_is_slash = MMI_FALSE;
							}
							
                            if (mmi_ucs2strlen(instance->file_path) > pathlen)
                            {
                                return MMI_FALSE;
                            }
                        }
                    }
                    else
                    {
                        S8* buffer = mmi_fmgri_get_and_lock_buffer();
                        S8* buffer2 = mmi_fmgri_get_and_lock_buffer(); 
                        mmi_ucs2ncpy(buffer, instance->file_path, SRV_FMGR_PATH_MAX_LEN + 1);
                        mmi_ucs2lwr(buffer);
                        mmi_ucs2ncpy(buffer2, path, SRV_FMGR_PATH_MAX_LEN + 1);
                        mmi_ucs2lwr(buffer2);
                        if ((mmi_ucs2ncmp(buffer, buffer2, pathlen) == 0) &&
                            (instance->file_path[pathlen*ENCODING_LENGTH] == '\\') &&
                            (instance->file_path[pathlen*ENCODING_LENGTH+1] == 0))
                        {
                            mmi_fmgri_free_and_unlock_buffer(buffer);
                            mmi_fmgri_free_and_unlock_buffer(buffer2);
                            return MMI_FALSE;
                        }

                        mmi_fmgri_free_and_unlock_buffer(buffer);
                        mmi_fmgri_free_and_unlock_buffer(buffer2);
#if defined (__MMI_FMGR_FOLDER_COPY_SUPPORT__)
                        /* If user would like to delete a folder which user selected to copy/move */
                        if (instance->type == MMI_FMGR_TYPE_APP
#ifdef __MMI_FMGR_MULTI_SELECT_SUPPORT__
							|| instance->type == MMI_FMGR_TYPE_SEL_FILE_MUlTI
#endif
							)
                        {
                            if (!mmi_fmgri_main_can_modify_folder(instance, path))
                            {
                                return MMI_FALSE;
                            }
                        }
#endif                        
                    }
                }
            }
            break;
    }
    
    if ((fmgr_instance_type_table[instance->type]) &&
        (fmgr_instance_type_table[instance->type]->notify_event_cb))
    {
        fmgr_instance_type_table[instance->type]->notify_event_cb(instance, event, data);
    }

    switch (event)
    {
        case FMGRI_EVENT_SCREEN_DELETING:
            /* Cancel sorting */
            mmi_fmgri_fsdata_instance_release_load(instance->id);
            /* Free instance */
            mmi_fmgri_instance_release(instance);
            break;
    }

    return MMI_TRUE;
}


static BOOL fmgr_general_error_handler(mmi_fmgr_instance_struct *instance, S32 error)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    FMGR_TRACE2(TRC_MMI_FMGR_5C377CEA4AAD41D793471C0965495ADC, "Fmgr > General > Error > id=%d, err=%d\n", instance->id, error);

    if(fmgr_instance_type_table[instance->type] &&
        fmgr_instance_type_table[instance->type]->error_cb)
    {
        return fmgr_instance_type_table[instance->type]->error_cb(instance, error);
    }
    
    return TRUE;
}

static void fmgr_general_lsk_hdlr(void)         { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_LSK, 0); }
static void fmgr_general_rsk_hdlr(void)         { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_RSK, 0); }
#ifndef __FMGR_KEY_RULE__    
static void fmgr_general_right_key_hdlr(void)   { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_RIGHT_ARROW, 0); }
static void fmgr_general_left_key_hdlr(void)    { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_LEFT_ARROW, 0); }
#endif
#ifdef __MMI_TOUCH_SCREEN__
#ifdef __MMI_FTE_SUPPORT__
static void fmgr_general_tap_hdlr(mmi_tap_type_enum tap_type,S32 index)       { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_TOUCH_CLICK, tap_type); }
#else
static void fmgr_general_click_hdlr(void)       { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_TOUCH_CLICK, 0); }
#endif
#endif
static void fmgr_general_csk_hdlr(void)         { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_CSK, 0); }
static void fmgr_general_send_key_hdlr(void)    { fmgr_general_key_event_hdlr(mmi_fmgri_get_active_instance(), FMGRI_EVENT_SEND_KEY, 0); }

static void fmgr_general_register_key_hdlr(mmi_fmgr_instance_struct *instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
#ifndef __FMGR_KEY_RULE__ 
    U8  key_binding;
#endif

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    
    SetLeftSoftkeyFunction(fmgr_general_lsk_hdlr, KEY_EVENT_UP);
    SetRightSoftkeyFunction(fmgr_general_rsk_hdlr, KEY_EVENT_UP);

#ifdef __MMI_TOUCH_SCREEN__
#ifdef __MMI_FTE_SUPPORT__
    wgui_register_tap_callback(fmgr_general_tap_hdlr);
#else
    wgui_register_list_item_selected_callback(fmgr_general_click_hdlr);
#endif
#endif

#ifndef __FMGR_KEY_RULE__    
#ifdef FMGR_TAB_SUPPORT
    if(!instance->tab_id)
#endif
    {
        key_binding = mmi_fmgri_gui_query_display_type_key(instance->display_type);
        if(!(key_binding & CAT213_ARROW_LEFT))
            SetKeyHandler(fmgr_general_left_key_hdlr, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
        if(!(key_binding & CAT213_ARROW_RIGHT))
            SetKeyHandler(fmgr_general_right_key_hdlr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
    }
#endif

#ifdef __FMGR_KEY_RULE__    
    SetCenterSoftkeyFunction(fmgr_general_csk_hdlr, KEY_EVENT_UP);
    register_center_softkey_to_enter_key();
#else
    if(instance->key_binding & MMI_FMGRI_KEY_CSK)
    {
        SetKeyHandler(fmgr_general_csk_hdlr, KEY_ENTER, KEY_EVENT_UP);
        if(get_softkey_label(MMI_CENTER_SOFTKEY) || get_softkey_icon(MMI_CENTER_SOFTKEY))
        {
            SetCenterSoftkeyFunction(fmgr_general_csk_hdlr, KEY_EVENT_UP);
            register_center_softkey_to_enter_key();
        }
    }
    else
    {
        ClearKeyHandler(KEY_ENTER, KEY_EVENT_UP);
        ClearKeyHandler(KEY_ENTER, KEY_EVENT_DOWN);
    }
#endif    

    if(instance->key_binding & MMI_FMGRI_KEY_SEND)
    {
        SetKeyDownHandler(fmgr_general_send_key_hdlr, KEY_SEND);
    }
}

static S32 fmgr_async_load_rsp_callback(U8 instance_id, S32 result, S32 search_index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;

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

    instance = mmi_fmgri_get_instance_by_id(instance_id);

    if (mmi_frm_group_get_active_id() != mmi_fmgri_instance_get_screen_id(instance->id))
    {
        if(result <= 0)
        {
            mmi_fmgri_fsdata_instance_release_load(instance->id);
        }
        return 0;
    }

    if(result < 0)
    {
        /* Error case */
#ifdef FMGR_TAB_SUPPORT
		if (result == FS_FILE_NOT_FOUND)
		{
			mmi_fmgri_fsdata_instance_release_load(instance->id);
            mmi_fmgri_fsdata_instance_load_empty_data(instance->id);
            mmi_fmgri_instance_general_refresh(instance);
		}
		else
#endif
        if(fmgr_general_error_handler(instance, result))
        {
            mmi_fmgri_fsdata_instance_release_load(instance->id);
            mmi_fmgri_fsdata_instance_load_empty_data(instance->id);
            mmi_fmgri_instance_general_refresh(instance);
        }
        return 0;
    }

    /* Enter real explorer */
    if (search_index != -1)
    {
        fmgr_general_refresh(instance, search_index);
    }
    else
    {
        mmi_fmgri_instance_general_refresh(instance);
    }
    return 0;

}

static S32 fmgr_async_load_progress_callback(U8 instance_id, S32 total_count, S32 progress_count)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;

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

    instance = mmi_fmgri_get_instance_by_id(instance_id);

    if (mmi_frm_group_get_active_id() != mmi_fmgri_instance_get_screen_id(instance->id))
    {
        return 0;
    }

    /* Update progress bar */
    mmi_fmgri_gui_update_progress(instance->id, (U32)progress_count, (U32)total_count);

    return 0;
}

static void fmgr_async_load_cancel_hdlr(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    fmgr_general_error_handler(mmi_fmgri_get_active_instance(), MMI_FMGR_ERROR_LOADING_CANCEL);
    
    /* Stop repeatedly cancel case */
    ClearKeyEvents();
}

static void fmgr_general_refresh(mmi_fmgr_instance_struct* instance, S32 new_index)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    FMGR_TRACE3(TRC_MMI_FMGR_F3C49440FE8D4257AA68EDAF99823BEC, "Fmgr > General > Refresh > id=%d, new_idx=%d, path=<%S>\n",
        instance->id, new_index, instance->file_path);
    
    if (new_index >= 0)
    {
        instance->dirty_level |= FMGRI_DIRTY_CHANGE_INDEX;
        instance->cur_index = new_index;
    }
    else if (new_index == FMGRI_INSTANCE_INDEX_TO_FIRST_POS)
    {
        instance->dirty_level |= (FMGRI_DIRTY_CHANGE_INDEX | FMGRI_DIRTY_RESET_TO_FIRST_INDEX);
        instance->cur_index = 0;
    }

    if (mmi_frm_group_get_active_id() == mmi_fmgri_instance_get_screen_id(instance->id) &&
        mmi_frm_scrn_get_active_id() == mmi_fmgri_instance_get_screen_id(instance->id))
    {
        mmi_frm_scrn_enter(mmi_fmgri_instance_get_screen_id(instance->id), SCR_ID_FMGR_GENERAL_DUMMY, NULL, (FuncPtr)mmi_frm_display_dummy_screen_ex, MMI_FRM_FG_ONLY_SCRN);
        mmi_frm_scrn_close(mmi_fmgri_instance_get_screen_id(instance->id), SCR_ID_FMGR_GENERAL_DUMMY);
    }
}

static mmi_ret fmgr_explorer_group_proc(mmi_event_struct *param)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;
    mmi_ret result;
    mmi_event_struct* delay_event;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = (mmi_fmgr_instance_struct*)param->user_data;

    if (fmgr_instance_type_table[instance->type] &&
        fmgr_instance_type_table[instance->type]->event_proc_cb)
    {
        result = fmgr_instance_type_table[instance->type]->event_proc_cb(instance, param);
        if (result != MMI_RET_OK)
        {
            return result;
        }
    }
    
    switch (param->evt_id)
    {
        case EVT_ID_GROUP_ACTIVE:
            break;
        case EVT_ID_GROUP_INACTIVE:
            FMGR_TRACE1(TRC_MMI_FMGR_90DC41707E094229959ABFA55404ABB1, "Fmgr > General > Explorer (%d) > Exit + Add history\n", instance->id);
            break;
        case EVT_ID_GROUP_DEINIT:
            fmgr_general_notify_event_hdlr(instance, FMGRI_EVENT_SCREEN_DELETING, 0);
            break;

        /* Popup handler */
        case EVT_ID_POPUP_QUIT:
            if (instance->flag & FMGR_IFLAG_WAIT_POPUP)
            {
                instance->flag &= ~FMGR_IFLAG_WAIT_POPUP;

                /* Post and clear delayed event */
                if (instance->delay_event)
                {
                    delay_event = instance->delay_event;
                    instance->delay_event = NULL;

                    mmi_frm_group_send_to_caller(mmi_fmgri_instance_get_screen_id(instance->id), 
                        (mmi_group_event_struct*)delay_event);

                    /* Instance may be free after send event */
                    OslMfree(delay_event);
                }
            }
            break;
    #ifdef __MMI_NCENTER_SUPPORT__
        case EVT_ID_VAPP_NCENTER_DRAG:
    	  {
              MMI_ASSERT(instance != NULL);
    	      if (instance->is_disable_ncenter)
    	      {
    	      	 return MMI_RET_ERR;
    	      }
    	  }
		  break;
    #endif
    }

    return MMI_RET_OK;
}

#ifdef FMGR_TAB_SUPPORT

static void fmgr_tab_page_exit(mmi_scrn_essential_struct* scr_info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;

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

    FMGR_ASSERT(mmi_fmgri_is_screen_id_valid(scr_info->group_id));

    instance = mmi_frm_group_get_user_data(scr_info->group_id);

    if (instance)
    {
        fmgr_general_notify_event_hdlr(instance, FMGRI_EVENT_SCREEN_EXIT, 0);
    }
}

static void fmgr_tab_page_entry(mmi_scrn_essential_struct* scr_info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;
    S32 curr_tab_index, new_tab_index;
    S32 fs_ret;
    S8  *buffer;
    BOOL small_screen_flag;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    FMGR_TRACE3(TRC_MMI_FMGR_COMMON_3,
        "[MMIFMGR] > %d > %d > %d\n", __LINE__, scr_info->group_id, scr_info->scrn_id);

    instance = (mmi_fmgr_instance_struct*)mmi_frm_group_get_user_data(scr_info->group_id);
    new_tab_index = (S32)scr_info->scrn_id - SCR_ID_FMGR_TAB_BASE;

    FMGR_ASSERT(instance->tab_id);

    curr_tab_index = mmi_fmgri_table_tab_get_index(instance->tab_id, (WCHAR*)instance->file_path);

    if (curr_tab_index != new_tab_index)
    {
        buffer = mmi_fmgri_get_and_lock_buffer();
        mmi_fmgri_table_tab_get_path(instance->tab_id, new_tab_index, (WCHAR*)buffer, (SRV_FMGR_PATH_MAX_LEN + 1) * ENCODING_LENGTH);
        fs_ret = srv_fmgr_fs_create_folder((const WCHAR*)buffer);   
        
        mmi_fmgri_instance_general_update_path(instance, buffer);
        mmi_fmgri_free_and_unlock_buffer(buffer);
        mmi_fmgri_fsdata_instance_release_load(instance->id);
        mmi_fmgri_instance_general_refresh(instance);
        
    }
    else
    {
        small_screen_flag = (BOOL)mmi_is_redrawing_bk_screens();
    
        mmi_frm_scrn_enter(scr_info->group_id, (mmi_id)(SCR_ID_FMGR_TAB_BASE + new_tab_index), 
            (FuncPtr)fmgr_tab_page_exit, (FuncPtr)fmgr_tab_page_entry, MMI_FRM_TAB_PAGE);

        SetKeyHandler(mmi_frm_general_tab_l_arrow_key_hdlr, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
        SetKeyHandler(mmi_frm_general_tab_r_arrow_key_hdlr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
        
        fmgr_general_entry_explorer_internel(instance, 
            mmi_frm_scrn_tab_page_get_active_gui_buf(),
            small_screen_flag);
    }
}
#endif

static void fmgr_general_exit_explorer(mmi_scrn_essential_struct* info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = (mmi_fmgr_instance_struct*)mmi_frm_group_get_user_data(info->group_id);
    fmgr_general_notify_event_hdlr(instance, FMGRI_EVENT_SCREEN_EXIT, 0);
}

static void fmgr_general_entry_explorer(mmi_scrn_essential_struct* info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;
    U16 explorer_id;
    BOOL small_screen_flag;
#ifdef FMGR_TAB_SUPPORT
    mmi_frm_tab_struct *tab_ptr;
    mmi_frm_tab_struct tab_pages_info[FMGR_MAX_TAB_COUNT];
    S32 i, tab_count;
#endif /* FMGR_TAB_SUPPORT */

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

    FMGR_PERF_START(fmgr_general_entry_explorer, 0);

    /* First we need to know which instance we focus now */
    instance = (mmi_fmgr_instance_struct*)mmi_frm_group_get_user_data(info->group_id);
	
    explorer_id = info->group_id;
    
    FMGR_TRACE2(TRC_MMI_FMGR_9840D8A9CCD24E5F8CE0AE0F24482CF7, "Fmgr > General > Explorer (%d) > Entry path<%S>\n", instance->id, instance->file_path);

    small_screen_flag = (BOOL)mmi_is_redrawing_bk_screens();

#ifdef FMGR_TAB_SUPPORT
    if (instance->tab_id)
    {
        tab_count = mmi_fmgri_table_tab_get_count(instance->tab_id);

        FMGR_ASSERT(tab_count <= FMGR_MAX_TAB_COUNT);

        for (i = 0; i < tab_count; i++)
        {
            tab_ptr = &tab_pages_info[i];
            tab_ptr->screen_id = SCR_ID_FMGR_TAB_BASE + i;
            tab_ptr->tab_entry_func = (FuncPtr)fmgr_tab_page_entry;
            tab_ptr->tab_icon = get_image(mmi_fmgri_table_tab_get_icon(instance->tab_id, i));
            tab_ptr->tab_string = NULL;
        }

        i = mmi_fmgri_table_tab_get_index(instance->tab_id, (WCHAR*)instance->file_path);

        mmi_frm_scrn_tab_change_page_items(explorer_id, explorer_id, tab_pages_info, (U8)tab_count);

        FMGR_TRACE3(TRC_MMI_FMGR_COMMON_3, "[MMIFMGR] > %d > %d > %d\n", __LINE__, explorer_id, i);

        mmi_frm_scrn_tab_enter(explorer_id, explorer_id, NULL, (FuncPtr)fmgr_general_entry_explorer, tab_pages_info, (U8)tab_count, (U8)i);

        FMGR_TRACE3(TRC_MMI_FMGR_COMMON_3, "[MMIFMGR] > %d > %d > %d\n", __LINE__, explorer_id, i);

        return;
    }
    else
#endif /* FMGR_TAB_SUPPORT */
    {
        /* Entry screen */
        if(!mmi_frm_scrn_enter(explorer_id, explorer_id, (FuncPtr)fmgr_general_exit_explorer, (FuncPtr)fmgr_general_entry_explorer, MMI_FRM_UNKNOW_SCRN))
        {			              
            return;
        }

        fmgr_general_entry_explorer_internel(instance, mmi_frm_scrn_get_active_gui_buf(), small_screen_flag);
    }

}

static void fmgr_general_entry_explorer_internel(mmi_fmgr_instance_struct *instance, U8 *guiBuffer, BOOL small_screen)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 result, idx;

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

    /* Dead, act as dummy */
    if (instance->flag & FMGR_IFLAG_DEAD)
    {
        FMGR_TRACE2(TRC_MMI_FMGR_5C377CEA4AAD41D793471C0965495ADC, 
            "Fmgr > General > Error > id=%d, err=%d\n", instance->id, __LINE__);
        return;
    }

    /* Highlight handler */
    RegisterHighlightHandler(fmgr_general_highlight_hdlr);

#ifdef __USB_IN_NORMAL_MODE__
    /* Check is in mass storage mode */
    if (srv_usb_is_in_mass_storage_mode())
    {
        if (!fmgr_general_error_handler(instance, MMI_FMGR_ERROR_USB_MODE))
        {
            FMGR_PERF_END(fmgr_general_entry_explorer);
            return;
        }
    }
#endif /* __USB_IN_NORMAL_MODE__ */

#ifdef __FMGR_HYPERLINK_SUPPORT__
    /* Prepare hyperlink data */
    mmi_fmgri_instance_prepare_hyperlink(instance->id);
#endif /* __FMGR_HYPERLINK_SUPPORT__ */

    /* Reload data */
    result = mmi_fmgri_fsdata_instance_load_data_async(instance->id,
        fmgr_async_load_rsp_callback,
        fmgr_async_load_progress_callback,
        (fmgr_p->search_instance_id == instance->id && 
        (fmgr_p->search_filename[0]||fmgr_p->search_filename[1])) ? fmgr_p->search_filename : NULL);

    /* Reset search */
    if (fmgr_p->search_instance_id == instance->id)
    {
        if (result > 0 && !CHECK_UCS2STR_EMPTY(fmgr_p->search_filename))
        {
            idx = fmgr_general_find_file_index(instance, fmgr_p->search_filename);
            if (idx >= 0)
            {
                instance->cur_index = idx;
                guiBuffer = NULL;
            }
        }
        
        SET_UCS2STR_EMPTY(fmgr_p->search_filename);
        fmgr_p->search_instance_id = 0;
    }

    if (result == SRV_FMGR_FILELIST_ERROR_FILE_NOT_READY)
    {
        /* Show please wait screen */
        mmi_fmgri_gui_display_progress(instance->id, guiBuffer);
    #ifdef FMGR_TAB_SUPPORT
        if (instance->tab_id)
        {
            ClearKeyHandler(KEY_LEFT_ARROW, KEY_EVENT_DOWN);
            ClearKeyHandler(KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
        }
    #endif /* FMGR_TAB_SUPPORT */
        SetRightSoftkeyFunction(fmgr_async_load_cancel_hdlr, KEY_EVENT_UP);
        FMGR_PERF_END(fmgr_general_entry_explorer);
        return;
    }
    else if (result < 0)
    {
        /* FS error */
        if (!fmgr_general_error_handler(instance, result))
        {
            FMGR_PERF_END(fmgr_general_entry_explorer);
            return;
        }
        result = 0;
    }
    else if (result == 0)
    {
        /* Empty case */
        if (!fmgr_general_error_handler(instance, MMI_FMGR_ERROR_EMPTY))
        {
            FMGR_PERF_END(fmgr_general_entry_explorer);
            return;
        }
    }

    /* Double check current index */
    if (result > 0)
    {
        if (instance->cur_index >= result)   /* Out of range */
        {
            instance->cur_index = result - 1;
            guiBuffer = NULL;
        }
        else if (instance->cur_index < 0)   /* No highlight */
        {
            instance->cur_index = 0;
            guiBuffer = NULL;
        }
    }
    else
    {
        instance->cur_index = -1;           /* Empty */
        guiBuffer = NULL;
    }

    if (instance->dirty_level & FMGRI_DIRTY_RESET_TO_FIRST_INDEX)
    {
        if (instance->cur_index == 0)
        {
        #ifdef __FMGR_HYPERLINK_SUPPORT__
            if (instance->type == MMI_FMGR_TYPE_APP)
            {
                /* Shift hyperlink count */
                instance->cur_index = mmi_fmgri_instance_get_hyperlink_count(instance->id);
                if (instance->cur_index >= result)
                {
                    instance->cur_index = 0;
                }
            }
        #endif /* __FMGR_HYPERLINK_SUPPORT__ */
        }
        instance->dirty_level &= ~FMGRI_DIRTY_RESET_TO_FIRST_INDEX;
    }

    /* GUI init */
    mmi_fmgri_gui_init();
    
    /* Notify screen entry */
    fmgr_general_notify_event_hdlr(instance, FMGRI_EVENT_SCREEN_ENTRY, result);

    /* Reset guiBuffer if necessary */
    if(instance->dirty_level & FMGRI_DIRTY_CHANGE_INDEX)
    {
        guiBuffer = NULL;
        instance->dirty_level &= ~FMGRI_DIRTY_CHANGE_INDEX;
    }

    /* ShowCategory */
    mmi_fmgri_gui_display_list(instance->id, result, guiBuffer);

    /* Empty case */
    if (result == 0)
    {
        fmgr_general_highlight_hdlr(-1);
    }

    /* Key event handler */
    fmgr_general_register_key_hdlr(instance);
    FMGR_PERF_END(fmgr_general_entry_explorer);
}

#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 !*/
#ifdef __MMI_SHOW_FILE_EXT__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#else
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/* under construction !*/
/* under construction !*/
#endif

static S32 fmgr_general_find_file_index(mmi_fmgr_instance_struct* instance, S8* filename)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 index;
    SRV_FMGR_DRVLIST_HANDLE drvlist_hdl;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (mmi_ucs2cmp(instance->file_path, (S8*)SRV_FMGR_PATH_ROOT) == 0)
    {
    #ifdef __FMGR_CUSTOM_ROOT_SUPPORT__
        if (instance->flag & FMGR_IFLAG_CUSTOM_ROOT)
        {
            index = mmi_fmgri_table_cr_get_index((U16*)filename,
                    (S8)(instance->type == MMI_FMGR_TYPE_APP ? MMI_FALSE : MMI_TRUE),
                    MMI_TRUE, instance->drv_type);
            if (index >= 0)
            {
                return index;
            }
        }
    #endif /* __FMGR_CUSTOM_ROOT_SUPPORT__ */

        drvlist_hdl = srv_fmgr_drivelist_create((srv_fmgr_drivelist_type_enum)instance->drv_type);
        index = srv_fmgr_drivelist_get_index_by_drv_letter(drvlist_hdl, (U8)filename[0]);
        srv_fmgr_drivelist_destroy(drvlist_hdl);

        if (index != -1)
        {
            return index;
        }
    }

    return FMGRI_INSTANCE_INDEX_NOT_CHANGE; /* Not found */
}

#define EXPORT_API

void mmi_fmgri_instance_general_entry_explorer(mmi_fmgr_instance_struct* instance, S8* default_highlight_filename)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U16 explorer_id;

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

    mmi_frm_group_enter(mmi_fmgri_instance_get_screen_id(instance->id), MMI_FRM_NODE_SMART_CLOSE_FLAG);

    /* Special display type */
    if(instance->display_type == FMGRI_DISPLAY_TYPE_NO_LIST)
    {
        return;
    }
	
    if(default_highlight_filename)
    {
        mmi_fmgri_instance_general_set_search_filename(instance, default_highlight_filename);
    }

    explorer_id = mmi_fmgri_instance_get_screen_id(instance->id);

    mmi_frm_scrn_first_enter(explorer_id, explorer_id, (FuncPtr)fmgr_general_entry_explorer, (void*)instance->id);
}

MMI_BOOL mmi_fmgri_instance_general_enter_folder(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 old_index;
    FMGR_FILE_INFO_STRUCT file_info;
    S32 length;
    fmgr_drive_info_struct *drv_info;
#ifdef __FMGR_CUSTOM_ROOT_SUPPORT__
    S32 fs_ret;
#endif /* __FMGR_CUSTOM_ROOT_SUPPORT__ */
#ifndef __MMI_ULTRA_SLIM_FILE_MANAGER__    
    FMGR_FILTER filter;
#endif

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

    old_index = instance->cur_index;
    length = mmi_ucs2strlen(instance->file_path);
    
    /* retrieve current file information */
    mmi_fmgri_fsdata_instance_get_file_info(instance->id, old_index, &file_info);
    
    if (mmi_ucs2cmp((S8*)SRV_FMGR_PATH_ROOT, instance->file_path) == 0)
    {
        drv_info = (fmgr_drive_info_struct*)&file_info;

    #ifdef __FMGR_CUSTOM_ROOT_SUPPORT__
        if (drv_info->drv_type == FMGR_LINK_FOLDER)
        {
            fs_ret = srv_fmgr_fs_create_folder((WCHAR *)drv_info->drv_path);
            if (fs_ret < 0 && (FS_GetDevStatus(drv_info->drv_path[0], FS_MOUNT_STATE_ENUM) == FS_NO_ERROR))
            {
                FMGR_DisplayPopup(srv_fmgr_fs_error_get_string(fs_ret), MMI_EVENT_FAILURE);
                return MMI_FALSE;
            }
        }
    #endif /* __FMGR_CUSTOM_ROOT_SUPPORT__ */

        mmi_ucs2cpy(instance->file_path, (S8*)drv_info->drv_path);
    #ifdef FMGR_TAB_SUPPORT
        instance->tab_id = drv_info->tab_id;
    #endif /* FMGR_TAB_SUPPORT */
#ifndef __MMI_ULTRA_SLIM_FILE_MANAGER__ 
        /* If it is empty folder, back to root */
        FMGR_FILTER_INIT(&filter);
        FMGR_FILTER_SET_ALL(&filter);
        if ((mmi_fmgri_instance_accept_empty_folder() == MMI_FALSE)
            && (srv_fmgr_fs_path_is_not_empty((WCHAR *)instance->file_path, &filter) == 0)
        #ifdef __FMGR_HYPERLINK_SUPPORT__
            && (mmi_fmgri_instance_get_hyperlink_count(instance->id) == 0)
        #endif /* __FMGR_HYPERLINK_SUPPORT__ */
            )
        {
            FMGR2_DisplayPopup(instance, STR_GLOBAL_EMPTY, MMI_EVENT_FAILURE);
            mmi_ucs2cpy(instance->file_path, (S8*)SRV_FMGR_PATH_ROOT);
        #ifdef FMGR_TAB_SUPPORT
            instance->tab_id = 0;
        #endif /* FMGR_TAB_SUPPORT */
            return MMI_FALSE;
        }
#endif
    }
    else
    {
        /* Folder changed, prepare for new path */
        if (mmi_fmgri_filepath_compose((S8*)instance->file_path,
                (SRV_FMGR_PATH_MAX_LEN + 1),
                (S8*)instance->file_path,
                &file_info,
                MMI_TRUE) == MMI_FALSE)
        {
            FMGR2_DisplayPopup(instance, FMGR_FS_PATH_OVER_LEN_ERROR_TEXT, MMI_EVENT_FAILURE);
            return MMI_FALSE;
        }
#ifndef __MMI_ULTRA_SLIM_FILE_MANAGER__         
        /* If it is empty folder, back to upper level */
        FMGR_FILTER_INIT(&filter);
        FMGR_FILTER_SET_ALL(&filter);
        if ((srv_fmgr_fs_path_is_not_empty((WCHAR *)instance->file_path, &filter) == 0) &&
        #ifdef __FMGR_HYPERLINK_SUPPORT__
            (mmi_fmgri_instance_get_hyperlink_count(instance->id) == 0) &&
        #endif /* __FMGR_HYPERLINK_SUPPORT__ */
            (mmi_fmgri_instance_accept_empty_folder() == MMI_FALSE))
        {
            FMGR2_DisplayPopup(instance, STR_GLOBAL_EMPTY, MMI_EVENT_FAILURE);
            mmi_fmgri_filepath_go_up_level(instance->file_path);
            return MMI_FALSE;
        }
#endif  
    }
    
    FMGR_TRACE3(TRC_MMI_FMGR_0FA1B539B9E34AACAE21B7004CC090AB,
        "[MMIFMGR] > Instance > Enter folder > old_len=%d, new_len=%d, old_index=%d\n", length, mmi_ucs2strlen(instance->file_path), old_index);

    /* Release fsdata */
    mmi_fmgri_fsdata_instance_release_load(instance->id);
    
    /* Refresh screen */
    fmgr_general_refresh(instance, FMGRI_INSTANCE_INDEX_TO_FIRST_POS);
    return MMI_TRUE;
}

MMI_BOOL mmi_fmgri_instance_general_leave_folder(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 new_index, length;
    S8  *ptr;
    U16 *filename; 
    MMI_BOOL ret = MMI_FALSE;

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

    /* Retrieve current file information */
    new_index = FMGRI_INSTANCE_INDEX_NOT_CHANGE;
    filename = NULL;

#ifdef __FMGR_CUSTOM_ROOT_SUPPORT__
    if (instance->flag & FMGR_IFLAG_CUSTOM_ROOT)
    {
    #ifdef FMGR_TAB_SUPPORT
        if (instance->tab_id)
        {
            new_index = mmi_fmgri_table_tab_get_root_index(instance->tab_id,
                            (WCHAR*)instance->file_path,
                            instance->drv_type,
                            (S8)(instance->type == MMI_FMGR_TYPE_APP ? MMI_FALSE : MMI_TRUE),
                            MMI_TRUE);
            if (new_index < 0)
            {
                new_index = FMGRI_INSTANCE_INDEX_NOT_CHANGE;
            }
        }
    #endif /* FMGR_TAB_SUPPORT */

        if (new_index == FMGRI_INSTANCE_INDEX_NOT_CHANGE)
        {
            new_index = mmi_fmgri_table_cr_get_index((U16*)instance->file_path,
                            (S8)(instance->type == MMI_FMGR_TYPE_APP ? MMI_FALSE : MMI_TRUE),
                            MMI_TRUE, instance->drv_type);
            if (new_index < 0)
            {
                new_index = FMGRI_INSTANCE_INDEX_NOT_CHANGE;
            }
        }
        
        if (new_index != FMGRI_INSTANCE_INDEX_NOT_CHANGE)
        {
            /* Found, back to root */
            length = mmi_ucs2strlen(instance->file_path);
            mmi_fmgri_instance_general_update_path(instance, (S8*)SRV_FMGR_PATH_ROOT);

            FMGR_TRACE3(TRC_MMI_FMGR_FCC22F0274674271A80A65DA1140B08B,
                "[MMIFMGR] > Instance > Leave folder > old_len=%d, new_len=%d, new_index=%d\n", length, mmi_ucs2strlen(instance->file_path), new_index);

            mmi_fmgri_fsdata_instance_release_load(instance->id);
            fmgr_general_refresh(instance, new_index);
            return MMI_TRUE;
        }
    }
#endif /* __FMGR_CUSTOM_ROOT_SUPPORT__ */

    /* Store the file_name to query later */
    ptr = (S8 *)srv_fmgr_path_get_filename_ptr((WCHAR *)instance->file_path);
    if (!ptr)
    {
        ptr = instance->file_path;
    }

    length = mmi_ucs2strlen(ptr);
    filename = OslMalloc((length + 1) * ENCODING_LENGTH);
    mmi_ucs2cpy((S8*)filename, ptr);

    /* Remove slash */
    srv_fmgr_path_remove_slash(filename);

    length = mmi_ucs2strlen(instance->file_path);

    if (mmi_fmgri_filepath_go_up_level(instance->file_path))
    {
        new_index = fmgr_general_find_file_index(instance, (S8*)filename);

        /* Still cannot find, we have to find it when loading */
        if (new_index == FMGRI_INSTANCE_INDEX_NOT_CHANGE)
        {
            mmi_fmgri_instance_general_set_search_filename(instance, (S8*)filename);
            new_index = FMGRI_INSTANCE_INDEX_TO_FIRST_POS;
        }
        
        FMGR_TRACE3(TRC_MMI_FMGR_FCC22F0274674271A80A65DA1140B08B,
            "[MMIFMGR] > Instance > Leave folder > old_len=%d, new_len=%d, new_index=%d\n", length, mmi_ucs2strlen(instance->file_path), new_index);

        /* Release fsdata */
        mmi_fmgri_fsdata_instance_release_load(instance->id);
        
        /* Refresh screen */
        fmgr_general_refresh(instance, new_index);
        ret = MMI_TRUE;
        
    }
    else
    {
        FMGR_TRACE3(TRC_MMI_FMGR_FCC22F0274674271A80A65DA1140B08B,
            "[MMIFMGR] > Instance > Leave folder > old_len=%d, new_len=%d, new_index=%d\n", length, mmi_ucs2strlen(instance->file_path), new_index);
    }

    /* Free memory */
    OslMfree(filename);
    return ret;
}

void mmi_fmgri_instance_general_update_path(mmi_fmgr_instance_struct* instance, const S8* new_path)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

#ifdef FMGR_TAB_SUPPORT
    if(mmi_ucs2cmp(new_path, (S8*)SRV_FMGR_PATH_ROOT) == 0)
    {
        instance->tab_id = 0;
    }
#endif /* FMGR_TAB_SUPPORT */

    mmi_ucs2ncpy(instance->file_path, new_path, SRV_FMGR_PATH_MAX_LEN);
    mmi_fmgri_instance_general_reset_index(instance);
}

void mmi_fmgri_instance_general_back_to_root(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 index, new_index;
    SRV_FMGR_DRVLIST_HANDLE drvlist_hdl;

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

    if (mmi_ucs2cmp(instance->file_path, (S8*)SRV_FMGR_PATH_ROOT) == 0)
    {
        return;
    }

    new_index = FMGRI_INSTANCE_INDEX_NOT_CHANGE;

#ifdef __FMGR_CUSTOM_ROOT_SUPPORT__
    if (instance->flag & FMGR_IFLAG_CUSTOM_ROOT)
    {
    #ifdef FMGR_TAB_SUPPORT
        if(instance->tab_id)
        {
            new_index = mmi_fmgri_table_tab_get_root_index(instance->tab_id, 
                                    (WCHAR*)instance->file_path,
                                    instance->drv_type,
                                    (S8)(instance->type == MMI_FMGR_TYPE_APP ? MMI_FALSE : MMI_TRUE),
                                    MMI_TRUE);
            if (new_index < 0)
            {
                new_index = FMGRI_INSTANCE_INDEX_NOT_CHANGE;
            }
        }
    #endif /* FMGR_TAB_SUPPORT */
        if (new_index == FMGRI_INSTANCE_INDEX_NOT_CHANGE)
        {
            new_index = mmi_fmgri_table_cr_get_index((U16*)instance->file_path,
                                    (S8)(instance->type == MMI_FMGR_TYPE_APP ? MMI_FALSE : MMI_TRUE),
                                    MMI_FALSE, instance->drv_type);
            if(new_index < 0)
            {
                new_index = FMGRI_INSTANCE_INDEX_NOT_CHANGE;
            }
        }
    }
    else
#endif /* __FMGR_CUSTOM_ROOT_SUPPORT__ */
    {
        drvlist_hdl = srv_fmgr_drivelist_create((srv_fmgr_drivelist_type_enum)instance->drv_type);
        index = srv_fmgr_drivelist_get_index_by_drv_letter(drvlist_hdl, (U8)instance->file_path[0]);
        srv_fmgr_drivelist_destroy(drvlist_hdl);

        if (index != -1)
        {
            new_index = index;
        }
    }

#ifdef FMGR_TAB_SUPPORT
    instance->tab_id = 0;
#endif /* FMGR_TAB_SUPPORT */
    mmi_ucs2cpy(instance->file_path, (S8*)SRV_FMGR_PATH_ROOT);
    fmgr_general_refresh(instance, new_index);

}

void mmi_fmgri_instance_general_reset_index(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    /* Move selection to first */
    instance->cur_index = 0;
    instance->dirty_level |= (FMGRI_DIRTY_CHANGE_INDEX | FMGRI_DIRTY_RESET_TO_FIRST_INDEX);
}

void mmi_fmgri_instance_general_refresh(mmi_fmgr_instance_struct* instance)
{
    fmgr_general_refresh(instance, FMGRI_INSTANCE_INDEX_NOT_CHANGE);
}

void mmi_fmgri_instance_general_refresh_by_id(U8 instance_id, S32 index)
{
    if(mmi_fmgri_is_instance_id_valid(instance_id))
    {
        fmgr_general_refresh(mmi_fmgri_get_instance_by_id(instance_id), index);
    }
}

S32 mmi_fmgri_instance_general_option_handler(U16 opt_menu_id, U16 menu_id, U32 data, U16 keyCode)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct* instance;
    FMGR_FILE_INFO_STRUCT file_info;
    mmi_fmgr_filetype_enum file_type;
    S8 *buffer;
    S32 fwd_menu_id;

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

    if (menu_id == 0)
    {
        return -1;
    }

    instance = mmi_fmgri_get_instance_by_id((U8)data);
    mmi_fmgri_fsdata_instance_get_file_info(instance->id, instance->cur_index, &file_info);

    switch (menu_id)
    {
        case MENU_ID_FMGR_GEN_OPTION_FORWARD_USE:
        case MENU_ID_FMGR_GEN_OPTION_FORWARD_SEND:
            buffer = mmi_fmgri_get_and_lock_buffer();
            if (!mmi_fmgri_filepath_compose(buffer, (SRV_FMGR_PATH_MAX_LEN + 1),
                      instance->file_path, &file_info, MMI_FALSE))
            {
                FMGR2_DisplayPopup(instance, FMGR_FS_PATH_OVER_LEN_ERROR_TEXT, MMI_EVENT_FAILURE);
                mmi_fmgri_free_and_unlock_buffer(buffer);
                break;
            }

            file_type = srv_fmgr_types_get_main_type(&file_info.file_type);

            if (menu_id == MENU_ID_FMGR_GEN_OPTION_FORWARD_USE)
            {
                fwd_menu_id = srv_fmgr_types_get_use_option_menu(file_type, (WCHAR*)buffer);
            }
            else
            {
                fwd_menu_id = srv_fmgr_types_get_send_option_menu(file_type, (WCHAR*)buffer);
            }

            mmi_fmgri_free_and_unlock_buffer(buffer);
        
            if (fwd_menu_id == 0)
            {
                FMGR2_DisplayPopup(instance, STR_ID_FMGR_NO_FORWARD_OPTION, MMI_EVENT_FAILURE);
                break;
            }
            else if (fwd_menu_id < 0)
            {
                FMGR2_DisplayPopup(instance, srv_fmgr_fs_error_get_string(fwd_menu_id), MMI_EVENT_FAILURE);
                break;
            }
            return fwd_menu_id;
	
        case MENU_ID_FMGR_GEN_OPTION_DETAIL:
            mmi_fmgri_main_detail(instance);
            mmi_fmgri_close_option(opt_menu_id, instance->id);
            break;
        case MENU_ID_FMGR_GEN_OPTION_RENAME:
            mmi_fmgri_main_rename(instance);
            mmi_fmgri_close_option(opt_menu_id, instance->id);
            break;
        case MENU_ID_FMGR_GEN_OPTION_DELETE:
            mmi_fmgri_main_delete_single(instance);            
            mmi_fmgri_close_option(opt_menu_id, instance->id);
            break;
#if !defined(__MMI_SLIM_FILE_MANAGER__)||defined(__TOPWELL_MMI_FM_SUPPORT_DELETE_ALL__)
        case MENU_ID_FMGR_GEN_OPTION_DELETE_ALL:
            mmi_fmgri_main_delete_all(instance);
            mmi_fmgri_close_option(opt_menu_id, instance->id);
            break;
#endif
        case MENU_ID_FMGR_GEN_OPTION_COPY:
            mmi_fmgri_main_copy(instance);
            mmi_fmgri_close_option(opt_menu_id, instance->id);
            break;
        case MENU_ID_FMGR_GEN_OPTION_MOVE:
            mmi_fmgri_main_move(instance);
            mmi_fmgri_close_option(opt_menu_id, instance->id);
            break;
    #ifdef __FS_SORT_SUPPORT__
        case MENU_ID_FMGR_GEN_OPTION_SORT:
            break;
    #endif /* __FS_SORT_SUPPORT__ */
	#if 0
    #ifdef __MMI_FMGR_MULTI_SELECT_SUPPORT__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
    #endif /* __MMI_FMGR_MULTI_SELECT_SUPPORT__ */
	#endif
    default:
        return -1;
    }

    return 0;
}

void mmi_fmgri_instance_general_set_search_filename(mmi_fmgr_instance_struct* instance, S8* search_name)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 len;

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

    /* Multi search may cause highlight wrong, but not fatal */
    if ((fmgr_p->search_instance_id) && (fmgr_p->search_instance_id != instance->id))
    {
        FMGR_TRACE2(TRC_MMI_FMGR_1FAF6A25FBF74982BACF2505BA889C76,   
            "[MMIFMGR] > Instance > mmi_fmgri_instance_general_set_search_filename > %d ow by %d\n",
            fmgr_p->search_instance_id, instance->id);
    }

    if (search_name)
    {
        len = mmi_ucs2strlen(search_name);
        if (len)
        {
            mmi_ucs2ncpy(fmgr_p->search_filename, (S8*)search_name, SRV_FMGR_PATH_MAX_FILE_NAME_LEN);
            len--;

            if ((fmgr_p->search_filename[len * ENCODING_LENGTH] == '\\') &&
                (fmgr_p->search_filename[len * ENCODING_LENGTH + 1] == 0))
            {
                fmgr_p->search_filename[len*ENCODING_LENGTH] = 0;
            }

            fmgr_p->search_instance_id = instance->id;
        }
    }
}

void mmi_fmgri_instance_general_close(mmi_fmgr_instance_struct* instance)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    if(mmi_fmgri_is_instance_id_valid(instance->id))
        mmi_frm_group_close(mmi_fmgri_instance_get_screen_id(instance->id));
}

#ifdef __DM_LAWMO_SUPPORT__	
void mmi_fmgri_instance_general_close_by_id(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if(mmi_fmgri_is_instance_id_valid(instance_id))
        mmi_frm_group_close(mmi_fmgri_instance_get_screen_id(instance_id));
}
#endif

#ifdef __FMGR_CUSTOM_ROOT_SUPPORT__

S32 mmi_fmgri_instance_cr_get_count(U8 instance_id, SRV_FMGR_DRVLIST_HANDLE drvlist_hdl)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;
    S8 exclude_item;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    instance = fmgr_get_instance_by_id(instance_id);
    if (!(instance->flag & FMGR_IFLAG_CUSTOM_ROOT))
    {
        return MMI_FMGR_ERROR_INVALID_PARAM;
    }
    exclude_item = (instance->type == MMI_FMGR_TYPE_APP) ? MMI_FALSE : MMI_TRUE;
    return mmi_fmgri_table_cr_get_count(drvlist_hdl, exclude_item);
}

S32 mmi_fmgri_instance_cr_get_info(U8 instance_id, SRV_FMGR_DRVLIST_HANDLE drvlist_hdl, S32 index, fmgr_drive_info_struct* info)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct *instance;
    S8 exclude_item;

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

    instance = fmgr_get_instance_by_id(instance_id);

    if(!(instance->flag & FMGR_IFLAG_CUSTOM_ROOT))
    {
        return MMI_FMGR_ERROR_INVALID_PARAM;
    }

    exclude_item = (instance->type == MMI_FMGR_TYPE_APP) ? FALSE : TRUE;
    
    if(mmi_fmgri_table_cr_get_info(drvlist_hdl, index, info, exclude_item))
    {
        return 0;
    }

    return MMI_FMGR_ERROR_INVALID_PARAM;
}

#ifdef FMGR_TAB_SUPPORT

S32  mmi_fmgri_instance_cr_tab_get_index(U8 instance_id)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_fmgr_instance_struct    *instance;

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

    instance = fmgr_get_instance_by_id(instance_id);

    if (!instance->tab_id)
    {
        return -1;
    }

    return mmi_fmgri_table_tab_get_index(instance->tab_id, (WCHAR*)instance->file_path);
}

#endif // FMGR_TAB_SUPPORT


#endif // __FMGR_CUSTOM_ROOT_SUPPORT__

void mmi_fmgr_close_option_screen(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_id                      grp_id;
    mmi_fmgr_instance_struct    *instance;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    for(grp_id = SCR_ID_FMGR_EXPLORER_BASE;
        grp_id < SCR_ID_FMGR_EXPLORER_END;
        grp_id ++)
    {
        instance = (mmi_fmgr_instance_struct*)mmi_frm_group_get_user_data(grp_id);
        if(!instance)
            continue;
        if(instance->display_type == FMGRI_DISPLAY_TYPE_NO_LIST)
            continue;

        mmi_fmgri_close_options(instance->id);
    }
}

static MMI_BOOL mmi_fmgri_instance_prepare_popup_arg(mmi_fmgr_instance_struct* instance, mmi_popup_property_struct *arg)
{
    if (instance->flag & FMGR_IFLAG_WAIT_POPUP)
    {
        return MMI_FALSE;
    }

    mmi_popup_property_init(arg);
    arg->parent_id = mmi_fmgri_instance_get_screen_id(instance->id);
    arg->callback = NULL;
    arg->user_tag = NULL;	

#ifdef __MMI_VUI_MEDIAWALL__
    /* Set popup rotation type */
    if (vapp_mediawall_get_direction() == VADP_MEDIAWALL_LANDSCAPE)
    {
        if (mmi_fmgri_instance_get_list_style(instance->id) == FMGR_DISPLAY_TYPE_MATRIX)
        {
            arg->rotation = MMI_FRM_SCREEN_ROTATE_270;
        }
    }
    else
    {
        arg->rotation = MMI_FRM_SCREEN_ROTATE_0;
    }
#endif

    return MMI_TRUE;
}

MMI_BOOL mmi_fmgri_instance_display_popup(mmi_fmgr_instance_struct* instance, U16 string_id, mmi_event_notify_enum popup_type, U16 parent_id, MMI_BOOL is_pop_with_cb, S32 line)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_popup_property_struct arg;
    MMI_ID ret;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    FMGR_TRACE3(TRC_MMI_FMGR_DB003BC7CA7E4FB392E536175D1F39C2, "Fmgr > Popup > id=%d at <%d>:%d \n", string_id, 0, line);

    //mmi_fmgri_instance_display_popup_str(instance, GetString(string_id), popup_type, line);
    if(instance)
    {
        if (!mmi_fmgri_instance_prepare_popup_arg(instance, &arg))
        {
            return MMI_FALSE;
        }
    }
    else
    {
        mmi_popup_property_init(&arg);
        arg.parent_id = parent_id;
        arg.callback = NULL;
        arg.user_tag = NULL;
    }

    ret = mmi_popup_display((WCHAR*)GetString(string_id), popup_type, &arg);

    if(is_pop_with_cb)
    {
        if (ret != GRP_ID_INVALID)
        {
            instance->flag |= FMGR_IFLAG_WAIT_POPUP;
            return MMI_TRUE;
        }
        return MMI_FALSE;
    }
    return MMI_TRUE;
}

#ifdef __MMI_FMGR_MULTI_SELECT_SUPPORT__
MMI_BOOL mmi_fmgri_instance_display_popup_str(mmi_fmgr_instance_struct* instance, S8* string_ptr, mmi_event_notify_enum popup_type, S32 line)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    mmi_popup_property_struct arg;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    FMGR_TRACE3(TRC_MMI_FMGR_DB003BC7CA7E4FB392E536175D1F39C2, "Fmgr > Popup > id=%d at <%d>:%d \n", 0, 0, line);

    if (!mmi_fmgri_instance_prepare_popup_arg(instance, &arg))
    {
        return MMI_FALSE;
    }    

    mmi_popup_display((WCHAR*)string_ptr, popup_type, &arg);

    return MMI_TRUE;
}
#endif
#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 !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* 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

void mmi_fmgri_instance_post_event(mmi_fmgr_instance_struct* instance, mmi_event_struct* event_ptr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    if (instance->flag & FMGR_IFLAG_WAIT_POPUP)
    {
        FMGR_ASSERT(!instance->delay_event);
        instance->delay_event = OslMalloc(event_ptr->size);
        memcpy(instance->delay_event, event_ptr, event_ptr->size);
    }
    else
    {
        mmi_frm_group_post_to_caller(mmi_fmgri_instance_get_screen_id(instance->id), (mmi_group_event_struct*)event_ptr);
    }
}

#ifdef __FS_CARD2_SUPPORT__
MMI_BOOL mmi_fmgri_is_drv_card_2_type_by_path(const S8 *file_path)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    MMI_BOOL result = MMI_FALSE;
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    do {
        if (!file_path || file_path[0] == 0)
        {
            break;
        }

		if (mmi_ucs2cmp((PS8)file_path, (PS8)SRV_FMGR_PATH_ROOT) == 0)
		{
			/* This is root */
			break;
		}

        if (srv_fmgr_drv_get_type(file_path[0]) == SRV_FMGR_DRV_CARD_2_TYPE)
        {			
            result = MMI_TRUE;
            break;
        }
    } while(0);
    return result;
}
#endif
#endif // defined (__MMI_FILE_MANAGER__)