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
|
#include "Pdapilot_calls.h"
#include "Pdapilot_Database.h"
#include "Pdapilot_Record.h"
#include "Pdapilot_Pref.h"
#include "Pdapilot_Dlp.h"
#include "Pdapilot_AppBlock.h"
#include "Pdapilot_SortBlock.h"
#include "Pdapilot_Resource.h"
#include "Pdapilot_CardInfo.h"
#include "Pdapilot_UserInfo.h"
#include "Pdapilot_SysInfo.h"
#include "Pdapilot_NetInfo.h"
#include "Pdapilot_CategoryAppBlock.h"
#include "Pdapilot_memo_Record.h"
#include "Pdapilot_memo_AppBlock.h"
#include "Pdapilot_todo_Record.h"
#include "Pdapilot_todo_AppBlock.h"
#include "Pdapilot_address_Record.h"
#include "Pdapilot_address_AppBlock.h"
#include "Pdapilot_appointment_Record.h"
#include "Pdapilot_appointment_AppBlock.h"
#include "Pdapilot_appointment_repeat.h"
#include "Pdapilot_appointment_time.h"
#include "Pdapilot_mail_Record.h"
#include "Pdapilot_mail_AppBlock.h"
#include "Pdapilot_mail_SyncPref.h"
#include "Pdapilot_mail_SignaturePref.h"
#include "Pdapilot_mail_sort.h"
#include "Pdapilot_mail_sync.h"
#include "Pdapilot_expense_Record.h"
#include "Pdapilot_expense_AppBlock.h"
#include "Pdapilot_expense_Pref.h"
#include "Pdapilot_expense_type.h"
#include "Pdapilot_expense_payment.h"
#include "Pdapilot_expense_distance.h"
#include "Pdapilot_expense_sort.h"
#include "Pdapilot_expense_CustomCurrency.h"
#include "Pdapilot_RecordID.h"
#include "Pdapilot_Char4.h"
#include "Pdapilot_DBInfo.h"
#include "Pdapilot_File.h"
#include "java_util_Date.h"
#include "pi-source.h"
#include "pi-dlp.h"
#include "pi-socket.h"
#include "pi-memo.h"
#include "pi-address.h"
#include "pi-datebook.h"
#include "pi-todo.h"
#include "pi-mail.h"
#include "pi-expense.h"
#include "pi-file.h"
#include <signal.h>
#if (JAVAMAJOR>1) || (JAVAMINOR>0)
# define NEW
#else
# define OLD
#endif
#ifdef OLD
# define javaint_t long
#else
# define javaint_t int32_t
#endif
/** Sun should be ashamed for the 1.0 JNI!
*/
static void throwDlpException(int code)
{
execute_java_static_method(0, FindClass(0, "Pdapilot/DlpException",1),
"kickWillyScuggins", "(I)V", (long)code);
}
static void throwCancelSyncException()
{
execute_java_static_method(0, FindClass(0, "Pdapilot/CancelSyncException",1),
"kickWillyScuggins", "()V");
}
static void throwIOException(int code)
{
SignalError(0, "java/lang/IOException", 0);
}
static HArrayOfByte * getByteArray(long length)
{
return (HArrayOfByte*)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"getByteArray", "(I)[B", (long)length);
}
static HArrayOfObject * makeRecordIDArray(long length)
{
return (HArrayOfObject*)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"makeRecordIDArray", "(I)[LPdapilot/RecordID;", (long)length);
}
static HArrayOfObject * makeStringArray(long length)
{
return (HArrayOfObject*)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"makeStringArray", "(I)[Ljava/lang/Object;", (long)length);
}
static HArrayOfObject * makeDateArray(long length)
{
return (HArrayOfObject*)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"makeDateArray", "(I)[Ljava/lang/Object;", (long)length);
}
static HArrayOfInt * makeIntArray(long length)
{
return (HArrayOfInt*)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"makeIntArray", "(I)[I", (long)length);
}
/*static HObject* makeBooleanArray(long length) Ptui!
{
return (HObject*)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"makeBooleanArray", "(I)[Z", (long)length);
}*/
static long getArrayLength(struct HArrayOfByte *b)
{
return (long)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"getArrayLength", "([B)I", b);
}
static long getObjectArrayLength(struct HArrayOfObject *b)
{
return (long)execute_java_static_method(0, FindClass(0, "Pdapilot/calls",1),
"getObjectArrayLength", "([Ljava/lang/Object;)I", b);
}
static Hjava_util_Date * makeJavaDate(time_t v) {
if (v < 18000) {
return 0;
} else {
struct tm * tm = localtime(&v);
return (Hjava_util_Date*)execute_java_constructor(0, "java/util/Date", 0,
"(IIIIII)",
tm->tm_year, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
}
static Hjava_util_Date * makeJavaDateTm(struct tm * tm) {
return (Hjava_util_Date*)execute_java_constructor(0, "java/util/Date", 0,
"(IIIIII)",
tm->tm_year, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
static HPdapilot_Char4 * makeJavaChar4(long id) {
return (HPdapilot_Char4*)execute_java_constructor(
0, "Pdapilot/Char4", 0,
"(I)", id);
}
static unsigned long getJavaChar4(HPdapilot_Char4 * id) {
if (id)
return unhand(id)->value;
else
return 0;
}
static HPdapilot_RecordID * makeJavaRecordID(long id) {
return (HPdapilot_RecordID*)execute_java_constructor(
0, "Pdapilot/RecordID", 0,
"(I)", id);
}
static int getJavaRecordID(HPdapilot_RecordID * id) {
if (id)
return unhand(id)->value;
else
return 0;
}
static time_t readJavaDate(Hjava_util_Date * date) {
struct tm tm;
tm.tm_year = (int)execute_java_dynamic_method(0, (HObject*)date, "getYear", "()I");
tm.tm_mon = (int)execute_java_dynamic_method(0, (HObject*)date, "getMonth", "()I");
tm.tm_mday = (int)execute_java_dynamic_method(0, (HObject*)date, "getDay", "()I");
tm.tm_hour = (int)execute_java_dynamic_method(0, (HObject*)date, "getHours", "()I");
tm.tm_min = (int)execute_java_dynamic_method(0, (HObject*)date, "getMinutes", "()I");
tm.tm_sec = (int)execute_java_dynamic_method(0, (HObject*)date, "getSeconds", "()I");
return mktime(&tm);
}
static struct tm * readJavaDateTm(Hjava_util_Date * date) {
static struct tm tm;
tm.tm_year = (int)execute_java_dynamic_method(0, (HObject*)date, "getYear", "()I");
tm.tm_mon = (int)execute_java_dynamic_method(0, (HObject*)date, "getMonth", "()I");
tm.tm_mday = (int)execute_java_dynamic_method(0, (HObject*)date, "getDay", "()I");
tm.tm_hour = (int)execute_java_dynamic_method(0, (HObject*)date, "getHours", "()I");
tm.tm_min = (int)execute_java_dynamic_method(0, (HObject*)date, "getMinutes", "()I");
tm.tm_sec = (int)execute_java_dynamic_method(0, (HObject*)date, "getSeconds", "()I");
return &tm;
}
extern javaint_t Pdapilot_calls_pi_socket(struct HPdapilot_calls*self, javaint_t domain, javaint_t type, javaint_t protocol)
{
int result = pi_socket(domain, type, protocol);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_bind(struct HPdapilot_calls*self, javaint_t socket, struct Hjava_lang_String * address)
{
javaint_t len = javaStringLength(address)+3;
struct pi_sockaddr * a = malloc(len);
javaint_t result;
a->pi_family = PI_AF_SLP;
javaString2CString(address, a->pi_device, len-2);
result = pi_bind(socket, (struct sockaddr*)a, len);
free(a);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_listen(struct HPdapilot_calls*self, javaint_t socket, javaint_t backlog)
{
int result = pi_listen(socket, backlog);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_accept(struct HPdapilot_calls*self, javaint_t socket)
{
int result=pi_accept(socket, 0, 0);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_read(struct HPdapilot_calls*self, javaint_t socket, HArrayOfByte *b, javaint_t len)
{
int result=pi_read(socket, unhand(b)->body, len);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_write(struct HPdapilot_calls*self, javaint_t socket, HArrayOfByte * b, javaint_t len)
{
int result=pi_write(socket, unhand(b)->body, len);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_close(struct HPdapilot_calls * self, javaint_t socket)
{
int result=pi_close(socket);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_version(struct HPdapilot_calls * self, javaint_t socket)
{
int result=pi_version(socket);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_watchdog(struct HPdapilot_calls * self, javaint_t socket, javaint_t interval)
{
int result=pi_watchdog(socket, interval);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_pi_tickle(struct HPdapilot_calls * self, javaint_t socket)
{
int result=pi_tickle(socket);
if (result<0)
throwIOException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_OpenDB(struct HPdapilot_calls * self, javaint_t socket, javaint_t card, javaint_t mode, Hjava_lang_String * name)
{
int handle;
int result = dlp_OpenDB(socket, card, mode, makeCString(name), &handle);
if (result < 0) {
throwDlpException(result);
return result;
}
return handle;
}
extern javaint_t Pdapilot_calls_dlp_CreateDB(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_Char4 * creator, HPdapilot_Char4 * type, javaint_t card, javaint_t flags, javaint_t version, Hjava_lang_String * name)
{
int handle;
int result = dlp_CreateDB(socket, unhand(creator)->value, unhand(creator)->value, card, flags, version, makeCString(name), &handle);
if (result < 0) {
throwDlpException(result);
return result;
}
return handle;
}
extern javaint_t Pdapilot_calls_dlp_DeleteDB(struct HPdapilot_calls * self, javaint_t socket, javaint_t card, Hjava_lang_String * name)
{
int result = dlp_DeleteDB(socket, card, makeCString(name));
if (result < 0) {
throwDlpException(result);
}
return result;
}
extern Hjava_util_Date * Pdapilot_calls_dlp_GetSysDateTime(struct HPdapilot_calls * self, javaint_t socket)
{
time_t t;
int result = dlp_GetSysDateTime(socket, &t);
if (result < 0) {
throwDlpException(result);
return 0;
}
return makeJavaDate(t);
}
extern javaint_t Pdapilot_calls_dlp_SetSysDateTime(struct HPdapilot_calls * self, javaint_t socket, Hjava_util_Date * date)
{
time_t t;
int result;
t = readJavaDate(date);
result = dlp_SetSysDateTime(socket, t);
if (result < 0) {
throwDlpException(result);
}
return result;
}
extern javaint_t Pdapilot_calls_dlp_AddSyncLogEntry(struct HPdapilot_calls * self, javaint_t socket, Hjava_lang_String * entry)
{
int result = dlp_AddSyncLogEntry(socket, makeCString(entry));
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_ResetSystem(struct HPdapilot_calls * self, javaint_t socket)
{
int result = dlp_ResetSystem(socket);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_EndOfSync(struct HPdapilot_calls * self, javaint_t socket, javaint_t status)
{
int result = dlp_EndOfSync(socket, status);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_MoveCategory(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t from, javaint_t to)
{
int result = dlp_MoveCategory(socket, handle, from, to);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_DeleteRecord(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t all, HPdapilot_RecordID * id)
{
int result = dlp_DeleteRecord(socket, handle, all, getJavaRecordID(id));
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_DeleteCategory(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t category)
{
int result = dlp_DeleteCategory(socket, handle, category);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_ReadOpenDBInfo(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle)
{
int count;
int result = dlp_ReadOpenDBInfo(socket, handle, &count);
if (result < 0)
throwDlpException(result);
return count;
}
extern javaint_t Pdapilot_calls_dlp_DeleteResource(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t all, HPdapilot_Char4 * type, javaint_t id)
{
int result = dlp_DeleteResource(socket, handle, all, unhand(type)->value, id);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_ResetSyncFlags(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle)
{
int result = dlp_ResetSyncFlags(socket, handle);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_CleanUpDatabase(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle)
{
int result = dlp_CleanUpDatabase(socket, handle);
if (result < 0)
throwDlpException(result);
return result;
}
extern HPdapilot_CardInfo * Pdapilot_calls_dlp_ReadStorageInfo(struct HPdapilot_calls * self, javaint_t socket, javaint_t card)
{
HPdapilot_CardInfo * output = NULL;
struct CardInfo c;
int result = dlp_ReadStorageInfo(socket, card, &c);
if (result == -5) {
return 0;
} else if (result < 0) {
throwDlpException(result);
return 0;
}
output = (HPdapilot_CardInfo*)execute_java_constructor(0,
"Pdapilot/CardInfo", 0, "()");
unhand(output)->name = makeJavaString(c.name, strlen(c.name));
unhand(output)->manufacturer = makeJavaString(c.manufacturer, strlen(c.manufacturer));
unhand(output)->card = c.card;
unhand(output)->romSize = c.romSize;
unhand(output)->ramSize = c.ramSize;
unhand(output)->ramFree = c.ramFree;
unhand(output)->more = c.more;
unhand(output)->creation = makeJavaDate(c.creation);
return output;
}
extern HPdapilot_SysInfo * Pdapilot_calls_dlp_ReadSysInfo(struct HPdapilot_calls * self, javaint_t socket)
{
HPdapilot_SysInfo * output = NULL;
struct SysInfo s;
int result = dlp_ReadSysInfo(socket, &s);
if (result < 0) {
throwDlpException(result);
return 0;
}
output = (HPdapilot_SysInfo*)execute_java_constructor(0,
"Pdapilot/SysInfo", 0, "()");
unhand(output)->romVersion = s.romVersion;
unhand(output)->locale = s.locale;
unhand(output)->name = makeJavaString(s.name, s.nameLength);
return output;
}
extern HPdapilot_DBInfo * Pdapilot_calls_dlp_ReadDBList(struct HPdapilot_calls * self, javaint_t socket, javaint_t card, javaint_t flags, javaint_t start)
{
HPdapilot_DBInfo * output = NULL;
struct DBInfo i;
int result = dlp_ReadDBList(socket, card, flags, start, &i);
if (result == -5)
return 0;
else if (result < 0) {
throwDlpException(result);
return 0;
}
output = (HPdapilot_DBInfo*)execute_java_constructor(0,
"Pdapilot/DBInfo", 0, "()");
unhand(output)->flagReadOnly = !!(i.flags & dlpDBFlagReadOnly);
unhand(output)->flagResource = !!(i.flags & dlpDBFlagResource);
unhand(output)->flagBackup = !!(i.flags & dlpDBFlagBackup);
unhand(output)->flagOpen = !!(i.flags & dlpDBFlagOpen);
unhand(output)->flagAppInfoDirty = !!(i.flags & dlpDBFlagAppInfoDirty);
unhand(output)->flagNewer = !!(i.flags & dlpDBFlagNewer);
unhand(output)->flagReset = !!(i.flags & dlpDBFlagReset);
unhand(output)->flagExcludeFromSync = !!(i.miscFlags & dlpDBMiscFlagExcludeFromSync);
unhand(output)->index = i.index;
unhand(output)->version = i.version;
unhand(output)->modnum = i.modnum;
unhand(output)->type = makeJavaChar4(i.type);
unhand(output)->creator = makeJavaChar4(i.creator);
unhand(output)->createDate = makeJavaDate(i.createDate);
unhand(output)->modifyDate = makeJavaDate(i.modifyDate);
unhand(output)->backupDate = makeJavaDate(i.backupDate);
unhand(output)->name = makeJavaString(i.name, strlen(i.name));
unhand(output)->card = card;
unhand(output)->more = i.more;
return output;
}
extern HPdapilot_UserInfo * Pdapilot_calls_dlp_ReadUserInfo(struct HPdapilot_calls * self, javaint_t socket)
{
HPdapilot_UserInfo * output = NULL;
struct PilotUser u;
int result = dlp_ReadUserInfo(socket, &u);
if (result < 0) {
throwDlpException(result);
return 0;
}
output = (HPdapilot_UserInfo*)execute_java_constructor(0,
"Pdapilot/UserInfo", 0, "()");
unhand(output)->username = makeJavaString(u.username, strlen(u.username));
unhand(output)->userID = u.userID;
unhand(output)->viewerID = u.viewerID;
unhand(output)->lastSyncPC = u.lastSyncPC;
unhand(output)->password= getByteArray(u.passwordLength);
memcpy(unhand(unhand(output)->password)->body, u.password, u.passwordLength);
unhand(output)->successfulSyncDate = makeJavaDate(u.successfulSyncDate);
unhand(output)->lastSyncDate = makeJavaDate(u.lastSyncDate);
return output;
}
extern javaint_t Pdapilot_calls_dlp_WriteUserInfo(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_UserInfo * user)
{
struct PilotUser u;
int result;
u.userID = unhand(user)->userID;
u.viewerID = unhand(user)->viewerID;
u.lastSyncPC = unhand(user)->lastSyncPC;
u.passwordLength = getArrayLength(unhand(user)->password);
memcpy(u.password, unhand(unhand(user)->password)->body, u.passwordLength);
u.successfulSyncDate = readJavaDate(unhand(user)->successfulSyncDate);
u.lastSyncDate = readJavaDate(unhand(user)->lastSyncDate);
javaString2CString(unhand(user)->username, u.username, 127);
result = dlp_WriteUserInfo(socket, &u);
if (result < 0) {
throwDlpException(result);
}
return result;
}
extern HPdapilot_NetInfo * Pdapilot_calls_dlp_ReadNetSyncInfo(struct HPdapilot_calls * self, javaint_t socket)
{
HPdapilot_NetInfo * output = NULL;
struct NetSyncInfo i;
int result = dlp_ReadNetSyncInfo(socket, &i);
if (result < 0) {
throwDlpException(result);
return 0;
}
output = (HPdapilot_NetInfo*)execute_java_constructor(0,
"Pdapilot/NetInfo", 0, "()");
unhand(output)->lanSync = i.lanSync;
unhand(output)->hostName = makeJavaString(i.hostName, strlen(i.hostName));
unhand(output)->hostAddress = makeJavaString(i.hostAddress, strlen(i.hostAddress));
unhand(output)->hostSubnetMask = makeJavaString(i.hostSubnetMask, strlen(i.hostSubnetMask));
return output;
}
extern javaint_t Pdapilot_calls_dlp_WriteNetSyncInfo(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_NetInfo * info)
{
struct NetSyncInfo i;
int result;
i.lanSync = unhand(info)->lanSync;
javaString2CString(unhand(info)->hostName, i.hostName, 256);
javaString2CString(unhand(info)->hostAddress, i.hostAddress, 40);
javaString2CString(unhand(info)->hostSubnetMask, i.hostSubnetMask, 40);
result = dlp_WriteNetSyncInfo(socket, &i);
if (result < 0) {
throwDlpException(result);
}
return result;
}
extern javaint_t Pdapilot_calls_dlp_OpenConduit(struct HPdapilot_calls * self, javaint_t socket)
{
int result = dlp_OpenConduit(socket);
if (result == dlpErrSync)
throwCancelSyncException();
else if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_CloseDB(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle)
{
int result;
result = dlp_CloseDB(socket, handle);
if (result<0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_ResetDBIndex(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle)
{
int result;
result = dlp_ResetDBIndex(socket, handle);
if (result<0)
throwDlpException(result);
return result;
}
extern Hjava_lang_String * Pdapilot_calls_dlp_strerror(struct HPdapilot_calls *self, javaint_t error)
{
char * result = dlp_strerror(error);
if (!result)
result = "Unknown DLP error";
return makeJavaString(result, strlen(result));
}
extern HPdapilot_Record * Pdapilot_calls_dlp_ReadRecordByIndex(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t index, HPdapilot_Database * dbClass)
{
int attr, cat;
recordid_t id;
char * buffer = malloc(0xffff);
int len;
HPdapilot_Record * output = NULL;
int result = dlp_ReadRecordByIndex(socket, handle, index, buffer, &id, &len, &attr, &cat);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, makeJavaRecordID(id), (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HArrayOfByte * Pdapilot_calls_dlp_CallApplication(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_Char4 * creator, javaint_t type, javaint_t action, HArrayOfByte * outgoing_data, HArrayOfInt * retcode)
{
char * buffer = malloc(0xffff);
int len;
unsigned long ret;
HArrayOfByte * incoming_data = 0;
int result = dlp_CallApplication(socket, getJavaChar4(creator), type, action, getArrayLength(outgoing_data), unhand(outgoing_data)->body, &ret, 0xffff, &len, buffer);
if (result >= 0) {
incoming_data = getByteArray(len);
memcpy(unhand(incoming_data)->body, buffer, len);
unhand(retcode)->body[0] = ret;
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return incoming_data;
}
extern HPdapilot_Record * Pdapilot_calls_dlp_ReadNextModifiedRec(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_Database * dbClass)
{
int attr, cat, index;
recordid_t id;
char * buffer = malloc(0xffff);
int len;
HPdapilot_Record * output = NULL;
int result = dlp_ReadNextModifiedRec(socket, handle, buffer, &id, &index, &len, &attr, &cat);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, makeJavaRecordID(id), (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_Record * Pdapilot_calls_dlp_ReadNextModifiedRecInCategory(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t cat, HPdapilot_Database * dbClass)
{
int attr, index;
recordid_t id;
char * buffer = malloc(0xffff);
int len;
HPdapilot_Record * output = NULL;
int result = dlp_ReadNextModifiedRecInCategory(socket, handle, cat, buffer, &id, &index, &len, &attr);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, makeJavaRecordID(id), (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_Record * Pdapilot_calls_dlp_ReadNextRecInCategory(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t cat, HPdapilot_Database * dbClass)
{
int attr, index;
recordid_t id;
char * buffer = malloc(0xffff);
int len;
HPdapilot_Record * output = NULL;
int result = dlp_ReadNextRecInCategory(socket, handle, cat, buffer, &id, &index, &len, &attr);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, makeJavaRecordID(id), (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_AppBlock * Pdapilot_calls_dlp_ReadAppBlock(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_Database * dbClass)
{
char * buffer = malloc(0xffff);
int len;
HPdapilot_AppBlock * output = NULL;
int result = dlp_ReadAppBlock(socket, handle, 0, buffer, 0xffff);
if (result >= 0) {
HArrayOfByte * a;
len = result;
a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_AppBlock*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newAppBlock", "([B)LPdapilot/AppBlock;",
a);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_Pref * Pdapilot_calls_dlp_ReadAppPreference(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_Char4 * creator, javaint_t id, javaint_t backup, HPdapilot_Database * dbClass)
{
char * buffer = malloc(0xffff);
int len, version;
HPdapilot_Pref * output = NULL;
int result = dlp_ReadAppPreference(socket, getJavaChar4(creator), id, backup, 0xffff, buffer, &len, &version);
if (result >= 0) {
HArrayOfByte * a;
a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Pref*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newPref", "([BLPdapilot/Char4;IIZ)LPdapilot/Pref;",
a, creator, id, version, backup);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern javaint_t Pdapilot_calls_dlp_ReadFeature(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_Char4 * creator, javaint_t id)
{
long feature;
int result = dlp_ReadFeature(socket, getJavaChar4(creator), id, &feature);
if (result < 0)
throwDlpException(result);
return feature;
}
extern HArrayOfObject * Pdapilot_calls_dlp_ReadRecordIDList(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t sort, javaint_t start, javaint_t max)
{
recordid_t * l = malloc(sizeof(recordid_t)*max);
int count;
int result;
HArrayOfObject * output = 0;
int i;
result = dlp_ReadRecordIDList(socket, handle, sort, start, max, l, &count);
if (result < 0)
throwDlpException(result);
else {
output = makeRecordIDArray(count);
if (output) {
for (i=0;i<count;i++) {
unhand(output)->body[i] = (HObject*)makeJavaRecordID(l[i]);
}
}
}
free(l);
return output;
}
extern HPdapilot_SortBlock * Pdapilot_calls_dlp_ReadSortBlock(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_Database * dbClass)
{
char * buffer = malloc(0xffff);
int len;
HPdapilot_SortBlock * output = NULL;
int result = dlp_ReadSortBlock(socket, handle, 0, buffer, 0xffff);
if (result >= 0) {
HArrayOfByte * a;
len = result;
a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_SortBlock*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newSortBlock", "([B)LPdapilot/SortBlock;",
a);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_Record * Pdapilot_calls_dlp_ReadRecordByID(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_RecordID * id, HPdapilot_Database * dbClass)
{
int attr, cat;
char * buffer = malloc(0xffff);
int len;
int index;
HPdapilot_Record * output = NULL;
int result = dlp_ReadRecordById(socket, handle, getJavaRecordID(id), buffer, &index, &len, &attr, &cat);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, id, (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_Resource * Pdapilot_calls_dlp_ReadResourceByType(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_Char4 * type, javaint_t id, HPdapilot_Database * dbClass)
{
char * buffer = malloc(0xffff);
int len;
int index;
HPdapilot_Resource * output = NULL;
int result = dlp_ReadResourceByType(socket, handle, unhand(type)->value, id, buffer, &index, &len);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Resource*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newResource", "([BLPdapilot/Char4;II)LPdapilot/Resource;",
a, type, (javaint_t)id, (javaint_t)index);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern HPdapilot_Resource * Pdapilot_calls_dlp_ReadResourceByIndex(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, javaint_t index, HPdapilot_Database * dbClass)
{
long type;
char * buffer = malloc(0xffff);
int len, id;
HPdapilot_Resource * output = NULL;
int result = dlp_ReadResourceByIndex(socket, handle, index, buffer, &type, &id, &len);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Resource*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newResource", "([BLPdapilot/Char4;II)LPdapilot/Resource;",
a, makeJavaChar4(type), (javaint_t)id, (javaint_t)index);
} else if (result != -5) {
throwDlpException(result);
}
free(buffer);
return output;
}
extern javaint_t Pdapilot_calls_dlp_WriteRecord(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_Record * record)
{
int attr, cat;
HArrayOfByte * b;
char * buffer;
int len;
recordid_t id;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)record, "pack", "()[B");
if (!b)
return 0;
id = getJavaRecordID(unhand(record)->id);
attr = 0;
attr |= unhand(record)->deleted ? 0x80 : 0;
attr |= unhand(record)->modified ? 0x40 : 0;
attr |= unhand(record)->busy ? 0x20 : 0;
attr |= unhand(record)->secret ? 0x10 : 0;
attr |= unhand(record)->archived ? 0x08 : 0;
cat = unhand(record)->category;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = dlp_WriteRecord(socket, handle, attr, id, cat, buffer, len, &id);
if (result >= 0) {
return id;
} else {
throwDlpException(result);
}
return 0;
}
extern javaint_t Pdapilot_calls_dlp_WriteAppPreference(struct HPdapilot_calls * self, javaint_t socket, HPdapilot_Pref * pref)
{
HArrayOfByte * b;
char * buffer;
int len;
javaint_t creator;
int id, version;
int result;
int backup;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)pref, "pack", "()[B");
if (!b)
return 0;
creator = getJavaChar4(unhand(pref)->creator);
id = unhand(pref)->id;
version = unhand(pref)->version;
backup = unhand(pref)->backup;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = dlp_WriteAppPreference(socket, creator, id, backup, version, buffer, len);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_WriteAppBlock(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_AppBlock * appblock)
{
HArrayOfByte * b;
char * buffer;
int len;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)appblock, "pack", "()[B");
if (!b)
return 0;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = dlp_WriteAppBlock(socket, handle, buffer, len);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_WriteSortBlock(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_SortBlock * sortblock)
{
HArrayOfByte * b;
char * buffer;
int len;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)sortblock, "pack", "()[B");
if (!b)
return 0;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = dlp_WriteSortBlock(socket, handle, buffer, len);
if (result < 0)
throwDlpException(result);
return result;
}
extern javaint_t Pdapilot_calls_dlp_WriteResource(struct HPdapilot_calls * self, javaint_t socket, javaint_t handle, HPdapilot_Resource * resource)
{
char * buffer;
HArrayOfByte * b;
int len;
javaint_t type;
javaint_t id;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)resource, "pack", "()[B");
if (!b)
return 0;
type = unhand(unhand(resource)->type)->value;
id = unhand(resource)->id;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = dlp_WriteResource(socket, handle, type, id, buffer, len);
if (result < 0)
throwDlpException(result);
return result;
}
extern void Pdapilot_memo_Record_unpack(struct HPdapilot_memo_Record * self, struct HArrayOfByte *b)
{
struct Memo m;
unpack_Memo(&m, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
unhand(self)->text = m.text ? makeJavaString(m.text, strlen(m.text)) : 0;
free_Memo(&m);
}
extern HArrayOfByte* Pdapilot_memo_Record_pack(struct HPdapilot_memo_Record * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct Memo m;
m.text = makeCString(unhand(self)->text);
len = pack_Memo(&m, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
static void doUnpackCategories(HPdapilot_CategoryAppBlock * self, struct CategoryAppInfo * c)
{
int i;
unhand(self)->categoryLastUniqueID = c->lastUniqueID;
if (!(unhand(self)->categoryName = makeStringArray(16)))
return;
if (!(unhand(self)->categoryID = makeIntArray(16)))
return;
if (!(unhand(self)->categoryRenamed = makeIntArray(16)))
return;
for (i=0;i<16;i++) {
unhand(unhand(self)->categoryName)->body[i] = (HObject*)makeJavaString(c->name[i], strlen(c->name[i]));
unhand(unhand(self)->categoryID)->body[i] = c->ID[i];
unhand(unhand(self)->categoryRenamed)->body[i] = c->renamed[i];
}
}
static void doPackCategories(HPdapilot_CategoryAppBlock * self, struct CategoryAppInfo * c)
{
int i;
c->lastUniqueID = unhand(self)->categoryLastUniqueID;
for (i=0;i<16;i++) {
javaString2CString((HString*)unhand(unhand(self)->categoryName)->body[i], c->name[i], 16);
c->ID[i] = unhand(unhand(self)->categoryID)->body[i];
c->renamed[i] = unhand(unhand(self)->categoryRenamed)->body[i];
}
}
extern void Pdapilot_memo_AppBlock_unpack(struct HPdapilot_memo_AppBlock * self, struct HArrayOfByte *b)
{
struct MemoAppInfo m;
unpack_MemoAppInfo(&m, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
doUnpackCategories((HPdapilot_CategoryAppBlock*)self, &m.category);
unhand(self)->sortByAlpha = m.sortByAlpha;
}
extern HArrayOfByte* Pdapilot_memo_AppBlock_pack(struct HPdapilot_memo_AppBlock * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct MemoAppInfo m;
doPackCategories((HPdapilot_CategoryAppBlock*)self, &m.category);
m.sortByAlpha = unhand(self)->sortByAlpha;
len = pack_MemoAppInfo(&m, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_todo_Record_unpack(struct HPdapilot_todo_Record * self, struct HArrayOfByte *b)
{
struct ToDo t;
unpack_ToDo(&t, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
unhand(self)->due = t.indefinite ? makeJavaDateTm(&t.due) : 0;
unhand(self)->priority = t.priority;
unhand(self)->complete = t.complete;
unhand(self)->description = t.description ? makeJavaString(t.description, strlen(t.description)) : 0;
unhand(self)->note = t.note ? makeJavaString(t.note, strlen(t.note)) : 0;
free_ToDo(&t);
}
extern HArrayOfByte* Pdapilot_todo_Record_pack(struct HPdapilot_todo_Record * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct ToDo t;
struct tm * tm;
t.description = unhand(self)->description ? makeCString(unhand(self)->description) : 0;
t.note = unhand(self)->note ? makeCString(unhand(self)->note) : 0;
t.priority = unhand(self)->priority;
t.complete = unhand(self)->complete;
t.indefinite = 1;
if (unhand(self)->due) {
tm = readJavaDateTm(unhand(self)->due);
if (tm) {
t.due = *tm;
t.indefinite = 0;
}
}
len = pack_ToDo(&t, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_todo_AppBlock_unpack(struct HPdapilot_todo_AppBlock * self, struct HArrayOfByte *b)
{
struct ToDoAppInfo t;
unpack_ToDoAppInfo(&t, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
doUnpackCategories((HPdapilot_CategoryAppBlock*)self, &t.category);
unhand(self)->dirty = t.dirty;
unhand(self)->sortByPriority = t.sortByPriority;
}
extern HArrayOfByte* Pdapilot_todo_AppBlock_pack(struct HPdapilot_todo_AppBlock * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct ToDoAppInfo t;
t.sortByPriority = unhand(self)->sortByPriority;
t.dirty = unhand(self)->dirty;
doPackCategories((HPdapilot_CategoryAppBlock*)self, &t.category);
len = pack_ToDoAppInfo(&t, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_CategoryAppBlock_unpack(struct HPdapilot_CategoryAppBlock * self, struct HArrayOfByte *b)
{
struct CategoryAppInfo c;
unpack_CategoryAppInfo(&c, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
doUnpackCategories(self, &c);
}
extern HArrayOfByte* Pdapilot_CategoryAppBlock_pack(struct HPdapilot_CategoryAppBlock * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct CategoryAppInfo c;
doPackCategories(self, &c);
len = pack_CategoryAppInfo(&c, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_address_Record_unpack(struct HPdapilot_address_Record * self, struct HArrayOfByte *b)
{
struct Address a;
int i;
unpack_Address(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
unhand(self)->showPhone = a.showPhone;
if (!(unhand(self)->entry = makeStringArray(19)))
return;
if (!(unhand(self)->phoneLabel = makeIntArray(5)))
return;
for (i=0;i<19;i++)
unhand(unhand(self)->entry)->body[i] = a.entry[i] ? (HObject*)makeJavaString(a.entry[i], strlen(a.entry[i])) : 0;
for (i=0;i<5;i++)
unhand(unhand(self)->phoneLabel)->body[i] = a.phoneLabel[i];
free_Address(&a);
}
extern HArrayOfByte* Pdapilot_address_Record_pack(struct HPdapilot_address_Record * self){
char * buffer = malloc(0xffff);
int len;
int i;
HArrayOfByte * output;
struct Address a;
for (i=0;i<19;i++)
javaString2CString((HString*)unhand(unhand(self)->entry)->body[i], a.entry[i], 16);
for (i=0;i<5;i++)
a.phoneLabel[i] = unhand(unhand(self)->phoneLabel)->body[i];
a.showPhone = unhand(self)->showPhone;
len = pack_Address(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_address_AppBlock_unpack(struct HPdapilot_address_AppBlock * self, struct HArrayOfByte *b)
{
struct AddressAppInfo a;
int i;
unpack_AddressAppInfo(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
doUnpackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
if (!(unhand(self)->labelRenamed = makeIntArray(22)))
return;
for(i=0;i<22;i++)
unhand(unhand(self)->labelRenamed)->body[i] = a.labelRenamed[i];
unhand(self)->sortByCompany = a.sortByCompany;
if (!(unhand(self)->label = makeStringArray(22)))
return;
if (!(unhand(self)->phoneLabel = makeStringArray(8)))
return;
for (i=0;i<22;i++)
unhand(unhand(self)->label)->body[i] = (HObject*)makeJavaString(a.labels[i], strlen(a.labels[i]));
for (i=0;i<8;i++)
unhand(unhand(self)->phoneLabel)->body[i] = (HObject*)makeJavaString(a.phoneLabels[i], strlen(a.phoneLabels[i]));
}
extern HArrayOfByte* Pdapilot_address_AppBlock_pack(struct HPdapilot_address_AppBlock * self){
char * buffer = malloc(0xffff);
int len;
int i;
HArrayOfByte * output;
struct AddressAppInfo a;
a.sortByCompany = unhand(self)->sortByCompany;
for(i=0;i<22;i++)
a.labelRenamed[i] = unhand(unhand(self)->labelRenamed)->body[i];
doPackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
for (i=0;i<22;i++)
javaString2CString((HString*)unhand(unhand(self)->label)->body[i], a.labels[i], 16);
for (i=0;i<8;i++)
javaString2CString((HString*)unhand(unhand(self)->phoneLabel)->body[i], a.phoneLabels[i], 16);
len = pack_AddressAppInfo(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_appointment_Record_unpack(struct HPdapilot_appointment_Record * self, struct HArrayOfByte *b)
{
struct Appointment a;
int i;
unpack_Appointment(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->note = a.note ? makeJavaString(a.note, strlen(a.note)) : 0;
unhand(self)->description = a.description ? makeJavaString(a.description, strlen(a.description)) : 0;
unhand(self)->begin = makeJavaDateTm(&a.begin);
unhand(self)->end = a.event ? 0 : makeJavaDateTm(&a.end);
unhand(self)->alarm = a.alarm;
unhand(self)->advance = a.advance;
unhand(self)->advanceUnits = (HPdapilot_appointment_time*)
execute_java_static_method(0, FindClass(0, "Pdapilot/appointment/time",1),
"get", "(I)LPdapilot/appointment/time;", (long)a.advanceUnits);
if (!unhand(self)->advanceUnits)
return;
/*(a.advanceUnits == 0) ? 60 : (a.advanceUnits == 1) ? 60*60 : (a.advanceUnits == 2) ? 60*60*26 : 0;*/
if (a.exceptions) {
if (!(unhand(self)->exceptions = makeDateArray(a.exceptions)))
return;
for(i=0;i<a.exceptions;i++)
unhand(unhand(self)->exceptions)->body[i] = (HObject*)makeJavaDateTm(&a.exception[i]);
}
unhand(self)->repeatDay = a.repeatDay;
unhand(self)->repeatWeekStart = a.repeatWeekstart;
/*unhand(self)->repeatType = a.repeatType;*/
unhand(self)->repeatType = (HPdapilot_appointment_repeat*)
execute_java_static_method(0, FindClass(0, "Pdapilot/appointment/repeat",1),
"get", "(I)LPdapilot/appointment/repeat;", (long)a.repeatType);
if (!unhand(self)->repeatType)
return;
if (!(unhand(self)->repeatWeekdays = makeIntArray(7)))
return;
for(i=0;i<7;i++)
unhand(unhand(self)->repeatWeekdays)->body[i] = a.repeatDays[i];
unhand(self)->repeatEnd = a.repeatForever ? 0 : makeJavaDateTm(&a.repeatEnd);
free_Appointment(&a);
}
extern HArrayOfByte* Pdapilot_appointment_Record_pack(struct HPdapilot_appointment_Record * self){
char * buffer = malloc(0xffff);
int len;
int i;
HArrayOfByte * output;
struct Appointment a;
a.note = unhand(self)->note ? makeCString(unhand(self)->note) : 0;
a.description = unhand(self)->description ? makeCString(unhand(self)->description) : 0;
a.begin = *readJavaDateTm(unhand(self)->begin);
if (unhand(self)->end) {
a.end = *readJavaDateTm(unhand(self)->end);
a.event = 1;
} else {
a.event = 0;
}
a.alarm = unhand(self)->alarm;
a.advance = unhand(self)->advance;
a.advanceUnits = (long)execute_java_dynamic_method(0, (HObject*)unhand(self)->advanceUnits,
"getValue", "()I");
a.repeatType = (long)execute_java_dynamic_method(0, (HObject*)unhand(self)->repeatType,
"getValue", "()I");
if (a.repeatType == repeatWeekly) {
for(i=0;i<7;i++)
a.repeatDays[i] = unhand(unhand(self)->repeatWeekdays)->body[i];
} else {
a.repeatDay = unhand(self)->repeatDay;
}
a.repeatWeekstart = unhand(self)->repeatWeekStart;
if (unhand(self)->repeatEnd) {
a.repeatForever = 0;
a.repeatEnd = *readJavaDateTm(unhand(self)->repeatEnd);
} else
a.repeatForever = 1;
if (unhand(self)->exceptions) {
a.exceptions = getObjectArrayLength(unhand(self)->exceptions);
a.exception = malloc(sizeof(struct tm)*a.exceptions);
for(i=0;i<a.exceptions;i++)
a.exception[i] = *readJavaDateTm((Hjava_util_Date*)unhand(unhand(self)->exceptions)->body[i]);
}
len = pack_Appointment(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_appointment_AppBlock_unpack(struct HPdapilot_appointment_AppBlock * self, struct HArrayOfByte *b)
{
struct AppointmentAppInfo a;
unpack_AppointmentAppInfo(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
doUnpackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
unhand(self)->startOfWeek = a.startOfWeek;
}
extern HArrayOfByte* Pdapilot_appointment_AppBlock_pack(struct HPdapilot_appointment_AppBlock * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct AppointmentAppInfo a;
a.startOfWeek = unhand(self)->startOfWeek;
doPackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
len = pack_AppointmentAppInfo(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
/* mail */
extern void Pdapilot_mail_Record_unpack(struct HPdapilot_mail_Record * self, struct HArrayOfByte *b)
{
struct Mail a;
unpack_Mail(&a, unhand(b)->body, getArrayLength(b));
if (a.dated)
unhand(self)->date = makeJavaDateTm(&a.date);
else
unhand(self)->date = 0;
unhand(self)->read = a.read;
unhand(self)->signature = a.signature;
unhand(self)->confirmRead = a.confirmRead;
unhand(self)->confirmDelivery = a.confirmDelivery;
unhand(self)->priority = a.priority;
unhand(self)->addressing = a.addressing;
unhand(self)->subject = a.subject ? makeJavaString(a.subject, strlen(a.subject)) : 0;
unhand(self)->from = a.from ? makeJavaString(a.from, strlen(a.from)) : 0;
unhand(self)->to = a.to ? makeJavaString(a.to, strlen(a.to)) : 0;
unhand(self)->cc = a.cc ? makeJavaString(a.cc, strlen(a.cc)) : 0;
unhand(self)->bcc = a.bcc ? makeJavaString(a.bcc, strlen(a.bcc)) : 0;
unhand(self)->replyTo = a.replyTo ? makeJavaString(a.replyTo, strlen(a.replyTo)) : 0;
unhand(self)->sentTo = a.sentTo ? makeJavaString(a.sentTo, strlen(a.sentTo)) : 0;
unhand(self)->body = a.body ? makeJavaString(a.body, strlen(a.body)) : 0;
free_Mail(&a);
}
extern HArrayOfByte* Pdapilot_mail_Record_pack(struct HPdapilot_mail_Record * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct Mail a;
a.dated = unhand(self)->date ? 1 : 0;
if (a.dated)
a.date = *readJavaDateTm(unhand(self)->date);
a.read = unhand(self)->read;
a.signature = unhand(self)->signature;
a.confirmRead = unhand(self)->confirmRead;
a.confirmDelivery = unhand(self)->confirmDelivery;
a.priority = unhand(self)->priority;
a.addressing = unhand(self)->addressing;
a.subject = unhand(self)->subject ? makeCString(unhand(self)->subject) : 0;
a.from = unhand(self)->from ? makeCString(unhand(self)->from) : 0;
a.to = unhand(self)->to ? makeCString(unhand(self)->to) : 0;
a.cc = unhand(self)->cc ? makeCString(unhand(self)->cc) : 0;
a.bcc = unhand(self)->bcc ? makeCString(unhand(self)->bcc) : 0;
a.replyTo = unhand(self)->replyTo ? makeCString(unhand(self)->replyTo) : 0;
a.sentTo = unhand(self)->sentTo ? makeCString(unhand(self)->sentTo) : 0;
a.body = unhand(self)->body ? makeCString(unhand(self)->body) : 0;
len = pack_Mail(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_mail_AppBlock_unpack(struct HPdapilot_mail_AppBlock * self, struct HArrayOfByte *b)
{
struct MailAppInfo a;
unpack_MailAppInfo(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
doUnpackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
unhand(self)->dirty = a.dirty;
unhand(self)->sortOrder = (HPdapilot_mail_sort*)
execute_java_static_method(0, FindClass(0, "Pdapilot/mail/sort",1),
"get", "(I)LPdapilot/mail/sort;", (long)a.sortOrder);
unhand(self)->unsentMessage = a.unsentMessage ? makeJavaRecordID(a.unsentMessage) : 0;
}
extern HArrayOfByte* Pdapilot_mail_AppBlock_pack(struct HPdapilot_mail_AppBlock * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct MailAppInfo a;
doPackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
a.sortOrder = (long)execute_java_dynamic_method(0,
(HObject*)unhand(self)->sortOrder, "getValue", "()I");
a.dirty = unhand(self)->dirty;
a.unsentMessage = unhand(self)->unsentMessage ? getJavaRecordID(unhand(self)->unsentMessage) : 0;
len = pack_MailAppInfo(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_mail_SyncPref_unpack(struct HPdapilot_mail_SyncPref * self, struct HArrayOfByte *b)
{
struct MailSyncPref a;
unpack_MailSyncPref(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
unhand(self)->syncType = (HPdapilot_mail_sync*)
execute_java_static_method(0, FindClass(0, "Pdapilot/mail/sync",1),
"get", "(I)LPdapilot/mail/sync;", (long)a.syncType);
unhand(self)->getHigh = a.getHigh;
unhand(self)->getContaining = a.getContaining;
unhand(self)->truncate = a.truncate;
unhand(self)->filterTo = a.filterTo ? makeJavaString(a.filterTo, strlen(a.filterTo)) : 0;
unhand(self)->filterFrom = a.filterFrom ? makeJavaString(a.filterFrom, strlen(a.filterFrom)) : 0;
unhand(self)->filterSubject = a.filterSubject ? makeJavaString(a.filterSubject, strlen(a.filterSubject)) : 0;
}
extern HArrayOfByte* Pdapilot_mail_SyncPref_pack(struct HPdapilot_mail_SyncPref * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct MailSyncPref a;
a.syncType = (long)execute_java_dynamic_method(0,
(HObject*)unhand(self)->syncType, "getValue", "()I");
a.getHigh = unhand(self)->getHigh;
a.getContaining = unhand(self)->getContaining;
a.truncate = unhand(self)->truncate;
a.filterTo = unhand(self)->filterTo ? makeCString(unhand(self)->filterTo) : 0;
a.filterFrom = unhand(self)->filterFrom ? makeCString(unhand(self)->filterFrom) : 0;
a.filterSubject = unhand(self)->filterSubject ? makeCString(unhand(self)->filterSubject) : 0;
len = pack_MailSyncPref(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_mail_SignaturePref_unpack(struct HPdapilot_mail_SignaturePref * self, struct HArrayOfByte *b)
{
struct MailSignaturePref a;
unpack_MailSignaturePref(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
unhand(self)->signature = a.signature ? makeJavaString(a.signature, strlen(a.signature)) : 0;
}
extern HArrayOfByte* Pdapilot_mail_SignaturePref_pack(struct HPdapilot_mail_SignaturePref * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct MailSignaturePref a;
a.signature = unhand(self)->signature ? makeCString(unhand(self)->signature) : 0;
len = pack_MailSignaturePref(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
/* expense */
extern void Pdapilot_expense_Record_unpack(struct HPdapilot_expense_Record * self, struct HArrayOfByte *b)
{
struct Expense a;
unpack_Expense(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->date = makeJavaDateTm(&a.date);
unhand(self)->type = (HPdapilot_expense_type*)
execute_java_static_method(0, FindClass(0, "Pdapilot/expense/type",1),
"get", "(I)LPdapilot/expense/type;", (long)a.type);
unhand(self)->payment = (HPdapilot_expense_payment*)
execute_java_static_method(0, FindClass(0, "Pdapilot/expense/payment",1),
"get", "(I)LPdapilot/expense/payment;", (long)a.payment);
unhand(self)->amount = a.amount ? makeJavaString(a.amount, strlen(a.amount)) : 0;
unhand(self)->vendor = a.vendor ? makeJavaString(a.vendor, strlen(a.vendor)) : 0;
unhand(self)->city = a.city ? makeJavaString(a.city, strlen(a.city)) : 0;
unhand(self)->attendees = a.attendees ? makeJavaString(a.attendees, strlen(a.attendees)) : 0;
unhand(self)->note = a.note ? makeJavaString(a.note, strlen(a.note)) : 0;
free_Expense(&a);
}
extern HArrayOfByte* Pdapilot_expense_Record_pack(struct HPdapilot_expense_Record * self){
char * buffer = malloc(0xffff);
int len;
HArrayOfByte * output;
struct Expense a;
a.date = *readJavaDateTm(unhand(self)->date);
a.currency = unhand(self)->currency;
a.type = (long)execute_java_dynamic_method(0,
(HObject*)unhand(self)->type, "getValue", "()I");
a.payment = (long)execute_java_dynamic_method(0,
(HObject*)unhand(self)->payment, "getValue", "()I");
a.amount = unhand(self)->amount ? makeCString(unhand(self)->amount) : 0;
a.vendor = unhand(self)->vendor ? makeCString(unhand(self)->vendor) : 0;
a.city = unhand(self)->city ? makeCString(unhand(self)->city) : 0;
a.attendees = unhand(self)->attendees ? makeCString(unhand(self)->attendees) : 0;
a.note = unhand(self)->note ? makeCString(unhand(self)->note) : 0;
len = pack_Expense(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_expense_AppBlock_unpack(struct HPdapilot_expense_AppBlock * self, struct HArrayOfByte *b)
{
int i;
struct ExpenseAppInfo a;
stack_item l;
unpack_ExpenseAppInfo(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
l.i = 4;
unhand(self)->currencies = (HArrayOfObject*)MultiArrayAlloc(1,
FindClass(0, "Pdapilot/expense/CustomCurrency",1),
&l);
if (!unhand(self)->currencies)
return;
for(i=0;i<4;i++) {
struct ExpenseCustomCurrency * ecc;
HPdapilot_expense_CustomCurrency * c =
(HPdapilot_expense_CustomCurrency*)execute_java_constructor(0,
"Pdapilot/expense/CustomCurrency", 0, "()");
unhand(unhand(self)->currencies)->body[i] = (HObject*)c;
ecc = &a.currencies[i];
unhand(c)->symbol = ecc->symbol ? makeJavaString(ecc->symbol, strlen(ecc->symbol)) : 0;
unhand(c)->name = ecc->name ? makeJavaString(ecc->name, strlen(ecc->name)) : 0;
unhand(c)->rate = ecc->rate ? makeJavaString(ecc->rate, strlen(ecc->rate)) : 0;
}
doUnpackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
unhand(self)->sortOrder = (HPdapilot_expense_sort*)
execute_java_static_method(0, FindClass(0, "Pdapilot/expense/sort",1),
"get", "(I)LPdapilot/expense/sort;", (long)a.sortOrder);;
}
extern HArrayOfByte* Pdapilot_expense_AppBlock_pack(struct HPdapilot_expense_AppBlock * self){
char * buffer = malloc(0xffff);
int len;
int i;
HArrayOfByte * output;
struct ExpenseAppInfo a;
a.sortOrder = (long)execute_java_dynamic_method(0,
(HObject*)unhand(self)->sortOrder, "getValue", "()I");
if (unhand(self)->currencies)
for(i=0;i<4;i++) {
HPdapilot_expense_CustomCurrency * c =
(HPdapilot_expense_CustomCurrency*)
unhand(unhand(self)->currencies)->body[i];
if (unhand(c)->name)
javaString2CString(unhand(c)->name, a.currencies[i].name, 16);
else
a.currencies[i].name[0] = 0;
if (unhand(c)->symbol)
javaString2CString(unhand(c)->symbol, a.currencies[i].symbol, 4);
else
a.currencies[i].symbol[0] = 0;
if (unhand(c)->rate)
javaString2CString(unhand(c)->rate, a.currencies[i].rate, 8);
else
a.currencies[i].rate[0] = 0;
}
doPackCategories((HPdapilot_CategoryAppBlock*)self, &a.category);
len = pack_ExpenseAppInfo(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_expense_Pref_unpack(struct HPdapilot_expense_Pref * self, struct HArrayOfByte *b)
{
struct ExpensePref a;
int i;
unpack_ExpensePref(&a, unhand(b)->body, getArrayLength(b));
unhand(self)->raw = b;
unhand(self)->currentCategory = a.currentCategory;
unhand(self)->defaultCategory = a.defaultCategory;
unhand(self)->currentCategory = a.noteFont;
unhand(self)->showAllCategories = a.showAllCategories;
unhand(self)->showCurrency = a.showCurrency;
unhand(self)->saveBackup = a.saveBackup;
unhand(self)->allowQuickFill = a.allowQuickFill;
unhand(self)->unitOfDistance = (HPdapilot_expense_distance*)
execute_java_static_method(0, FindClass(0, "Pdapilot/expense/distance",1),
"get", "(I)LPdapilot/expense/distance;", (long)a.unitOfDistance);
unhand(self)->currencies = makeIntArray(7);
for (i=0;i<7;i++)
unhand(unhand(self)->currencies)->body[i] = a.currencies[i];
}
extern HArrayOfByte* Pdapilot_expense_Pref_pack(struct HPdapilot_expense_Pref * self){
char * buffer = malloc(0xffff);
int len;
int i;
HArrayOfByte * output;
struct ExpensePref a;
a.currentCategory = unhand(self)->currentCategory;
a.defaultCategory = unhand(self)->defaultCategory;
a.noteFont = unhand(self)->currentCategory;
a.showAllCategories = unhand(self)->showAllCategories;
a.showCurrency = unhand(self)->showCurrency;
a.saveBackup = unhand(self)->saveBackup;
a.allowQuickFill = unhand(self)->allowQuickFill;
a.unitOfDistance = (long)execute_java_dynamic_method(0,
(HObject*)unhand(self)->unitOfDistance, "getValue", "()I");
for (i=0;i<7;i++)
a.currencies[i] = unhand(unhand(self)->currencies)->body[i];
len = pack_ExpensePref(&a, buffer, 0xffff);
output = getByteArray(len);
memcpy(unhand(output)->body, buffer, len);
unhand(self)->raw = output;
free(buffer);
return output;
}
extern void Pdapilot_File_pi_file_create(struct HPdapilot_File * self,struct Hjava_lang_String * name,struct HPdapilot_DBInfo * info)
{
struct pi_file * pf;
struct DBInfo dbInfo;
dbInfo.flags =
(unhand(info)->flagReadOnly ? dlpDBFlagReadOnly : 0) |
(unhand(info)->flagResource ? dlpDBFlagResource : 0) |
(unhand(info)->flagBackup ? dlpDBFlagBackup : 0) |
(unhand(info)->flagOpen ? dlpDBFlagOpen : 0) |
(unhand(info)->flagAppInfoDirty ? dlpDBFlagAppInfoDirty : 0) |
(unhand(info)->flagNewer ? dlpDBFlagNewer : 0) |
(unhand(info)->flagReset ? dlpDBFlagReset : 0);
dbInfo.miscFlags = (unhand(info)->flagExcludeFromSync ? dlpDBMiscFlagExcludeFromSync : 0);
dbInfo.version = unhand(info)->version;
dbInfo.modnum = unhand(info)->modnum;
dbInfo.type = getJavaChar4(unhand(info)->type);
dbInfo.creator = getJavaChar4(unhand(info)->creator);
dbInfo.createDate = readJavaDate(unhand(info)->createDate);
dbInfo.modifyDate = readJavaDate(unhand(info)->modifyDate);
dbInfo.backupDate = readJavaDate(unhand(info)->backupDate);
javaString2CString(unhand(info)->name, dbInfo.name, 34);
unhand(self)->_pf = 0;
pf = pi_file_create(makeCString(name), &dbInfo);
if (!pf) {
throwIOException(errno);
return;
}
unhand(self)->_pf = (javaint_t)pf;
}
extern void Pdapilot_File_pi_file_open(struct HPdapilot_File * self,struct Hjava_lang_String * name)
{
struct pi_file * pf = pi_file_open(makeCString(name));
unhand(self)->_pf = 0;
if (!pf) {
throwIOException(errno);
return;
}
unhand(self)->_pf = (javaint_t)pf;
}
extern void Pdapilot_File_pi_file_close(struct HPdapilot_File * self)
{
if (unhand(self)->_pf) {
pi_file_close((struct pi_file*)(unhand(self)->_pf));
unhand(self)->_pf = 0;
}
}
extern void Pdapilot_File_pi_file_install(struct HPdapilot_File * self, javaint_t socket, javaint_t cardno)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int result = pi_file_install(pf, socket, cardno);
if (result<0) {
throwIOException(errno);
}
}
extern void Pdapilot_File_pi_file_retrieve(struct HPdapilot_File * self, javaint_t socket, javaint_t cardno)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int result = pi_file_retrieve(pf, socket, cardno);
if (result<0) {
throwIOException(errno);
}
}
extern void Pdapilot_File_pi_file_merge(struct HPdapilot_File * self, javaint_t socket, javaint_t cardno)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int result = pi_file_merge(pf, socket, cardno);
if (result<0) {
throwIOException(errno);
}
}
extern javaint_t Pdapilot_File_pi_file_get_entries(struct HPdapilot_File * self)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int entries;
int result = pi_file_get_entries(pf, &entries);
if (result < 0) {
throwIOException(errno);
return 0;
}
return entries;
}
extern struct HPdapilot_Record *Pdapilot_File_pi_file_read_record(struct HPdapilot_File * self, javaint_t index ,struct HPdapilot_Database * dbClass)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int attr, cat;
recordid_t id;
int len;
void * buffer;
HPdapilot_Record * output = NULL;
int result = pi_file_read_record(pf, index, &buffer, &len, &attr, &cat, &id);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, makeJavaRecordID(id), (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else {
throwIOException(errno);
return 0;
}
return output;
}
extern struct HPdapilot_Resource *Pdapilot_File_pi_file_read_resource(struct HPdapilot_File * self, javaint_t index ,struct HPdapilot_Database * dbClass)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int id;
unsigned long type;
int len;
void * buffer;
HPdapilot_Resource * output = NULL;
int result = pi_file_read_resource(pf, index, &buffer, &len, &type, &id);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Resource*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newResource", "([BLPdapilot/Char4;II)LPdapilot/Resource;",
a, type, (javaint_t)id, (javaint_t)index);
} else {
throwIOException(errno);
return 0;
}
return output;
}
extern struct HPdapilot_Record *Pdapilot_File_pi_file_read_record_by_id(struct HPdapilot_File * self, struct HPdapilot_RecordID * jid ,struct HPdapilot_Database * dbClass)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int attr, cat, index;
recordid_t id = getJavaRecordID(jid);
int len;
void * buffer;
HPdapilot_Record * output = NULL;
int result = pi_file_read_record_by_id(pf, id, &buffer, &len, &index, &attr, &cat);
if (result >= 0) {
HArrayOfByte * a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_Record*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newRecord", "([BLPdapilot/RecordID;III)LPdapilot/Record;",
a, makeJavaRecordID(id), (javaint_t)index, (javaint_t)attr, (javaint_t)cat);
} else {
throwIOException(errno);
return 0;
}
return output;
}
extern struct HPdapilot_DBInfo * Pdapilot_File_pi_file_get_info(struct HPdapilot_File * self)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
struct HPdapilot_DBInfo * output;
struct DBInfo i;
if (pi_file_get_info(pf, &i)<0) {
throwIOException(errno);
return 0;
}
output = (HPdapilot_DBInfo*)execute_java_constructor(0,
"Pdapilot/DBInfo", 0, "()");
unhand(output)->flagReadOnly = !!(i.flags & dlpDBFlagReadOnly);
unhand(output)->flagResource = !!(i.flags & dlpDBFlagResource);
unhand(output)->flagBackup = !!(i.flags & dlpDBFlagBackup);
unhand(output)->flagOpen = !!(i.flags & dlpDBFlagOpen);
unhand(output)->flagAppInfoDirty = !!(i.flags & dlpDBFlagAppInfoDirty);
unhand(output)->flagNewer = !!(i.flags & dlpDBFlagNewer);
unhand(output)->flagReset = !!(i.flags & dlpDBFlagReset);
unhand(output)->flagExcludeFromSync = !!(i.miscFlags & dlpDBMiscFlagExcludeFromSync);
unhand(output)->index = i.index;
unhand(output)->version = i.version;
unhand(output)->modnum = i.modnum;
unhand(output)->type = makeJavaChar4(i.type);
unhand(output)->creator = makeJavaChar4(i.creator);
unhand(output)->createDate = makeJavaDate(i.createDate);
unhand(output)->modifyDate = makeJavaDate(i.modifyDate);
unhand(output)->backupDate = makeJavaDate(i.backupDate);
unhand(output)->name = makeJavaString(i.name, strlen(i.name));
unhand(output)->card = 0;
unhand(output)->more = i.more;
return output;
}
extern void Pdapilot_File_pi_file_set_info(struct HPdapilot_File * self, struct HPdapilot_DBInfo * info)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
struct DBInfo dbInfo;
dbInfo.flags =
(unhand(info)->flagReadOnly ? dlpDBFlagReadOnly : 0) |
(unhand(info)->flagResource ? dlpDBFlagResource : 0) |
(unhand(info)->flagBackup ? dlpDBFlagBackup : 0) |
(unhand(info)->flagOpen ? dlpDBFlagOpen : 0) |
(unhand(info)->flagAppInfoDirty ? dlpDBFlagAppInfoDirty : 0) |
(unhand(info)->flagNewer ? dlpDBFlagNewer : 0) |
(unhand(info)->flagReset ? dlpDBFlagReset : 0);
dbInfo.miscFlags = (unhand(info)->flagExcludeFromSync ? dlpDBMiscFlagExcludeFromSync : 0);
dbInfo.version = unhand(info)->version;
dbInfo.modnum = unhand(info)->modnum;
dbInfo.type = getJavaChar4(unhand(info)->type);
dbInfo.creator = getJavaChar4(unhand(info)->creator);
dbInfo.createDate = readJavaDate(unhand(info)->createDate);
dbInfo.modifyDate = readJavaDate(unhand(info)->modifyDate);
dbInfo.backupDate = readJavaDate(unhand(info)->backupDate);
javaString2CString(unhand(info)->name, dbInfo.name, 34);
if (pi_file_set_info(pf, &dbInfo)<0)
throwIOException(errno);
}
extern void Pdapilot_File_pi_file_set_app_info(struct HPdapilot_File * self, struct HPdapilot_AppBlock * appblock)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
HArrayOfByte * b;
char * buffer;
int len;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)appblock, "pack", "()[B");
if (!b)
return;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = pi_file_set_app_info(pf, buffer, len);
if (result < 0)
throwIOException(errno);
}
extern struct HPdapilot_AppBlock *Pdapilot_File_pi_file_get_app_info(struct HPdapilot_File * self, HPdapilot_Database * dbClass)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
void * buffer;
int len;
HPdapilot_AppBlock * output;
int result = pi_file_get_app_info(pf, &buffer, &len);
if (result >= 0) {
HArrayOfByte * a;
len = result;
a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_AppBlock*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newAppBlock", "([B)LPdapilot/AppBlock;",
a);
} else {
throwIOException(errno);
return 0;
}
return output;
}
extern struct HPdapilot_SortBlock *Pdapilot_File_pi_file_get_sort_info(struct HPdapilot_File * self, HPdapilot_Database * dbClass)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
void * buffer;
int len;
HPdapilot_SortBlock * output;
int result = pi_file_get_app_info(pf, &buffer, &len);
if (result >= 0) {
HArrayOfByte * a;
len = result;
a = getByteArray(len);
memcpy(unhand(a)->body, buffer, len);
output = (HPdapilot_SortBlock*)execute_java_dynamic_method(0, (HObject*)dbClass,
"newSortBlock", "([B)LPdapilot/SortBlock;",
a);
} else {
throwIOException(errno);
return 0;
}
return output;
}
extern void Pdapilot_File_pi_file_set_sort_info(struct HPdapilot_File * self, struct HPdapilot_SortBlock * sortblock)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
HArrayOfByte * b;
char * buffer;
int len;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)sortblock, "pack", "()[B");
if (!b)
return;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = pi_file_set_sort_info(pf, buffer, len);
if (result < 0)
throwIOException(errno);
}
extern void Pdapilot_File_pi_file_append_record(struct HPdapilot_File * self, HPdapilot_Record * record)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
int attr, cat;
HArrayOfByte * b;
char * buffer;
int len;
recordid_t id;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)record, "pack", "()[B");
if (!b)
return;
id = getJavaRecordID(unhand(record)->id);
attr = 0;
attr |= unhand(record)->deleted ? 0x80 : 0;
attr |= unhand(record)->modified ? 0x40 : 0;
attr |= unhand(record)->busy ? 0x20 : 0;
attr |= unhand(record)->secret ? 0x10 : 0;
attr |= unhand(record)->archived ? 0x08 : 0;
cat = unhand(record)->category;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = pi_file_append_record(pf, buffer, len, attr, cat, id);
if (result < 0)
throwIOException(errno);
}
extern void Pdapilot_File_pi_file_append_resource(struct HPdapilot_File * self, HPdapilot_Resource * resource)
{
struct pi_file * pf = (struct pi_file*)unhand(self)->_pf;
char * buffer;
HArrayOfByte * b;
int len;
javaint_t type;
javaint_t id;
int result;
b = (HArrayOfByte*)execute_java_dynamic_method(0, (HObject*)resource, "pack", "()[B");
if (!b)
return;
type = unhand(unhand(resource)->type)->value;
id = unhand(resource)->id;
buffer = unhand(b)->body;
len = getArrayLength(b);
result = pi_file_append_resource(pf, buffer, len, type, id);
if (result < 0)
throwIOException(errno);
}
|