DLAgentSrvConfig.c 64 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
/*****************************************************************************
*  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!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

/****************************************************************************
* Include Files                                                                
*****************************************************************************/

#include "MMI_features.h"
#if defined (__MMI_DOWNLOAD_AGENT__)

//#include "CommonScreens.h"
//#include "ProtocolEvents.h"
#include "app_mine.h"
//#include "FileMgr.h"
//#include "FileManagerGProt.h"

#include "drm_def.h"                    /* DRM_PROC_RESULT_OK */
#include "DLAgentSrvDef.h"
#include "DLAgentSrvGprot.h"
#include "DLAgentSrvIProt.h"
#include "DLAgentSrvProt.h"
#ifdef __MMI_DOWNLOAD_AGENT__
#include "mmi_rp_srv_downloadagent_def.h"
#endif
#if defined(__MMI_VIDEO_PDL__) || defined(__MMI_VIDEO_STREAM__)
#ifdef __MMI_VIDEO_PLAYER__
#include "VdoPlyGProt.h"
#endif /*__MMI_VIDEO_PLAYER__*/
#endif 

#if defined(__MMI_VIDEO_PDL__) || defined(__MMI_AUDIO_PDL__) || defined(__MMI_MEDIA_PLAYER_STREAM__)
#ifdef __MMI_MEDIA_PLAYER__
#include "MediaPlayerGProt.h"
#endif /*__MMI_MEDIA_PLAYER__*/
#endif /*defined(__MMI_VIDEO_PDL__) || defined(__MMI_AUDIO_PDL__) || defined(__MMI_MEDIA_PLAYER_STREAM__)*/
#ifdef __COSMOS_MMI_PACKAGE__
#if defined(__MMI_VIDEO_PDL__) && (defined(__MMI_FTO_GALLERY__)|| defined(__MMI_GALLERY_SLIM__))
#include "vapp_gallery_gprot.h"
#endif
#endif

#ifdef __MMI_KURO_SUPPORT__
#include "MediaPlayerGProt.h"
#endif

#if defined (__MMI_SWFLASH__)
#include "SWFlashGProt.h"
#endif

#ifdef __MMI_SYNCML_SERVER_ALERT_SYNC_SUPPORT__
/* under construction !*/
#endif
#ifdef __MMI_BARCODEREADER__
#include "mmi_features_barcodereader.h"
#include "barcodereadergprot.h"
#endif

#ifdef __MMI_OP01_DCD__
#include "DCDGProt.h"
#endif

#include "ProvisioningSrvGprot.h"
#ifdef __MMI_PROVISIONING_SERVICE_SUPPORT__
#include "ProvisioningSrvMain.h"
#endif




    #include "MMIDataType.h"
	#include "GlobalResDef.h"
    #include "wgui.h"
    #include "FileMgrGProt.h"
    #include "mmi_rp_srv_downloadagent_def.h"
    #include "kal_general_types.h"
    #include "FileMgrType.h"
    #include "Unicodexdcl.h"
    #include "kal_public_api.h"
    #include "DebugInitDef_Int.h"
    #include "string.h"
    #include "MMI_conn_app_trc.h"
    #include "mmi_conn_app_trc.h"
    #include "kal_trace.h"
    #include "mmi_frm_mem_gprot.h"


#ifndef __COSMOS_MMI_PACKAGE__
#define MMI_DLA_DEFAULT_FOLDER_IMAGES    FMGR_DEFAULT_FOLDER_IMAGES
#define MMI_DLA_DEFAULT_FOLDER_AUDIOS    FMGR_DEFAULT_FOLDER_AUDIO
#define MMI_DLA_DEFAULT_FOLDER_VIDEOS    FMGR_DEFAULT_FOLDER_VIDEO
#define MMI_DLA_DEFAULT_FOLDER_EBOOKS    FMGR_DEFAULT_FOLDER_EBOOKS
#define MMI_DLA_DEFAULT_FOLDER_RECEIVED  FMGR_DEFAULT_FOLDER_RECEIVED
#define MMI_DLA_DEFAULT_FOLDER_MRE       L"Mre\\"
#else
#include "custom_mmi_folders_config.h"
#define MMI_DLA_DEFAULT_FOLDER_IMAGES    IMAGE_DOWNLOAD_FOLDER_NAME
#define MMI_DLA_DEFAULT_FOLDER_AUDIOS    AUDIO_DOWNLOAD_FOLDER_NAME
#define MMI_DLA_DEFAULT_FOLDER_VIDEOS    VIDEO_DOWNLOAD_FOLDER_NAME
#define MMI_DLA_DEFAULT_FOLDER_EBOOKS    EBOOK_DOWNLOAD_FOLDER_NAME
#define MMI_DLA_DEFAULT_FOLDER_RECEIVED  RECEIVED_DOWNLOAD_FOLDER_NAME
#define MMI_DLA_DEFAULT_FOLDER_MRE       APPLICATION_DOWNLOAD_FOLDER_NAME
#endif


extern void srv_da_receive_da_file(S32 session_id, S32 mime_type, S32 mime_subtype,
                                S32 action_type, PU16 filename, PS8 download_url,
                                PS8 mime_type_string);

extern void srv_da_receive_unsupported_file(S32 session_id, S32 mime_type, S32 mime_subtype,
                                S32 action_type, PU16 filename, PS8 download_url,
                                PS8 mime_type_string);


#ifdef __MMI_EMAIL__
extern void srv_email_receive_emn_file(
                S32 session_id,
                S32 mime_type,
                S32 mime_subtype,
                S32 action,
                PU16 filepath,
                PS8 url,
                PS8 mime_type_string);
#endif /* __MMI_EMAIL__ */

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

#if defined (__IMPS__)
extern void imps_receive_da_file(S32 session_id,S32 mime_type, S32 mime_subtype, S32 action, PU16 file_path, PS8 url, PS8 mime_type_string);
#endif

#ifdef __MMI_MMS_MMA_MMS_OBJECT_IND__
extern void srv_mms_handle_mms_file(S32 session_id,
        S32 mime_type,
        S32 mime_subtype,
        S32 action_type,
        PU16 filename,
        PS8 download_url,
        PS8 mime_type_str_string);
#endif

#ifdef OBIGO_Q03C_MMS_V01
extern void mmi_mmsv01_agent_handle_mms_file(
        S32 session_id,
        S32 mime_type,
        S32 mime_subtype,
        S32 action_type,
        PU16 filename,
        PS8 download_url,
        PS8 mime_type_str_string);
#endif /* OBIGO_Q03C_MMS_V01 */


#ifdef __MMI_OP01_BARCODEREADER__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif

#if defined(__AGPS_SUPPORT__) && defined(__SUPL_SUPPORT__)
extern void mmi_gps_mgr_da_file(S32 session_id, S32 mime_type, S32 mime_subtype, S32 action, PU16 file_path, PS8 url, PS8 mime_type_string);
#endif

#ifdef SYNCML_DM_SUPPORT
extern void srv_dm_session_bootstrap_receive_da_file(
                S32 session_id,
                S32 mime_type,
                S32 mime_subtype,
                S32 action,
                PU16 filepath,
                PS8 url,
                PS8 mime_type_string);
extern void srv_dm_session_da_push_setting(
                S32 session_id,
                S32 mime_type,
                S32 mime_subtype,
                S32 action,
                U32 filesize,
                PS8 url,
                PS8 mime_type_string,
                U32 content_len,
                PS8 content,
                srv_da_setting_struct * setting);
extern void srv_dm_session_notification_receive_da_file(
                S32 session_id,
                S32 mime_type,
                S32 mime_subtype,
                S32 action,
                PU16 filepath,
                PS8 url,
                PS8 mime_type_string);
extern  void srv_dm_dl_receive_upc_file(
                S32 session_id,
                S32 mime_type,
                S32 mime_subtype,
                S32 action,
                PU16 filepath,
                PS8 url,
                PS8 mime_type_string);
extern void srv_dm_dl_da_fumo_setting(
                S32 session_id,
                S32 mime_type,
                S32 mime_subtype,
                S32 action,
                U32 filesize,
                S8 *url,
                S8 *mime_type_string,
                U32 content_len,
                S8 *content,
                srv_da_setting_struct *setting);
#endif /* SYNCML_DM_SUPPORT */

#ifndef __MMI_MMS_MMA_MMS_OBJECT_IND__
void srv_da_handle_mms_file(S32 session_id, S32 mime_type, S32 mime_subtype,
                                S32 action_type, PU16 filename, PS8 download_url,
                                PS8 mime_type_string);
#endif

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

typedef struct
{
    applib_mime_subtype_enum mime_subtype;
    UI_string_ID_type string_id;
} srv_da_mime_type_str_struct;


typedef struct srv_da_dynamic_reg_hdlr_element_struct_s {
    srv_da_type_handler_struct type_handler;
    struct srv_da_dynamic_reg_hdlr_element_struct_s *next;
} srv_da_dynamic_reg_hdlr_element_struct;


/****************************************************************************
 * Static Variable
 *****************************************************************************/

/*--------------------------------------------------------------------------
 * Register your MIME type handler following:
 * { mime_type, subtype, dispatch_handler, presetting_handler, setting_handler}
 *--------------------------------------------------------------------------*/
 
const static srv_da_type_handler_struct srv_da_hdlr_tbl[] =
{
#ifdef __COSMOS_MMI_PACKAGE__
    {MIME_TYPE_UNKNOWN, MIME_SUBTYPE_UNRECOGNIZED, srv_da_receive_unsupported_file, srv_da_default_presetting, srv_da_default_setting},
#else
    {MIME_TYPE_UNKNOWN, MIME_SUBTYPE_UNRECOGNIZED, NULL, srv_da_default_presetting, srv_da_default_setting},
#endif

#ifdef __J2ME__
    {MIME_TYPE_TEXT, MIME_SUBTYPE_JAD, srv_da_adp_java_receive_da_file, srv_da_default_presetting, srv_da_adp_java_setting},
#ifdef __NO_JAR_DL__
    {MIME_TYPE_TEXT, MIME_SUBTYPE_JAR, NULL, srv_da_default_presetting, srv_da_default_setting},
#else
    {MIME_TYPE_TEXT, MIME_SUBTYPE_JAR, srv_da_adp_java_receive_da_file, srv_da_default_presetting, srv_da_adp_java_setting},
#endif
#endif

#ifdef __DRM_SUPPORT__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DRM_CONTENT, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_drm_content_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DRM_MESSAGE, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_drm_content_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DRM_RIGHTS_WBXML, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_push_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DRM_RIGHTS_XML, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_push_setting},
    #ifdef __DRM_V02__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DRM_CONTENT_V2, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_drm_content_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_ROAP_PDU, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_drm_content_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_ROAP_TRIGGER, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_drm_content_setting},
    {MIME_TYPE_APPLICATION, MIMI_SUBTYPE_PROTECTED_RO, srv_da_receive_da_file, srv_da_drm_presetting, srv_da_push_setting},
    #endif
#endif

#ifdef __MMI_OMA_DD_DOWNLOAD__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_OMA_DD,srv_da_oma_process_dd_file, srv_da_oma_dd_presetting, srv_da_oma_dd_setting},
#ifdef __MMI_OMA_DD2_DOWNLOAD__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_OMA_DD2,srv_da_oma_process_dd2_file, srv_da_oma_dd_presetting, srv_da_oma2_setting},
#endif
#endif

#ifdef __CERTMAN_SUPPORT__
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_CA_CERT,srv_da_adp_certman_install_file, srv_da_default_presetting, srv_da_default_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_USR_CERT,srv_da_adp_certman_install_file, srv_da_default_presetting, srv_da_default_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_PKCS7_CERT,srv_da_adp_certman_install_file, srv_da_default_presetting, srv_da_default_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_PKCS12_CERT,srv_da_adp_certman_install_file, srv_da_default_presetting, srv_da_default_setting},
#else        
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_CA_CERT, NULL, srv_da_default_presetting, srv_da_default_setting},
#endif /*__CERTMAN_SUPPORT__*/
#ifdef OBIGO_Q03C_MMS_V01
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_MMS,mmi_mmsv01_agent_handle_mms_file, srv_da_default_presetting, srv_da_push_setting},
#else
#ifdef __MMI_MMS_MMA_MMS_OBJECT_IND__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_MMS,srv_mms_handle_mms_file, srv_da_default_presetting, srv_da_push_setting},  
#else
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_MMS,srv_da_handle_mms_file,srv_da_default_presetting, srv_da_push_setting},
#endif
#endif
#ifdef __IMPS__
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_CSP_XML,imps_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_CSP_WBXML,imps_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_CSP_CIR,imps_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_CSP_SMS,imps_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
#endif
#ifdef __MMI_SWFLASH__
	{MIME_TYPE_APPLICATION,MIME_SUBTYPE_ZDD,mmi_swflash_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
#endif
#ifdef __MMI_VIDEO_PDL__
#ifdef __MMI_VIDEO_PLAYER__
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_3GPP_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_vdoply_pdl_da_notify_file},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_3GPP_VIDEO_1, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_vdoply_pdl_da_notify_file},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_3GPP_VIDEO_2, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_vdoply_pdl_da_notify_file},
#endif /*__MMI_VIDEO_PLAYER__*/

#ifdef __MMI_MEDIA_PLAYER__
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_3GPP_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_3GPP_VIDEO_1, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_3GPP_VIDEO_2, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_MP4, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_MPEG4, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
#ifdef __FLV_FILE_FORMAT_SUPPORT__
        {MIME_TYPE_VIDEO, MIME_SUBTYPE_FLV_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
        {MIME_TYPE_VIDEO, MIME_SUBTYPE_F4V_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_video_file},
#endif 
#endif /*__MMI_MEDIA_PLAYER__*/
#ifdef __COSMOS_MMI_PACKAGE__
#if defined(__MMI_FTO_GALLERY__) || defined(__MMI_GALLERY_SLIM__)
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_3GPP_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_3GPP_VIDEO_1, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_3GPP_VIDEO_2, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_MP4, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_MPEG4, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    #ifdef __FLV_FILE_FORMAT_SUPPORT__
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_F4V_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    {MIME_TYPE_VIDEO, MIME_SUBTYPE_FLV_VIDEO, srv_da_receive_da_file, srv_da_need_content_presetting, vapp_gallery_pdl_da_notify_video_file},
    #endif
#endif /* __MMI_FTO_GALLERY__*/
#endif

#endif /*__MMI_VIDEO_PDL__*/

#if defined(__MMI_AUDIO_PDL__) && (__MTK_TARGET__)

#ifdef __MMI_MEDIA_PLAYER__
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AMR, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_WAV, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#ifdef AU_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AU, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AU_XULAW, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*AU_DECODE*/
#ifdef SND_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_SND, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*SND_DECODE*/
#ifdef AIFF_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AIFF, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AIF, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AIFC, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*AIFF_DECODE*/
#ifdef AAC_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AAC, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*AAC_DECODE*/
#ifdef M4A_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_M4A, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*M4A_DECODE*/
#ifdef AMRWB_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AWB, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*AMRWB_DECODE*/
#ifdef DAF_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AUDIO_MP3, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*DAF_DECODE*/
#ifdef WMA_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_WMA, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*WMA_DECODE*/
#ifdef MUSICAM_DECODE
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AUDIO_MP2, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif /*MUSICAM_DECODE*/
#ifdef __FLAC_DECODE__
    {MIME_TYPE_AUDIO, MIME_SUBTYPE_AUDIO_FLAC, srv_da_receive_da_file, srv_da_need_content_presetting, mmi_medply_sinlge_pdl_da_notify_audio_file},
#endif/*__FLAC_DECODE__*/

#endif /*__MMI_MEDIA_PLAYER__*/
#endif /*__MMI_AUDIO_PDL__*/

#ifdef __MMI_VIDEO_STREAM__

#ifdef __MMI_VIDEO_PLAYER__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_SDP, mmi_vdoply_stream_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
#endif
#ifdef __MMI_MEDIA_PLAYER_STREAM__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_SDP,mmi_medply_single_stream_receive_da_file, srv_da_default_presetting, srv_da_bypass_setting},
#endif

#endif /*__MMI_VIDEO_STREAM__*/

#ifdef SYNCML_DM_SUPPORT
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DM_WBXML, srv_dm_session_bootstrap_receive_da_file, srv_da_default_presetting, srv_dm_session_da_push_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DM_XML, srv_dm_session_bootstrap_receive_da_file, srv_da_default_presetting, srv_dm_session_da_push_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DM_NOTIFICATION, srv_dm_session_notification_receive_da_file, srv_da_default_presetting, srv_dm_session_da_push_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_DM_FUMO, srv_dm_dl_receive_upc_file, srv_da_default_presetting, srv_dm_dl_da_fumo_setting},
#endif /* SYNCML_DM_SUPPORT */
#ifdef __MMI_SYNCML_SERVER_ALERT_SYNC_SUPPORT__
/* under construction !*/
#endif
#ifdef __MMI_OP01_DCD__
    {MIME_TYPE_TEXT,        MIME_SUBTYPE_SL,    mmi_dcd_receive_da_file, srv_da_default_presetting, srv_da_push_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_SLC,   mmi_dcd_receive_da_file, srv_da_default_presetting, srv_da_push_setting},
#endif

	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_OMA_PROV_WBXML, srv_prov_receive_da_file, srv_da_default_presetting, srv_prov_da_push_setting},
#ifdef __PROV_NOKIA_OTA_SUPPORT__
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_NOKIA_PROV_BROWSER,    srv_prov_receive_da_file, srv_da_default_presetting, srv_prov_da_push_setting},
	{MIME_TYPE_APPLICATION, MIME_SUBTYPE_NOKIA_PROV_BOOKMARKS,  srv_prov_receive_da_file, srv_da_default_presetting, srv_prov_da_push_setting},
#endif

#ifdef __MMI_OP01_BARCODEREADER__
/* under construction !*/
#endif
#if defined(__AGPS_SUPPORT__) && defined(__SUPL_SUPPORT__)
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_SUPL, mmi_gps_mgr_da_file, srv_da_default_presetting, srv_da_push_setting},
#endif

#ifdef __MMI_KURO_SUPPORT__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_KUR, srv_da_receive_da_file, srv_da_default_presetting, mmi_medply_kuro_bypass_settings},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_KLR, srv_da_receive_da_file, srv_da_default_presetting, mmi_medply_kuro_bypass_settings},
#endif

#ifdef __MMI_EMAIL__
    {MIME_TYPE_TEXT, MIME_SUBTYPE_EMN_XML, srv_email_receive_emn_file, srv_da_default_presetting, srv_da_push_setting},
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_EMN_WBXML, srv_email_receive_emn_file, srv_da_default_presetting, srv_da_push_setting},
#endif /* __MMI_EMAIL__ */

#ifdef __MMI_GADGET_SUPPORT__
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_WIDGET, srv_da_receive_da_file, srv_da_default_presetting, srv_da_default_setting},
#endif
    {MIME_TYPE_APPLICATION, MIME_SUBTYPE_VXP, srv_da_receive_da_file, srv_da_default_presetting, srv_da_default_setting},
    {MIME_TYPE_NONE, MIME_SUBTYPE_NONE, srv_da_receive_da_file, srv_da_default_presetting, srv_da_default_setting}
};

const static S32 srv_da_hdlr_num = sizeof(srv_da_hdlr_tbl) / sizeof(srv_da_type_handler_struct);


static struct {
    U32 size;
    srv_da_dynamic_reg_hdlr_element_struct *head;
}
g_srv_da_dynamic_reg_hdlr_tbl =
{
    0,
    NULL 
};


/*--------------------------------------------------------------------------
 * Register your hook handler following:
 * { mime_type, subtype, handler_function }
 *--------------------------------------------------------------------------*/
const static srv_da_hook_handler_struct srv_da_hook_hdlr_tbl[] =
{
#ifdef __MMI_OP11_BARCODEREADER__
/* under construction !*/
#endif
    {MIME_TYPE_NONE, MIME_SUBTYPE_NONE, NULL}
};
const static S32 srv_da_hook_hdlr_num = (sizeof(srv_da_hook_hdlr_tbl) / sizeof(srv_da_hook_handler_struct)) - 1;


const static srv_da_mime_type_str_struct srv_da_mime_type_string_tbl[] =
{
    {MIME_SUBTYPE_JPEG,		     STR_DA_IMAGE_FILE},   /*      image/jpeg */
    {MIME_SUBTYPE_VCARD,         STR_DA_VCARD_FILE},
    {MIME_SUBTYPE_XVCARD,        STR_DA_VCARD_FILE},
    {MIME_SUBTYPE_CALENDAR,      STR_DA_VCALENDAR_FILE},
    {MIME_SUBTYPE_XVCALENDAR,    STR_DA_VCALENDAR_FILE},
    {MIME_SUBTYPE_XIMELODY,      STR_DA_AUDIO_FILE},   /*      text/x-imelody */
    {MIME_SUBTYPE_THEME,         STR_DA_APP_FILE},
#ifdef M3D_MMI_SUPPORT
    {MIME_SUBTYPE_M3D,           STR_DA_IMAGE_FILE},
#endif
#if defined(MP4_DECODE)
    {MIME_SUBTYPE_3GPP_AUDIO,    STR_DA_VIDEO_FILE},
#endif
    {MIME_SUBTYPE_UNRECOGNIZED,  STR_DA_UNKNOWN_FILE} /*      Un-recognized file type */

};
const static S32 srv_da_mime_type_string_num = sizeof(srv_da_mime_type_string_tbl) / sizeof(srv_da_mime_type_str_struct);


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


/*****************************************************************************
 * FUNCTION
 *  srv_da_default_presetting
 * DESCRIPTION
 *  Set the presetting to default values.
 * PARAMETERS
 *  param       [IN]  Parameters to determine pre-setting
 *  presetting  [OUT] Pre-setting
 * RETURNS
 *  void
 *****************************************************************************/
void srv_da_default_presetting(
    const srv_da_presetting_param_struct *param,
    srv_da_presetting_struct *presetting)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    /* Confirm with user before download */
    presetting->confirm_download = MMI_TRUE;

    /* Not need content to determine setting */
    presetting->need_content = MMI_FALSE;
}



/*****************************************************************************
 * FUNCTION
 *  srv_da_need_content_presetting
 * DESCRIPTION
 *  Set the presetting to default values, but need_content = MMI_TRUE.
 * PARAMETERS
 *  param       [IN]  Parameters to determine pre-setting
 *  presetting  [OUT] Pre-setting
 * RETURNS
 *  void
 *****************************************************************************/
void srv_da_need_content_presetting(
    const srv_da_presetting_param_struct *param,
    srv_da_presetting_struct *presetting)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    srv_da_default_presetting(param, presetting);

    /* Need content to determine setting */
    presetting->need_content = MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_config_set_folder
 * DESCRIPTION
 *  
 * PARAMETERS
 *  mime_type       [IN]  MIME type
 *  mime_subtype    [IN]  MIME subtype
 *  folder          [OUT] folder
 * RETURNS
 *  void
 *****************************************************************************/
static void srv_da_config_set_folder(S32 mime_type, S32 mime_subtype, U16 *folder)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    const U16 *folder_setting;

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

    folder_setting = MMI_DLA_DEFAULT_FOLDER_RECEIVED;

    switch (mime_type)
    {
        case MIME_TYPE_AUDIO:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_AUDIOS;
            break;
            
        case MIME_TYPE_IMAGE:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_IMAGES;
            break;
            
        case MIME_TYPE_VIDEO:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_VIDEOS;
            break;
            
        case MIME_TYPE_APPLICATION:
            if (mime_subtype == MIME_SUBTYPE_THEME)
            {
                folder_setting = FMGR_DEFAULT_FOLDER_THEMES;
            }
            else
            {
                folder_setting = MMI_DLA_DEFAULT_FOLDER_RECEIVED;
            }
            break;
            
        default:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_RECEIVED;
            break;
    }

    switch (mime_subtype)
    {
    #ifdef M3D_MMI_SUPPORT
        case MIME_SUBTYPE_M3D:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_IMAGES;
            break;
    #endif

    #ifdef __MMI_EBOOK_READER__
        case MIME_SUBTYPE_PDB:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_EBOOKS;
            break;
    #endif

    #if defined(__MMI_BARCODEREADER__) && !defined(__MMI_OP11_BARCODEREADER__)
        case MIME_SUBTYPE_MBC:
            folder_setting = FMGR_DEFAULT_FOLDER_BARCODE;
            break;
    #endif

    #ifdef LANGLN_DIGIDEA
        case MIME_SUBTYPE_DZD:
            folder_setting = FMGR_DEFAULT_FOLDER_LANGLN;
            break;
    #endif

    #ifdef __MMI_MESSAGES_EMS__
        case MIME_SUBTYPE_EMS:
        case MIME_SUBTYPE_ANM:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_IMAGES;
            break;
    #endif
		case MIME_SUBTYPE_VXP:
            folder_setting = MMI_DLA_DEFAULT_FOLDER_MRE;

        default:
            break;
    }


    mmi_wcscpy(folder, folder_setting);

    MMI_ASSERT(mmi_wcslen(folder) > 0);
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_type_needs_processing
 * DESCRIPTION
 *  Determine if the type needs processing. This function is designed for
 *  bypass_setting and push_setting. If the file needs processing,
 *  DLAgent should hard-code special rules for these files.
 * PARAMETERS
 *  subtype     [IN] applib_mime_subtype_enum
 * RETURNS
 *  MMI_BOOL
 *****************************************************************************/
static MMI_BOOL srv_da_type_needs_processing(S32 subtype)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    switch (subtype)
    {
#ifdef __DRM_SUPPORT__
        case MIME_SUBTYPE_DRM_CONTENT:
        case MIME_SUBTYPE_DRM_MESSAGE:
        case MIME_SUBTYPE_DRM_RIGHTS_WBXML:
        case MIME_SUBTYPE_DRM_RIGHTS_XML:
    #ifdef __DRM_V02__
        case MIME_SUBTYPE_DRM_CONTENT_V2:
        case MIME_SUBTYPE_ROAP_PDU:
        case MIME_SUBTYPE_ROAP_TRIGGER:
        case MIMI_SUBTYPE_PROTECTED_RO:
    #endif
            return MMI_TRUE;
#endif

        default:
            break;
    }

    return MMI_FALSE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_default_setting
 * DESCRIPTION
 *  Default setting function for convenience. Please see the comments to know
 *  the detail of behavior.
 * PARAMETERS
 *  session_id          [IN]    Session ID
 *  mime_type           [IN]    applib_mime_type_enum
 *  mime_subtype        [IN]    applib_mime_subtype_enum
 *  action              [IN]    srv_da_action_enum
 *  filesize            [IN]    File size
 *  url                 [IN]    URL: url[WAP_DL_MAX_URL_LEN]
 *  mime_type_string    [IN]    MIME type string: mime_type_string[WAP_DL_MAX_MIME_TYPE_LEN]
 *  content_len         [IN]    Content-Length in HTTP header, may be 0.
 *  content             [IN]    Content in HTTP response, may be NULL
 *  setting             [OUT]   Appropriate behavior setting by previous information.
 * RETURNS
 *  void
 *****************************************************************************/
void srv_da_default_setting(
        S32	session_id,
        S32	mime_type,
        S32	mime_subtype,
        S32 action,
        U32	filesize,
        PS8	url,
        PS8	mime_type_string,
        U32	content_len,
        PS8	content,
        srv_da_setting_struct *setting)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    memset(setting, 0, sizeof(srv_da_setting_struct));

    /* Let user to decide the storage */
    setting->storage = SRV_DA_STORAGE_NONE;
    setting->drv = 0;
    
    /* Let user to input the filename */
    setting->default_filename = MMI_FALSE;
    setting->filename[0] = setting->filename[1] = L'\0';

    /* Default folder */
    srv_da_config_set_folder(mime_type, mime_subtype, setting->folder);

    /* Confirm with user before dispatch */
    setting->confirm_dispatch = MMI_TRUE;

    /* Popup when received via push. */
    setting->confirm_push = MMI_TRUE;

    /* Background download is allowed */
    setting->can_minimize = MMI_TRUE;

    /* Dispatch after file received. */
    setting->do_dispatch = MMI_TRUE;

    /* Not need to report during downloading. */
    setting->filepath_hdlr = NULL;
    setting->report_hdlr = NULL;


    /* --- OBSOLETE --- */
    setting->bypass = MMI_DA_BYPASS_FALSE;
    setting->keepfile = MMI_FALSE;
    setting->percentage_bar = MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_bypass_setting
 * DESCRIPTION
 *  Please refer to the comments for further detail.
 *
 *  (Old description)
 *  This setting is used for application want to control the file by itself
 *  User cannot input filename and select drv.
 *  Download agent will save the file into temp folder.
 *  Application must move the file to suitable folder if they want reserve
 *  the file. The temp folder would be deleted.
 * PARAMETERS
 *  session_id          [IN]    Session ID
 *  mime_type           [IN]    applib_mime_type_enum
 *  mime_subtype        [IN]    applib_mime_subtype_enum
 *  action              [IN]    srv_da_action_enum
 *  filesize            [IN]    File size
 *  url                 [IN]    URL: url[WAP_DL_MAX_URL_LEN]
 *  mime_type_string    [IN]    MIME type string: mime_type_string[WAP_DL_MAX_MIME_TYPE_LEN]
 *  content_len         [IN]    Content-Length in HTTP header, may be 0.
 *  content             [IN]    Content in HTTP response, may be NULL
 *  setting             [OUT]   Appropriate behavior setting by previous information.
 * RETURNS
 *  void
 *****************************************************************************/
void srv_da_bypass_setting(
        S32	session_id,
        S32	mime_type,
        S32	mime_subtype,
        S32 action,
        U32	filesize,
        PS8	url,
        PS8	mime_type_string,
        U32	content_len,
        PS8	content,
        srv_da_setting_struct *setting)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    if (action == MMI_DA_SAVE_AS && !srv_da_type_needs_processing(mime_subtype))
    {
        srv_da_default_setting(
            session_id,
            mime_type,
            mime_subtype,
            action,
            filesize,
            url,
            mime_type_string,
            content_len,
            content,
            setting);

        setting->confirm_dispatch = MMI_FALSE;
        setting->do_dispatch = MMI_FALSE;
        
        return;
    }

    /* Let DLAgent to decide the storage */
    setting->storage = SRV_DA_STORAGE_AUTO;
    setting->drv = 0;
    
    /* Let DLAgent to decide the filename */
    setting->default_filename = MMI_TRUE;
    setting->filename[0] = setting->filename[1] = L'\0';

    /* Background download is not allowed */
    setting->can_minimize = MMI_FALSE;

    /* Save in temp folder */
    mmi_ucs2cpy((S8*)setting->folder, (S8*)FMGR_DEFAULT_FOLDER_TEMP);

    /* Don't confirm with user before dispatch */
    setting->confirm_dispatch = MMI_FALSE;

    /* Popup when received via push. */
    setting->confirm_push = MMI_TRUE;

    /* Dispatch after file received. */
    setting->do_dispatch = MMI_TRUE;

    /* Not need to report during downloading. */
    setting->filepath_hdlr = NULL;
    setting->report_hdlr = NULL;


    /* --- OBSOLETE --- */
    setting->bypass = MMI_DA_BYPASS_LEVEL_2;
    setting->keepfile = MMI_FALSE;
    setting->percentage_bar = MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_push_setting
 * DESCRIPTION
 *  Please refer to the comments for further detail.
 * PARAMETERS
 *  session_id          [IN]    Session ID
 *  mime_type           [IN]    applib_mime_type_enum
 *  mime_subtype        [IN]    applib_mime_subtype_enum
 *  action              [IN]    srv_da_action_enum
 *  filesize            [IN]    File size
 *  url                 [IN]    URL: url[WAP_DL_MAX_URL_LEN]
 *  mime_type_string    [IN]    MIME type string: mime_type_string[WAP_DL_MAX_MIME_TYPE_LEN]
 *  content_len         [IN]    Content-Length in HTTP header, may be 0.
 *  content             [IN]    Content in HTTP response, may be NULL
 *  setting             [OUT]   Appropriate behavior setting by previous information.
 * RETURNS
 *  void
 *****************************************************************************/
void srv_da_push_setting(
        S32	session_id,
        S32	mime_type,
        S32	mime_subtype,
        S32 action,
        U32	filesize,
        PS8	url,
        PS8	mime_type_string,
        U32	content_len,
        PS8	content,
        srv_da_setting_struct *setting)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

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

    if (action == MMI_DA_SAVE_AS && !srv_da_type_needs_processing(mime_subtype))
    {
        srv_da_default_setting(
            session_id,
            mime_type,
            mime_subtype,
            action,
            filesize,
            url,
            mime_type_string,
            content_len,
            content,
            setting);

        setting->confirm_dispatch = MMI_FALSE;
        setting->do_dispatch = MMI_FALSE;
            
        return;
    }
    
    /* Let DLAgent to decide the storage */
    if (action == MMI_DA_PUSH || action == MMI_DA_PUSH_SIM2 || action == MMI_DA_PUSH_SIM3 || action == MMI_DA_PUSH_SIM4)
    {
        setting->storage = SRV_DA_STORAGE_PUSH_TEMP;
    }
    else
    {
        setting->storage = SRV_DA_STORAGE_AUTO;
    }
    setting->drv = 0;
    
    /* Let DLAgent to decide the filename */
    setting->default_filename = MMI_TRUE;
    setting->filename[0] = setting->filename[1] = L'\0';

    /* Always save into temp folder */
    mmi_ucs2cpy((S8*)setting->folder, (S8*)FMGR_DEFAULT_FOLDER_TEMP);

    /* Don't confirm with user before dispatch */
    setting->confirm_dispatch = MMI_FALSE;

    /* Not inform the user by DLAgent when file received */
    setting->confirm_push = MMI_FALSE;

    /* Dispatch after file received. */
    setting->do_dispatch = MMI_TRUE;

    /* Background download is not allowed. */
    setting->can_minimize = MMI_FALSE;

    /* Not need to report during downloading. */
    setting->filepath_hdlr = NULL;
    setting->report_hdlr = NULL;


    /* --- OBSOLETE --- */
    setting->bypass = MMI_DA_BYPASS_LEVEL_3;
    setting->percentage_bar = MMI_TRUE;
    setting->keepfile = MMI_FALSE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_get_default_mime_type_handler
 * DESCRIPTION
 *  Get the default MIME type handler.
 * PARAMETERS
 *  void
 * RETURNS
 *  The default MIME type handler.
 *****************************************************************************/
const srv_da_type_handler_struct* srv_da_get_default_mime_type_handler(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    return &(srv_da_hdlr_tbl[srv_da_hdlr_num-1]);
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_search_mime_type_handler_by_subtype
 * DESCRIPTION
 *  Search corresponding mime type handler
 * PARAMETERS
 *  mime_subtype      [IN] MIME subtype
 * RETURNS
 *  A pointer points to the corresponding handler structure.
 *****************************************************************************/
static const srv_da_type_handler_struct* srv_da_search_mime_type_handler_by_subtype(
    applib_mime_subtype_enum mime_subtype)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 i;
    srv_da_dynamic_reg_hdlr_element_struct *hdlr_ele;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (mime_subtype == 0)
    {
        return &(srv_da_hdlr_tbl[0]);
    }

    for (i = srv_da_hdlr_num - 1; i >= 0; i--)
    {
        if (srv_da_hdlr_tbl[i].mime_subtype == mime_subtype)
        {
            return &(srv_da_hdlr_tbl[i]);
        }
    }

    for (hdlr_ele = g_srv_da_dynamic_reg_hdlr_tbl.head; hdlr_ele != NULL; hdlr_ele = hdlr_ele->next)
    {
        if (hdlr_ele->type_handler.mime_subtype == mime_subtype)
        {
            return &(hdlr_ele->type_handler);
        }
    }

    return srv_da_get_default_mime_type_handler();
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_search_mime_type_handler
 * DESCRIPTION
 *  Search corresponding mime type handler
 * PARAMETERS
 *  type      [IN]  The MIME type
 * RETURNS
 *  A pointer points to the corresponding handler structure.
 *****************************************************************************/
const srv_da_type_handler_struct* srv_da_search_mime_type_handler(const applib_mime_type_struct* type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (type == NULL)
    {
        return &(srv_da_hdlr_tbl[0]);
    }

    return srv_da_search_mime_type_handler_by_subtype(type->mime_subtype);
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_register_type_handler
 * DESCRIPTION
 *  Register a type handler to DLAgent.
 * PARAMETERS
 *  mime_type       [IN] MIME type
 *  mime_subtype    [IN] MIME subtype
 *  presetting_hdlr [IN] Presetting handler
 *  setting_hdlr    [IN] Setting handler
 *  dispatch_hdlr   [IN] Dispatch handler
 * RETURNS
 *  Successfully registered
 *****************************************************************************/
MMI_BOOL srv_da_register_type_handler(
    applib_mime_type_enum mime_type,
    applib_mime_subtype_enum mime_subtype,
    srv_da_presetting_hdlr presetting_hdlr,
    srv_da_setting_hdlr setting_hdlr,
    srv_da_dispatch_hdlr dispatch_hdlr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_da_dynamic_reg_hdlr_element_struct *hdlr_ele;

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

    MMI_TRACE(MMI_DA_TRACE_GROUP, MMI_DA_TRC_REGISTER_TYPE_HANDLER,
                mime_type, mime_subtype, presetting_hdlr, setting_hdlr, dispatch_hdlr);

    if (mime_subtype != 0 &&
        srv_da_search_mime_type_handler_by_subtype(mime_subtype) != srv_da_get_default_mime_type_handler())
    {
        hdlr_ele = (srv_da_dynamic_reg_hdlr_element_struct*)srv_da_adp_mem_allocate(sizeof(srv_da_dynamic_reg_hdlr_element_struct));

        hdlr_ele->type_handler.mime_type = mime_type;
        hdlr_ele->type_handler.mime_subtype = mime_subtype;
        hdlr_ele->type_handler.get_presetting = presetting_hdlr;
        hdlr_ele->type_handler.setting_hdlr = setting_hdlr;
        hdlr_ele->type_handler.dispatch_hdlr = dispatch_hdlr;

        /* Add to list */
        hdlr_ele->next = g_srv_da_dynamic_reg_hdlr_tbl.head;
        g_srv_da_dynamic_reg_hdlr_tbl.head = hdlr_ele;
        g_srv_da_dynamic_reg_hdlr_tbl.size++;

        return MMI_TRUE;
    }
    
    return MMI_FALSE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_search_hook_handler
 * DESCRIPTION
 *  Get the hook handler from s_index.
 * PARAMETERS
 *  type        [IN]    The MIME type
 *  s_index     [IN]    Start index to search
 *  p_hdlr      [OUT]   Hook handler.
 * RETURNS
 *  Next index to search. If no hook handler is found, returns -1.
 *****************************************************************************/
S32 srv_da_search_hook_handler(
        const applib_mime_type_struct *type, 
        S32 s_index, 
        srv_da_hook_dispatch_hdlr *p_hdlr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (type != NULL)
    {
        while (s_index < srv_da_hook_hdlr_num)
        {
            if (srv_da_hook_hdlr_tbl[s_index].mime_subtype == type->mime_subtype)
            {
                *p_hdlr = srv_da_hook_hdlr_tbl[s_index].hook_hdlr;
                return s_index+1;
            }
            s_index++;
        }
    }

    *p_hdlr = NULL;
    
    return -1;
}


/*****************************************************************************
* FUNCTION
*  srv_da_search_mime_type_string
* DESCRIPTION
*  Search the mime type string in table by mime_subtype
* PARAMETERS
*  mime_subtype    IN  Which mime_subtype you want to search.
* RETURNS
*  The string id
*****************************************************************************/
UI_string_ID_type srv_da_search_mime_type_string(const applib_mime_type_struct * type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 i;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if(type == NULL)
    {
        return STR_DA_UNKNOWN_FILE;
    }
    for (i = srv_da_mime_type_string_num - 1; i >= 0; i--)
    {
        if (type->mime_subtype == srv_da_mime_type_string_tbl[i].mime_subtype)
        {
            return srv_da_mime_type_string_tbl[i].string_id;
        }
    }

    switch (type->mime_type)
    {
        case MIME_TYPE_TEXT:
            return STR_DA_TEXT_FILE;
        case MIME_TYPE_IMAGE:
            return STR_DA_IMAGE_FILE;
        case MIME_TYPE_AUDIO:
            return STR_DA_AUDIO_FILE;
        case MIME_TYPE_VIDEO:
            return STR_DA_VIDEO_FILE;
        case MIME_TYPE_APPLICATION:
            return STR_DA_APP_FILE;
        case MIME_TYPE_MESSAGE:
            return STR_DA_MSG_FILE;
        case MIME_TYPE_MULTIPART:
            return STR_DA_MULTI_FILE;
        default:
            return STR_DA_UNKNOWN_FILE;
    }

   
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_setting_check
 * DESCRIPTION
 *  Check the validaity of setting
 * PARAMETERS
 *  setting     [IN]
 * RETURNS
 *  MMI_TRUE if pass
 *****************************************************************************/
MMI_BOOL srv_da_setting_check(const srv_da_setting_struct *setting)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    switch (setting->storage)
    {
        case SRV_DA_STORAGE_USER_SELECT:
        case SRV_DA_STORAGE_AUTO:
        case SRV_DA_STORAGE_PUSH_TEMP:
            break;

        case SRV_DA_STORAGE_GIVEN:
        default:
            if (setting->drv == L'\0')
            {
                return MMI_FALSE;
            }
            break;
    }

    /* if ap use the default_filename, the length of filename must be zero */
    if (setting->default_filename == MMI_TRUE && setting->filename[0] != L'\0')
    {
        return MMI_FALSE;
    }


    return MMI_TRUE;
}


/*****************************************************************************
 * FUNCTION
 *  srv_da_dispatch_to_app
 * DESCRIPTION
 *  Dispatch a file to application registered.
 *  It will search the hook handler first. If no hook handler accepts
 *  the file, dispatch to type handler finally.
 * PARAMETERS
 *  session_id          [IN] Session ID which will be passed into hook/dispatch handler
 *  action              [IN] srv_da_action_enum
 *  filepath            [IN] Path of file to be dispatched
 *  url                 [IN] Source URI
 *  mime_type_string    [IN] MIME type string.
 *                           If NULL, the string will be extracted by using mime_type.
 *  type_hdlr           [IN] If no hook handler, dispatch to the dispatch_hdlr() in
 *                           this type handler. If NULL, try to find a proper type handler.
 * RETURNS
 *  MMI_TRUE if dispatched successfully; otherwise, returns MMI_FALSE
 *****************************************************************************/
MMI_BOOL srv_da_dispatch_to_app(
    S32 session_id, 
    const applib_mime_type_struct *mime_type,
    srv_da_action_enum action, 
    U16 *filepath,
    S8 *url,
    const S8 *mime_type_string,
    const srv_da_type_handler_struct *type_hdlr)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    srv_da_hook_dispatch_hdlr hook_hdlr;
    S32 hook_idx;
    S32 mime_type_enum_value, mime_subtype_enum_value;

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

    if (mime_type_string == NULL && mime_type != NULL)
    {
        mime_type_string = mime_type->mime_string;
    }

    mime_type_enum_value = (mime_type != NULL ? mime_type->mime_type : 0);
    mime_subtype_enum_value = (mime_type != NULL ? mime_type->mime_subtype : 0);

    /* Dispatch to hook handler first */
    hook_idx = 0;
    do
    {
        hook_idx = srv_da_search_hook_handler(mime_type, hook_idx, &hook_hdlr);

        if (hook_idx >= 0 && hook_hdlr != NULL)
        {        
            if (hook_hdlr(session_id,
                    mime_type_enum_value,
                    mime_subtype_enum_value,
                    action,
                    filepath,
                    url,
                    (S8*)mime_type_string))
            {
                MMI_TRACE(MMI_DA_TRACE_GROUP, MMI_DA_TRC_DISPATCH_TO_APP,
                    mime_type_enum_value, mime_subtype_enum_value, 'H', hook_idx);
                
                return MMI_TRUE;
            }
            else
            {
                /* To find next hook handler */
            }
        }
        else
        {
            /* No next */
            break;
        }
    } while (MMI_TRUE);

	if (action == MMI_DA_WAP_DOWNLOAD && mime_subtype_enum_value == MIME_SUBTYPE_MMS)
	{
		srv_da_receive_da_file(session_id,
					mime_type_enum_value,
					mime_subtype_enum_value,
					action,
					filepath,
					url,
					(S8*)mime_type_string);
	}
	else
	{
    /* Dispatch to type handler */
    if (type_hdlr == NULL)
    {
        type_hdlr = srv_da_search_mime_type_handler(mime_type);
    }

    if (type_hdlr != NULL && type_hdlr->dispatch_hdlr != NULL)
    {
        type_hdlr->dispatch_hdlr(
            session_id,
            mime_type_enum_value,
            mime_subtype_enum_value,
            action,
            filepath,
            url,
            (S8*)mime_type_string);

        MMI_TRACE(MMI_DA_TRACE_GROUP, MMI_DA_TRC_DISPATCH_TO_APP,
            mime_type_enum_value, mime_subtype_enum_value, 'D', -1);

        return MMI_TRUE;
    }
	}

    MMI_TRACE(MMI_DA_TRACE_GROUP, MMI_DA_TRC_DISPATCH_TO_APP,
        mime_type_enum_value, mime_subtype_enum_value, 'N', -1);

    return MMI_FALSE;
}



/*************************************************************************
* FUNCTION
*   srv_da_receive_da_file
* DESCRIPTION
*   Start to handle file
* PARAMETERS
*   mime_type   [IN]    the mime type of file
*   mime_subtype[IN]    the sub mime type of file
*   action_type [IN]    defined in Download agent
*   filename    [IN]    the filepath of file
*   download_url[IN]    the source of file, normally is a link
*   mime_type_string    [IN]    the originaly mime type string get from server
* RETURNS
*   void
*************************************************************************/
void srv_da_receive_unsupported_file(S32 session_id, S32 mime_type, S32 mime_subtype,
                                S32 action_type, PU16 filename, PS8 download_url,
                                PS8 mime_type_string)
{
    srv_da_adp_popup (SRV_DA_GLOBAL_NOT_SUPPORTED, 0, SRV_DA_POPUP_TYPE_ERROR);
}


/*************************************************************************
* FUNCTION
*   srv_da_receive_da_file
* DESCRIPTION
*   Start to handle file
* PARAMETERS
*   mime_type   [IN]    the mime type of file
*   mime_subtype[IN]    the sub mime type of file
*   action_type [IN]    defined in Download agent
*   filename    [IN]    the filepath of file
*   download_url[IN]    the source of file, normally is a link
*   mime_type_string    [IN]    the originaly mime type string get from server
* RETURNS
*   void
*************************************************************************/
void srv_da_receive_da_file(S32 session_id, S32 mime_type, S32 mime_subtype,
                                S32 action_type, PU16 filename, PS8 download_url,
                                PS8 mime_type_string)
{
    
#ifndef __COSMOS_MMI_PACKAGE__
#ifndef __MMI_ULTRA_SLIM_FILE_MANAGER__
	mmi_fmgr_receive_da_file(session_id, mime_type, mime_subtype, action_type, filename, download_url, mime_type_string);
#endif
#else
    S32 file_type = -1;
    S32 menu_opt = -1;
    file_type = srv_fmgr_types_find_type_by_filepath (filename);
    if (file_type > 0)
    {
        //menu_opt = srv_fmgr_types_get_use_option_menu(file_type, (const WCHAR*) filename);
        menu_opt = srv_fmgr_types_get_option_menu((filetypes_file_type_enum)file_type, NULL, 0);
        if (menu_opt > 0)
        {
            S32 child_id = GetSeqItemId(menu_opt, 0);
            if (0 > srv_fmgr_types_launch_option ((const WCHAR*) filename, child_id))
            {
                goto ERROR;
            }
        }
        else
        {
            goto ERROR;
        }
    }
    else
    {
        goto ERROR;
    }

    return;
ERROR:
    srv_da_adp_popup (SRV_DA_GLOBAL_UNSUPPORTED_FORMAT, 0, SRV_DA_POPUP_TYPE_ERROR);
#endif
}
    
/*************************************************************************
* FUNCTION
*   srv_da_handle_mms_file
* DESCRIPTION
*   Delete unhandled mms file
* PARAMETERS
*   mime_type   [IN]    the mime type of file
*   mime_subtype[IN]    the sub mime type of file
*   action_type [IN]    defined in Download agent
*   filename    [IN]    the filepath of file
*   download_url[IN]    the source of file, normally is a link
*   mime_type_string    [IN]    the originaly mime type string get from server
* RETURNS
*   void
*************************************************************************/
#ifndef __MMI_MMS_MMA_MMS_OBJECT_IND__
void srv_da_handle_mms_file(S32 session_id, S32 mime_type, S32 mime_subtype,
                                S32 action_type, PU16 filename, PS8 download_url,
                                PS8 mime_type_string)
{
	FS_HANDLE file_handle;
    S8 temp_filename[100];

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

    memset(temp_filename, 0, sizeof(temp_filename));
    mmi_ucs2_n_to_asc(temp_filename, (S8*) filename, 99);

    file_handle = FS_Open((const WCHAR*)filename, FS_READ_ONLY);

    if (file_handle < FS_NO_ERROR)
    {
        return;
    }

    ASSERT(FS_Close(file_handle) == FS_NO_ERROR);
    FS_Delete((const WCHAR*)filename);

}
#endif
    
#endif