/usr/share/perl5/Net/Jabber/Protocol.pm is in libnet-jabber-perl 2.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 | ##############################################################################
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Copyright (C) 1998-2004 Jabber Software Foundation http://jabber.org/
#
##############################################################################
package Net::Jabber::Protocol;
=head1 NAME
Net::Jabber::Protocol - Jabber Protocol Library
=head1 SYNOPSIS
Net::Jabber::Protocol is a module that provides a developer easy
access to the Jabber Instant Messaging protocol. It provides high
level functions to the Net::Jabber Client, Component, and Server
objects. These functions are automatically indluded in those modules
through AUTOLOAD and delegates.
=head1 DESCRIPTION
Protocol.pm seeks to provide enough high level APIs and automation of
the low level APIs that writing a Jabber Client/Transport in Perl is
trivial. For those that wish to work with the low level you can do
that too, but those functions are covered in the documentation for
each module.
Net::Jabber::Protocol provides functions to login, send and receive
messages, set personal information, create a new user account, manage
the roster, and disconnect. You can use all or none of the functions,
there is no requirement.
For more information on how the details for how Net::Jabber is written
please see the help for Net::Jabber itself.
For more information on writing a Client see Net::Jabber::Client.
For more information on writing a Transport see Net::Jabber::Transport.
=head2 Modes
Several of the functions take a mode argument that let you specify how
the function should behave:
block - send the packet with an ID, and then block until an answer
comes back. You can optionally specify a timeout so that
you do not block forever.
nonblock - send the packet with an ID, but then return that id and
control to the master program. Net::Jabber is still
tracking this packet, so you must use the CheckID function
to tell when it comes in. (This might not be very
useful...)
passthru - send the packet with an ID, but do NOT register it with
Net::Jabber, then return the ID. This is useful when
combined with the XPath function because you can register
a one shot function tied to the id you get back.
=head2 Basic Functions
use Net::Jabber qw( Client );
$Con = new Net::Jabber::Client(); # From
$status = $Con->Connect(hostname=>"jabber.org"); # Net::Jabber::Client
or
use Net::Jabber qw( Component );
$Con = new Net::Jabber::Component(); #
$status = $Con->Connect(hostname=>"jabber.org", # From
secret=>"bob"); # Net::Jabber::Component
#
# For callback setup, see Net::XMPP::Protocol
#
$Con->Info(name=>"Jarl",
version=>"v0.6000");
=head2 ID Functions
$id = $Con->SendWithID($sendObj);
$id = $Con->SendWithID("<tag>XML</tag>");
$receiveObj = $Con->SendAndReceiveWithID($sendObj);
$receiveObj = $Con->SendAndReceiveWithID($sendObj,
10);
$receiveObj = $Con->SendAndReceiveWithID("<tag>XML</tag>");
$receiveObj = $Con->SendAndReceiveWithID("<tag>XML</tag>",
5);
$yesno = $Con->ReceivedID($id);
$receiveObj = $Con->GetID($id);
$receiveObj = $Con->WaitForID($id);
$receiveObj = $Con->WaitForID($id,
20);
=head2 IQ Functions
=head2 Agents Functions
%agents = $Con->AgentsGet();
%agents = $Con->AgentsGet(to=>"transport.jabber.org");
=head2 Browse Functions
%hash = $Con->BrowseRequest(jid=>"jabber.org");
%hash = $Con->BrowseRequest(jid=>"jabber.org",
timeout=>10);
$id = $Con->BrowseRequest(jid=>"jabber.org",
mode=>"nonblock");
$id = $Con->BrowseRequest(jid=>"jabber.org",
mode=>"passthru");
=head2 Browse DB Functions
$Con->BrowseDBDelete("jabber.org");
$Con->BrowseDBDelete(Net::Jabber::JID);
$presence = $Con->BrowseDBQuery(jid=>"bob\@jabber.org");
$presence = $Con->BrowseDBQuery(jid=>Net::Jabber::JID);
$presence = $Con->BrowseDBQuery(jid=>"users.jabber.org",
timeout=>10);
$presence = $Con->BrowseDBQuery(jid=>"conference.jabber.org",
refresh=>1);
=head2 Bystreams Functions
%hash = $Con->ByteStreamsProxyRequest(jid=>"proxy.server");
%hash = $Con->ByteStreamsProxyRequest(jid=>"proxy.server",
timeout=>10);
$id = $Con->ByteStreamsProxyRequest(jid=>"proxy.server",
mode=>"nonblock");
$id = $Con->ByteStreamsProxyRequest(jid=>"proxy.server",
mode=>"passthru");
%hash = $Con->ByteStreamsProxyParse($query);
$status = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server");
$status = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server",
timeout=>10);
$id = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server",
mode=>"nonblock");
$id = $Con->ByteStreamsProxyActivate(sid=>"stream_id",
jid=>"proxy.server",
mode=>"passthru");
$jid = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{jid=>"jid",
host=>"host",
port=>"port",
zeroconf=>"zero",
},
...
],
jid=>"bob\@jabber.org");
$jid = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{},{},...],
jid=>"bob\@jabber.org",
timeout=>10);
$id = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{},{},...],
jid=>"bob\@jabber.org",
mode=>"nonblock");
$id = $Con->ByteStreamsOffer(sid=>"stream_id",
streamhosts=>[{},{},...],
jid=>"bob\@jabber.org",
mode=>"passthru");
=head2 Disco Functions
%hash = $Con->DiscoInfoRequest(jid=>"jabber.org");
%hash = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...");
%hash = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...",
timeout=>10);
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
mode=>"nonblock");
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...",
mode=>"nonblock");
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
mode=>"passthru");
$id = $Con->DiscoInfoRequest(jid=>"jabber.org",
node=>"node...",
mode=>"passthru");
%hash = $Con->DiscoInfoParse($query);
%hash = $Con->DiscoItemsRequest(jid=>"jabber.org");
%hash = $Con->DiscoItemsRequest(jid=>"jabber.org",
timeout=>10);
$id = $Con->DiscoItemsRequest(jid=>"jabber.org",
mode=>"nonblock");
$id = $Con->DiscoItemsRequest(jid=>"jabber.org",
mode=>"passthru");
%hash = $Con->DiscoItemsParse($query);
=head2 Feature Negotiation Functions
%hash = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ feat1=>["opt1","opt2",...],
feat2=>["optA","optB",...]
}
);
%hash = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ ... },
timeout=>10);
$id = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ ... },
mode=>"nonblock");
$id = $Con->FeatureNegRequest(jid=>"jabber.org",
features=>{ ... },
mode=>"passthru");
my $query = $self->FeatureNegQuery(\{ ... });
$iq->AddQuery($query);
%hash = $Con->FeatureNegParse($query);
=head2 File Transfer Functions
$method = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>["http://jabber.org/protocol/si/profile/bytestreams",
"jabber:iq:oob",
...
]
);
$method = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>\@methods,
timeout=>"10");
$id = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>\@methods,
mode=>"nonblock");
$id = $Con->FileTransferOffer(jid=>"bob\@jabber.org",
sid=>"stream_id",
filename=>"/path/to/file",
methods=>\@methods,
mode=>"passthru");
=head2 Last Functions
$Con->LastQuery();
$Con->LastQuery(to=>"bob@jabber.org");
%result = $Con->LastQuery(mode=>"block");
%result = $Con->LastQuery(to=>"bob@jabber.org",
mode=>"block");
%result = $Con->LastQuery(to=>"bob@jabber.org",
mode=>"block",
timeout=>10);
%result = $Con->LastQuery(mode=>"block",
timeout=>10);
$Con->LastSend(to=>"bob@jabber.org");
$seconds = $Con->LastActivity();
=head2 Multi-User Chat Functions
$Con->MUCJoin(room=>"jabber",
server=>"conference.jabber.org",
nick=>"nick");
$Con->MUCJoin(room=>"jabber",
server=>"conference.jabber.org",
nick=>"nick",
password=>"secret");
=head2 Register Functions
@result = $Con->RegisterSendData("users.jabber.org",
first=>"Bob",
last=>"Smith",
nick=>"bob",
email=>"foo@bar.net");
=head2 RPC Functions
$query = $Con->RPCEncode(type=>"methodCall",
methodName=>"methodName",
params=>[param,param,...]);
$query = $Con->RPCEncode(type=>"methodResponse",
params=>[param,param,...]);
$query = $Con->RPCEncode(type=>"methodResponse",
faultCode=>4,
faultString=>"Too many params");
@response = $Con->RPCParse($iq);
@response = $Con->RPCCall(to=>"dataHouse.jabber.org",
methodname=>"numUsers",
params=>[ param,param,... ]
);
$Con->RPCResponse(to=>"you\@jabber.org",
params=>[ param,param,... ]);
$Con->RPCResponse(to=>"you\@jabber.org",
faultCode=>"4",
faultString=>"Too many parameters"
);
$Con->RPCSetCallBacks(myMethodA=>\&methoda,
myMethodB=>\&do_somthing,
etc...
);
=head2 Search Functions
%fields = $Con->SearchRequest();
%fields = $Con->SearchRequest(to=>"users.jabber.org");
%fields = $Con->SearchRequest(to=>"users.jabber.org",
timeout=>10);
$Con->SearchSend(to=>"somewhere",
name=>"",
first=>"Bob",
last=>"",
nick=>"bob",
email=>"",
key=>"some key");
$Con->SearchSendData("users.jabber.org",
first=>"Bob",
last=>"",
nick=>"bob",
email=>"");
=head2 Time Functions
$Con->TimeQuery();
$Con->TimeQuery(to=>"bob@jabber.org");
%result = $Con->TimeQuery(mode=>"block");
%result = $Con->TimeQuery(to=>"bob@jabber.org",
mode=>"block");
$Con->TimeSend(to=>"bob@jabber.org");
=head2 Version Functions
$Con->VersionQuery();
$Con->VersionQuery(to=>"bob@jabber.org");
%result = $Con->VersionQuery(mode=>"block");
%result = $Con->VersionQuery(to=>"bob@jabber.org",
mode=>"block");
$Con->VersionSend(to=>"bob@jabber.org",
name=>"Net::Jabber",
ver=>"1.0a",
os=>"Perl");
=head1 METHODS
=head2 Basic Functions
Info(name=>string, - Set some information so that Net::Jabber
version=>string) can auto-reply to some packets for you to
reduce the work you have to do.
NOTE: This requires that you use the
SetIQCallBacks methodology and not the
SetCallBacks for <iq/> packets.
=head2 IQ Functions
=head2 Agents Functions
********************************
* *
* Deprecated in favor of Disco *
* *
********************************
AgentsGet(to=>string, - takes all of the information and
AgentsGet() builds a Net::Jabber::IQ::Agents packet.
It then sends that packet either to the
server, or to the specified transport,
with an ID and waits for that ID to return.
Then it looks in the resulting packet and
builds a hash that contains the values
of the agent list. The hash is layed out
like this: (NOTE: the jid is the key to
distinguish the various agents)
$hash{<JID>}->{order} = 4
->{name} = "ICQ Transport"
->{transport} = "ICQ #"
->{description} = "ICQ..blah.."
->{service} = "icq"
->{register} = 1
->{search} = 1
etc...
The order field determines the order that
it came from the server in... in case you
care. For more info on the valid fields
see the Net::Jabber::Query jabber:iq:agent
namespace.
=head2 Browse Functions
********************************
* *
* Deprecated in favor of Disco *
* *
********************************
BrowseRequest(jid=>string, - sends a jabber:iq:browse request to
mode=>string, the jid passed as an argument.
timeout=>int) Returns a hash with the resulting
tree if mode is set to "block":
$browse{'category'} = "conference"
$browse{'children'}->[0]
$browse{'children'}->[1]
$browse{'children'}->[11]
$browse{'jid'} = "conference.jabber.org"
$browse{'name'} = "Jabber.org Conferencing Center"
$browse{'ns'}->[0]
$browse{'ns'}->[1]
$browse{'type'} = "public"
The ns array is an array of the
namespaces that this jid supports.
The children array points to hashs
of this form, and represent the fact
that they can be browsed to.
See MODES above for using the mode
and timeout.
=head2 Browse DB Functions
BrowseDBDelete(string|Net::Jabber::JID) - delete thes JID browse
data from the DB.
BrowseDBQuery(jid=>string | NJ::JID, - returns the browse data
timeout=>integer, for the requested JID. If
refresh=>0|1) the DB does not contain
the data for the JID, then
it attempts to fetch the
data via BrowseRequest().
The timeout is passed to
the BrowseRequest() call,
and refresh tells the DB
to request the data, even
if it already has some.
=head2 Bytestreams Functions
ByteStreamsProxyRequest(jid=>string, - sends a bytestreams request
mode=>string, to the jid passed as an
timeout=>int) argument. Returns an array
ref with the resulting tree
if mode is set to "block".
See ByteStreamsProxyParse
for the format of the
resulting tree.
See MODES above for using
the mode and timeout.
ByteStreamsProxyParse(Net::Jabber::Query) - parses the query and
returns an array ref
to the resulting tree:
$host[0]->{jid} = "bytestreams1.proxy.server";
$host[0]->{host} = "proxy1.server";
$host[0]->{port} = "5006";
$host[1]->{jid} = "bytestreams2.proxy.server";
$host[1]->{host} = "proxy2.server";
$host[1]->{port} = "5007";
...
ByteStreamsProxyActivate(jid=>string, - sends a bytestreams activate
sid=>string, to the jid passed as an
mode=>string, argument. Returns 1 if the
timeout=>int) proxy activated (undef if
it did not) if mode is set
to "block".
sid is the stream id that
is being used to talk about
this stream.
See MODES above for using
the mode and timeout.
ByteStreamsOffer(jid=>string, - sends a bytestreams offer
sid=>string, to the jid passed as an
streamhosts=>arrayref argument. Returns the jid
mode=>string, of the streamhost that the
timeout=>int) user selected if mode is set
to "block".
streamhosts is the same
format as the array ref
returned from
ByteStreamsProxyParse.
See MODES above for using
the mode and timeout.
=head2 Disco Functions
DiscoInfoRequest(jid=>string, - sends a disco#info request to
node=>string, the jid passed as an argument,
mode=>string, and the node if specified.
timeout=>int) Returns a hash with the resulting
tree if mode is set to "block".
See DiscoInfoParse for the format
of the resulting tree.
See MODES above for using the mode
and timeout.
DiscoInfoParse(Net::Jabber::Query) - parses the query and
returns a hash ref
to the resulting tree:
$info{identity}->[0]->{category} = "groupchat";
$info{identity}->[0]->{name} = "Public Chatrooms";
$info{identity}->[0]->{type} = "public";
$info{identity}->[1]->{category} = "groupchat";
$info{identity}->[1]->{name} = "Private Chatrooms";
$info{identity}->[1]->{type} = "private";
$info{feature}->{http://jabber.org/protocol/disco#info} = 1;
$info{feature}->{http://jabber.org/protocol/muc#admin} = 1;
DiscoItemsRequest(jid=>string, - sends a disco#items request to
mode=>string, the jid passed as an argument.
timeout=>int) Returns a hash with the resulting
tree if mode is set to "block".
See DiscoItemsParse for the format
of the resulting tree.
See MODES above for using the mode
and timeout.
DiscoItemsParse(Net::Jabber::Query) - parses the query and
returns a hash ref
to the resulting tree:
$items{jid}->{node} = name;
$items{"proxy.server"}->{""} = "Bytestream Proxy Server";
$items{"conf.server"}->{"public"} = "Public Chatrooms";
$items{"conf.server"}->{"private"} = "Private Chatrooms";
=head2 Feature Negotiation Functions
FeatureNegRequest(jid=>string, - sends a feature negotiation to
features=>hash ref, the jid passed as an argument,
mode=>string, using the features specified.
timeout=>int) Returns a hash with the resulting
tree if mode is set to "block".
See DiscoInfoQuery for the format
of the features hash ref.
See DiscoInfoParse for the format
of the resulting tree.
See MODES above for using the mode
and timeout.
FeatureNegParse(Net::Jabber::Query) - parses the query and
returns a hash ref
to the resulting tree:
$features->{feat1} = ["opt1","opt2",...];
$features->{feat2} = ["optA","optB",...];
....
If this is a result:
$features->{feat1} = "opt2";
$features->{feat2} = "optA";
....
FeatureNeqQuery(hash ref) - takes a hash ref and turns it into a
feature negotiation query that you can
AddQuery into your packaet. The format
of the hash ref is as follows:
$features->{feat1} = ["opt1","opt2",...];
$features->{feat2} = ["optA","optB",...];
....
=head2 File Transfer Functions
FileTransferOffer(jid=>string, - sends a file transfer stream
sid=>string, initiation to the jid passed
filename=>string, as an argument. Returns the
mode=>string, method (if the users accepts),
timeout=>int) undef (if the user declines),
if the mode is set to "block".
See MODES above for using
the mode and timeout.
=head2 Last Functions
LastQuery(to=>string, - asks the jid specified for its last
mode=>string, activity. If the to is blank, then it
timeout=>int) queries the server. Returns a hash with
LastQuery() the various items set if mode is set to
"block":
$last{seconds} - Seconds since activity
$last{message} - Message for activity
See MODES above for using the mode
and timeout.
LastSend(to=>string, - sends the specified last to the specified jid.
hash) the hash is the seconds and message as shown
in the Net::Jabber::Query man page.
LastActivity() - returns the number of seconds since the last activity
by the user.
=head2 Multi-User Chat Functions
MUCJoin(room=>string, - Sends the appropriate MUC protocol to join
server=>string, the specified room with the specified nick.
nick=>string,
password=>string)
=head2 Register Functions
RegisterSendData(string|JID, - takes the contents of the hash and
hash) builds a jabebr:x:data return packet
which it sends in a Net::Jabber::Query
jabber:iq:register namespace packet.
The first argument is the JID to send
the packet to. This function returns
an array that looks like this:
[ type , message ]
If type is "ok" then registration was
successful, otherwise message contains
a little more detail about the error.
=head2 RPC Functions
RPCParse(IQ object) - returns an array. The first argument tells
the status "ok" or "fault". The second
argument is an array if "ok", or a hash if
"fault".
RPCCall(to=>jid|string, - takes the methodName and params,
methodName=>string, builds the RPC calls and sends it
params=>array, to the specified address. Returns
mode=>string, the above data from RPCParse.
timeout=>int)
See MODES above for using the mode
and timeout.
RPCResponse(to=>jid|string, - generates a response back to
params=>array, the caller. If any part of
faultCode=>int, fault is specified, then it
faultString=>string) wins.
Note: To ensure that you get the correct type for a param sent
back, you can specify the type by prepending the type to
the value:
"i4:5" or "int:5"
"boolean:0"
"string:56"
"double:5.0"
"datetime:20020415T11:11:11"
"base64:...."
RPCSetCallBacks(method=>function, - sets the callback functions
method=>function, for the specified methods.
etc...) The method comes from the
<methodName/> and is case
sensitive. The single
arguemnt is a ref to an
array that contains the
<params/>. The function you
write should return one of two
things:
["ok", [...] ]
The [...] is a list of the
<params/> you want to return.
["fault", {faultCode=>1,
faultString=>...} ]
If you set the function to undef,
then the method is removed from
the list.
=head2 Search Functions
SearchRequest(to=>string, - send an <iq/> request to the specified
mode=>string, server/transport, if not specified it
timeout=>int) sends to the current active server.
SearchRequest() The function returns a hash that
contains the required fields. Here
is an example of the hash:
$hash{fields} - The raw fields from
the iq:register. To
be used if there is
no x:data in the
packet.
$hash{instructions} - How to fill out
the form.
$hash{form} - The new dynamic forms.
In $hash{form}, the fields that are
present are the required fields the
server needs.
See MODES above for using the mode
and timeout.
SearchSend(to=>string|JID, - takes the contents of the hash and
hash) passes it to the SetSearch function
in the Net::Jabber::Query
jabber:iq:search namespace. And then
sends the packet.
SearchSendData(string|JID, - takes the contents of the hash and
hash) builds a jabebr:x:data return packet
which it sends in a Net::Jabber::Query
jabber:iq:search namespace packet.
The first argument is the JID to send
the packet to.
=head2 Time Functions
TimeQuery(to=>string, - asks the jid specified for its localtime.
mode=>string, If the to is blank, then it queries the
timeout=>int) server. Returns a hash with the various
TimeQuery() items set if mode is set to "block":
$time{utc} - Time in UTC
$time{tz} - Timezone
$time{display} - Display string
See MODES above for using the mode
and timeout.
TimeSend(to=>string) - sends the current UTC time to the specified
jid.
=head2 Version Functions
VersionQuery(to=>string, - asks the jid specified for its
mode=>string, client version information. If the
timeout=>int) to is blank, then it queries the
VersionQuery() server. Returns ahash with the
various items set if mode is set to
"block":
$version{name} - Name
$version{ver} - Version
$version{os} - Operating System/
Platform
See MODES above for using the mode
and timeout.
VersionSend(to=>string, - sends the specified version information
name=>string, to the jid specified in the to.
ver=>string,
os=>string)
=head1 AUTHOR
Ryan Eatmon
=head1 COPYRIGHT
This module is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
use strict;
use Carp;
use vars qw($VERSION);
$VERSION = "2.0";
##############################################################################
# BuildObject takes a root tag and builds the correct object. NEWOBJECT is
# the table that maps tag to package. Override these, or provide new ones.
#-----------------------------------------------------------------------------
$Net::XMPP::Protocol::NEWOBJECT{'iq'} = "Net::Jabber::IQ";
$Net::XMPP::Protocol::NEWOBJECT{'message'} = "Net::Jabber::Message";
$Net::XMPP::Protocol::NEWOBJECT{'presence'} = "Net::Jabber::Presence";
$Net::XMPP::Protocol::NEWOBJECT{'jid'} = "Net::Jabber::JID";
##############################################################################
###############################################################################
#+-----------------------------------------------------------------------------
#|
#| Base API
#|
#+-----------------------------------------------------------------------------
###############################################################################
###############################################################################
#
# Info - set the base information about this Jabber Client/Component for
# use in a default response.
#
###############################################################################
sub Info
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
foreach my $arg (keys(%args))
{
$self->{INFO}->{$arg} = $args{$arg};
}
}
###############################################################################
#
# DefineNamespace - adds the namespace and corresponding functions onto the
# of available functions based on namespace.
#
# Deprecated in favor of AddNamespace
#
###############################################################################
sub DefineNamespace
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
croak("You must specify xmlns=>'' for the function call to DefineNamespace")
if !exists($args{xmlns});
croak("You must specify type=>'' for the function call to DefineNamespace")
if !exists($args{type});
croak("You must specify functions=>'' for the function call to DefineNamespace")
if !exists($args{functions});
my %xpath;
my $tag;
if (exists($args{tag}))
{
$tag = $args{tag};
}
else
{
$tag = "x" if ($args{type} eq "X");
$tag = "query" if ($args{type} eq "Query");
}
foreach my $function (@{$args{functions}})
{
my %tempHash = %{$function};
my %funcHash;
foreach my $func (keys(%tempHash))
{
$funcHash{lc($func)} = $tempHash{$func};
}
croak("You must specify name=>'' for each function in call to DefineNamespace")
if !exists($funcHash{name});
my $name = delete($funcHash{name});
if (!exists($funcHash{set}) && exists($funcHash{get}))
{
croak("The DefineNamespace arugments have changed, and I cannot determine the\nnew values automatically for name($name). Please read the man page\nfor Net::Jabber::Namespaces. I apologize for this incompatability.\n");
}
if (exists($funcHash{type}) || exists($funcHash{path}) ||
exists($funcHash{child}) || exists($funcHash{calls}))
{
foreach my $type (keys(%funcHash))
{
if ($type eq "child")
{
$xpath{$name}->{$type}->{ns} = $funcHash{$type}->[1];
my $i = 2;
while( $i <= $#{$funcHash{$type}} )
{
if ($funcHash{$type}->[$i] eq "__netjabber__:skip_xmlns")
{
$xpath{$name}->{$type}->{skip_xmlns} = 1;
}
if ($funcHash{$type}->[$i] eq "__netjabber__:specifyname")
{
$xpath{$name}->{$type}->{specify_name} = 1;
$i++;
$xpath{$name}->{$type}->{tag} = $funcHash{$type}->[$i+1];
}
$i++;
}
}
else
{
$xpath{$name}->{$type} = $funcHash{$type};
}
}
next;
}
my $type = $funcHash{set}->[0];
my $xpath = $funcHash{set}->[1];
if (exists($funcHash{hash}))
{
$xpath = "text()" if ($funcHash{hash} eq "data");
$xpath .= "/text()" if ($funcHash{hash} eq "child-data");
$xpath = "\@$xpath" if ($funcHash{hash} eq "att");
$xpath = "$1/\@$2" if ($funcHash{hash} =~ /^att-(\S+)-(.+)$/);
}
if ($type eq "master")
{
$xpath{$name}->{type} = $type;
next;
}
if ($type eq "scalar")
{
$xpath{$name}->{path} = $xpath;
next;
}
if ($type eq "flag")
{
$xpath{$name}->{type} = 'flag';
$xpath{$name}->{path} = $xpath;
next;
}
if (($funcHash{hash} eq "child-add") && exists($funcHash{add}))
{
$xpath{$name}->{type} = "node";
$xpath{$name}->{path} = $funcHash{add}->[3];
$xpath{$name}->{child}->{ns} = $funcHash{add}->[1];
$xpath{$name}->{calls} = [ 'Add' ];
next;
}
}
$self->AddNamespace(ns => $args{xmlns},
tag => $tag,
xpath => \%xpath );
}
###############################################################################
#
# AgentsGet - Sends an empty IQ to the server/transport to request that the
# list of supported Agents be sent to them. Returns a hash
# containing the values for the agents.
#
###############################################################################
sub AgentsGet
{
my $self = shift;
my $iq = $self->_iq();
$iq->SetIQ(@_);
$iq->SetIQ(type=>"get");
my $query = $iq->NewQuery("jabber:iq:agents");
$iq = $self->SendAndReceiveWithID($iq);
return unless defined($iq);
$query = $iq->GetQuery();
my @agents = $query->GetAgents();
my %agents;
my $count = 0;
foreach my $agent (@agents)
{
my $jid = $agent->GetJID();
$agents{$jid}->{name} = $agent->GetName();
$agents{$jid}->{description} = $agent->GetDescription();
$agents{$jid}->{transport} = $agent->GetTransport();
$agents{$jid}->{service} = $agent->GetService();
$agents{$jid}->{register} = $agent->DefinedRegister();
$agents{$jid}->{search} = $agent->DefinedSearch();
$agents{$jid}->{groupchat} = $agent->DefinedGroupChat();
$agents{$jid}->{agents} = $agent->DefinedAgents();
$agents{$jid}->{order} = $count++;
}
return %agents;
}
###############################################################################
#
# BrowseRequest - requests the browse information from the specified JID.
#
###############################################################################
sub BrowseRequest
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"get");
my $query = $iq->NewQuery("jabber:iq:browse");
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
my %browse = %{$self->BrowseParse($query)};
return %browse;
}
else
{
return;
}
}
###############################################################################
#
# BrowseParse - helper function for BrowseRequest to convert the object
# tree into a hash for better consumption.
#
###############################################################################
sub BrowseParse
{
my $self = shift;
my $item = shift;
my %browse;
if ($item->DefinedCategory())
{
$browse{category} = $item->GetCategory();
}
else
{
$browse{category} = $item->GetTag();
}
$browse{type} = $item->GetType();
$browse{name} = $item->GetName();
$browse{jid} = $item->GetJID();
$browse{ns} = [ $item->GetNS() ];
foreach my $subitem ($item->GetItems())
{
my ($subbrowse) = $self->BrowseParse($subitem);
push(@{$browse{children}},$subbrowse);
}
return \%browse;
}
###############################################################################
#
# BrowseDBDelete - delete the JID from the DB completely.
#
###############################################################################
sub BrowseDBDelete
{
my $self = shift;
my ($jid) = @_;
my $indexJID = $jid;
$indexJID = $jid->GetJID() if (ref($jid) eq "Net::Jabber::JID");
return if !exists($self->{BROWSEDB}->{$indexJID});
delete($self->{BROWSEDB}->{$indexJID});
$self->{DEBUG}->Log1("BrowseDBDelete: delete ",$indexJID," from the DB");
}
###############################################################################
#
# BrowseDBQuery - retrieve the last Net::Jabber::Browse received with
# the highest priority.
#
###############################################################################
sub BrowseDBQuery
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
$args{timeout} = 10 unless exists($args{timeout});
my $indexJID = $args{jid};
$indexJID = $args{jid}->GetJID() if (ref($args{jid}) eq "Net::Jabber::JID");
if ((exists($args{refresh}) && ($args{refresh} eq "1")) ||
(!exists($self->{BROWSEDB}->{$indexJID})))
{
my %browse = $self->BrowseRequest(jid=>$args{jid},
timeout=>$args{timeout});
$self->{BROWSEDB}->{$indexJID} = \%browse;
}
return %{$self->{BROWSEDB}->{$indexJID}};
}
###############################################################################
#
# ByteStreamsProxyRequest - This queries a proxy server to get a list of
#
###############################################################################
sub ByteStreamsProxyRequest
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"get");
my $query = $iq->NewQuery("http://jabber.org/protocol/bytestreams");
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
my @hosts = @{$self->ByteStreamsProxyParse($query)};
return @hosts;
}
else
{
return;
}
}
###############################################################################
#
# ByteStreamsProxyParse - helper function for ByteStreamProxyRequest to convert
# the object tree into a hash for better consumption.
#
###############################################################################
sub ByteStreamsProxyParse
{
my $self = shift;
my $item = shift;
my @hosts;
foreach my $host ($item->GetStreamHosts())
{
my %host;
$host{jid} = $host->GetJID();
$host{host} = $host->GetHost() if $host->DefinedHost();
$host{port} = $host->GetPort() if $host->DefinedPort();
$host{zeroconf} = $host->GetZeroConf() if $host->DefinedZeroConf();
push(@hosts,\%host);
}
return \@hosts;
}
###############################################################################
#
# ByteStreamsProxyActivate - This tells a proxy to activate the connection
#
###############################################################################
sub ByteStreamsProxyActivate
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"set");
my $query = $iq->NewQuery("http://jabber.org/protocol/bytestreams");
$query->SetByteStreams(sid=>$args{sid},
activate=>(ref($args{recipient}) eq "Net::Jabber::JID" ? $args{recipient}->GetJID("full") : $args{recipient})
);
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
return 1;
}
###############################################################################
#
# ByteStreamsOffer - This offers a recipient a list of stream hosts to pick
# from.
#
###############################################################################
sub ByteStreamsOffer
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"set");
my $query = $iq->NewQuery("http://jabber.org/protocol/bytestreams");
$query->SetByteStreams(sid=>$args{sid});
foreach my $host (@{$args{streamhosts}})
{
$query->AddStreamHost(jid=>$host->{jid},
(exists($host->{host}) ? (host=>$host->{host}) : ()),
(exists($host->{port}) ? (port=>$host->{port}) : ()),
(exists($host->{zeroconf}) ? (zeroconf=>$host->{zeroconf}) : ()),
);
}
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
return $query->GetStreamHostUsedJID();
}
else
{
return;
}
}
###############################################################################
#
# DiscoInfoRequest - requests the disco information from the specified JID.
#
###############################################################################
sub DiscoInfoRequest
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"get");
my $query = $iq->NewQuery("http://jabber.org/protocol/disco#info");
$query->SetDiscoInfo(node=>$args{node}) if exists($args{node});
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
return unless $iq->DefinedQuery();
$query = $iq->GetQuery();
return %{$self->DiscoInfoParse($query)};
}
###############################################################################
#
# DiscoInfoParse - helper function for DiscoInfoRequest to convert the object
# tree into a hash for better consumption.
#
###############################################################################
sub DiscoInfoParse
{
my $self = shift;
my $item = shift;
my %disco;
foreach my $ident ($item->GetIdentities())
{
my %identity;
$identity{category} = $ident->GetCategory();
$identity{name} = $ident->GetName();
$identity{type} = $ident->GetType();
push(@{$disco{identity}},\%identity);
}
foreach my $feat ($item->GetFeatures())
{
$disco{feature}->{$feat->GetVar()} = 1;
}
return \%disco;
}
###############################################################################
#
# DiscoItemsRequest - requests the disco information from the specified JID.
#
###############################################################################
sub DiscoItemsRequest
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"get");
my $query = $iq->NewQuery("http://jabber.org/protocol/disco#items");
$query->SetDiscoItems(node=>$args{node}) if exists($args{node});
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
my %disco = %{$self->DiscoItemsParse($query)};
return %disco;
}
else
{
return;
}
}
###############################################################################
#
# DiscoItemsParse - helper function for DiscoItemsRequest to convert the object
# tree into a hash for better consumption.
#
###############################################################################
sub DiscoItemsParse
{
my $self = shift;
my $item = shift;
my %disco;
foreach my $item ($item->GetItems())
{
$disco{$item->GetJID()}->{$item->GetNode()} = $item->GetName();
}
return \%disco;
}
###############################################################################
#
# FeatureNegRequest - requests a feature negotiation from the specified JID.
#
###############################################################################
sub FeatureNegRequest
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"get");
my $query = $self->FeatureNegQuery($args{features});
$iq->AddQuery($query);
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
my %feats = %{$self->FeatureNegParse($query)};
return %feats;
}
else
{
return;
}
}
#xxx fneg needs to reutrn a type='submit' on the x:data in a result
###############################################################################
#
# FeatureNegQuery - given a feature hash, return a query that contains it.
#
###############################################################################
sub FeatureNegQuery
{
my $self = shift;
my $features = shift;
my $tag = "query";
$tag = $Net::Jabber::Query::TAGS{'http://jabber.org/protocol/feature-neg'}
if exists($Net::Jabber::Query::TAGS{'http://jabber.org/protocol/feature-neg'});
my $query = new Net::Jabber::Query($tag);
$query->SetXMLNS("http://jabber.org/protocol/feature-neg");
my $xdata = $query->NewX("jabber:x:data");
foreach my $feature (keys(%{$features}))
{
my $field = $xdata->AddField(type=>"list-single",
var=>$feature);
foreach my $value (@{$features->{$feature}})
{
$field->AddOption(value=>$value);
}
}
return $query;
}
###############################################################################
#
# FeatureNegParse - helper function for FeatureNegRequest to convert the object
# tree into a hash for better consumption.
#
###############################################################################
sub FeatureNegParse
{
my $self = shift;
my $item = shift;
my %feats;
my $xdata = $item->GetX("jabber:x:data");
foreach my $field ($xdata->GetFields())
{
my @options;
foreach my $option ($field->GetOptions())
{
push(@options,$option->GetValue());
}
if ($#options == -1)
{
$feats{$field->GetVar()} = $field->GetValue();
}
else
{
$feats{$field->GetVar()} = \@options;
}
}
return \%feats;
}
#XXX - need a feature-neg answer function...
###############################################################################
#
# FileTransferOffer - offer a file transfer JEP-95
#
###############################################################################
sub FileTransferOffer
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"set");
my $query = $iq->NewQuery("http://jabber.org/protocol/si");
my $profile = $query->NewQuery("http://jabber.org/protocol/si/profile/file-transfer");
# XXX support hashing via MD5
# XXX support date via JEP-82
my ($filename) = ($args{filename} =~ /\/?([^\/]+)$/);
$profile->SetFile(name=>$filename,
size=>(-s $args{filename})
);
$profile->SetFile(desc=>$args{desc}) if exists($args{desc});
$query->SetStream(mimetype=>(-B $args{filename} ?
"application/octect-stream" :
"text/plain"
),
id=>$args{sid},
profile=>"http://jabber.org/protocol/si/profile/file-transfer"
);
if (!exists($args{skip_methods}))
{
if ($#{$args{methods}} == -1)
{
print STDERR "You did not provide any valid methods for file transfer.\n";
return;
}
my $fneg = $self->FeatureNegQuery({'stream-method'=>$args{methods}});
$query->AddQuery($fneg);
}
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
my @fneg = $query->GetQuery("http://jabber.org/protocol/feature-neg");
my @xdata = $fneg[0]->GetX("jabber:x:data");
my @fields = $xdata[0]->GetFields();
return $fields[0]->GetValue();
# XXX need better error handling
}
else
{
return;
}
}
###############################################################################
#
# TreeTransferOffer - offer a file transfer JEP-95
#
###############################################################################
sub TreeTransferOffer
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>$args{jid},
type=>"set");
my $query = $iq->NewQuery("http://jabber.org/protocol/si");
my $profile = $query->NewQuery("http://jabber.org/protocol/si/profile/tree-transfer");
my ($root) = ($args{directory} =~ /\/?([^\/]+)$/);
my $rootDir = $profile->AddDirectory(name=>$root);
my %tree;
$tree{counter} = 0;
$self->TreeTransferDescend($args{sidbase},
$args{directory},
$rootDir,
\%tree
);
$profile->SetTree(numfiles=>$tree{counter},
size=>$tree{size}
);
$query->SetStream(id=>$args{sidbase},
profile=>"http://jabber.org/protocol/si/profile/tree-transfer"
);
if ($#{$args{methods}} == -1)
{
print STDERR "You did not provide any valid methods for the tree transfer.\n";
return;
}
my $fneg = $self->FeatureNegQuery({'stream-method'=>$args{methods}});
$query->AddQuery($fneg);
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
$tree{id} = $id;
return %tree;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
return;
}
$query = $iq->GetQuery();
if (defined($query))
{
my @fneg = $query->GetQuery("http://jabber.org/protocol/feature-neg");
my @xdata = $fneg[0]->GetX("jabber:x:data");
my @fields = $xdata[0]->GetFields();
return $fields[0]->GetValue();
# XXX need better error handling
}
else
{
return;
}
}
###############################################################################
#
# TreeTransferDescend - descend a directory structure and build the packet.
#
###############################################################################
sub TreeTransferDescend
{
my $self = shift;
my $sidbase = shift;
my $path = shift;
my $parent = shift;
my $tree = shift;
$tree->{size} += (-s $path);
opendir(DIR, $path);
foreach my $file ( sort {$a cmp $b} readdir(DIR) )
{
next if ($file =~ /^\.\.?$/);
if (-d "$path/$file")
{
my $tempParent = $parent->AddDirectory(name=>$file);
$self->TreeTransferDescend($sidbase,
"$path/$file",
$tempParent,
$tree
);
}
else
{
$tree->{size} += (-s "$path/$file");
$tree->{tree}->{"$path/$file"}->{order} = $tree->{counter};
$tree->{tree}->{"$path/$file"}->{sid} =
$sidbase."-".$tree->{counter};
$tree->{tree}->{"$path/$file"}->{name} = $file;
$parent->AddFile(name=>$tree->{tree}->{"$path/$file"}->{name},
sid=>$tree->{tree}->{"$path/$file"}->{sid});
$tree->{counter}++;
}
}
closedir(DIR);
}
###############################################################################
#
# LastQuery - Sends an iq:last query to either the server or the specified
# JID.
#
###############################################################################
sub LastQuery
{
my $self = shift;
my %args;
$args{mode} = "passthru";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
$args{waitforid} = 0 unless exists($args{waitforid});
my $waitforid = delete($args{waitforid});
$args{mode} = "block" if $waitforid;
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to})) if exists($args{to});
$iq->SetIQ(type=>'get');
my $last = $iq->NewQuery("jabber:iq:last");
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
return unless defined($iq);
$last = $iq->GetQuery();
return unless defined($last);
return $last->GetLast();
}
###############################################################################
#
# LastSend - sends an iq:last packet to the specified user.
#
###############################################################################
sub LastSend
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
$args{ignoreactivity} = 0 unless exists($args{ignoreactivity});
my $ignoreActivity = delete($args{ignoreactivity});
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to}),
type=>'result');
my $last = $iq->NewQuery("jabber:iq:last");
$last->SetLast(%args);
$self->Send($iq,$ignoreActivity);
}
###############################################################################
#
# LastActivity - returns number of seconds since the last activity.
#
###############################################################################
sub LastActivity
{
my $self = shift;
return (time - $self->{STREAM}->LastActivity($self->{SESSION}->{id}));
}
###############################################################################
#
# RegisterSendData - This is a self contained function to send a register iq
# tag with an id. It uses the jabber:x:data method to
# return the data.
#
###############################################################################
sub RegisterSendData
{
my $self = shift;
my $to = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
#--------------------------------------------------------------------------
# Create a Net::Jabber::IQ object to send to the server
#--------------------------------------------------------------------------
my $iq = $self->_iq();
$iq->SetIQ(to=>$to) if (defined($to) && ($to ne ""));
$iq->SetIQ(type=>"set");
my $iqRegister = $iq->NewQuery("jabber:iq:register");
my $xForm = $iqRegister->NewX("jabber:x:data");
foreach my $var (keys(%args))
{
next if ($args{$var} eq "");
$xForm->AddField(var=>$var,
value=>$args{$var}
);
}
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
$iq = $self->SendAndReceiveWithID($iq);
#--------------------------------------------------------------------------
# From the reply IQ determine if we were successful or not. If yes then
# return "". If no then return error string from the reply.
#--------------------------------------------------------------------------
return unless defined($iq);
return ( $iq->GetErrorCode() , $iq->GetError() )
if ($iq->GetType() eq "error");
return ("ok","");
}
###############################################################################
#
# RPCSetCallBacks - place to register a callback for RPC calls. This is
# used in conjunction with the default IQ callback.
#
###############################################################################
sub RPCSetCallBacks
{
my $self = shift;
while($#_ >= 0) {
my $func = pop(@_);
my $method = pop(@_);
$self->{DEBUG}->Log2("RPCSetCallBacks: method($method) func($func)");
if (defined($func))
{
$self->{RPCCB}{$method} = $func;
}
else
{
delete($self->{RPCCB}{$method});
}
}
}
###############################################################################
#
# RPCCall - Make an RPC call to the specified JID.
#
###############################################################################
sub RPCCall
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(type=>"set",
to=>delete($args{to}));
$iq->AddQuery($self->RPCEncode(type=>"methodCall",
%args));
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
return unless defined($iq);
return $self->RPCParse($iq);
}
###############################################################################
#
# RPCResponse - Send back an RPC response, or fault, to the specified JID.
#
###############################################################################
sub RPCResponse
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $iq = $self->_iq();
$iq->SetIQ(type=>"result",
to=>delete($args{to}));
$iq->AddQuery($self->RPCEncode(type=>"methodResponse",
%args));
$iq = $self->SendAndReceiveWithID($iq);
return unless defined($iq);
return $self->RPCParse($iq);
}
###############################################################################
#
# RPCEncode - Returns a Net::Jabber::Query with the arguments encoded for the
# RPC packet.
#
###############################################################################
sub RPCEncode
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $query = new Net::Jabber::Stanza("query");
$query->SetXMLNS("jabber:iq:rpc");
my $source;
if ($args{type} eq "methodCall")
{
$source = $query->AddMethodCall();
$source->SetMethodName($args{methodname});
}
if ($args{type} eq "methodResponse")
{
$source = $query->AddMethodResponse();
}
if (exists($args{faultcode}) || exists($args{faultstring}))
{
my $struct = $source->AddFault()->AddValue()->AddStruct();
$struct->AddMember(name=>"faultCode")->AddValue(i4=>$args{faultcode});
$struct->AddMember(name=>"faultString")->AddValue(string=>$args{faultstring});
}
elsif (exists($args{params}))
{
my $params = $source->AddParams();
foreach my $param (@{$args{params}})
{
$self->RPCEncode_Value($params->AddParam(),$param);
}
}
return $query;
}
###############################################################################
#
# RPCEncode_Value - Run through the value, and encode it into XML.
#
###############################################################################
sub RPCEncode_Value
{
my $self = shift;
my $obj = shift;
my $value = shift;
if (ref($value) eq "ARRAY")
{
my $array = $obj->AddValue()->AddArray();
foreach my $data (@{$value})
{
$self->RPCEncode_Value($array->AddData(),$data);
}
}
elsif (ref($value) eq "HASH")
{
my $struct = $obj->AddValue()->AddStruct();
foreach my $key (sort keys(%{$value}))
{
$self->RPCEncode_Value($struct->AddMember(name=>$key),$value->{$key});
}
}
else
{
if ($value =~ /^(int|i4|boolean|string|double|datetime|base64):/i)
{
my $type = $1;
my($val) = ($value =~ /^$type:(.*)$/);
$obj->AddValue($type=>$val);
}
elsif ($value =~ /^[+-]?\d+$/)
{
$obj->AddValue(i4=>$value);
}
elsif ($value =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+)|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/)
{
$obj->AddValue(double=>$value);
}
else
{
$obj->AddValue(string=>$value);
}
}
}
###############################################################################
#
# RPCParse - Returns an array of the params sent in the RPC packet.
#
###############################################################################
sub RPCParse
{
my $self = shift;
my($iq) = @_;
my $query = $iq->GetQuery();
my $source;
$source = $query->GetMethodCall() if $query->DefinedMethodCall();
$source = $query->GetMethodResponse() if $query->DefinedMethodResponse();
if (defined($source))
{
if (($source->GetTag() eq "methodResponse") && ($source->DefinedFault()))
{
my %response =
$self->RPCParse_Struct($source->GetFault()->GetValue()->GetStruct());
return ("fault",\%response);
}
if ($source->DefinedParams())
{
#------------------------------------------------------------------
# The <param/>s part
#------------------------------------------------------------------
my @response;
foreach my $param ($source->GetParams()->GetParams())
{
push(@response,$self->RPCParse_Value($param->GetValue()));
}
return ("ok",\@response);
}
}
else
{
print "AAAAHHHH!!!!\n";
}
}
###############################################################################
#
# RPCParse_Value - Takes a <value/> and returns the data it represents
#
###############################################################################
sub RPCParse_Value
{
my $self = shift;
my($value) = @_;
if ($value->DefinedStruct())
{
my %struct = $self->RPCParse_Struct($value->GetStruct());
return \%struct;
}
if ($value->DefinedArray())
{
my @array = $self->RPCParse_Array($value->GetArray());
return \@array;
}
return $value->GetI4() if $value->DefinedI4();
return $value->GetInt() if $value->DefinedInt();
return $value->GetBoolean() if $value->DefinedBoolean();
return $value->GetString() if $value->DefinedString();
return $value->GetDouble() if $value->DefinedDouble();
return $value->GetDateTime() if $value->DefinedDateTime();
return $value->GetBase64() if $value->DefinedBase64();
return $value->GetValue();
}
###############################################################################
#
# RPCParse_Struct - Takes a <struct/> and returns the hash of values.
#
###############################################################################
sub RPCParse_Struct
{
my $self = shift;
my($struct) = @_;
my %struct;
foreach my $member ($struct->GetMembers())
{
$struct{$member->GetName()} = $self->RPCParse_Value($member->GetValue());
}
return %struct;
}
###############################################################################
#
# RPCParse_Array - Takes a <array/> and returns the hash of values.
#
###############################################################################
sub RPCParse_Array
{
my $self = shift;
my($array) = @_;
my @array;
foreach my $data ($array->GetDatas())
{
push(@array,$self->RPCParse_Value($data->GetValue()));
}
return @array;
}
###############################################################################
#
# SearchRequest - This is a self contained function to send an iq tag
# an id that requests the target address to send back
# the required fields. It waits for a reply what the
# same id to come back and tell the caller what the
# fields are.
#
###############################################################################
sub SearchRequest
{
my $self = shift;
my %args;
$args{mode} = "block";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
#--------------------------------------------------------------------------
# Create a Net::Jabber::IQ object to send to the server
#--------------------------------------------------------------------------
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to})) if exists($args{to});
$iq->SetIQ(type=>"get");
my $query = $iq->NewQuery("jabber:iq:search");
$self->{DEBUG}->Log1("SearchRequest: sent(",$iq->GetXML(),")");
#--------------------------------------------------------------------------
# Send the IQ with the next available ID and wait for a reply with that
# id to be received. Then grab the IQ reply.
#--------------------------------------------------------------------------
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
$self->{DEBUG}->Log1("SearchRequest: received(",$iq->GetXML(),")")
if defined($iq);
#--------------------------------------------------------------------------
# Check if there was an error.
#--------------------------------------------------------------------------
return unless defined($iq);
if ($iq->GetType() eq "error")
{
$self->SetErrorCode($iq->GetErrorCode().": ".$iq->GetError());
$self->{DEBUG}->Log1("SearchRequest: error(",$self->GetErrorCode(),")");
return;
}
my %search;
#--------------------------------------------------------------------------
# From the reply IQ determine what fields are required and send a hash
# back with the fields and any values that are already defined (like key)
#--------------------------------------------------------------------------
$query = $iq->GetQuery();
$search{fields} = { $query->GetSearch() };
#--------------------------------------------------------------------------
# Get any forms so that we have the option of showing a nive dynamic form
# to the user and not just a bunch of fields.
#--------------------------------------------------------------------------
&ExtractForms(\%search,$query->GetX("jabber:x:data"));
#--------------------------------------------------------------------------
# Get any oobs so that we have the option of sending the user to the http
# form and not a dynamic one.
#--------------------------------------------------------------------------
&ExtractOobs(\%search,$query->GetX("jabber:x:oob"));
return %search;
}
###############################################################################
#
# SearchSend - This is a self contained function to send a search
# iq tag with an id. Then wait for a reply what the same
# id to come back and tell the caller what the result was.
#
###############################################################################
sub SearchSend
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
#--------------------------------------------------------------------------
# Create a Net::Jabber::IQ object to send to the server
#--------------------------------------------------------------------------
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to})) if exists($args{to});
$iq->SetIQ(type=>"set");
my $iqSearch = $iq->NewQuery("jabber:iq:search");
$iqSearch->SetSearch(%args);
#--------------------------------------------------------------------------
# Send the IQ.
#--------------------------------------------------------------------------
$self->Send($iq);
}
###############################################################################
#
# SearchSendData - This is a self contained function to send a search iq tag
# with an id. It uses the jabber:x:data method to return the
# data.
#
###############################################################################
sub SearchSendData
{
my $self = shift;
my $to = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
#--------------------------------------------------------------------------
# Create a Net::Jabber::IQ object to send to the server
#--------------------------------------------------------------------------
my $iq = $self->_iq();
$iq->SetIQ(to=>$to) if (defined($to) && ($to ne ""));
$iq->SetIQ(type=>"set");
my $iqSearch = $iq->NewQuery("jabber:iq:search");
my $xForm = $iqSearch->NewX("jabber:x:data");
foreach my $var (keys(%args))
{
next if ($args{$var} eq "");
$xForm->AddField(var=>$var,
value=>$args{$var}
);
}
#--------------------------------------------------------------------------
# Send the IQ.
#--------------------------------------------------------------------------
$self->Send($iq);
}
###############################################################################
#
# TimeQuery - Sends an iq:time query to either the server or the specified
# JID.
#
###############################################################################
sub TimeQuery
{
my $self = shift;
my %args;
$args{mode} = "passthru";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
$args{waitforid} = 0 unless exists($args{waitforid});
my $waitforid = delete($args{waitforid});
$args{mode} = "block" if $waitforid;
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to})) if exists($args{to});
$iq->SetIQ(type=>'get',%args);
my $time = $iq->NewQuery("jabber:iq:time");
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
return unless defined($iq);
my $query = $iq->GetQuery();
return unless defined($query);
my %result;
$result{utc} = $query->GetUTC();
$result{display} = $query->GetDisplay();
$result{tz} = $query->GetTZ();
return %result;
}
###############################################################################
#
# TimeSend - sends an iq:time packet to the specified user.
#
###############################################################################
sub TimeSend
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to}),
type=>'result');
my $time = $iq->NewQuery("jabber:iq:time");
$time->SetTime(%args);
$self->Send($iq);
}
###############################################################################
#
# VersionQuery - Sends an iq:version query to either the server or the
# specified JID.
#
###############################################################################
sub VersionQuery
{
my $self = shift;
my %args;
$args{mode} = "passthru";
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
$args{waitforid} = 0 unless exists($args{waitforid});
my $waitforid = delete($args{waitforid});
$args{mode} = "block" if $waitforid;
my $timeout = exists($args{timeout}) ? delete($args{timeout}) : undef;
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to})) if exists($args{to});
$iq->SetIQ(type=>'get',%args);
my $version = $iq->NewQuery("jabber:iq:version");
if ($args{mode} eq "passthru")
{
my $id = $self->UniqueID();
$iq->SetIQ(id=>$id);
$self->Send($iq);
return $id;
}
return $self->SendWithID($iq) if ($args{mode} eq "nonblock");
$iq = $self->SendAndReceiveWithID($iq,$timeout);
return unless defined($iq);
my $query = $iq->GetQuery();
return unless defined($query);
my %result;
$result{name} = $query->GetName();
$result{ver} = $query->GetVer();
$result{os} = $query->GetOS();
return %result;
}
###############################################################################
#
# VersionSend - sends an iq:version packet to the specified user.
#
###############################################################################
sub VersionSend
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $iq = $self->_iq();
$iq->SetIQ(to=>delete($args{to}),
type=>'result');
my $version = $iq->NewQuery("jabber:iq:version");
$version->SetVersion(%args);
$self->Send($iq);
}
###############################################################################
#
# MUCJoin - join a MUC room
#
###############################################################################
sub MUCJoin
{
my $self = shift;
my %args;
while($#_ >= 0) { $args{ lc pop(@_) } = pop(@_); }
my $presence = $self->_presence();
$presence->SetTo($args{room}.'@'.$args{server}.'/'.$args{nick});
my $x = $presence->NewChild("http://jabber.org/protocol/muc");
if (exists($args{password}) && ($args{password} ne ""))
{
$x->SetMUC(password=>$args{password});
}
return $presence->GetXML() if exists($args{'__netjabber__:test'});
$self->Send($presence);
}
###############################################################################
#+-----------------------------------------------------------------------------
#|
#| Helper Functions
#|
#+-----------------------------------------------------------------------------
###############################################################################
###############################################################################
#
# ExtractForms - Helper function to make extracting jabber:x:data for forms
# more centrally definable.
#
###############################################################################
sub ExtractForms
{
my ($target,@xForms) = @_;
my $tempVar = "1";
foreach my $xForm (@xForms) {
$target->{instructions} = $xForm->GetInstructions();
my $order = 0;
foreach my $field ($xForm->GetFields())
{
$target->{form}->[$order]->{type} = $field->GetType()
if $field->DefinedType();
$target->{form}->[$order]->{label} = $field->GetLabel()
if $field->DefinedLabel();
$target->{form}->[$order]->{desc} = $field->GetDesc()
if $field->DefinedDesc();
$target->{form}->[$order]->{var} = $field->GetVar()
if $field->DefinedVar();
$target->{form}->[$order]->{var} = "__netjabber__:tempvar:".$tempVar++
if !$field->DefinedVar();
if ($field->DefinedValue())
{
if ($field->GetType() eq "list-multi")
{
$target->{form}->[$order]->{value} = [ $field->GetValue() ];
}
else
{
$target->{form}->[$order]->{value} = ($field->GetValue())[0];
}
}
my $count = 0;
foreach my $option ($field->GetOptions())
{
$target->{form}->[$order]->{options}->[$count]->{value} =
$option->GetValue();
$target->{form}->[$order]->{options}->[$count]->{label} =
$option->GetLabel();
$count++;
}
$order++;
}
foreach my $reported ($xForm->GetReported())
{
my $order = 0;
foreach my $field ($reported->GetFields())
{
$target->{reported}->[$order]->{label} = $field->GetLabel();
$target->{reported}->[$order]->{var} = $field->GetVar();
$order++;
}
}
}
}
###############################################################################
#
# ExtractOobs - Helper function to make extracting jabber:x:oob for forms
# more centrally definable.
#
###############################################################################
sub ExtractOobs
{
my ($target,@xOobs) = @_;
foreach my $xOob (@xOobs)
{
$target->{oob}->{url} = $xOob->GetURL();
$target->{oob}->{desc} = $xOob->GetDesc();
}
}
###############################################################################
#+-----------------------------------------------------------------------------
#|
#| Default CallBacks
#|
#+-----------------------------------------------------------------------------
###############################################################################
###############################################################################
#
# callbackInit - initialize the default callbacks
#
###############################################################################
sub callbackInit
{
my $self = shift;
$self->SUPER::callbackInit();
$self->SetIQCallBacks("jabber:iq:last"=>
{
get=>sub{ $self->callbackGetIQLast(@_) },
result=>sub{ $self->callbackResultIQLast(@_) }
},
"jabber:iq:rpc"=>
{
set=>sub{ $self->callbackSetIQRPC(@_) },
},
"jabber:iq:time"=>
{
get=>sub{ $self->callbackGetIQTime(@_) },
result=>sub{ $self->callbackResultIQTime(@_) }
},
"jabber:iq:version"=>
{
get=>sub{ $self->callbackGetIQVersion(@_) },
result=>sub{ $self->callbackResultIQVersion(@_) }
},
);
}
###############################################################################
#
# callbackSetIQRPC - callback to handle auto-replying to an iq:rpc by calling
# the user registered functions.
#
###############################################################################
sub callbackSetIQRPC
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $query = $iq->GetQuery();
my $reply = $iq->Reply(type=>"result");
my $replyQuery = $reply->GetQuery();
if (!$query->DefinedMethodCall())
{
my $methodResponse = $replyQuery->AddMethodResponse();
my $struct = $methodResponse->AddFault()->AddValue()->AddStruct();
$struct->AddMember(name=>"faultCode")->AddValue(int=>400);
$struct->AddMember(name=>"faultString")->AddValue(string=>"Missing methodCall.");
$self->Send($reply,1);
return;
}
if (!$query->GetMethodCall()->DefinedMethodName())
{
my $methodResponse = $replyQuery->AddMethodResponse();
my $struct = $methodResponse->AddFault()->AddValue()->AddStruct();
$struct->AddMember(name=>"faultCode")->AddValue(int=>400);
$struct->AddMember(name=>"faultString")->AddValue(string=>"Missing methodName.");
$self->Send($reply,1);
return;
}
my $methodName = $query->GetMethodCall()->GetMethodName();
if (!exists($self->{RPCCB}->{$methodName}))
{
my $methodResponse = $replyQuery->AddMethodResponse();
my $struct = $methodResponse->AddFault()->AddValue()->AddStruct();
$struct->AddMember(name=>"faultCode")->AddValue(int=>404);
$struct->AddMember(name=>"faultString")->AddValue(string=>"methodName $methodName not defined.");
$self->Send($reply,1);
return;
}
my @params = $self->RPCParse($iq);
my @return = &{$self->{RPCCB}->{$methodName}}($iq,$params[1]);
if ($return[0] ne "ok") {
my $methodResponse = $replyQuery->AddMethodResponse();
my $struct = $methodResponse->AddFault()->AddValue()->AddStruct();
$struct->AddMember(name=>"faultCode")->AddValue(int=>$return[1]->{faultCode});
$struct->AddMember(name=>"faultString")->AddValue(string=>$return[1]->{faultString});
$self->Send($reply,1);
return;
}
$reply->RemoveQuery();
$reply->AddQuery($self->RPCEncode(type=>"methodResponse",
params=>$return[1]));
$self->Send($reply,1);
}
###############################################################################
#
# callbackGetIQTime - callback to handle auto-replying to an iq:time get.
#
###############################################################################
sub callbackGetIQTime
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $query = $iq->GetQuery();
my $reply = $iq->Reply(type=>"result");
my $replyQuery = $reply->GetQuery();
$replyQuery->SetTime();
$self->Send($reply,1);
}
###############################################################################
#
# callbackResultIQTime - callback to handle formatting iq:time result into
# a message.
#
###############################################################################
sub callbackResultIQTime
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $fromJID = $iq->GetFrom("jid");
my $query = $iq->GetQuery();
my $body = "UTC: ".$query->GetUTC()."\n";
$body .= "Time: ".$query->GetDisplay()."\n";
$body .= "Timezone: ".$query->GetTZ()."\n";
my $message = $self->_message();
$message->SetMessage(to=>$iq->GetTo(),
from=>$iq->GetFrom(),
subject=>"CTCP: Time",
body=>$body);
$self->CallBack($sid,$message);
}
###############################################################################
#
# callbackGetIQVersion - callback to handle auto-replying to an iq:time
# get.
#
###############################################################################
sub callbackGetIQVersion
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $query = $iq->GetQuery();
my $reply = $iq->Reply(type=>"result");
my $replyQuery = $reply->GetQuery();
$replyQuery->SetVersion(name=>$self->{INFO}->{name},
ver=>$self->{INFO}->{version},
os=>"");
$self->Send($reply,1);
}
###############################################################################
#
# callbackResultIQVersion - callback to handle formatting iq:time result
# into a message.
#
###############################################################################
sub callbackResultIQVersion
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $query = $iq->GetQuery();
my $body = "Program: ".$query->GetName()."\n";
$body .= "Version: ".$query->GetVer()."\n";
$body .= "OS: ".$query->GetOS()."\n";
my $message = $self->_message();
$message->SetMessage(to=>$iq->GetTo(),
from=>$iq->GetFrom(),
subject=>"CTCP: Version",
body=>$body);
$self->CallBack($sid,$message);
}
###############################################################################
#
# callbackGetIQLast - callback to handle auto-replying to an iq:last get.
#
###############################################################################
sub callbackGetIQLast
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $query = $iq->GetQuery();
my $reply = $iq->Reply(type=>"result");
my $replyQuery = $reply->GetQuery();
$replyQuery->SetLast(seconds=>$self->LastActivity());
$self->Send($reply,1);
}
###############################################################################
#
# callbackResultIQLast - callback to handle formatting iq:last result into
# a message.
#
###############################################################################
sub callbackResultIQLast
{
my $self = shift;
my $sid = shift;
my $iq = shift;
my $fromJID = $iq->GetFrom("jid");
my $query = $iq->GetQuery();
my $seconds = $query->GetSeconds();
my $lastTime = &Net::Jabber::GetTimeStamp("local",(time - $seconds),"long");
my $elapsedTime = &Net::Jabber::GetHumanTime($seconds);
my $body;
if ($fromJID->GetUserID() eq "")
{
$body = "Start Time: $lastTime\n";
$body .= "Up time: $elapsedTime\n";
$body .= "Message: ".$query->GetMessage()."\n"
if ($query->DefinedMessage());
}
elsif ($fromJID->GetResource() eq "")
{
$body = "Logout Time: $lastTime\n";
$body .= "Elapsed time: $elapsedTime\n";
$body .= "Message: ".$query->GetMessage()."\n"
if ($query->DefinedMessage());
}
else
{
$body = "Last activity: $lastTime\n";
$body .= "Elapsed time: $elapsedTime\n";
$body .= "Message: ".$query->GetMessage()."\n"
if ($query->DefinedMessage());
}
my $message = $self->_message();
$message->SetMessage(from=>$iq->GetFrom(),
subject=>"Last Activity",
body=>$body);
$self->CallBack($sid,$message);
}
1;
|