1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
|
/**
* @file llviewermessage.cpp
* @brief Dumping ground for viewer-side message system callbacks.
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llviewermessage.h"
#include "boost/lexical_cast.hpp"
// Linden libraries
#include "llanimationstates.h"
#include "llaudioengine.h"
#include "llavataractions.h"
#include "llavatarnamecache.h" // IDEVO HACK
#include "lscript_byteformat.h"
#include "lleconomy.h"
#include "lleventtimer.h"
#include "llfloaterreg.h"
#include "llfolderview.h"
#include "llfollowcamparams.h"
#include "llinventorydefines.h"
#include "lllslconstants.h"
#include "llregionhandle.h"
#include "llsd.h"
#include "llsdserialize.h"
#include "llteleportflags.h"
#include "lltoastnotifypanel.h"
#include "lltransactionflags.h"
#include "llvfile.h"
#include "llvfs.h"
#include "llxfermanager.h"
#include "mean_collision_data.h"
#include "llagent.h"
#include "llagentcamera.h"
#include "llcallingcard.h"
#include "llbuycurrencyhtml.h"
#include "llfirstuse.h"
#include "llfloaterbuyland.h"
#include "llfloaterland.h"
#include "llfloaterregioninfo.h"
#include "llfloaterlandholdings.h"
#include "llfloaterpreference.h"
#include "llfloatersidepanelcontainer.h"
#include "llfloatersnapshot.h"
#include "llhudeffecttrail.h"
#include "llhudmanager.h"
#include "llimview.h"
#include "llinventoryfunctions.h"
#include "llinventoryobserver.h"
#include "llinventorypanel.h"
#include "llfloaterimnearbychat.h"
#include "llnotifications.h"
#include "llnotificationsutil.h"
#include "llpanelgrouplandmoney.h"
#include "llrecentpeople.h"
#include "llscriptfloater.h"
#include "llselectmgr.h"
#include "llstartup.h"
#include "llsky.h"
#include "llslurl.h"
#include "llstatenums.h"
#include "llstatusbar.h"
#include "llimview.h"
#include "llspeakers.h"
#include "lltrans.h"
#include "lltranslate.h"
#include "llviewerfoldertype.h"
#include "llvoavatar.h" // IDEVO HACK
#include "lluri.h"
#include "llviewergenericmessage.h"
#include "llviewermenu.h"
#include "llviewerinventory.h"
#include "llviewerjoystick.h"
#include "llviewerobjectlist.h"
#include "llviewerparcelmgr.h"
#include "llviewerstats.h"
#include "llviewertexteditor.h"
#include "llviewerthrottle.h"
#include "llviewerwindow.h"
#include "llvlmanager.h"
#include "llvoavatarself.h"
#include "llworld.h"
#include "pipeline.h"
#include "llfloaterworldmap.h"
#include "llviewerdisplay.h"
#include "llkeythrottle.h"
#include "llgroupactions.h"
#include "llagentui.h"
#include "llpanelblockedlist.h"
#include "llpanelplaceprofile.h"
#include "llviewerregion.h"
#include "llfloaterregionrestarting.h"
#include <boost/algorithm/string/split.hpp> //
#include <boost/regex.hpp>
#include "llnotificationmanager.h" //
#if LL_MSVC
// disable boost::lexical_cast warning
#pragma warning (disable:4702)
#endif
extern void on_new_message(const LLSD& msg);
//
// Constants
//
const F32 BIRD_AUDIBLE_RADIUS = 32.0f;
const F32 SIT_DISTANCE_FROM_TARGET = 0.25f;
const F32 CAMERA_POSITION_THRESHOLD_SQUARED = 0.001f * 0.001f;
static const F32 LOGOUT_REPLY_TIME = 3.f; // Wait this long after LogoutReply before quitting.
// Determine how quickly residents' scripts can issue question dialogs
// Allow bursts of up to 5 dialogs in 10 seconds. 10*2=20 seconds recovery if throttle kicks in
static const U32 LLREQUEST_PERMISSION_THROTTLE_LIMIT = 5; // requests
static const F32 LLREQUEST_PERMISSION_THROTTLE_INTERVAL = 10.0f; // seconds
extern BOOL gDebugClicks;
extern bool gShiftFrame;
// function prototypes
bool check_offer_throttle(const std::string& from_name, bool check_only);
bool check_asset_previewable(const LLAssetType::EType asset_type);
static void process_money_balance_reply_extended(LLMessageSystem* msg);
//inventory offer throttle globals
LLFrameTimer gThrottleTimer;
const U32 OFFER_THROTTLE_MAX_COUNT=5; //number of items per time period
const F32 OFFER_THROTTLE_TIME=10.f; //time period in seconds
//script permissions
const std::string SCRIPT_QUESTIONS[SCRIPT_PERMISSION_EOF] =
{
"ScriptTakeMoney",
"ActOnControlInputs",
"RemapControlInputs",
"AnimateYourAvatar",
"AttachToYourAvatar",
"ReleaseOwnership",
"LinkAndDelink",
"AddAndRemoveJoints",
"ChangePermissions",
"TrackYourCamera",
"ControlYourCamera",
"TeleportYourAgent",
"JoinAnExperience",
"SilentlyManageEstateAccess",
"OverrideYourAnimations",
"ScriptReturnObjects"
};
const BOOL SCRIPT_QUESTION_IS_CAUTION[SCRIPT_PERMISSION_EOF] =
{
TRUE, // ScriptTakeMoney,
FALSE, // ActOnControlInputs
FALSE, // RemapControlInputs
FALSE, // AnimateYourAvatar
FALSE, // AttachToYourAvatar
FALSE, // ReleaseOwnership,
FALSE, // LinkAndDelink,
FALSE, // AddAndRemoveJoints
FALSE, // ChangePermissions
FALSE, // TrackYourCamera,
FALSE, // ControlYourCamera
FALSE, // TeleportYourAgent
FALSE, // JoinAnExperience
FALSE, // SilentlyManageEstateAccess
FALSE, // OverrideYourAnimations
FALSE, // ScriptReturnObjects
};
bool friendship_offer_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLMessageSystem* msg = gMessageSystem;
const LLSD& payload = notification["payload"];
LLNotificationPtr notification_ptr = LLNotifications::instance().find(notification["id"].asUUID());
// this will be skipped if the user offering friendship is blocked
if (notification_ptr)
{
// add friend to recent people list
LLRecentPeople::instance().add(payload["from_id"]);
switch(option)
{
case 0:
{
// accept
LLAvatarTracker::formFriendship(payload["from_id"]);
const LLUUID fid = gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD);
// This will also trigger an onlinenotification if the user is online
msg->newMessageFast(_PREHASH_AcceptFriendship);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_TransactionBlock);
msg->addUUIDFast(_PREHASH_TransactionID, payload["session_id"]);
msg->nextBlockFast(_PREHASH_FolderData);
msg->addUUIDFast(_PREHASH_FolderID, fid);
msg->sendReliable(LLHost(payload["sender"].asString()));
LLSD payload = notification["payload"];
LLNotificationsUtil::add("FriendshipAcceptedByMe",
notification["substitutions"], payload);
break;
}
case 1: // Decline
{
LLSD payload = notification["payload"];
LLNotificationsUtil::add("FriendshipDeclinedByMe",
notification["substitutions"], payload);
}
// fall-through
case 2: // Send IM - decline and start IM session
{
// decline
// We no longer notify other viewers, but we DO still send
// the rejection to the simulator to delete the pending userop.
msg->newMessageFast(_PREHASH_DeclineFriendship);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_TransactionBlock);
msg->addUUIDFast(_PREHASH_TransactionID, payload["session_id"]);
msg->sendReliable(LLHost(payload["sender"].asString()));
// start IM session
if(2 == option)
{
LLAvatarActions::startIM(payload["from_id"].asUUID());
}
}
default:
// close button probably, possibly timed out
break;
}
// TODO: this set of calls has undesirable behavior under Windows OS (CHUI-985):
// here appears three additional toasts instead one modified
// need investigation and fix
// LLNotificationFormPtr modified_form(new LLNotificationForm(*notification_ptr->getForm()));
// modified_form->setElementEnabled("Accept", false);
// modified_form->setElementEnabled("Decline", false);
// notification_ptr->updateForm(modified_form);
// notification_ptr->repost();
}
return false;
}
static LLNotificationFunctorRegistration friendship_offer_callback_reg("OfferFriendship", friendship_offer_callback);
static LLNotificationFunctorRegistration friendship_offer_callback_reg_nm("OfferFriendshipNoMessage", friendship_offer_callback);
// Functions
//
void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_group,
S32 trx_type, const std::string& desc)
{
if(0 == amount || !region) return;
amount = abs(amount);
LL_INFOS("Messaging") << "give_money(" << uuid << "," << amount << ")"<< LL_ENDL;
if(can_afford_transaction(amount))
{
// gStatusBar->debitBalance(amount);
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_MoneyTransferRequest);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_MoneyData);
msg->addUUIDFast(_PREHASH_SourceID, gAgent.getID() );
msg->addUUIDFast(_PREHASH_DestID, uuid);
msg->addU8Fast(_PREHASH_Flags, pack_transaction_flags(FALSE, is_group));
msg->addS32Fast(_PREHASH_Amount, amount);
msg->addU8Fast(_PREHASH_AggregatePermNextOwner, (U8)LLAggregatePermissions::AP_EMPTY);
msg->addU8Fast(_PREHASH_AggregatePermInventory, (U8)LLAggregatePermissions::AP_EMPTY);
msg->addS32Fast(_PREHASH_TransactionType, trx_type );
msg->addStringFast(_PREHASH_Description, desc);
msg->sendReliable(region->getHost());
}
else
{
LLStringUtil::format_map_t args;
args["AMOUNT"] = llformat("%d", amount);
LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("giving", args), amount );
}
}
void send_complete_agent_movement(const LLHost& sim_host)
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_CompleteAgentMovement);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->addU32Fast(_PREHASH_CircuitCode, msg->mOurCircuitCode);
msg->sendReliable(sim_host);
}
void process_logout_reply(LLMessageSystem* msg, void**)
{
// The server has told us it's ok to quit.
LL_DEBUGS("Messaging") << "process_logout_reply" << LL_ENDL;
LLUUID agent_id;
msg->getUUID("AgentData", "AgentID", agent_id);
LLUUID session_id;
msg->getUUID("AgentData", "SessionID", session_id);
if((agent_id != gAgent.getID()) || (session_id != gAgent.getSessionID()))
{
LL_WARNS("Messaging") << "Bogus Logout Reply" << LL_ENDL;
}
LLInventoryModel::update_map_t parents;
S32 count = msg->getNumberOfBlocksFast( _PREHASH_InventoryData );
for(S32 i = 0; i < count; ++i)
{
LLUUID item_id;
msg->getUUIDFast(_PREHASH_InventoryData, _PREHASH_ItemID, item_id, i);
if( (1 == count) && item_id.isNull() )
{
// Detect dummy item. Indicates an empty list.
break;
}
// We do not need to track the asset ids, just account for an
// updated inventory version.
LL_INFOS("Messaging") << "process_logout_reply itemID=" << item_id << LL_ENDL;
LLInventoryItem* item = gInventory.getItem( item_id );
if( item )
{
parents[item->getParentUUID()] = 0;
gInventory.addChangedMask(LLInventoryObserver::INTERNAL, item_id);
}
else
{
LL_INFOS("Messaging") << "process_logout_reply item not found: " << item_id << LL_ENDL;
}
}
LLAppViewer::instance()->forceQuit();
}
void process_layer_data(LLMessageSystem *mesgsys, void **user_data)
{
LLViewerRegion *regionp = LLWorld::getInstance()->getRegion(mesgsys->getSender());
if(!regionp)
{
llwarns << "Invalid region for layer data." << llendl;
return;
}
S32 size;
S8 type;
mesgsys->getS8Fast(_PREHASH_LayerID, _PREHASH_Type, type);
size = mesgsys->getSizeFast(_PREHASH_LayerData, _PREHASH_Data);
if (0 == size)
{
LL_WARNS("Messaging") << "Layer data has zero size." << LL_ENDL;
return;
}
if (size < 0)
{
// getSizeFast() is probably trying to tell us about an error
LL_WARNS("Messaging") << "getSizeFast() returned negative result: "
<< size
<< LL_ENDL;
return;
}
U8 *datap = new U8[size];
mesgsys->getBinaryDataFast(_PREHASH_LayerData, _PREHASH_Data, datap, size);
LLVLData *vl_datap = new LLVLData(regionp, type, datap, size);
if (mesgsys->getReceiveCompressedSize())
{
gVLManager.addLayerData(vl_datap, mesgsys->getReceiveCompressedSize());
}
else
{
gVLManager.addLayerData(vl_datap, mesgsys->getReceiveSize());
}
}
// S32 exported_object_count = 0;
// S32 exported_image_count = 0;
// S32 current_object_count = 0;
// S32 current_image_count = 0;
// extern LLNotifyBox *gExporterNotify;
// extern LLUUID gExporterRequestID;
// extern std::string gExportDirectory;
// extern LLUploadDialog *gExportDialog;
// std::string gExportedFile;
// std::map<LLUUID, std::string> gImageChecksums;
// void export_complete()
// {
// LLUploadDialog::modalUploadFinished();
// gExporterRequestID.setNull();
// gExportDirectory = "";
// LLFILE* fXML = LLFile::fopen(gExportedFile, "rb"); /* Flawfinder: ignore */
// fseek(fXML, 0, SEEK_END);
// long length = ftell(fXML);
// fseek(fXML, 0, SEEK_SET);
// U8 *buffer = new U8[length + 1];
// size_t nread = fread(buffer, 1, length, fXML);
// if (nread < (size_t) length)
// {
// LL_WARNS("Messaging") << "Short read" << LL_ENDL;
// }
// buffer[nread] = '\0';
// fclose(fXML);
// char *pos = (char *)buffer;
// while ((pos = strstr(pos+1, "<sl:image ")) != 0)
// {
// char *pos_check = strstr(pos, "checksum=\"");
// if (pos_check)
// {
// char *pos_uuid = strstr(pos_check, "\">");
// if (pos_uuid)
// {
// char image_uuid_str[UUID_STR_SIZE]; /* Flawfinder: ignore */
// memcpy(image_uuid_str, pos_uuid+2, UUID_STR_SIZE-1); /* Flawfinder: ignore */
// image_uuid_str[UUID_STR_SIZE-1] = 0;
// LLUUID image_uuid(image_uuid_str);
// LL_INFOS("Messaging") << "Found UUID: " << image_uuid << LL_ENDL;
// std::map<LLUUID, std::string>::iterator itor = gImageChecksums.find(image_uuid);
// if (itor != gImageChecksums.end())
// {
// LL_INFOS("Messaging") << "Replacing with checksum: " << itor->second << LL_ENDL;
// if (!itor->second.empty())
// {
// memcpy(&pos_check[10], itor->second.c_str(), 32); /* Flawfinder: ignore */
// }
// }
// }
// }
// }
// LLFILE* fXMLOut = LLFile::fopen(gExportedFile, "wb"); /* Flawfinder: ignore */
// if (fwrite(buffer, 1, length, fXMLOut) != length)
// {
// LL_WARNS("Messaging") << "Short write" << LL_ENDL;
// }
// fclose(fXMLOut);
// delete [] buffer;
// }
// void exported_item_complete(const LLTSCode status, void *user_data)
// {
// //std::string *filename = (std::string *)user_data;
// if (status < LLTS_OK)
// {
// LL_WARNS("Messaging") << "Export failed!" << LL_ENDL;
// }
// else
// {
// ++current_object_count;
// if (current_image_count == exported_image_count && current_object_count == exported_object_count)
// {
// LL_INFOS("Messaging") << "*** Export complete ***" << LL_ENDL;
// export_complete();
// }
// else
// {
// gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count));
// }
// }
// }
// struct exported_image_info
// {
// LLUUID image_id;
// std::string filename;
// U32 image_num;
// };
// void exported_j2c_complete(const LLTSCode status, void *user_data)
// {
// exported_image_info *info = (exported_image_info *)user_data;
// LLUUID image_id = info->image_id;
// U32 image_num = info->image_num;
// std::string filename = info->filename;
// delete info;
// if (status < LLTS_OK)
// {
// LL_WARNS("Messaging") << "Image download failed!" << LL_ENDL;
// }
// else
// {
// LLFILE* fIn = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
// if (fIn)
// {
// LLPointer<LLImageJ2C> ImageUtility = new LLImageJ2C;
// LLPointer<LLImageTGA> TargaUtility = new LLImageTGA;
// fseek(fIn, 0, SEEK_END);
// S32 length = ftell(fIn);
// fseek(fIn, 0, SEEK_SET);
// U8 *buffer = ImageUtility->allocateData(length);
// if (fread(buffer, 1, length, fIn) != length)
// {
// LL_WARNS("Messaging") << "Short read" << LL_ENDL;
// }
// fclose(fIn);
// LLFile::remove(filename);
// // Convert to TGA
// LLPointer<LLImageRaw> image = new LLImageRaw();
// ImageUtility->updateData();
// ImageUtility->decode(image, 100000.0f);
// TargaUtility->encode(image);
// U8 *data = TargaUtility->getData();
// S32 data_size = TargaUtility->getDataSize();
// std::string file_path = gDirUtilp->getDirName(filename);
// std::string output_file = llformat("%s/image-%03d.tga", file_path.c_str(), image_num);//filename;
// //S32 name_len = output_file.length();
// //strcpy(&output_file[name_len-3], "tga");
// LLFILE* fOut = LLFile::fopen(output_file, "wb"); /* Flawfinder: ignore */
// char md5_hash_string[33]; /* Flawfinder: ignore */
// strcpy(md5_hash_string, "00000000000000000000000000000000"); /* Flawfinder: ignore */
// if (fOut)
// {
// if (fwrite(data, 1, data_size, fOut) != data_size)
// {
// LL_WARNS("Messaging") << "Short write" << LL_ENDL;
// }
// fseek(fOut, 0, SEEK_SET);
// fclose(fOut);
// fOut = LLFile::fopen(output_file, "rb"); /* Flawfinder: ignore */
// LLMD5 my_md5_hash(fOut);
// my_md5_hash.hex_digest(md5_hash_string);
// }
// gImageChecksums.insert(std::pair<LLUUID, std::string>(image_id, md5_hash_string));
// }
// }
// ++current_image_count;
// if (current_image_count == exported_image_count && current_object_count == exported_object_count)
// {
// LL_INFOS("Messaging") << "*** Export textures complete ***" << LL_ENDL;
// export_complete();
// }
// else
// {
// gExportDialog->setMessage(llformat("Exported %d/%d object files, %d/%d textures.", current_object_count, exported_object_count, current_image_count, exported_image_count));
// }
//}
void process_derez_ack(LLMessageSystem*, void**)
{
if(gViewerWindow) gViewerWindow->getWindow()->decBusyCount();
}
void process_places_reply(LLMessageSystem* msg, void** data)
{
LLUUID query_id;
msg->getUUID("AgentData", "QueryID", query_id);
if (query_id.isNull())
{
LLFloaterLandHoldings::processPlacesReply(msg, data);
}
else if(gAgent.isInGroup(query_id))
{
LLPanelGroupLandMoney::processPlacesReply(msg, data);
}
else
{
LL_WARNS("Messaging") << "Got invalid PlacesReply message" << LL_ENDL;
}
}
void send_sound_trigger(const LLUUID& sound_id, F32 gain)
{
if (sound_id.isNull() || gAgent.getRegion() == NULL)
{
// disconnected agent or zero guids don't get sent (no sound)
return;
}
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_SoundTrigger);
msg->nextBlockFast(_PREHASH_SoundData);
msg->addUUIDFast(_PREHASH_SoundID, sound_id);
// Client untrusted, ids set on sim
msg->addUUIDFast(_PREHASH_OwnerID, LLUUID::null );
msg->addUUIDFast(_PREHASH_ObjectID, LLUUID::null );
msg->addUUIDFast(_PREHASH_ParentID, LLUUID::null );
msg->addU64Fast(_PREHASH_Handle, gAgent.getRegion()->getHandle());
LLVector3 position = gAgent.getPositionAgent();
msg->addVector3Fast(_PREHASH_Position, position);
msg->addF32Fast(_PREHASH_Gain, gain);
gAgent.sendMessage();
}
bool join_group_response(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
bool accept_invite = false;
LLUUID group_id = notification["payload"]["group_id"].asUUID();
LLUUID transaction_id = notification["payload"]["transaction_id"].asUUID();
std::string name = notification["payload"]["name"].asString();
std::string message = notification["payload"]["message"].asString();
S32 fee = notification["payload"]["fee"].asInteger();
if (option == 2 && !group_id.isNull())
{
LLGroupActions::show(group_id);
LLSD args;
args["MESSAGE"] = message;
LLNotificationsUtil::add("JoinGroup", args, notification["payload"]);
return false;
}
if(option == 0 && !group_id.isNull())
{
// check for promotion or demotion.
S32 max_groups = gMaxAgentGroups;
if(gAgent.isInGroup(group_id)) ++max_groups;
if(gAgent.mGroups.count() < max_groups)
{
accept_invite = true;
}
else
{
LLSD args;
args["NAME"] = name;
LLNotificationsUtil::add("JoinedTooManyGroupsMember", args, notification["payload"]);
}
}
if (accept_invite)
{
// If there is a fee to join this group, make
// sure the user is sure they want to join.
if (fee > 0)
{
LLSD args;
args["COST"] = llformat("%d", fee);
// Set the fee for next time to 0, so that we don't keep
// asking about a fee.
LLSD next_payload = notification["payload"];
next_payload["fee"] = 0;
LLNotificationsUtil::add("JoinGroupCanAfford",
args,
next_payload);
}
else
{
send_improved_im(group_id,
std::string("name"),
std::string("message"),
IM_ONLINE,
IM_GROUP_INVITATION_ACCEPT,
transaction_id);
}
}
else
{
send_improved_im(group_id,
std::string("name"),
std::string("message"),
IM_ONLINE,
IM_GROUP_INVITATION_DECLINE,
transaction_id);
}
return false;
}
static void highlight_inventory_objects_in_panel(const std::vector<LLUUID>& items, LLInventoryPanel *inventory_panel)
{
if (NULL == inventory_panel) return;
for (std::vector<LLUUID>::const_iterator item_iter = items.begin();
item_iter != items.end();
++item_iter)
{
const LLUUID& item_id = (*item_iter);
if(!highlight_offered_object(item_id))
{
continue;
}
LLInventoryObject* item = gInventory.getObject(item_id);
llassert(item);
if (!item) {
continue;
}
LL_DEBUGS("Inventory_Move") << "Highlighting inventory item: " << item->getName() << ", " << item_id << LL_ENDL;
LLFolderView* fv = inventory_panel->getRootFolder();
if (fv)
{
LLFolderViewItem* fv_item = inventory_panel->getItemByID(item_id);
if (fv_item)
{
LLFolderViewItem* fv_folder = fv_item->getParentFolder();
if (fv_folder)
{
// Parent folders can be different in case of 2 consecutive drag and drop
// operations when the second one is started before the first one completes.
LL_DEBUGS("Inventory_Move") << "Open folder: " << fv_folder->getName() << LL_ENDL;
fv_folder->setOpen(TRUE);
if (fv_folder->isSelected())
{
fv->changeSelection(fv_folder, FALSE);
}
}
fv->changeSelection(fv_item, TRUE);
}
}
}
}
static LLNotificationFunctorRegistration jgr_1("JoinGroup", join_group_response);
static LLNotificationFunctorRegistration jgr_2("JoinedTooManyGroupsMember", join_group_response);
static LLNotificationFunctorRegistration jgr_3("JoinGroupCanAfford", join_group_response);
//-----------------------------------------------------------------------------
// Instant Message
//-----------------------------------------------------------------------------
class LLOpenAgentOffer : public LLInventoryFetchItemsObserver
{
public:
LLOpenAgentOffer(const LLUUID& object_id,
const std::string& from_name) :
LLInventoryFetchItemsObserver(object_id),
mFromName(from_name) {}
/*virtual*/ void startFetch()
{
for (uuid_vec_t::const_iterator it = mIDs.begin(); it < mIDs.end(); ++it)
{
LLViewerInventoryCategory* cat = gInventory.getCategory(*it);
if (cat)
{
mComplete.push_back((*it));
}
}
LLInventoryFetchItemsObserver::startFetch();
}
/*virtual*/ void done()
{
open_inventory_offer(mComplete, mFromName);
gInventory.removeObserver(this);
delete this;
}
private:
std::string mFromName;
};
/**
* Class to observe adding of new items moved from the world to user's inventory to select them in inventory.
*
* We can't create it each time items are moved because "drop" event is sent separately for each
* element even while multi-dragging. We have to have the only instance of the observer. See EXT-4347.
*/
class LLViewerInventoryMoveFromWorldObserver : public LLInventoryAddItemByAssetObserver
{
public:
LLViewerInventoryMoveFromWorldObserver()
: LLInventoryAddItemByAssetObserver()
{
}
void setMoveIntoFolderID(const LLUUID& into_folder_uuid) {mMoveIntoFolderID = into_folder_uuid; }
private:
/*virtual */void onAssetAdded(const LLUUID& asset_id)
{
// Store active Inventory panel.
if (LLInventoryPanel::getActiveInventoryPanel())
{
mActivePanel = LLInventoryPanel::getActiveInventoryPanel()->getHandle();
}
// Store selected items (without destination folder)
mSelectedItems.clear();
if (LLInventoryPanel::getActiveInventoryPanel())
{
std::set<LLFolderViewItem*> selection = LLInventoryPanel::getActiveInventoryPanel()->getRootFolder()->getSelectionList();
for (std::set<LLFolderViewItem*>::iterator it = selection.begin(), end_it = selection.end();
it != end_it;
++it)
{
mSelectedItems.insert(static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID());
}
}
mSelectedItems.erase(mMoveIntoFolderID);
}
/**
* Selects added inventory items watched by their Asset UUIDs if selection was not changed since
* all items were started to watch (dropped into a folder).
*/
void done()
{
LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get());
// if selection is not changed since watch started lets hightlight new items.
if (active_panel && !isSelectionChanged())
{
LL_DEBUGS("Inventory_Move") << "Selecting new items..." << LL_ENDL;
active_panel->clearSelection();
highlight_inventory_objects_in_panel(mAddedItems, active_panel);
}
}
/**
* Returns true if selected inventory items were changed since moved inventory items were started to watch.
*/
bool isSelectionChanged()
{
LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get());
if (NULL == active_panel)
{
return true;
}
// get selected items (without destination folder)
selected_items_t selected_items;
std::set<LLFolderViewItem*> selection = LLInventoryPanel::getActiveInventoryPanel()->getRootFolder()->getSelectionList();
for (std::set<LLFolderViewItem*>::iterator it = selection.begin(), end_it = selection.end();
it != end_it;
++it)
{
selected_items.insert(static_cast<LLFolderViewModelItemInventory*>((*it)->getViewModelItem())->getUUID());
}
selected_items.erase(mMoveIntoFolderID);
// compare stored & current sets of selected items
selected_items_t different_items;
std::set_symmetric_difference(mSelectedItems.begin(), mSelectedItems.end(),
selected_items.begin(), selected_items.end(), std::inserter(different_items, different_items.begin()));
LL_DEBUGS("Inventory_Move") << "Selected firstly: " << mSelectedItems.size()
<< ", now: " << selected_items.size() << ", difference: " << different_items.size() << LL_ENDL;
return different_items.size() > 0;
}
LLHandle<LLPanel> mActivePanel;
typedef std::set<LLUUID> selected_items_t;
selected_items_t mSelectedItems;
/**
* UUID of FolderViewFolder into which watched items are moved.
*
* Destination FolderViewFolder becomes selected while mouse hovering (when dragged items are dropped).
*
* If mouse is moved out it set unselected and number of selected items is changed
* even if selected items in Inventory stay the same.
* So, it is used to update stored selection list.
*
* @see onAssetAdded()
* @see isSelectionChanged()
*/
LLUUID mMoveIntoFolderID;
};
LLViewerInventoryMoveFromWorldObserver* gInventoryMoveObserver = NULL;
void set_dad_inventory_item(LLInventoryItem* inv_item, const LLUUID& into_folder_uuid)
{
start_new_inventory_observer();
gInventoryMoveObserver->setMoveIntoFolderID(into_folder_uuid);
gInventoryMoveObserver->watchAsset(inv_item->getAssetUUID());
}
/**
* Class to observe moving of items and to select them in inventory.
*
* Used currently for dragging from inbox to regular inventory folders
*/
class LLViewerInventoryMoveObserver : public LLInventoryObserver
{
public:
LLViewerInventoryMoveObserver(const LLUUID& object_id)
: LLInventoryObserver()
, mObjectID(object_id)
{
if (LLInventoryPanel::getActiveInventoryPanel())
{
mActivePanel = LLInventoryPanel::getActiveInventoryPanel()->getHandle();
}
}
virtual ~LLViewerInventoryMoveObserver() {}
virtual void changed(U32 mask);
private:
LLUUID mObjectID;
LLHandle<LLPanel> mActivePanel;
};
void LLViewerInventoryMoveObserver::changed(U32 mask)
{
LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get());
if (NULL == active_panel)
{
gInventory.removeObserver(this);
return;
}
if((mask & (LLInventoryObserver::STRUCTURE)) != 0)
{
const std::set<LLUUID>& changed_items = gInventory.getChangedIDs();
std::set<LLUUID>::const_iterator id_it = changed_items.begin();
std::set<LLUUID>::const_iterator id_end = changed_items.end();
for (;id_it != id_end; ++id_it)
{
if ((*id_it) == mObjectID)
{
active_panel->clearSelection();
std::vector<LLUUID> items;
items.push_back(mObjectID);
highlight_inventory_objects_in_panel(items, active_panel);
active_panel->getRootFolder()->scrollToShowSelection();
gInventory.removeObserver(this);
break;
}
}
}
}
void set_dad_inbox_object(const LLUUID& object_id)
{
LLViewerInventoryMoveObserver* move_observer = new LLViewerInventoryMoveObserver(object_id);
gInventory.addObserver(move_observer);
}
//unlike the FetchObserver for AgentOffer, we only make one
//instance of the AddedObserver for TaskOffers
//and it never dies. We do this because we don't know the UUID of
//task offers until they are accepted, so we don't wouldn't
//know what to watch for, so instead we just watch for all additions.
class LLOpenTaskOffer : public LLInventoryAddedObserver
{
protected:
/*virtual*/ void done()
{
for (uuid_vec_t::iterator it = mAdded.begin(); it != mAdded.end();)
{
const LLUUID& item_uuid = *it;
bool was_moved = false;
LLInventoryObject* added_object = gInventory.getObject(item_uuid);
if (added_object)
{
// cast to item to get Asset UUID
LLInventoryItem* added_item = dynamic_cast<LLInventoryItem*>(added_object);
if (added_item)
{
const LLUUID& asset_uuid = added_item->getAssetUUID();
if (gInventoryMoveObserver->isAssetWatched(asset_uuid))
{
LL_DEBUGS("Inventory_Move") << "Found asset UUID: " << asset_uuid << LL_ENDL;
was_moved = true;
}
}
}
if (was_moved)
{
it = mAdded.erase(it);
}
else ++it;
}
open_inventory_offer(mAdded, "");
mAdded.clear();
}
};
class LLOpenTaskGroupOffer : public LLInventoryAddedObserver
{
protected:
/*virtual*/ void done()
{
open_inventory_offer(mAdded, "group_offer");
mAdded.clear();
gInventory.removeObserver(this);
delete this;
}
};
//one global instance to bind them
LLOpenTaskOffer* gNewInventoryObserver=NULL;
class LLNewInventoryHintObserver : public LLInventoryAddedObserver
{
protected:
/*virtual*/ void done()
{
LLFirstUse::newInventory();
}
};
LLNewInventoryHintObserver* gNewInventoryHintObserver=NULL;
void start_new_inventory_observer()
{
if (!gNewInventoryObserver) //task offer observer
{
// Observer is deleted by gInventory
gNewInventoryObserver = new LLOpenTaskOffer;
gInventory.addObserver(gNewInventoryObserver);
}
if (!gInventoryMoveObserver) //inventory move from the world observer
{
// Observer is deleted by gInventory
gInventoryMoveObserver = new LLViewerInventoryMoveFromWorldObserver;
gInventory.addObserver(gInventoryMoveObserver);
}
if (!gNewInventoryHintObserver)
{
// Observer is deleted by gInventory
gNewInventoryHintObserver = new LLNewInventoryHintObserver();
gInventory.addObserver(gNewInventoryHintObserver);
}
}
class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver
{
LOG_CLASS(LLDiscardAgentOffer);
public:
LLDiscardAgentOffer(const LLUUID& folder_id, const LLUUID& object_id) :
LLInventoryFetchItemsObserver(object_id),
mFolderID(folder_id),
mObjectID(object_id) {}
virtual void done()
{
LL_DEBUGS("Messaging") << "LLDiscardAgentOffer::done()" << LL_ENDL;
// We're invoked from LLInventoryModel::notifyObservers().
// If we now try to remove the inventory item, it will cause a nested
// notifyObservers() call, which won't work.
// So defer moving the item to trash until viewer gets idle (in a moment).
// Use removeObject() rather than removeItem() because at this level,
// the object could be either an item or a folder.
LLAppViewer::instance()->addOnIdleCallback(boost::bind(&LLInventoryModel::removeObject, &gInventory, mObjectID));
gInventory.removeObserver(this);
delete this;
}
protected:
LLUUID mFolderID;
LLUUID mObjectID;
};
//Returns TRUE if we are OK, FALSE if we are throttled
//Set check_only true if you want to know the throttle status
//without registering a hit
bool check_offer_throttle(const std::string& from_name, bool check_only)
{
static U32 throttle_count;
static bool throttle_logged;
LLChat chat;
std::string log_message;
if (!gSavedSettings.getBOOL("ShowNewInventory"))
return false;
if (check_only)
{
return gThrottleTimer.hasExpired();
}
if(gThrottleTimer.checkExpirationAndReset(OFFER_THROTTLE_TIME))
{
LL_DEBUGS("Messaging") << "Throttle Expired" << LL_ENDL;
throttle_count=1;
throttle_logged=false;
return true;
}
else //has not expired
{
LL_DEBUGS("Messaging") << "Throttle Not Expired, Count: " << throttle_count << LL_ENDL;
// When downloading the initial inventory we get a lot of new items
// coming in and can't tell that from spam.
if (LLStartUp::getStartupState() >= STATE_STARTED
&& throttle_count >= OFFER_THROTTLE_MAX_COUNT)
{
if (!throttle_logged)
{
// Use the name of the last item giver, who is probably the person
// spamming you.
LLStringUtil::format_map_t arg;
std::string log_msg;
std::ostringstream time ;
time<<OFFER_THROTTLE_TIME;
arg["APP_NAME"] = LLAppViewer::instance()->getSecondLifeTitle();
arg["TIME"] = time.str();
if (!from_name.empty())
{
arg["FROM_NAME"] = from_name;
log_msg = LLTrans::getString("ItemsComingInTooFastFrom", arg);
}
else
{
log_msg = LLTrans::getString("ItemsComingInTooFast", arg);
}
//this is kinda important, so actually put it on screen
LLSD args;
args["MESSAGE"] = log_msg;
LLNotificationsUtil::add("SystemMessage", args);
throttle_logged=true;
}
return false;
}
else
{
throttle_count++;
return true;
}
}
}
// Return "true" if we have a preview method for that asset type, "false" otherwise
bool check_asset_previewable(const LLAssetType::EType asset_type)
{
return (asset_type == LLAssetType::AT_NOTECARD) ||
(asset_type == LLAssetType::AT_LANDMARK) ||
(asset_type == LLAssetType::AT_TEXTURE) ||
(asset_type == LLAssetType::AT_ANIMATION) ||
(asset_type == LLAssetType::AT_SCRIPT) ||
(asset_type == LLAssetType::AT_SOUND);
}
void open_inventory_offer(const uuid_vec_t& objects, const std::string& from_name)
{
for (uuid_vec_t::const_iterator obj_iter = objects.begin();
obj_iter != objects.end();
++obj_iter)
{
const LLUUID& obj_id = (*obj_iter);
if(!highlight_offered_object(obj_id))
{
continue;
}
const LLInventoryObject *obj = gInventory.getObject(obj_id);
if (!obj)
{
llwarns << "Cannot find object [ itemID:" << obj_id << " ] to open." << llendl;
continue;
}
const LLAssetType::EType asset_type = obj->getActualType();
// Either an inventory item or a category.
const LLInventoryItem* item = dynamic_cast<const LLInventoryItem*>(obj);
if (item && check_asset_previewable(asset_type))
{
////////////////////////////////////////////////////////////////////////////////
// Special handling for various types.
if (check_offer_throttle(from_name, false)) // If we are throttled, don't display
{
LL_DEBUGS("Messaging") << "Highlighting inventory item: " << item->getUUID() << LL_ENDL;
// If we opened this ourselves, focus it
const BOOL take_focus = from_name.empty() ? TAKE_FOCUS_YES : TAKE_FOCUS_NO;
switch(asset_type)
{
case LLAssetType::AT_NOTECARD:
{
LLFloaterReg::showInstance("preview_notecard", LLSD(obj_id), take_focus);
break;
}
case LLAssetType::AT_LANDMARK:
{
LLInventoryCategory* parent_folder = gInventory.getCategory(item->getParentUUID());
if ("inventory_handler" == from_name)
{
LLFloaterSidePanelContainer::showPanel("places", LLSD().with("type", "landmark").with("id", item->getUUID()));
}
else if("group_offer" == from_name)
{
// "group_offer" is passed by LLOpenTaskGroupOffer
// Notification about added landmark will be generated under the "from_name.empty()" called from LLOpenTaskOffer::done().
LLSD args;
args["type"] = "landmark";
args["id"] = obj_id;
LLFloaterSidePanelContainer::showPanel("places", args);
continue;
}
else if(from_name.empty())
{
std::string folder_name;
if (parent_folder)
{
// Localize folder name.
// *TODO: share this code?
folder_name = parent_folder->getName();
if (LLFolderType::lookupIsProtectedType(parent_folder->getPreferredType()))
{
LLTrans::findString(folder_name, "InvFolder " + folder_name);
}
}
else
{
folder_name = LLTrans::getString("Unknown");
}
// we receive a message from LLOpenTaskOffer, it mean that new landmark has been added.
LLSD args;
args["LANDMARK_NAME"] = item->getName();
args["FOLDER_NAME"] = folder_name;
LLNotificationsUtil::add("LandmarkCreated", args);
}
}
break;
case LLAssetType::AT_TEXTURE:
{
LLFloaterReg::showInstance("preview_texture", LLSD(obj_id), take_focus);
break;
}
case LLAssetType::AT_ANIMATION:
LLFloaterReg::showInstance("preview_anim", LLSD(obj_id), take_focus);
break;
case LLAssetType::AT_SCRIPT:
LLFloaterReg::showInstance("preview_script", LLSD(obj_id), take_focus);
break;
case LLAssetType::AT_SOUND:
LLFloaterReg::showInstance("preview_sound", LLSD(obj_id), take_focus);
break;
default:
LL_DEBUGS("Messaging") << "No preview method for previewable asset type : " << LLAssetType::lookupHumanReadable(asset_type) << LL_ENDL;
break;
}
}
}
////////////////////////////////////////////////////////////////////////////////
// Highlight item
const BOOL auto_open =
gSavedSettings.getBOOL("ShowInInventory") && // don't open if showininventory is false
!from_name.empty(); // don't open if it's not from anyone.
LLInventoryPanel::openInventoryPanelAndSetSelection(auto_open, obj_id);
}
}
bool highlight_offered_object(const LLUUID& obj_id)
{
const LLInventoryObject* obj = gInventory.getObject(obj_id);
if(!obj)
{
LL_WARNS("Messaging") << "Unable to show inventory item: " << obj_id << LL_ENDL;
return false;
}
////////////////////////////////////////////////////////////////////////////////
// Don't highlight if it's in certain "quiet" folders which don't need UI
// notification (e.g. trash, cof, lost-and-found).
if(!gAgent.getAFK())
{
const LLViewerInventoryCategory *parent = gInventory.getFirstNondefaultParent(obj_id);
if (parent)
{
const LLFolderType::EType parent_type = parent->getPreferredType();
if (LLViewerFolderType::lookupIsQuietType(parent_type))
{
return false;
}
}
}
return true;
}
void inventory_offer_mute_callback(const LLUUID& blocked_id,
const std::string& full_name,
bool is_group)
{
// *NOTE: blocks owner if the offer came from an object
LLMute::EType mute_type = is_group ? LLMute::GROUP : LLMute::AGENT;
LLMute mute(blocked_id, full_name, mute_type);
if (LLMuteList::getInstance()->add(mute))
{
LLPanelBlockedList::showPanelAndSelect(blocked_id);
}
// purge the message queue of any previously queued inventory offers from the same source.
class OfferMatcher : public LLNotificationsUI::LLScreenChannel::Matcher
{
public:
OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
bool matches(const LLNotificationPtr notification) const
{
if(notification->getName() == "ObjectGiveItem"
|| notification->getName() == "OwnObjectGiveItem"
|| notification->getName() == "UserGiveItem")
{
return (notification->getPayload()["from_id"].asUUID() == blocked_id);
}
return FALSE;
}
private:
const LLUUID& blocked_id;
};
LLNotificationsUI::LLChannelManager::getInstance()->killToastsFromChannel(LLUUID(
gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(blocked_id));
}
std::string LLOfferInfo::mResponderType = "offer_info";
LLOfferInfo::LLOfferInfo()
: LLNotificationResponderInterface()
, mFromGroup(FALSE)
, mFromObject(FALSE)
, mIM(IM_NOTHING_SPECIAL)
, mType(LLAssetType::AT_NONE)
, mPersist(false)
{
}
LLOfferInfo::LLOfferInfo(const LLSD& sd)
{
mIM = (EInstantMessage)sd["im_type"].asInteger();
mFromID = sd["from_id"].asUUID();
mFromGroup = sd["from_group"].asBoolean();
mFromObject = sd["from_object"].asBoolean();
mTransactionID = sd["transaction_id"].asUUID();
mFolderID = sd["folder_id"].asUUID();
mObjectID = sd["object_id"].asUUID();
mType = LLAssetType::lookup(sd["type"].asString().c_str());
mFromName = sd["from_name"].asString();
mDesc = sd["description"].asString();
mHost = LLHost(sd["sender"].asString());
mPersist = sd["persist"].asBoolean();
}
LLOfferInfo::LLOfferInfo(const LLOfferInfo& info)
{
mIM = info.mIM;
mFromID = info.mFromID;
mFromGroup = info.mFromGroup;
mFromObject = info.mFromObject;
mTransactionID = info.mTransactionID;
mFolderID = info.mFolderID;
mObjectID = info.mObjectID;
mType = info.mType;
mFromName = info.mFromName;
mDesc = info.mDesc;
mHost = info.mHost;
mPersist = info.mPersist;
}
LLSD LLOfferInfo::asLLSD()
{
LLSD sd;
sd["responder_type"] = mResponderType;
sd["im_type"] = mIM;
sd["from_id"] = mFromID;
sd["from_group"] = mFromGroup;
sd["from_object"] = mFromObject;
sd["transaction_id"] = mTransactionID;
sd["folder_id"] = mFolderID;
sd["object_id"] = mObjectID;
sd["type"] = LLAssetType::lookup(mType);
sd["from_name"] = mFromName;
sd["description"] = mDesc;
sd["sender"] = mHost.getIPandPort();
sd["persist"] = mPersist;
return sd;
}
void LLOfferInfo::fromLLSD(const LLSD& params)
{
*this = params;
}
void LLOfferInfo::send_auto_receive_response(void)
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ImprovedInstantMessage);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_MessageBlock);
msg->addBOOLFast(_PREHASH_FromGroup, FALSE);
msg->addUUIDFast(_PREHASH_ToAgentID, mFromID);
msg->addU8Fast(_PREHASH_Offline, IM_ONLINE);
msg->addUUIDFast(_PREHASH_ID, mTransactionID);
msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary
std::string name;
LLAgentUI::buildFullname(name);
msg->addStringFast(_PREHASH_FromAgentName, name);
msg->addStringFast(_PREHASH_Message, "");
msg->addU32Fast(_PREHASH_ParentEstateID, 0);
msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null);
msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent());
// Auto Receive Message. The math for the dialog works, because the accept
// for inventory_offered, task_inventory_offer or
// group_notice_inventory is 1 greater than the offer integer value.
// Generates IM_INVENTORY_ACCEPTED, IM_TASK_INVENTORY_ACCEPTED,
// or IM_GROUP_NOTICE_INVENTORY_ACCEPTED
msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 1));
msg->addBinaryDataFast(_PREHASH_BinaryBucket, &(mFolderID.mData),
sizeof(mFolderID.mData));
// send the message
msg->sendReliable(mHost);
if(IM_INVENTORY_OFFERED == mIM)
{
// add buddy to recent people list
LLRecentPeople::instance().add(mFromID);
}
}
void LLOfferInfo::handleRespond(const LLSD& notification, const LLSD& response)
{
initRespondFunctionMap();
const std::string name = notification["name"].asString();
if(mRespondFunctions.find(name) == mRespondFunctions.end())
{
llwarns << "Unexpected notification name : " << name << llendl;
llassert(!"Unexpected notification name");
return;
}
mRespondFunctions[name](notification, response);
}
bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& response)
{
LLChat chat;
std::string log_message;
S32 button = LLNotificationsUtil::getSelectedOption(notification, response);
LLInventoryObserver* opener = NULL;
LLViewerInventoryCategory* catp = NULL;
catp = (LLViewerInventoryCategory*)gInventory.getCategory(mObjectID);
LLViewerInventoryItem* itemp = NULL;
if(!catp)
{
itemp = (LLViewerInventoryItem*)gInventory.getItem(mObjectID);
}
LLNotificationPtr notification_ptr = LLNotifications::instance().find(notification["id"].asUUID());
// For muting, we need to add the mute, then decline the offer.
// This must be done here because:
// * callback may be called immediately,
// * adding the mute sends a message,
// * we can't build two messages at once.
if (IOR_MUTE == button) // Block
{
if (notification_ptr != NULL)
{
gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback, _1, _2, _3));
}
}
std::string from_string; // Used in the pop-up.
std::string chatHistory_string; // Used in chat history.
// TODO: when task inventory offers can also be handled the new way, migrate the code that sets these strings here:
from_string = chatHistory_string = mFromName;
LLNotificationFormPtr modified_form(notification_ptr ? new LLNotificationForm(*notification_ptr->getForm()) : new LLNotificationForm());
switch(button)
{
case IOR_SHOW:
// we will want to open this item when it comes back.
LL_DEBUGS("Messaging") << "Initializing an opener for tid: " << mTransactionID
<< LL_ENDL;
switch (mIM)
{
case IM_INVENTORY_OFFERED:
{
// This is an offer from an agent. In this case, the back
// end has already copied the items into your inventory,
// so we can fetch it out of our inventory.
if (gSavedSettings.getBOOL("ShowOfferedInventory"))
{
LLOpenAgentOffer* open_agent_offer = new LLOpenAgentOffer(mObjectID, from_string);
open_agent_offer->startFetch();
if(catp || (itemp && itemp->isFinished()))
{
open_agent_offer->done();
}
else
{
opener = open_agent_offer;
}
}
}
break;
case IM_GROUP_NOTICE:
opener = new LLOpenTaskGroupOffer;
send_auto_receive_response();
break;
case IM_TASK_INVENTORY_OFFERED:
case IM_GROUP_NOTICE_REQUESTED:
// This is an offer from a task or group.
// We don't use a new instance of an opener
// We instead use the singular observer gOpenTaskOffer
// Since it already exists, we don't need to actually do anything
break;
default:
LL_WARNS("Messaging") << "inventory_offer_callback: unknown offer type" << LL_ENDL;
break;
}
if (modified_form != NULL)
{
modified_form->setElementEnabled("Show", false);
}
break;
// end switch (mIM)
case IOR_ACCEPT:
//don't spam them if they are getting flooded
if (check_offer_throttle(mFromName, true))
{
log_message = chatHistory_string + " " + LLTrans::getString("InvOfferGaveYou") + " " + mDesc + LLTrans::getString(".");
LLSD args;
args["MESSAGE"] = log_message;
LLNotificationsUtil::add("SystemMessageTip", args);
}
break;
case IOR_MUTE:
if (modified_form != NULL)
{
modified_form->setElementEnabled("Mute", false);
}
// MUTE falls through to decline
case IOR_DECLINE:
{
{
LLStringUtil::format_map_t log_message_args;
log_message_args["DESC"] = mDesc;
log_message_args["NAME"] = mFromName;
log_message = LLTrans::getString("InvOfferDecline", log_message_args);
}
chat.mText = log_message;
if( LLMuteList::getInstance()->isMuted(mFromID ) && ! LLMuteList::getInstance()->isLinden(mFromName) ) // muting for SL-42269
{
chat.mMuted = TRUE;
}
// *NOTE dzaporozhan
// Disabled logging to old chat floater to fix crash in group notices - EXT-4149
// LLFloaterChat::addChatHistory(chat);
LLDiscardAgentOffer* discard_agent_offer = new LLDiscardAgentOffer(mFolderID, mObjectID);
discard_agent_offer->startFetch();
if (catp || (itemp && itemp->isFinished()))
{
discard_agent_offer->done();
}
else
{
opener = discard_agent_offer;
}
if (modified_form != NULL)
{
modified_form->setElementEnabled("Show", false);
modified_form->setElementEnabled("Discard", false);
}
break;
}
default:
// close button probably
// The item has already been fetched and is in your inventory, we simply won't highlight it
// OR delete it if the notification gets killed, since we don't want that to be a vector for
// losing inventory offers.
break;
}
if(opener)
{
gInventory.addObserver(opener);
}
if(!mPersist)
{
delete this;
}
return false;
}
bool LLOfferInfo::inventory_task_offer_callback(const LLSD& notification, const LLSD& response)
{
LLChat chat;
std::string log_message;
S32 button = LLNotification::getSelectedOption(notification, response);
// For muting, we need to add the mute, then decline the offer.
// This must be done here because:
// * callback may be called immediately,
// * adding the mute sends a message,
// * we can't build two messages at once.
if (2 == button)
{
LLNotificationPtr notification_ptr = LLNotifications::instance().find(notification["id"].asUUID());
llassert(notification_ptr != NULL);
if (notification_ptr != NULL)
{
gCacheName->get(mFromID, mFromGroup, boost::bind(&inventory_offer_mute_callback, _1, _2, _3));
}
}
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_ImprovedInstantMessage);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_MessageBlock);
msg->addBOOLFast(_PREHASH_FromGroup, FALSE);
msg->addUUIDFast(_PREHASH_ToAgentID, mFromID);
msg->addU8Fast(_PREHASH_Offline, IM_ONLINE);
msg->addUUIDFast(_PREHASH_ID, mTransactionID);
msg->addU32Fast(_PREHASH_Timestamp, NO_TIMESTAMP); // no timestamp necessary
std::string name;
LLAgentUI::buildFullname(name);
msg->addStringFast(_PREHASH_FromAgentName, name);
msg->addStringFast(_PREHASH_Message, "");
msg->addU32Fast(_PREHASH_ParentEstateID, 0);
msg->addUUIDFast(_PREHASH_RegionID, LLUUID::null);
msg->addVector3Fast(_PREHASH_Position, gAgent.getPositionAgent());
LLInventoryObserver* opener = NULL;
std::string from_string; // Used in the pop-up.
std::string chatHistory_string; // Used in chat history.
if (mFromObject == TRUE)
{
if (mFromGroup)
{
std::string group_name;
if (gCacheName->getGroupName(mFromID, group_name))
{
from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+"'"
+ mFromName + LLTrans::getString("'") +" " + LLTrans::getString("InvOfferOwnedByGroup")
+ " "+ "'" + group_name + "'";
chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByGroup")
+ " " + group_name + "'";
}
else
{
from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+"'"
+ mFromName +"'"+ " " + LLTrans::getString("InvOfferOwnedByUnknownGroup");
chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownGroup");
}
}
else
{
std::string full_name;
if (gCacheName->getFullName(mFromID, full_name))
{
from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+ LLTrans::getString("'") + mFromName
+ LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedBy") + full_name;
chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedBy") + " " + full_name;
}
else
{
from_string = LLTrans::getString("InvOfferAnObjectNamed") + " "+LLTrans::getString("'")
+ mFromName + LLTrans::getString("'")+" " + LLTrans::getString("InvOfferOwnedByUnknownUser");
chatHistory_string = mFromName + " " + LLTrans::getString("InvOfferOwnedByUnknownUser");
}
}
}
else
{
from_string = chatHistory_string = mFromName;
}
bool is_do_not_disturb = gAgent.isDoNotDisturb();
switch(button)
{
case IOR_ACCEPT:
// ACCEPT. The math for the dialog works, because the accept
// for inventory_offered, task_inventory_offer or
// group_notice_inventory is 1 greater than the offer integer value.
// Generates IM_INVENTORY_ACCEPTED, IM_TASK_INVENTORY_ACCEPTED,
// or IM_GROUP_NOTICE_INVENTORY_ACCEPTED
msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 1));
msg->addBinaryDataFast(_PREHASH_BinaryBucket, &(mFolderID.mData),
sizeof(mFolderID.mData));
// send the message
msg->sendReliable(mHost);
//don't spam them if they are getting flooded
if (check_offer_throttle(mFromName, true))
{
log_message = chatHistory_string + " " + LLTrans::getString("InvOfferGaveYou") + " " + mDesc + LLTrans::getString(".");
LLSD args;
args["MESSAGE"] = log_message;
LLNotificationsUtil::add("SystemMessageTip", args);
}
// we will want to open this item when it comes back.
LL_DEBUGS("Messaging") << "Initializing an opener for tid: " << mTransactionID
<< LL_ENDL;
switch (mIM)
{
case IM_TASK_INVENTORY_OFFERED:
case IM_GROUP_NOTICE:
case IM_GROUP_NOTICE_REQUESTED:
{
// This is an offer from a task or group.
// We don't use a new instance of an opener
// We instead use the singular observer gOpenTaskOffer
// Since it already exists, we don't need to actually do anything
}
break;
default:
LL_WARNS("Messaging") << "inventory_offer_callback: unknown offer type" << LL_ENDL;
break;
} // end switch (mIM)
break;
case IOR_MUTE:
// MUTE falls through to decline
case IOR_DECLINE:
// DECLINE. The math for the dialog works, because the decline
// for inventory_offered, task_inventory_offer or
// group_notice_inventory is 2 greater than the offer integer value.
// Generates IM_INVENTORY_DECLINED, IM_TASK_INVENTORY_DECLINED,
// or IM_GROUP_NOTICE_INVENTORY_DECLINED
default:
// close button probably (or any of the fall-throughs from above)
msg->addU8Fast(_PREHASH_Dialog, (U8)(mIM + 2));
msg->addBinaryDataFast(_PREHASH_BinaryBucket, EMPTY_BINARY_BUCKET, EMPTY_BINARY_BUCKET_SIZE);
// send the message
msg->sendReliable(mHost);
if (gSavedSettings.getBOOL("LogInventoryDecline"))
{
LLStringUtil::format_map_t log_message_args;
log_message_args["DESC"] = mDesc;
log_message_args["NAME"] = mFromName;
log_message = LLTrans::getString("InvOfferDecline", log_message_args);
LLSD args;
args["MESSAGE"] = log_message;
LLNotificationsUtil::add("SystemMessageTip", args);
}
if (is_do_not_disturb && (!mFromGroup && !mFromObject))
{
send_do_not_disturb_message(msg,mFromID);
}
break;
}
if(opener)
{
gInventory.addObserver(opener);
}
if(!mPersist)
{
delete this;
}
return false;
}
class LLPostponedOfferNotification: public LLPostponedNotification
{
protected:
/* virtual */
void modifyNotificationParams()
{
LLSD substitutions = mParams.substitutions;
substitutions["NAME"] = mName;
mParams.substitutions = substitutions;
}
};
void LLOfferInfo::initRespondFunctionMap()
{
if(mRespondFunctions.empty())
{
mRespondFunctions["ObjectGiveItem"] = boost::bind(&LLOfferInfo::inventory_task_offer_callback, this, _1, _2);
mRespondFunctions["OwnObjectGiveItem"] = boost::bind(&LLOfferInfo::inventory_task_offer_callback, this, _1, _2);
mRespondFunctions["UserGiveItem"] = boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2);
}
}
void inventory_offer_handler(LLOfferInfo* info)
{
// If muted, don't even go through the messaging stuff. Just curtail the offer here.
// Passing in a null UUID handles the case of where you have muted one of your own objects by_name.
// The solution for STORM-1297 seems to handle the cases where the object is owned by someone else.
if (LLMuteList::getInstance()->isMuted(info->mFromID, info->mFromName) ||
LLMuteList::getInstance()->isMuted(LLUUID::null, info->mFromName))
{
info->forceResponse(IOR_MUTE);
return;
}
bool bAutoAccept(false);
// Avoid the Accept/Discard dialog if the user so desires. JC
if (gSavedSettings.getBOOL("AutoAcceptNewInventory")
&& (info->mType == LLAssetType::AT_NOTECARD
|| info->mType == LLAssetType::AT_LANDMARK
|| info->mType == LLAssetType::AT_TEXTURE))
{
// For certain types, just accept the items into the inventory,
// and possibly open them on receipt depending upon "ShowNewInventory".
bAutoAccept = true;
}
// Strip any SLURL from the message display. (DEV-2754)
std::string msg = info->mDesc;
int indx = msg.find(" ( http://slurl.com/secondlife/");
if(indx == std::string::npos)
{
// try to find new slurl host
indx = msg.find(" ( http://maps.secondlife.com/secondlife/");
}
if(indx >= 0)
{
LLStringUtil::truncate(msg, indx);
}
LLSD args;
args["[OBJECTNAME]"] = msg;
LLSD payload;
// must protect against a NULL return from lookupHumanReadable()
std::string typestr = ll_safe_string(LLAssetType::lookupHumanReadable(info->mType));
if (!typestr.empty())
{
// human readable matches string name from strings.xml
// lets get asset type localized name
args["OBJECTTYPE"] = LLTrans::getString(typestr);
}
else
{
LL_WARNS("Messaging") << "LLAssetType::lookupHumanReadable() returned NULL - probably bad asset type: " << info->mType << LL_ENDL;
args["OBJECTTYPE"] = "";
// This seems safest, rather than propagating bogosity
LL_WARNS("Messaging") << "Forcing an inventory-decline for probably-bad asset type." << LL_ENDL;
info->forceResponse(IOR_DECLINE);
return;
}
// If mObjectID is null then generate the object_id based on msg to prevent
// multiple creation of chiclets for same object.
LLUUID object_id = info->mObjectID;
if (object_id.isNull())
object_id.generate(msg);
payload["from_id"] = info->mFromID;
// Needed by LLScriptFloaterManager to bind original notification with
// faked for toast one.
payload["object_id"] = object_id;
// Flag indicating that this notification is faked for toast.
payload["give_inventory_notification"] = FALSE;
args["OBJECTFROMNAME"] = info->mFromName;
args["NAME"] = info->mFromName;
if (info->mFromGroup)
{
args["NAME_SLURL"] = LLSLURL("group", info->mFromID, "about").getSLURLString();
}
else
{
args["NAME_SLURL"] = LLSLURL("agent", info->mFromID, "about").getSLURLString();
}
std::string verb = "select?name=" + LLURI::escape(msg);
args["ITEM_SLURL"] = LLSLURL("inventory", info->mObjectID, verb.c_str()).getSLURLString();
LLNotification::Params p;
// Object -> Agent Inventory Offer
if (info->mFromObject && !bAutoAccept)
{
// Inventory Slurls don't currently work for non agent transfers, so only display the object name.
args["ITEM_SLURL"] = msg;
// Note: sets inventory_task_offer_callback as the callback
p.substitutions(args).payload(payload).functor.responder(LLNotificationResponderPtr(info));
info->mPersist = true;
// Offers from your own objects need a special notification template.
p.name = info->mFromID == gAgentID ? "OwnObjectGiveItem" : "ObjectGiveItem";
// Pop up inv offer chiclet and let the user accept (keep), or reject (and silently delete) the inventory.
LLPostponedNotification::add<LLPostponedOfferNotification>(p, info->mFromID, info->mFromGroup == TRUE);
}
else // Agent -> Agent Inventory Offer
{
p.responder = info;
// Note: sets inventory_offer_callback as the callback
// *TODO fix memory leak
// inventory_offer_callback() is not invoked if user received notification and
// closes viewer(without responding the notification)
p.substitutions(args).payload(payload).functor.responder(LLNotificationResponderPtr(info));
info->mPersist = true;
p.name = "UserGiveItem";
p.offer_from_agent = true;
// Prefetch the item into your local inventory.
LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID);
fetch_item->startFetch();
if(fetch_item->isFinished())
{
fetch_item->done();
}
else
{
gInventory.addObserver(fetch_item);
}
// In viewer 2 we're now auto receiving inventory offers and messaging as such (not sending reject messages).
info->send_auto_receive_response();
if (gAgent.isDoNotDisturb())
{
send_do_not_disturb_message(gMessageSystem, info->mFromID);
}
if( !bAutoAccept ) // if we auto accept, do not pester the user
{
// Inform user that there is a script floater via toast system
payload["give_inventory_notification"] = TRUE;
p.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>(p, info->mFromID, false);
}
}
LLFirstUse::newInventory();
}
bool lure_callback(const LLSD& notification, const LLSD& response)
{
S32 option = 0;
if (response.isInteger())
{
option = response.asInteger();
}
else
{
option = LLNotificationsUtil::getSelectedOption(notification, response);
}
LLUUID from_id = notification["payload"]["from_id"].asUUID();
LLUUID lure_id = notification["payload"]["lure_id"].asUUID();
BOOL godlike = notification["payload"]["godlike"].asBoolean();
switch(option)
{
case 0:
{
// accept
gAgent.teleportViaLure(lure_id, godlike);
}
break;
case 1:
default:
// decline
send_simple_im(from_id,
LLStringUtil::null,
IM_LURE_DECLINED,
lure_id);
break;
}
LLNotificationPtr notification_ptr = LLNotifications::instance().find(notification["id"].asUUID());
if (notification_ptr)
{
LLNotificationFormPtr modified_form(new LLNotificationForm(*notification_ptr->getForm()));
modified_form->setElementEnabled("Teleport", false);
modified_form->setElementEnabled("Cancel", false);
notification_ptr->updateForm(modified_form);
notification_ptr->repost();
}
return false;
}
static LLNotificationFunctorRegistration lure_callback_reg("TeleportOffered", lure_callback);
bool mature_lure_callback(const LLSD& notification, const LLSD& response)
{
S32 option = 0;
if (response.isInteger())
{
option = response.asInteger();
}
else
{
option = LLNotificationsUtil::getSelectedOption(notification, response);
}
LLUUID from_id = notification["payload"]["from_id"].asUUID();
LLUUID lure_id = notification["payload"]["lure_id"].asUUID();
BOOL godlike = notification["payload"]["godlike"].asBoolean();
U8 region_access = static_cast<U8>(notification["payload"]["region_maturity"].asInteger());
switch(option)
{
case 0:
{
// accept
gSavedSettings.setU32("PreferredMaturity", static_cast<U32>(region_access));
gAgent.setMaturityRatingChangeDuringTeleport(region_access);
gAgent.teleportViaLure(lure_id, godlike);
}
break;
case 1:
default:
// decline
send_simple_im(from_id,
LLStringUtil::null,
IM_LURE_DECLINED,
lure_id);
break;
}
return false;
}
static LLNotificationFunctorRegistration mature_lure_callback_reg("TeleportOffered_MaturityExceeded", mature_lure_callback);
bool goto_url_callback(const LLSD& notification, const LLSD& response)
{
std::string url = notification["payload"]["url"].asString();
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if(1 == option)
{
LLWeb::loadURL(url);
}
return false;
}
static LLNotificationFunctorRegistration goto_url_callback_reg("GotoURL", goto_url_callback);
bool inspect_remote_object_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option)
{
LLFloaterReg::showInstance("inspect_remote_object", notification["payload"]);
}
return false;
}
static LLNotificationFunctorRegistration inspect_remote_object_callback_reg("ServerObjectMessage", inspect_remote_object_callback);
class LLPostponedServerObjectNotification: public LLPostponedNotification
{
protected:
/* virtual */
void modifyNotificationParams()
{
LLSD payload = mParams.payload;
mParams.payload = payload;
}
};
static bool parse_lure_bucket(const std::string& bucket,
U64& region_handle,
LLVector3& pos,
LLVector3& look_at,
U8& region_access)
{
// tokenize the bucket
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
tokenizer tokens(bucket, sep);
tokenizer::iterator iter = tokens.begin();
S32 gx,gy,rx,ry,rz,lx,ly,lz;
try
{
gx = boost::lexical_cast<S32>((*(iter)).c_str());
gy = boost::lexical_cast<S32>((*(++iter)).c_str());
rx = boost::lexical_cast<S32>((*(++iter)).c_str());
ry = boost::lexical_cast<S32>((*(++iter)).c_str());
rz = boost::lexical_cast<S32>((*(++iter)).c_str());
lx = boost::lexical_cast<S32>((*(++iter)).c_str());
ly = boost::lexical_cast<S32>((*(++iter)).c_str());
lz = boost::lexical_cast<S32>((*(++iter)).c_str());
}
catch( boost::bad_lexical_cast& )
{
LL_WARNS("parse_lure_bucket")
<< "Couldn't parse lure bucket."
<< LL_ENDL;
return false;
}
// Grab region access
region_access = SIM_ACCESS_MIN;
if (++iter != tokens.end())
{
std::string access_str((*iter).c_str());
LLStringUtil::trim(access_str);
if ( access_str == "A" )
{
region_access = SIM_ACCESS_ADULT;
}
else if ( access_str == "M" )
{
region_access = SIM_ACCESS_MATURE;
}
else if ( access_str == "PG" )
{
region_access = SIM_ACCESS_PG;
}
}
pos.setVec((F32)rx, (F32)ry, (F32)rz);
look_at.setVec((F32)lx, (F32)ly, (F32)lz);
region_handle = to_region_handle(gx, gy);
return true;
}
// Strip out "Resident" for display, but only if the message came from a user
// (rather than a script)
static std::string clean_name_from_im(const std::string& name, EInstantMessage type)
{
switch(type)
{
case IM_NOTHING_SPECIAL:
case IM_MESSAGEBOX:
case IM_GROUP_INVITATION:
case IM_INVENTORY_OFFERED:
case IM_INVENTORY_ACCEPTED:
case IM_INVENTORY_DECLINED:
case IM_GROUP_VOTE:
case IM_GROUP_MESSAGE_DEPRECATED:
//IM_TASK_INVENTORY_OFFERED
//IM_TASK_INVENTORY_ACCEPTED
//IM_TASK_INVENTORY_DECLINED
case IM_NEW_USER_DEFAULT:
case IM_SESSION_INVITE:
case IM_SESSION_P2P_INVITE:
case IM_SESSION_GROUP_START:
case IM_SESSION_CONFERENCE_START:
case IM_SESSION_SEND:
case IM_SESSION_LEAVE:
//IM_FROM_TASK
case IM_DO_NOT_DISTURB_AUTO_RESPONSE:
case IM_CONSOLE_AND_CHAT_HISTORY:
case IM_LURE_USER:
case IM_LURE_ACCEPTED:
case IM_LURE_DECLINED:
case IM_GODLIKE_LURE_USER:
case IM_TELEPORT_REQUEST:
case IM_GROUP_ELECTION_DEPRECATED:
//IM_GOTO_URL
//IM_FROM_TASK_AS_ALERT
case IM_GROUP_NOTICE:
case IM_GROUP_NOTICE_INVENTORY_ACCEPTED:
case IM_GROUP_NOTICE_INVENTORY_DECLINED:
case IM_GROUP_INVITATION_ACCEPT:
case IM_GROUP_INVITATION_DECLINE:
case IM_GROUP_NOTICE_REQUESTED:
case IM_FRIENDSHIP_OFFERED:
case IM_FRIENDSHIP_ACCEPTED:
case IM_FRIENDSHIP_DECLINED_DEPRECATED:
//IM_TYPING_START
//IM_TYPING_STOP
return LLCacheName::cleanFullName(name);
default:
return name;
}
}
static std::string clean_name_from_task_im(const std::string& msg,
BOOL from_group)
{
boost::smatch match;
static const boost::regex returned_exp(
"(.*been returned to your inventory lost and found folder by )(.+)( (from|near).*)");
if (boost::regex_match(msg, match, returned_exp))
{
// match objects are 1-based for groups
std::string final = match[1].str();
std::string name = match[2].str();
// Don't try to clean up group names
if (!from_group)
{
final += LLCacheName::buildUsername(name);
}
final += match[3].str();
return final;
}
return msg;
}
static void notification_display_name_callback(const LLUUID& id,
const LLAvatarName& av_name,
const std::string& name,
LLSD& substitutions,
const LLSD& payload)
{
substitutions["NAME"] = av_name.getDisplayName();
LLNotificationsUtil::add(name, substitutions, payload);
}
class LLPostponedIMSystemTipNotification: public LLPostponedNotification
{
protected:
/* virtual */
void modifyNotificationParams()
{
LLSD payload = mParams.payload;
payload["SESSION_NAME"] = mName;
mParams.payload = payload;
}
};
// Callback for name resolution of a god/estate message
static void god_message_name_cb(const LLAvatarName& av_name, LLChat chat, std::string message)
{
LLSD args;
args["NAME"] = av_name.getCompleteName();
args["MESSAGE"] = message;
LLNotificationsUtil::add("GodMessage", args);
// Treat like a system message and put in chat history.
chat.mText = av_name.getCompleteName() + ": " + message;
LLFloaterIMNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLFloaterIMNearbyChat>("nearby_chat");
if (nearby_chat)
{
nearby_chat->addMessage(chat);
}
}
void process_improved_im(LLMessageSystem *msg, void **user_data)
{
LLUUID from_id;
BOOL from_group;
LLUUID to_id;
U8 offline;
U8 d = 0;
LLUUID session_id;
U32 timestamp;
std::string name;
std::string message;
U32 parent_estate_id = 0;
LLUUID region_id;
LLVector3 position;
U8 binary_bucket[MTUBYTES];
S32 binary_bucket_size;
LLChat chat;
std::string buffer;
// *TODO: Translate - need to fix the full name to first/last (maybe)
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, from_id);
msg->getBOOLFast(_PREHASH_MessageBlock, _PREHASH_FromGroup, from_group);
msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ToAgentID, to_id);
msg->getU8Fast( _PREHASH_MessageBlock, _PREHASH_Offline, offline);
msg->getU8Fast( _PREHASH_MessageBlock, _PREHASH_Dialog, d);
msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, session_id);
msg->getU32Fast( _PREHASH_MessageBlock, _PREHASH_Timestamp, timestamp);
//msg->getData("MessageBlock", "Count", &count);
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, name);
msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, message);
msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_ParentEstateID, parent_estate_id);
msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_RegionID, region_id);
msg->getVector3Fast(_PREHASH_MessageBlock, _PREHASH_Position, position);
msg->getBinaryDataFast( _PREHASH_MessageBlock, _PREHASH_BinaryBucket, binary_bucket, 0, 0, MTUBYTES);
binary_bucket_size = msg->getSizeFast(_PREHASH_MessageBlock, _PREHASH_BinaryBucket);
EInstantMessage dialog = (EInstantMessage)d;
// make sure that we don't have an empty or all-whitespace name
LLStringUtil::trim(name);
if (name.empty())
{
name = LLTrans::getString("Unnamed");
}
// Preserve the unaltered name for use in group notice mute checking.
std::string original_name = name;
// IDEVO convert new-style "Resident" names for display
name = clean_name_from_im(name, dialog);
BOOL is_do_not_disturb = gAgent.isDoNotDisturb();
BOOL is_muted = LLMuteList::getInstance()->isMuted(from_id, name, LLMute::flagTextChat)
// object IMs contain sender object id in session_id (STORM-1209)
|| dialog == IM_FROM_TASK && LLMuteList::getInstance()->isMuted(session_id);
BOOL is_owned_by_me = FALSE;
BOOL is_friend = (LLAvatarTracker::instance().getBuddyInfo(from_id) == NULL) ? false : true;
BOOL accept_im_from_only_friend = gSavedSettings.getBOOL("VoiceCallsFriendsOnly");
BOOL is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT &&
LLMuteList::getInstance()->isLinden(name);
chat.mMuted = is_muted;
chat.mFromID = from_id;
chat.mFromName = name;
chat.mSourceType = (from_id.isNull() || (name == std::string(SYSTEM_FROM))) ? CHAT_SOURCE_SYSTEM : CHAT_SOURCE_AGENT;
LLViewerObject *source = gObjectList.findObject(session_id); //Session ID is probably the wrong thing.
if (source)
{
is_owned_by_me = source->permYouOwner();
}
std::string separator_string(": ");
LLSD args;
LLSD payload;
LLNotification::Params params;
switch(dialog)
{
case IM_CONSOLE_AND_CHAT_HISTORY:
args["MESSAGE"] = message;
payload["from_id"] = from_id;
params.name = "IMSystemMessageTip";
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedIMSystemTipNotification>(params, from_id, false);
break;
case IM_NOTHING_SPECIAL: // p2p IM
// Don't show dialog, just do IM
if (!gAgent.isGodlike()
&& gAgent.getRegion()->isPrelude()
&& to_id.isNull() )
{
// do nothing -- don't distract newbies in
// Prelude with global IMs
}
else if (offline == IM_ONLINE
&& is_do_not_disturb
&& from_id.notNull() //not a system message
&& to_id.notNull()) //not global message
{
// return a standard "do not disturb" message, but only do it to online IM
// (i.e. not other auto responses and not store-and-forward IM)
if (!gIMMgr->hasSession(session_id))
{
// if there is not a panel for this conversation (i.e. it is a new IM conversation
// initiated by the other party) then...
send_do_not_disturb_message(msg, from_id, session_id);
}
// now store incoming IM in chat history
buffer = message;
LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
// add to IM panel, but do not bother the user
gIMMgr->addMessage(
session_id,
from_id,
name,
buffer,
IM_OFFLINE == offline,
LLStringUtil::null,
dialog,
parent_estate_id,
region_id,
position,
true);
}
else if (from_id.isNull())
{
LLSD args;
args["MESSAGE"] = message;
LLNotificationsUtil::add("SystemMessage", args);
}
else if (to_id.isNull())
{
// Message to everyone from GOD, look up the fullname since
// server always slams name to legacy names
LLAvatarNameCache::get(from_id, boost::bind(god_message_name_cb, _2, chat, message));
}
else
{
// standard message, not from system
std::string saved;
if(offline == IM_OFFLINE)
{
LLStringUtil::format_map_t args;
args["[LONG_TIMESTAMP]"] = formatted_time(timestamp);
saved = LLTrans::getString("Saved_message", args);
}
buffer = saved + message;
LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
bool mute_im = is_muted;
if(accept_im_from_only_friend && !is_friend && !is_linden)
{
if (!gIMMgr->isNonFriendSessionNotified(session_id))
{
std::string message = LLTrans::getString("IM_unblock_only_groups_friends");
gIMMgr->addMessage(session_id, from_id, name, message, IM_OFFLINE == offline);
gIMMgr->addNotifiedNonFriendSessionID(session_id);
}
mute_im = true;
}
if (!mute_im)
{
gIMMgr->addMessage(
session_id,
from_id,
name,
buffer,
IM_OFFLINE == offline,
LLStringUtil::null,
dialog,
parent_estate_id,
region_id,
position,
true);
}
else
{
/*
EXT-5099
currently there is no way to store in history only...
using LLNotificationsUtil::add will add message to Nearby Chat
// muted user, so don't start an IM session, just record line in chat
// history. Pretend the chat is from a local agent,
// so it will go into the history but not be shown on screen.
LLSD args;
args["MESSAGE"] = buffer;
LLNotificationsUtil::add("SystemMessageTip", args);
*/
}
}
break;
case IM_TYPING_START:
{
LLPointer<LLIMInfo> im_info = new LLIMInfo(gMessageSystem);
gIMMgr->processIMTypingStart(im_info);
}
break;
case IM_TYPING_STOP:
{
LLPointer<LLIMInfo> im_info = new LLIMInfo(gMessageSystem);
gIMMgr->processIMTypingStop(im_info);
}
break;
case IM_MESSAGEBOX:
{
// This is a block, modeless dialog.
//*TODO: Translate
args["MESSAGE"] = message;
LLNotificationsUtil::add("SystemMessageTip", args);
}
break;
case IM_GROUP_NOTICE:
case IM_GROUP_NOTICE_REQUESTED:
{
LL_INFOS("Messaging") << "Received IM_GROUP_NOTICE message." << LL_ENDL;
// Read the binary bucket for more information.
struct notice_bucket_header_t
{
U8 has_inventory;
U8 asset_type;
LLUUID group_id;
};
struct notice_bucket_full_t
{
struct notice_bucket_header_t header;
U8 item_name[DB_INV_ITEM_NAME_BUF_SIZE];
}* notice_bin_bucket;
// Make sure the binary bucket is big enough to hold the header
// and a null terminated item name.
if ( (binary_bucket_size < (S32)((sizeof(notice_bucket_header_t) + sizeof(U8))))
|| (binary_bucket[binary_bucket_size - 1] != '\0') )
{
LL_WARNS("Messaging") << "Malformed group notice binary bucket" << LL_ENDL;
break;
}
// The group notice packet does not have an AgentID. Obtain one from the name cache.
// If last name is "Resident" strip it out so the cache name lookup works.
U32 index = original_name.find(" Resident");
if (index != std::string::npos)
{
original_name = original_name.substr(0, index);
}
std::string legacy_name = gCacheName->buildLegacyName(original_name);
LLUUID agent_id;
gCacheName->getUUID(legacy_name, agent_id);
if (agent_id.isNull())
{
LL_WARNS("Messaging") << "buildLegacyName returned null while processing " << original_name << LL_ENDL;
}
else if (LLMuteList::getInstance()->isMuted(agent_id))
{
break;
}
notice_bin_bucket = (struct notice_bucket_full_t*) &binary_bucket[0];
U8 has_inventory = notice_bin_bucket->header.has_inventory;
U8 asset_type = notice_bin_bucket->header.asset_type;
LLUUID group_id = notice_bin_bucket->header.group_id;
std::string item_name = ll_safe_string((const char*) notice_bin_bucket->item_name);
// If there is inventory, give the user the inventory offer.
LLOfferInfo* info = NULL;
if (has_inventory)
{
info = new LLOfferInfo();
info->mIM = IM_GROUP_NOTICE;
info->mFromID = from_id;
info->mFromGroup = from_group;
info->mTransactionID = session_id;
info->mType = (LLAssetType::EType) asset_type;
info->mFolderID = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(info->mType));
std::string from_name;
from_name += "A group member named ";
from_name += name;
info->mFromName = from_name;
info->mDesc = item_name;
info->mHost = msg->getSender();
}
std::string str(message);
// Tokenize the string.
// TODO: Support escaped tokens ("||" -> "|")
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("|","",boost::keep_empty_tokens);
tokenizer tokens(str, sep);
tokenizer::iterator iter = tokens.begin();
std::string subj(*iter++);
std::string mes(*iter++);
// Send the notification down the new path.
// For requested notices, we don't want to send the popups.
if (dialog != IM_GROUP_NOTICE_REQUESTED)
{
payload["subject"] = subj;
payload["message"] = mes;
payload["sender_name"] = name;
payload["group_id"] = group_id;
payload["inventory_name"] = item_name;
if(info && info->asLLSD())
{
payload["inventory_offer"] = info->asLLSD();
}
LLSD args;
args["SUBJECT"] = subj;
args["MESSAGE"] = mes;
LLNotifications::instance().add(LLNotification::Params("GroupNotice").substitutions(args).payload(payload).time_stamp(timestamp));
}
// Also send down the old path for now.
if (IM_GROUP_NOTICE_REQUESTED == dialog)
{
LLPanelGroup::showNotice(subj,mes,group_id,has_inventory,item_name,info);
}
else
{
delete info;
}
}
break;
case IM_GROUP_INVITATION:
{
if (is_do_not_disturb || is_muted)
{
send_do_not_disturb_message(msg, from_id);
}
if (!is_muted)
{
LL_INFOS("Messaging") << "Received IM_GROUP_INVITATION message." << LL_ENDL;
// Read the binary bucket for more information.
struct invite_bucket_t
{
S32 membership_fee;
LLUUID role_id;
}* invite_bucket;
// Make sure the binary bucket is the correct size.
if (binary_bucket_size != sizeof(invite_bucket_t))
{
LL_WARNS("Messaging") << "Malformed group invite binary bucket" << LL_ENDL;
break;
}
invite_bucket = (struct invite_bucket_t*) &binary_bucket[0];
S32 membership_fee = ntohl(invite_bucket->membership_fee);
LLSD payload;
payload["transaction_id"] = session_id;
payload["group_id"] = from_id;
payload["name"] = name;
payload["message"] = message;
payload["fee"] = membership_fee;
LLSD args;
args["MESSAGE"] = message;
// we shouldn't pass callback functor since it is registered in LLFunctorRegistration
LLNotificationsUtil::add("JoinGroup", args, payload);
}
}
break;
case IM_INVENTORY_OFFERED:
case IM_TASK_INVENTORY_OFFERED:
// Someone has offered us some inventory.
{
LLOfferInfo* info = new LLOfferInfo;
if (IM_INVENTORY_OFFERED == dialog)
{
struct offer_agent_bucket_t
{
S8 asset_type;
LLUUID object_id;
}* bucketp;
if (sizeof(offer_agent_bucket_t) != binary_bucket_size)
{
LL_WARNS("Messaging") << "Malformed inventory offer from agent" << LL_ENDL;
delete info;
break;
}
bucketp = (struct offer_agent_bucket_t*) &binary_bucket[0];
info->mType = (LLAssetType::EType) bucketp->asset_type;
info->mObjectID = bucketp->object_id;
info->mFromObject = FALSE;
}
else // IM_TASK_INVENTORY_OFFERED
{
if (sizeof(S8) != binary_bucket_size)
{
LL_WARNS("Messaging") << "Malformed inventory offer from object" << LL_ENDL;
delete info;
break;
}
info->mType = (LLAssetType::EType) binary_bucket[0];
info->mObjectID = LLUUID::null;
info->mFromObject = TRUE;
}
info->mIM = dialog;
info->mFromID = from_id;
info->mFromGroup = from_group;
info->mTransactionID = session_id;
info->mFolderID = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(info->mType));
info->mFromName = name;
info->mDesc = message;
info->mHost = msg->getSender();
//if (((is_do_not_disturb && !is_owned_by_me) || is_muted))
if (is_muted)
{
// Prefetch the offered item so that it can be discarded by the appropriate observer. (EXT-4331)
LLInventoryFetchItemsObserver* fetch_item = new LLInventoryFetchItemsObserver(info->mObjectID);
fetch_item->startFetch();
delete fetch_item;
// Same as closing window
info->forceResponse(IOR_DECLINE);
}
// old logic: busy mode must not affect interaction with objects (STORM-565)
// new logic: inventory offers from in-world objects should be auto-declined (CHUI-519)
else if (is_do_not_disturb && dialog == IM_TASK_INVENTORY_OFFERED)
{
// Until throttling is implemented, do not disturb mode should reject inventory instead of silently
// accepting it. SEE SL-39554
info->forceResponse(IOR_DECLINE);
}
else
{
inventory_offer_handler(info);
}
}
break;
case IM_INVENTORY_ACCEPTED:
{
args["NAME"] = LLSLURL("agent", from_id, "completename").getSLURLString();;
LLSD payload;
payload["from_id"] = from_id;
// Passing the "SESSION_NAME" to use it for IM notification logging
// in LLTipHandler::processNotification(). See STORM-941.
payload["SESSION_NAME"] = name;
LLNotificationsUtil::add("InventoryAccepted", args, payload);
break;
}
case IM_INVENTORY_DECLINED:
{
args["NAME"] = LLSLURL("agent", from_id, "completename").getSLURLString();;
LLSD payload;
payload["from_id"] = from_id;
LLNotificationsUtil::add("InventoryDeclined", args, payload);
break;
}
// TODO: _DEPRECATED suffix as part of vote removal - DEV-24856
case IM_GROUP_VOTE:
{
LL_WARNS("Messaging") << "Received IM: IM_GROUP_VOTE_DEPRECATED" << LL_ENDL;
}
break;
case IM_GROUP_ELECTION_DEPRECATED:
{
LL_WARNS("Messaging") << "Received IM: IM_GROUP_ELECTION_DEPRECATED" << LL_ENDL;
}
break;
case IM_FROM_TASK:
{
if (is_do_not_disturb && !is_owned_by_me)
{
return;
}
// Build a link to open the object IM info window.
std::string location = ll_safe_string((char*)binary_bucket, binary_bucket_size-1);
if (session_id.notNull())
{
chat.mFromID = session_id;
}
else
{
// This message originated on a region without the updated code for task id and slurl information.
// We just need a unique ID for this object that isn't the owner ID.
// If it is the owner ID it will overwrite the style that contains the link to that owner's profile.
// This isn't ideal - it will make 1 style for all objects owned by the the same person/group.
// This works because the only thing we can really do in this case is show the owner name and link to their profile.
chat.mFromID = from_id ^ gAgent.getSessionID();
}
chat.mSourceType = CHAT_SOURCE_OBJECT;
// To conclude that the source type of message is CHAT_SOURCE_SYSTEM it's not
// enough to check only from name (i.e. fromName = "Second Life"). For example
// source type of messages from objects called "Second Life" should not be CHAT_SOURCE_SYSTEM.
bool chat_from_system = (SYSTEM_FROM == name) && region_id.isNull() && position.isNull();
if(chat_from_system)
{
// System's UUID is NULL (fixes EXT-4766)
chat.mFromID = LLUUID::null;
chat.mSourceType = CHAT_SOURCE_SYSTEM;
}
// IDEVO Some messages have embedded resident names
message = clean_name_from_task_im(message, from_group);
LLSD query_string;
query_string["owner"] = from_id;
query_string["slurl"] = location;
query_string["name"] = name;
if (from_group)
{
query_string["groupowned"] = "true";
}
chat.mURL = LLSLURL("objectim", session_id, "").getSLURLString();
chat.mText = message;
// Note: lie to Nearby Chat, pretending that this is NOT an IM, because
// IMs from obejcts don't open IM sessions.
LLFloaterIMNearbyChat* nearby_chat = LLFloaterReg::getTypedInstance<LLFloaterIMNearbyChat>("nearby_chat");
if(!chat_from_system && nearby_chat)
{
chat.mOwnerID = from_id;
LLSD args;
args["slurl"] = location;
// Look for IRC-style emotes here so object name formatting is correct
std::string prefix = message.substr(0, 4);
if (prefix == "/me " || prefix == "/me'")
{
chat.mChatStyle = CHAT_STYLE_IRC;
}
LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args);
}
//Object IMs send with from name: 'Second Life' need to be displayed also in notification toasts (EXT-1590)
if (!chat_from_system) break;
LLSD substitutions;
substitutions["NAME"] = name;
substitutions["MSG"] = message;
LLSD payload;
payload["object_id"] = session_id;
payload["owner_id"] = from_id;
payload["from_id"] = from_id;
payload["slurl"] = location;
payload["name"] = name;
std::string session_name;
if (from_group)
{
payload["group_owned"] = "true";
}
LLNotification::Params params("ServerObjectMessage");
params.substitutions = substitutions;
params.payload = payload;
LLPostponedNotification::add<LLPostponedServerObjectNotification>(params, from_id, from_group);
}
break;
case IM_SESSION_SEND: // ad-hoc or group IMs
// Only show messages if we have a session open (which
// should happen after you get an "invitation"
if ( !gIMMgr->hasSession(session_id) )
{
return;
}
else if (offline == IM_ONLINE && is_do_not_disturb)
{
// return a standard "do not disturb" message, but only do it to online IM
// (i.e. not other auto responses and not store-and-forward IM)
if (!gIMMgr->hasSession(session_id))
{
// if there is not a panel for this conversation (i.e. it is a new IM conversation
// initiated by the other party) then...
send_do_not_disturb_message(msg, from_id, session_id);
}
// now store incoming IM in chat history
buffer = message;
LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
// add to IM panel, but do not bother the user
gIMMgr->addMessage(
session_id,
from_id,
name,
buffer,
IM_OFFLINE == offline,
ll_safe_string((char*)binary_bucket),
IM_SESSION_INVITE,
parent_estate_id,
region_id,
position,
true);
}
else
{
// standard message, not from system
std::string saved;
if(offline == IM_OFFLINE)
{
saved = llformat("(Saved %s) ", formatted_time(timestamp).c_str());
}
buffer = saved + message;
LL_INFOS("Messaging") << "process_improved_im: session_id( " << session_id << " ), from_id( " << from_id << " )" << LL_ENDL;
gIMMgr->addMessage(
session_id,
from_id,
name,
buffer,
IM_OFFLINE == offline,
ll_safe_string((char*)binary_bucket),
IM_SESSION_INVITE,
parent_estate_id,
region_id,
position,
true);
}
break;
case IM_FROM_TASK_AS_ALERT:
if (is_do_not_disturb && !is_owned_by_me)
{
return;
}
{
// Construct a viewer alert for this message.
args["NAME"] = name;
args["MESSAGE"] = message;
LLNotificationsUtil::add("ObjectMessage", args);
}
break;
case IM_DO_NOT_DISTURB_AUTO_RESPONSE:
if (is_muted)
{
LL_DEBUGS("Messaging") << "Ignoring do-not-disturb response from " << from_id << LL_ENDL;
return;
}
else
{
gIMMgr->addMessage(session_id, from_id, name, message);
}
break;
case IM_LURE_USER:
case IM_TELEPORT_REQUEST:
{
if (is_muted)
{
return;
}
else if (is_do_not_disturb)
{
send_do_not_disturb_message(msg, from_id);
}
else
{
LLVector3 pos, look_at;
U64 region_handle(0);
U8 region_access(SIM_ACCESS_MIN);
std::string region_info = ll_safe_string((char*)binary_bucket, binary_bucket_size);
std::string region_access_str = LLStringUtil::null;
std::string region_access_icn = LLStringUtil::null;
std::string region_access_lc = LLStringUtil::null;
bool canUserAccessDstRegion = true;
bool doesUserRequireMaturityIncrease = false;
// Do not parse the (empty) lure bucket for TELEPORT_REQUEST
if (IM_TELEPORT_REQUEST != dialog && parse_lure_bucket(region_info, region_handle, pos, look_at, region_access))
{
region_access_str = LLViewerRegion::accessToString(region_access);
region_access_icn = LLViewerRegion::getAccessIcon(region_access);
region_access_lc = region_access_str;
LLStringUtil::toLower(region_access_lc);
if (!gAgent.isGodlike())
{
switch (region_access)
{
case SIM_ACCESS_MIN :
case SIM_ACCESS_PG :
break;
case SIM_ACCESS_MATURE :
if (gAgent.isTeen())
{
canUserAccessDstRegion = false;
}
else if (gAgent.prefersPG())
{
doesUserRequireMaturityIncrease = true;
}
break;
case SIM_ACCESS_ADULT :
if (!gAgent.isAdult())
{
canUserAccessDstRegion = false;
}
else if (!gAgent.prefersAdult())
{
doesUserRequireMaturityIncrease = true;
}
break;
default :
llassert(0);
break;
}
}
}
LLSD args;
// *TODO: Translate -> [FIRST] [LAST] (maybe)
args["NAME_SLURL"] = LLSLURL("agent", from_id, "about").getSLURLString();
args["MESSAGE"] = message;
args["MATURITY_STR"] = region_access_str;
args["MATURITY_ICON"] = region_access_icn;
args["REGION_CONTENT_MATURITY"] = region_access_lc;
LLSD payload;
payload["from_id"] = from_id;
payload["lure_id"] = session_id;
payload["godlike"] = FALSE;
payload["region_maturity"] = region_access;
if (!canUserAccessDstRegion)
{
LLNotification::Params params("TeleportOffered_MaturityBlocked");
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false);
send_simple_im(from_id, LLTrans::getString("TeleportMaturityExceeded"), IM_NOTHING_SPECIAL, session_id);
send_simple_im(from_id, LLStringUtil::null, IM_LURE_DECLINED, session_id);
}
else if (doesUserRequireMaturityIncrease)
{
LLNotification::Params params("TeleportOffered_MaturityExceeded");
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false);
}
else
{
LLNotification::Params params;
if (IM_LURE_USER == dialog)
{
params.name = "TeleportOffered";
params.functor.name = "TeleportOffered";
}
else if (IM_TELEPORT_REQUEST == dialog)
{
params.name = "TeleportRequest";
params.functor.name = "TeleportRequest";
}
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false);
}
}
}
break;
case IM_GODLIKE_LURE_USER:
{
LLVector3 pos, look_at;
U64 region_handle(0);
U8 region_access(SIM_ACCESS_MIN);
std::string region_info = ll_safe_string((char*)binary_bucket, binary_bucket_size);
std::string region_access_str = LLStringUtil::null;
std::string region_access_icn = LLStringUtil::null;
std::string region_access_lc = LLStringUtil::null;
bool canUserAccessDstRegion = true;
bool doesUserRequireMaturityIncrease = false;
if (parse_lure_bucket(region_info, region_handle, pos, look_at, region_access))
{
region_access_str = LLViewerRegion::accessToString(region_access);
region_access_icn = LLViewerRegion::getAccessIcon(region_access);
region_access_lc = region_access_str;
LLStringUtil::toLower(region_access_lc);
if (!gAgent.isGodlike())
{
switch (region_access)
{
case SIM_ACCESS_MIN :
case SIM_ACCESS_PG :
break;
case SIM_ACCESS_MATURE :
if (gAgent.isTeen())
{
canUserAccessDstRegion = false;
}
else if (gAgent.prefersPG())
{
doesUserRequireMaturityIncrease = true;
}
break;
case SIM_ACCESS_ADULT :
if (!gAgent.isAdult())
{
canUserAccessDstRegion = false;
}
else if (!gAgent.prefersAdult())
{
doesUserRequireMaturityIncrease = true;
}
break;
default :
llassert(0);
break;
}
}
}
LLSD args;
// *TODO: Translate -> [FIRST] [LAST] (maybe)
args["NAME_SLURL"] = LLSLURL("agent", from_id, "about").getSLURLString();
args["MESSAGE"] = message;
args["MATURITY_STR"] = region_access_str;
args["MATURITY_ICON"] = region_access_icn;
args["REGION_CONTENT_MATURITY"] = region_access_lc;
LLSD payload;
payload["from_id"] = from_id;
payload["lure_id"] = session_id;
payload["godlike"] = TRUE;
payload["region_maturity"] = region_access;
if (!canUserAccessDstRegion)
{
LLNotification::Params params("TeleportOffered_MaturityBlocked");
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false);
send_simple_im(from_id, LLTrans::getString("TeleportMaturityExceeded"), IM_NOTHING_SPECIAL, session_id);
send_simple_im(from_id, LLStringUtil::null, IM_LURE_DECLINED, session_id);
}
else if (doesUserRequireMaturityIncrease)
{
LLNotification::Params params("TeleportOffered_MaturityExceeded");
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false);
}
else
{
// do not show a message box, because you're about to be
// teleported.
LLNotifications::instance().forceResponse(LLNotification::Params("TeleportOffered").payload(payload), 0);
}
}
break;
case IM_GOTO_URL:
{
LLSD args;
// n.b. this is for URLs sent by the system, not for
// URLs sent by scripts (i.e. llLoadURL)
if (binary_bucket_size <= 0)
{
LL_WARNS("Messaging") << "bad binary_bucket_size: "
<< binary_bucket_size
<< " - aborting function." << LL_ENDL;
return;
}
std::string url;
url.assign((char*)binary_bucket, binary_bucket_size-1);
args["MESSAGE"] = message;
args["URL"] = url;
LLSD payload;
payload["url"] = url;
LLNotificationsUtil::add("GotoURL", args, payload );
}
break;
case IM_FRIENDSHIP_OFFERED:
{
LLSD payload;
payload["from_id"] = from_id;
payload["session_id"] = session_id;;
payload["online"] = (offline == IM_ONLINE);
payload["sender"] = msg->getSender().getIPandPort();
bool add_notification = true;
for (LLToastNotifyPanel::instance_iter ti(LLToastNotifyPanel::beginInstances())
, tend(LLToastNotifyPanel::endInstances()); ti != tend; ++ti)
{
LLToastNotifyPanel& panel = *ti;
const std::string& notification_name = panel.getNotificationName();
if (notification_name == "OfferFriendship" && panel.isControlPanelEnabled())
{
add_notification = false;
break;
}
}
if (is_muted && add_notification)
{
LLNotifications::instance().forceResponse(LLNotification::Params("OfferFriendship").payload(payload), 1);
}
else
{
if (is_do_not_disturb)
{
send_do_not_disturb_message(msg, from_id);
}
args["NAME_SLURL"] = LLSLURL("agent", from_id, "about").getSLURLString();
if (add_notification)
{
if(message.empty())
{
//support for frienship offers from clients before July 2008
LLNotificationsUtil::add("OfferFriendshipNoMessage", args, payload);
}
else
{
args["[MESSAGE]"] = message;
LLNotification::Params params("OfferFriendship");
params.substitutions = args;
params.payload = payload;
LLPostponedNotification::add<LLPostponedOfferNotification>( params, from_id, false);
}
}
}
}
break;
case IM_FRIENDSHIP_ACCEPTED:
{
// In the case of an offline IM, the formFriendship() may be extraneous
// as the database should already include the relationship. But it
// doesn't hurt for dupes.
LLAvatarTracker::formFriendship(from_id);
std::vector<std::string> strings;
strings.push_back(from_id.asString());
send_generic_message("requestonlinenotification", strings);
args["NAME"] = name;
LLSD payload;
payload["from_id"] = from_id;
LLAvatarNameCache::get(from_id, boost::bind(¬ification_display_name_callback,_1,_2,"FriendshipAccepted",args,payload));
}
break;
case IM_FRIENDSHIP_DECLINED_DEPRECATED:
default:
LL_WARNS("Messaging") << "Instant message calling for unknown dialog "
<< (S32)dialog << LL_ENDL;
break;
}
LLWindow* viewer_window = gViewerWindow->getWindow();
if (viewer_window && viewer_window->getMinimized())
{
viewer_window->flashIcon(5.f);
}
}
void send_do_not_disturb_message (LLMessageSystem* msg, const LLUUID& from_id, const LLUUID& session_id)
{
if (gAgent.isDoNotDisturb())
{
std::string my_name;
LLAgentUI::buildFullname(my_name);
std::string response = gSavedPerAccountSettings.getString("DoNotDisturbModeResponse");
pack_instant_message(
msg,
gAgent.getID(),
FALSE,
gAgent.getSessionID(),
from_id,
my_name,
response,
IM_ONLINE,
IM_DO_NOT_DISTURB_AUTO_RESPONSE,
session_id);
gAgent.sendReliableMessage();
}
}
bool callingcard_offer_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLUUID fid;
LLUUID from_id;
LLMessageSystem* msg = gMessageSystem;
switch(option)
{
case 0:
// accept
msg->newMessageFast(_PREHASH_AcceptCallingCard);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_TransactionBlock);
msg->addUUIDFast(_PREHASH_TransactionID, notification["payload"]["transaction_id"].asUUID());
fid = gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD);
msg->nextBlockFast(_PREHASH_FolderData);
msg->addUUIDFast(_PREHASH_FolderID, fid);
msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
break;
case 1:
// decline
msg->newMessageFast(_PREHASH_DeclineCallingCard);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_TransactionBlock);
msg->addUUIDFast(_PREHASH_TransactionID, notification["payload"]["transaction_id"].asUUID());
msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
send_do_not_disturb_message(msg, notification["payload"]["source_id"].asUUID());
break;
default:
// close button probably, possibly timed out
break;
}
return false;
}
static LLNotificationFunctorRegistration callingcard_offer_cb_reg("OfferCallingCard", callingcard_offer_callback);
void process_offer_callingcard(LLMessageSystem* msg, void**)
{
// someone has offered to form a friendship
LL_DEBUGS("Messaging") << "callingcard offer" << LL_ENDL;
LLUUID source_id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, source_id);
LLUUID tid;
msg->getUUIDFast(_PREHASH_AgentBlock, _PREHASH_TransactionID, tid);
LLSD payload;
payload["transaction_id"] = tid;
payload["source_id"] = source_id;
payload["sender"] = msg->getSender().getIPandPort();
LLViewerObject* source = gObjectList.findObject(source_id);
LLSD args;
std::string source_name;
if(source && source->isAvatar())
{
LLNameValue* nvfirst = source->getNVPair("FirstName");
LLNameValue* nvlast = source->getNVPair("LastName");
if (nvfirst && nvlast)
{
source_name = LLCacheName::buildFullName(
nvfirst->getString(), nvlast->getString());
}
}
if(!source_name.empty())
{
if (gAgent.isDoNotDisturb()
|| LLMuteList::getInstance()->isMuted(source_id, source_name, LLMute::flagTextChat))
{
// automatically decline offer
LLNotifications::instance().forceResponse(LLNotification::Params("OfferCallingCard").payload(payload), 1);
}
else
{
args["NAME"] = source_name;
LLNotificationsUtil::add("OfferCallingCard", args, payload);
}
}
else
{
LL_WARNS("Messaging") << "Calling card offer from an unknown source." << LL_ENDL;
}
}
void process_accept_callingcard(LLMessageSystem* msg, void**)
{
LLNotificationsUtil::add("CallingCardAccepted");
}
void process_decline_callingcard(LLMessageSystem* msg, void**)
{
LLNotificationsUtil::add("CallingCardDeclined");
}
class ChatTranslationReceiver : public LLTranslate::TranslationReceiver
{
public :
ChatTranslationReceiver(const std::string &from_lang, const std::string &to_lang, const std::string &mesg,
const LLChat &chat, const LLSD &toast_args)
: LLTranslate::TranslationReceiver(from_lang, to_lang),
m_chat(chat),
m_toastArgs(toast_args),
m_origMesg(mesg)
{
}
static ChatTranslationReceiver* build(const std::string &from_lang, const std::string &to_lang, const std::string &mesg, const LLChat &chat, const LLSD &toast_args)
{
return new ChatTranslationReceiver(from_lang, to_lang, mesg, chat, toast_args);
}
protected:
void handleResponse(const std::string &translation, const std::string &detected_language)
{
// filter out non-interesting responeses
if ( !translation.empty()
&& (mToLang != detected_language)
&& (LLStringUtil::compareInsensitive(translation, m_origMesg) != 0) )
{
m_chat.mText += " (" + translation + ")";
}
LLNotificationsUI::LLNotificationManager::instance().onChat(m_chat, m_toastArgs);
}
void handleFailure(int status, const std::string& err_msg)
{
llwarns << "Translation failed for mesg " << m_origMesg << " toLang " << mToLang << " fromLang " << mFromLang << llendl;
std::string msg = LLTrans::getString("TranslationFailed", LLSD().with("[REASON]", err_msg));
LLStringUtil::replaceString(msg, "\n", " "); // we want one-line error messages
m_chat.mText += " (" + msg + ")";
LLNotificationsUI::LLNotificationManager::instance().onChat(m_chat, m_toastArgs);
}
private:
LLChat m_chat;
std::string m_origMesg;
LLSD m_toastArgs;
};
void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
{
LLChat chat;
std::string mesg;
std::string from_name;
U8 source_temp;
U8 type_temp;
U8 audible_temp;
LLColor4 color(1.0f, 1.0f, 1.0f, 1.0f);
LLUUID from_id;
LLUUID owner_id;
LLViewerObject* chatter;
msg->getString("ChatData", "FromName", from_name);
msg->getUUID("ChatData", "SourceID", from_id);
chat.mFromID = from_id;
// Object owner for objects
msg->getUUID("ChatData", "OwnerID", owner_id);
msg->getU8Fast(_PREHASH_ChatData, _PREHASH_SourceType, source_temp);
chat.mSourceType = (EChatSourceType)source_temp;
msg->getU8("ChatData", "ChatType", type_temp);
chat.mChatType = (EChatType)type_temp;
msg->getU8Fast(_PREHASH_ChatData, _PREHASH_Audible, audible_temp);
chat.mAudible = (EChatAudible)audible_temp;
chat.mTime = LLFrameTimer::getElapsedSeconds();
// IDEVO Correct for new-style "Resident" names
if (chat.mSourceType == CHAT_SOURCE_AGENT)
{
// I don't know if it's OK to change this here, if
// anything downstream does lookups by name, for instance
LLAvatarName av_name;
if (LLAvatarNameCache::get(from_id, &av_name))
{
chat.mFromName = av_name.getDisplayName();
}
else
{
chat.mFromName = LLCacheName::cleanFullName(from_name);
}
}
else
{
chat.mFromName = from_name;
}
BOOL is_do_not_disturb = gAgent.isDoNotDisturb();
BOOL is_muted = FALSE;
BOOL is_linden = FALSE;
is_muted = LLMuteList::getInstance()->isMuted(
from_id,
from_name,
LLMute::flagTextChat)
|| LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagTextChat);
is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT &&
LLMuteList::getInstance()->isLinden(from_name);
BOOL is_audible = (CHAT_AUDIBLE_FULLY == chat.mAudible);
chatter = gObjectList.findObject(from_id);
if (chatter)
{
chat.mPosAgent = chatter->getPositionAgent();
// Make swirly things only for talking objects. (not script debug messages, though)
if (chat.mSourceType == CHAT_SOURCE_OBJECT
&& chat.mChatType != CHAT_TYPE_DEBUG_MSG
&& gSavedSettings.getBOOL("EffectScriptChatParticles") )
{
LLPointer<LLViewerPartSourceChat> psc = new LLViewerPartSourceChat(chatter->getPositionAgent());
psc->setSourceObject(chatter);
psc->setColor(color);
//We set the particles to be owned by the object's owner,
//just in case they should be muted by the mute list
psc->setOwnerUUID(owner_id);
LLViewerPartSim::getInstance()->addPartSource(psc);
}
// record last audible utterance
if (is_audible
&& (is_linden || (!is_muted && !is_do_not_disturb)))
{
if (chat.mChatType != CHAT_TYPE_START
&& chat.mChatType != CHAT_TYPE_STOP)
{
gAgent.heardChat(chat.mFromID);
}
}
}
if (is_audible)
{
//BOOL visible_in_chat_bubble = FALSE;
color.setVec(1.f,1.f,1.f,1.f);
msg->getStringFast(_PREHASH_ChatData, _PREHASH_Message, mesg);
BOOL ircstyle = FALSE;
// Look for IRC-style emotes here so chatbubbles work
std::string prefix = mesg.substr(0, 4);
if (prefix == "/me " || prefix == "/me'")
{
ircstyle = TRUE;
}
chat.mText = mesg;
// Look for the start of typing so we can put "..." in the bubbles.
if (CHAT_TYPE_START == chat.mChatType)
{
LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, TRUE);
// Might not have the avatar constructed yet, eg on login.
if (chatter && chatter->isAvatar())
{
((LLVOAvatar*)chatter)->startTyping();
}
return;
}
else if (CHAT_TYPE_STOP == chat.mChatType)
{
LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, FALSE);
// Might not have the avatar constructed yet, eg on login.
if (chatter && chatter->isAvatar())
{
((LLVOAvatar*)chatter)->stopTyping();
}
return;
}
// Look for IRC-style emotes
if (ircstyle)
{
// set CHAT_STYLE_IRC to avoid adding Avatar Name as author of message. See EXT-656
chat.mChatStyle = CHAT_STYLE_IRC;
// Do nothing, ircstyle is fixed above for chat bubbles
}
else
{
chat.mText = "";
switch(chat.mChatType)
{
case CHAT_TYPE_WHISPER:
chat.mText = LLTrans::getString("whisper") + " ";
break;
case CHAT_TYPE_DEBUG_MSG:
case CHAT_TYPE_OWNER:
case CHAT_TYPE_NORMAL:
case CHAT_TYPE_DIRECT:
break;
case CHAT_TYPE_SHOUT:
chat.mText = LLTrans::getString("shout") + " ";
break;
case CHAT_TYPE_START:
case CHAT_TYPE_STOP:
LL_WARNS("Messaging") << "Got chat type start/stop in main chat processing." << LL_ENDL;
break;
default:
LL_WARNS("Messaging") << "Unknown type " << chat.mChatType << " in chat!" << LL_ENDL;
break;
}
chat.mText += mesg;
}
// We have a real utterance now, so can stop showing "..." and proceed.
if (chatter && chatter->isAvatar())
{
LLLocalSpeakerMgr::getInstance()->setSpeakerTyping(from_id, FALSE);
((LLVOAvatar*)chatter)->stopTyping();
if (!is_muted && !is_do_not_disturb)
{
//visible_in_chat_bubble = gSavedSettings.getBOOL("UseChatBubbles");
std::string formated_msg = "";
LLViewerChat::formatChatMsg(chat, formated_msg);
LLChat chat_bubble = chat;
chat_bubble.mText = formated_msg;
((LLVOAvatar*)chatter)->addChat(chat_bubble);
}
}
if (chatter)
{
chat.mPosAgent = chatter->getPositionAgent();
}
// truth table:
// LINDEN BUSY MUTED OWNED_BY_YOU TASK DISPLAY STORE IN HISTORY
// F F F F * Yes Yes
// F F F T * Yes Yes
// F F T F * No No
// F F T T * No No
// F T F F * No Yes
// F T F T * Yes Yes
// F T T F * No No
// F T T T * No No
// T * * * F Yes Yes
chat.mMuted = is_muted && !is_linden;
// pass owner_id to chat so that we can display the remote
// object inspect for an object that is chatting with you
LLSD args;
chat.mOwnerID = owner_id;
if (gSavedSettings.getBOOL("TranslateChat") && chat.mSourceType != CHAT_SOURCE_SYSTEM)
{
if (chat.mChatStyle == CHAT_STYLE_IRC)
{
mesg = mesg.substr(4, std::string::npos);
}
const std::string from_lang = ""; // leave empty to trigger autodetect
const std::string to_lang = LLTranslate::getTranslateLanguage();
LLTranslate::TranslationReceiverPtr result = ChatTranslationReceiver::build(from_lang, to_lang, mesg, chat, args);
LLTranslate::translateMessage(result, from_lang, to_lang, mesg);
}
else
{
LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args);
}
LLSD msg_notify = LLSD(LLSD::emptyMap());
msg_notify["session_id"] = LLUUID();
msg_notify["from_id"] = chat.mFromID;
msg_notify["source_type"] = chat.mSourceType;
on_new_message(msg_notify);
}
}
// Simulator we're on is informing the viewer that the agent
// is starting to teleport (perhaps to another sim, perhaps to the
// same sim). If we initiated the teleport process by sending some kind
// of TeleportRequest, then this info is redundant, but if the sim
// initiated the teleport (via a script call, being killed, etc.)
// then this info is news to us.
void process_teleport_start(LLMessageSystem *msg, void**)
{
// on teleport, don't tell them about destination guide anymore
LLFirstUse::notUsingDestinationGuide(false);
U32 teleport_flags = 0x0;
msg->getU32("Info", "TeleportFlags", teleport_flags);
LL_DEBUGS("Messaging") << "Got TeleportStart with TeleportFlags=" << teleport_flags << ". gTeleportDisplay: " << gTeleportDisplay << ", gAgent.mTeleportState: " << gAgent.getTeleportState() << LL_ENDL;
// *NOTE: The server sends two StartTeleport packets when you are teleporting to a LM
LLViewerMessage::getInstance()->mTeleportStartedSignal();
if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL)
{
gViewerWindow->setProgressCancelButtonVisible(FALSE);
}
else
{
gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Cancel"));
}
// Freeze the UI and show progress bar
// Note: could add data here to differentiate between normal teleport and death.
if( gAgent.getTeleportState() == LLAgent::TELEPORT_NONE )
{
gTeleportDisplay = TRUE;
gAgent.setTeleportState( LLAgent::TELEPORT_START );
make_ui_sound("UISndTeleportOut");
LL_INFOS("Messaging") << "Teleport initiated by remote TeleportStart message with TeleportFlags: " << teleport_flags << LL_ENDL;
// Don't call LLFirstUse::useTeleport here because this could be
// due to being killed, which would send you home, not to a Telehub
}
}
boost::signals2::connection LLViewerMessage::setTeleportStartedCallback(teleport_started_callback_t cb)
{
return mTeleportStartedSignal.connect(cb);
}
void process_teleport_progress(LLMessageSystem* msg, void**)
{
LLUUID agent_id;
msg->getUUID("AgentData", "AgentID", agent_id);
if((gAgent.getID() != agent_id)
|| (gAgent.getTeleportState() == LLAgent::TELEPORT_NONE))
{
LL_WARNS("Messaging") << "Unexpected teleport progress message." << LL_ENDL;
return;
}
U32 teleport_flags = 0x0;
msg->getU32("Info", "TeleportFlags", teleport_flags);
if (teleport_flags & TELEPORT_FLAGS_DISABLE_CANCEL)
{
gViewerWindow->setProgressCancelButtonVisible(FALSE);
}
else
{
gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Cancel"));
}
std::string buffer;
msg->getString("Info", "Message", buffer);
LL_DEBUGS("Messaging") << "teleport progress: " << buffer << LL_ENDL;
//Sorta hacky...default to using simulator raw messages
//if we don't find the coresponding mapping in our progress mappings
std::string message = buffer;
if (LLAgent::sTeleportProgressMessages.find(buffer) !=
LLAgent::sTeleportProgressMessages.end() )
{
message = LLAgent::sTeleportProgressMessages[buffer];
}
gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages[message]);
}
class LLFetchInWelcomeArea : public LLInventoryFetchDescendentsObserver
{
public:
LLFetchInWelcomeArea(const uuid_vec_t &ids) :
LLInventoryFetchDescendentsObserver(ids)
{}
virtual void done()
{
LLIsType is_landmark(LLAssetType::AT_LANDMARK);
LLIsType is_card(LLAssetType::AT_CALLINGCARD);
LLInventoryModel::cat_array_t card_cats;
LLInventoryModel::item_array_t card_items;
LLInventoryModel::cat_array_t land_cats;
LLInventoryModel::item_array_t land_items;
uuid_vec_t::iterator it = mComplete.begin();
uuid_vec_t::iterator end = mComplete.end();
for(; it != end; ++it)
{
gInventory.collectDescendentsIf(
(*it),
land_cats,
land_items,
LLInventoryModel::EXCLUDE_TRASH,
is_landmark);
gInventory.collectDescendentsIf(
(*it),
card_cats,
card_items,
LLInventoryModel::EXCLUDE_TRASH,
is_card);
}
gInventory.removeObserver(this);
delete this;
}
};
class LLPostTeleportNotifiers : public LLEventTimer
{
public:
LLPostTeleportNotifiers();
virtual ~LLPostTeleportNotifiers();
//function to be called at the supplied frequency
virtual BOOL tick();
};
LLPostTeleportNotifiers::LLPostTeleportNotifiers() : LLEventTimer( 2.0 )
{
};
LLPostTeleportNotifiers::~LLPostTeleportNotifiers()
{
}
BOOL LLPostTeleportNotifiers::tick()
{
BOOL all_done = FALSE;
if ( gAgent.getTeleportState() == LLAgent::TELEPORT_NONE )
{
// get callingcards and landmarks available to the user arriving.
uuid_vec_t folders;
const LLUUID callingcard_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CALLINGCARD);
if(callingcard_id.notNull())
folders.push_back(callingcard_id);
const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK);
if(folder_id.notNull())
folders.push_back(folder_id);
if(!folders.empty())
{
LLFetchInWelcomeArea* fetcher = new LLFetchInWelcomeArea(folders);
fetcher->startFetch();
if(fetcher->isFinished())
{
fetcher->done();
}
else
{
gInventory.addObserver(fetcher);
}
}
all_done = TRUE;
}
return all_done;
}
// Teleport notification from the simulator
// We're going to pretend to be a new agent
void process_teleport_finish(LLMessageSystem* msg, void**)
{
LL_DEBUGS("Messaging") << "Got teleport location message" << LL_ENDL;
LLUUID agent_id;
msg->getUUIDFast(_PREHASH_Info, _PREHASH_AgentID, agent_id);
if (agent_id != gAgent.getID())
{
LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL;
return;
}
// Teleport is finished; it can't be cancelled now.
gViewerWindow->setProgressCancelButtonVisible(FALSE);
// Do teleport effect for where you're leaving
// VEFFECT: TeleportStart
LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE);
effectp->setPositionGlobal(gAgent.getPositionGlobal());
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
LLHUDManager::getInstance()->sendEffects();
U32 location_id;
U32 sim_ip;
U16 sim_port;
LLVector3 pos, look_at;
U64 region_handle;
msg->getU32Fast(_PREHASH_Info, _PREHASH_LocationID, location_id);
msg->getIPAddrFast(_PREHASH_Info, _PREHASH_SimIP, sim_ip);
msg->getIPPortFast(_PREHASH_Info, _PREHASH_SimPort, sim_port);
//msg->getVector3Fast(_PREHASH_Info, _PREHASH_Position, pos);
//msg->getVector3Fast(_PREHASH_Info, _PREHASH_LookAt, look_at);
msg->getU64Fast(_PREHASH_Info, _PREHASH_RegionHandle, region_handle);
U32 teleport_flags;
msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags);
std::string seedCap;
msg->getStringFast(_PREHASH_Info, _PREHASH_SeedCapability, seedCap);
// update home location if we are teleporting out of prelude - specific to teleporting to welcome area
if((teleport_flags & TELEPORT_FLAGS_SET_HOME_TO_TARGET)
&& (!gAgent.isGodlike()))
{
gAgent.setHomePosRegion(region_handle, pos);
// Create a timer that will send notices when teleporting is all finished. Since this is
// based on the LLEventTimer class, it will be managed by that class and not orphaned or leaked.
new LLPostTeleportNotifiers();
}
LLHost sim_host(sim_ip, sim_port);
// Viewer trusts the simulator.
gMessageSystem->enableCircuit(sim_host, TRUE);
LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host);
/*
// send camera update to new region
gAgentCamera.updateCamera();
// likewise make sure the camera is behind the avatar
gAgentCamera.resetView(TRUE);
LLVector3 shift_vector = regionp->getPosRegionFromGlobal(gAgent.getRegion()->getOriginGlobal());
gAgent.setRegion(regionp);
gObjectList.shiftObjects(shift_vector);
if (isAgentAvatarValid())
{
gAgentAvatarp->clearChatText();
gAgentCamera.slamLookAt(look_at);
}
gAgent.setPositionAgent(pos);
gAssetStorage->setUpstream(sim);
gCacheName->setUpstream(sim);
*/
// Make sure we're standing
gAgent.standUp();
// now, use the circuit info to tell simulator about us!
LL_INFOS("Messaging") << "process_teleport_finish() Enabling "
<< sim_host << " with code " << msg->mOurCircuitCode << LL_ENDL;
msg->newMessageFast(_PREHASH_UseCircuitCode);
msg->nextBlockFast(_PREHASH_CircuitCode);
msg->addU32Fast(_PREHASH_Code, msg->getOurCircuitCode());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->addUUIDFast(_PREHASH_ID, gAgent.getID());
msg->sendReliable(sim_host);
send_complete_agent_movement(sim_host);
gAgent.setTeleportState( LLAgent::TELEPORT_MOVING );
gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages["contacting"]);
regionp->setSeedCapability(seedCap);
// Don't send camera updates to the new region until we're
// actually there...
// Now do teleport effect for where you're going.
// VEFFECT: TeleportEnd
effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE);
effectp->setPositionGlobal(gAgent.getPositionGlobal());
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
LLHUDManager::getInstance()->sendEffects();
// gTeleportDisplay = TRUE;
// gTeleportDisplayTimer.reset();
// gViewerWindow->setShowProgress(TRUE);
}
// stuff we have to do every time we get an AvatarInitComplete from a sim
/*
void process_avatar_init_complete(LLMessageSystem* msg, void**)
{
LLVector3 agent_pos;
msg->getVector3Fast(_PREHASH_AvatarData, _PREHASH_Position, agent_pos);
agent_movement_complete(msg->getSender(), agent_pos);
}
*/
void process_agent_movement_complete(LLMessageSystem* msg, void**)
{
gShiftFrame = true;
gAgentMovementCompleted = true;
LLUUID agent_id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
LLUUID session_id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
if((gAgent.getID() != agent_id) || (gAgent.getSessionID() != session_id))
{
LL_WARNS("Messaging") << "Incorrect id in process_agent_movement_complete()"
<< LL_ENDL;
return;
}
LL_DEBUGS("Messaging") << "process_agent_movement_complete()" << LL_ENDL;
// *TODO: check timestamp to make sure the movement compleation
// makes sense.
LLVector3 agent_pos;
msg->getVector3Fast(_PREHASH_Data, _PREHASH_Position, agent_pos);
LLVector3 look_at;
msg->getVector3Fast(_PREHASH_Data, _PREHASH_LookAt, look_at);
U64 region_handle;
msg->getU64Fast(_PREHASH_Data, _PREHASH_RegionHandle, region_handle);
std::string version_channel;
msg->getString("SimData", "ChannelVersion", version_channel);
if (!isAgentAvatarValid())
{
// Could happen if you were immediately god-teleported away on login,
// maybe other cases. Continue, but warn.
LL_WARNS("Messaging") << "agent_movement_complete() with NULL avatarp." << LL_ENDL;
}
F32 x, y;
from_region_handle(region_handle, &x, &y);
LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle);
if (!regionp)
{
if (gAgent.getRegion())
{
LL_WARNS("Messaging") << "current region " << gAgent.getRegion()->getOriginGlobal() << LL_ENDL;
}
LL_WARNS("Messaging") << "Agent being sent to invalid home region: "
<< x << ":" << y
<< " current pos " << gAgent.getPositionGlobal()
<< LL_ENDL;
LLAppViewer::instance()->forceDisconnect(LLTrans::getString("SentToInvalidRegion"));
return;
}
LL_INFOS("Messaging") << "Changing home region to " << x << ":" << y << LL_ENDL;
// set our upstream host the new simulator and shuffle things as
// appropriate.
LLVector3 shift_vector = regionp->getPosRegionFromGlobal(
gAgent.getRegion()->getOriginGlobal());
gAgent.setRegion(regionp);
gObjectList.shiftObjects(shift_vector);
gAssetStorage->setUpstream(msg->getSender());
gCacheName->setUpstream(msg->getSender());
gViewerThrottle.sendToSim();
gViewerWindow->sendShapeToSim();
bool is_teleport = gAgent.getTeleportState() == LLAgent::TELEPORT_MOVING;
if( is_teleport )
{
if (gAgent.getTeleportKeepsLookAt())
{
// *NOTE: the LookAt data we get from the sim here doesn't
// seem to be useful, so get it from the camera instead
look_at = LLViewerCamera::getInstance()->getAtAxis();
}
// Force the camera back onto the agent, don't animate.
gAgentCamera.setFocusOnAvatar(TRUE, FALSE);
gAgentCamera.slamLookAt(look_at);
gAgentCamera.updateCamera();
gAgent.setTeleportState( LLAgent::TELEPORT_START_ARRIVAL );
// set the appearance on teleport since the new sim does not
// know what you look like.
gAgent.sendAgentSetAppearance();
if (isAgentAvatarValid())
{
// Set the new position
gAgentAvatarp->setPositionAgent(agent_pos);
gAgentAvatarp->clearChat();
gAgentAvatarp->slamPosition();
}
}
else
{
// This is initial log-in or a region crossing
gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
if(LLStartUp::getStartupState() < STATE_STARTED)
{ // This is initial log-in, not a region crossing:
// Set the camera looking ahead of the AV so send_agent_update() below
// will report the correct location to the server.
LLVector3 look_at_point = look_at;
look_at_point = agent_pos + look_at_point.rotVec(gAgent.getQuat());
static LLVector3 up_direction(0.0f, 0.0f, 1.0f);
LLViewerCamera::getInstance()->lookAt(agent_pos, look_at_point, up_direction);
}
}
if ( LLTracker::isTracking(NULL) )
{
// Check distance to beacon, if < 5m, remove beacon
LLVector3d beacon_pos = LLTracker::getTrackedPositionGlobal();
LLVector3 beacon_dir(agent_pos.mV[VX] - (F32)fmod(beacon_pos.mdV[VX], 256.0), agent_pos.mV[VY] - (F32)fmod(beacon_pos.mdV[VY], 256.0), 0);
if (beacon_dir.magVecSquared() < 25.f)
{
LLTracker::stopTracking(NULL);
}
else if ( is_teleport && !gAgent.getTeleportKeepsLookAt() && look_at.isExactlyZero())
{
//look at the beacon
LLVector3 global_agent_pos = agent_pos;
global_agent_pos[0] += x;
global_agent_pos[1] += y;
look_at = (LLVector3)beacon_pos - global_agent_pos;
look_at.normVec();
gAgentCamera.slamLookAt(look_at);
}
}
// TODO: Put back a check for flying status! DK 12/19/05
// Sim tells us whether the new position is off the ground
/*
if (teleport_flags & TELEPORT_FLAGS_IS_FLYING)
{
gAgent.setFlying(TRUE);
}
else
{
gAgent.setFlying(FALSE);
}
*/
send_agent_update(TRUE, TRUE);
if (gAgent.getRegion()->getBlockFly())
{
gAgent.setFlying(gAgent.canFly());
}
// force simulator to recognize do not disturb state
if (gAgent.isDoNotDisturb())
{
gAgent.setDoNotDisturb(true);
}
else
{
gAgent.setDoNotDisturb(false);
}
if (isAgentAvatarValid())
{
gAgentAvatarp->mFootPlane.clearVec();
}
// send walk-vs-run status
gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun());
// If the server version has changed, display an info box and offer
// to display the release notes, unless this is the initial log in.
if (gLastVersionChannel == version_channel)
{
return;
}
gLastVersionChannel = version_channel;
}
void process_crossed_region(LLMessageSystem* msg, void**)
{
LLUUID agent_id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
LLUUID session_id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_SessionID, session_id);
if((gAgent.getID() != agent_id) || (gAgent.getSessionID() != session_id))
{
LL_WARNS("Messaging") << "Incorrect id in process_crossed_region()"
<< LL_ENDL;
return;
}
LL_INFOS("Messaging") << "process_crossed_region()" << LL_ENDL;
gAgentAvatarp->resetRegionCrossingTimer();
U32 sim_ip;
msg->getIPAddrFast(_PREHASH_RegionData, _PREHASH_SimIP, sim_ip);
U16 sim_port;
msg->getIPPortFast(_PREHASH_RegionData, _PREHASH_SimPort, sim_port);
LLHost sim_host(sim_ip, sim_port);
U64 region_handle;
msg->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);
std::string seedCap;
msg->getStringFast(_PREHASH_RegionData, _PREHASH_SeedCapability, seedCap);
send_complete_agent_movement(sim_host);
LLViewerRegion* regionp = LLWorld::getInstance()->addRegion(region_handle, sim_host);
regionp->setSeedCapability(seedCap);
}
// Sends avatar and camera information to simulator.
// Sent roughly once per frame, or 20 times per second, whichever is less often
const F32 THRESHOLD_HEAD_ROT_QDOT = 0.9997f; // ~= 2.5 degrees -- if its less than this we need to update head_rot
const F32 MAX_HEAD_ROT_QDOT = 0.99999f; // ~= 0.5 degrees -- if its greater than this then no need to update head_rot
// between these values we delay the updates (but no more than one second)
static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE_SEND("Send Message");
void send_agent_update(BOOL force_send, BOOL send_reliable)
{
if (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE)
{
// We don't care if they want to send an agent update, they're not allowed to until the simulator
// that's the target is ready to receive them (after avatar_init_complete is received)
return;
}
// We have already requested to log out. Don't send agent updates.
if(LLAppViewer::instance()->logoutRequestSent())
{
return;
}
// no region to send update to
if(gAgent.getRegion() == NULL)
{
return;
}
const F32 TRANSLATE_THRESHOLD = 0.01f;
// NOTA BENE: This is (intentionally?) using the small angle sine approximation to test for rotation
// Plus, there is an extra 0.5 in the mix since the perpendicular between last_camera_at and getAtAxis() bisects cam_rot_change
// Thus, we're actually testing against 0.2 degrees
const F32 ROTATION_THRESHOLD = 0.1f * 2.f*F_PI/360.f; // Rotation thresh 0.2 deg, see note above
const U8 DUP_MSGS = 1; // HACK! number of times to repeat data on motionless agent
// Store data on last sent update so that if no changes, no send
static LLVector3 last_camera_pos_agent,
last_camera_at,
last_camera_left,
last_camera_up;
static LLVector3 cam_center_chg,
cam_rot_chg;
static LLQuaternion last_head_rot;
static U32 last_control_flags = 0;
static U8 last_render_state;
static U8 duplicate_count = 0;
static F32 head_rot_chg = 1.0;
static U8 last_flags;
LLMessageSystem *msg = gMessageSystem;
LLVector3 camera_pos_agent; // local to avatar's region
U8 render_state;
LLQuaternion body_rotation = gAgent.getFrameAgent().getQuaternion();
LLQuaternion head_rotation = gAgent.getHeadRotation();
camera_pos_agent = gAgentCamera.getCameraPositionAgent();
render_state = gAgent.getRenderState();
U32 control_flag_change = 0;
U8 flag_change = 0;
cam_center_chg = last_camera_pos_agent - camera_pos_agent;
cam_rot_chg = last_camera_at - LLViewerCamera::getInstance()->getAtAxis();
// If a modifier key is held down, turn off
// LBUTTON and ML_LBUTTON so that using the camera (alt-key) doesn't
// trigger a control event.
U32 control_flags = gAgent.getControlFlags();
MASK key_mask = gKeyboard->currentMask(TRUE);
if (key_mask & MASK_ALT || key_mask & MASK_CONTROL)
{
control_flags &= ~( AGENT_CONTROL_LBUTTON_DOWN |
AGENT_CONTROL_ML_LBUTTON_DOWN );
control_flags |= AGENT_CONTROL_LBUTTON_UP |
AGENT_CONTROL_ML_LBUTTON_UP ;
}
control_flag_change = last_control_flags ^ control_flags;
U8 flags = AU_FLAGS_NONE;
if (gAgent.isGroupTitleHidden())
{
flags |= AU_FLAGS_HIDETITLE;
}
if (gAgent.getAutoPilot())
{
flags |= AU_FLAGS_CLIENT_AUTOPILOT;
}
flag_change = last_flags ^ flags;
head_rot_chg = dot(last_head_rot, head_rotation);
//static S32 msg_number = 0; // Used for diagnostic log messages
if (force_send ||
(cam_center_chg.magVec() > TRANSLATE_THRESHOLD) ||
(head_rot_chg < THRESHOLD_HEAD_ROT_QDOT) ||
(last_render_state != render_state) ||
(cam_rot_chg.magVec() > ROTATION_THRESHOLD) ||
control_flag_change != 0 ||
flag_change != 0)
{
/* Diagnotics to show why we send the AgentUpdate message. Also un-commment the msg_number code above and below this block
msg_number += 1;
if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT)
{
//LL_INFOS("Messaging") << "head rot " << head_rotation << LL_ENDL;
LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", head_rot_chg " << head_rot_chg << LL_ENDL;
}
if (cam_rot_chg.magVec() > ROTATION_THRESHOLD)
{
LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", cam rot " << cam_rot_chg.magVec() << LL_ENDL;
}
if (cam_center_chg.magVec() > TRANSLATE_THRESHOLD)
{
LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", cam center " << cam_center_chg.magVec() << LL_ENDL;
}
// if (drag_delta_chg.magVec() > TRANSLATE_THRESHOLD)
// {
// LL_INFOS("Messaging") << "drag delta " << drag_delta_chg.magVec() << LL_ENDL;
// }
if (control_flag_change)
{
LL_INFOS("Messaging") << "msg " << msg_number << ", frame " << LLFrameTimer::getFrameCount() << ", dcf = " << control_flag_change << LL_ENDL;
}
*/
duplicate_count = 0;
}
else
{
duplicate_count++;
if (head_rot_chg < MAX_HEAD_ROT_QDOT && duplicate_count < AGENT_UPDATES_PER_SECOND)
{
// The head_rotation is sent for updating things like attached guns.
// We only trigger a new update when head_rotation deviates beyond
// some threshold from the last update, however this can break fine
// adjustments when trying to aim an attached gun, so what we do here
// (where we would normally skip sending an update when nothing has changed)
// is gradually reduce the threshold to allow a better update to
// eventually get sent... should update to within 0.5 degrees in less
// than a second.
if (head_rot_chg < THRESHOLD_HEAD_ROT_QDOT + (MAX_HEAD_ROT_QDOT - THRESHOLD_HEAD_ROT_QDOT) * duplicate_count / AGENT_UPDATES_PER_SECOND)
{
duplicate_count = 0;
}
else
{
return;
}
}
else
{
return;
}
}
if (duplicate_count < DUP_MSGS && !gDisconnected)
{
/* More diagnostics to count AgentUpdate messages
static S32 update_sec = 0;
static S32 update_count = 0;
static S32 max_update_count = 0;
S32 cur_sec = lltrunc( LLTimer::getTotalSeconds() );
update_count += 1;
if (cur_sec != update_sec)
{
if (update_sec != 0)
{
update_sec = cur_sec;
//msg_number = 0;
max_update_count = llmax(max_update_count, update_count);
llinfos << "Sent " << update_count << " AgentUpdate messages per second, max is " << max_update_count << llendl;
}
update_sec = cur_sec;
update_count = 0;
}
*/
LLFastTimer t(FTM_AGENT_UPDATE_SEND);
// Build the message
msg->newMessageFast(_PREHASH_AgentUpdate);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->addQuatFast(_PREHASH_BodyRotation, body_rotation);
msg->addQuatFast(_PREHASH_HeadRotation, head_rotation);
msg->addU8Fast(_PREHASH_State, render_state);
msg->addU8Fast(_PREHASH_Flags, flags);
// if (camera_pos_agent.mV[VY] > 255.f)
// {
// LL_INFOS("Messaging") << "Sending camera center " << camera_pos_agent << LL_ENDL;
// }
msg->addVector3Fast(_PREHASH_CameraCenter, camera_pos_agent);
msg->addVector3Fast(_PREHASH_CameraAtAxis, LLViewerCamera::getInstance()->getAtAxis());
msg->addVector3Fast(_PREHASH_CameraLeftAxis, LLViewerCamera::getInstance()->getLeftAxis());
msg->addVector3Fast(_PREHASH_CameraUpAxis, LLViewerCamera::getInstance()->getUpAxis());
msg->addF32Fast(_PREHASH_Far, gAgentCamera.mDrawDistance);
msg->addU32Fast(_PREHASH_ControlFlags, control_flags);
if (gDebugClicks)
{
if (control_flags & AGENT_CONTROL_LBUTTON_DOWN)
{
LL_INFOS("Messaging") << "AgentUpdate left button down" << LL_ENDL;
}
if (control_flags & AGENT_CONTROL_LBUTTON_UP)
{
LL_INFOS("Messaging") << "AgentUpdate left button up" << LL_ENDL;
}
}
gAgent.enableControlFlagReset();
if (!send_reliable)
{
gAgent.sendMessage();
}
else
{
gAgent.sendReliableMessage();
}
// LL_DEBUGS("Messaging") << "agent " << avatar_pos_agent << " cam " << camera_pos_agent << LL_ENDL;
// Copy the old data
last_head_rot = head_rotation;
last_render_state = render_state;
last_camera_pos_agent = camera_pos_agent;
last_camera_at = LLViewerCamera::getInstance()->getAtAxis();
last_camera_left = LLViewerCamera::getInstance()->getLeftAxis();
last_camera_up = LLViewerCamera::getInstance()->getUpAxis();
last_control_flags = control_flags;
last_flags = flags;
}
}
// *TODO: Remove this dependency, or figure out a better way to handle
// this hack.
extern U32 gObjectBits;
void process_object_update(LLMessageSystem *mesgsys, void **user_data)
{
// Update the data counters
if (mesgsys->getReceiveCompressedSize())
{
gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
}
else
{
gObjectBits += mesgsys->getReceiveSize() * 8;
}
// Update the object...
gObjectList.processObjectUpdate(mesgsys, user_data, OUT_FULL);
}
void process_compressed_object_update(LLMessageSystem *mesgsys, void **user_data)
{
// Update the data counters
if (mesgsys->getReceiveCompressedSize())
{
gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
}
else
{
gObjectBits += mesgsys->getReceiveSize() * 8;
}
// Update the object...
gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_FULL_COMPRESSED);
}
void process_cached_object_update(LLMessageSystem *mesgsys, void **user_data)
{
// Update the data counters
if (mesgsys->getReceiveCompressedSize())
{
gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
}
else
{
gObjectBits += mesgsys->getReceiveSize() * 8;
}
// Update the object...
gObjectList.processCachedObjectUpdate(mesgsys, user_data, OUT_FULL_CACHED);
}
void process_terse_object_update_improved(LLMessageSystem *mesgsys, void **user_data)
{
if (mesgsys->getReceiveCompressedSize())
{
gObjectBits += mesgsys->getReceiveCompressedSize() * 8;
}
else
{
gObjectBits += mesgsys->getReceiveSize() * 8;
}
gObjectList.processCompressedObjectUpdate(mesgsys, user_data, OUT_TERSE_IMPROVED);
}
static LLFastTimer::DeclareTimer FTM_PROCESS_OBJECTS("Process Kill Objects");
void process_kill_object(LLMessageSystem *mesgsys, void **user_data)
{
LLFastTimer t(FTM_PROCESS_OBJECTS);
LLUUID id;
U32 local_id;
S32 i;
S32 num_objects;
num_objects = mesgsys->getNumberOfBlocksFast(_PREHASH_ObjectData);
for (i = 0; i < num_objects; i++)
{
mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i);
LLViewerObjectList::getUUIDFromLocal(id,
local_id,
gMessageSystem->getSenderIP(),
gMessageSystem->getSenderPort());
if (id == LLUUID::null)
{
LL_DEBUGS("Messaging") << "Unknown kill for local " << local_id << LL_ENDL;
continue;
}
else
{
LL_DEBUGS("Messaging") << "Kill message for local " << local_id << LL_ENDL;
}
// ...don't kill the avatar
if (!(id == gAgentID))
{
LLViewerObject *objectp = gObjectList.findObject(id);
if (objectp)
{
// Display green bubble on kill
if ( gShowObjectUpdates )
{
LLColor4 color(0.f,1.f,0.f,1.f);
gPipeline.addDebugBlip(objectp->getPositionAgent(), color);
}
// Do the kill
gObjectList.killObject(objectp);
}
}
// We should remove the object from selection after it is marked dead by gObjectList to make LLToolGrab,
// which is using the object, release the mouse capture correctly when the object dies.
// See LLToolGrab::handleHoverActive() and LLToolGrab::handleHoverNonPhysical().
LLSelectMgr::getInstance()->removeObjectFromSelections(id);
}
}
void process_time_synch(LLMessageSystem *mesgsys, void **user_data)
{
LLVector3 sun_direction;
LLVector3 sun_ang_velocity;
F32 phase;
U64 space_time_usec;
U32 seconds_per_day;
U32 seconds_per_year;
// "SimulatorViewerTimeMessage"
mesgsys->getU64Fast(_PREHASH_TimeInfo, _PREHASH_UsecSinceStart, space_time_usec);
mesgsys->getU32Fast(_PREHASH_TimeInfo, _PREHASH_SecPerDay, seconds_per_day);
mesgsys->getU32Fast(_PREHASH_TimeInfo, _PREHASH_SecPerYear, seconds_per_year);
// This should eventually be moved to an "UpdateHeavenlyBodies" message
mesgsys->getF32Fast(_PREHASH_TimeInfo, _PREHASH_SunPhase, phase);
mesgsys->getVector3Fast(_PREHASH_TimeInfo, _PREHASH_SunDirection, sun_direction);
mesgsys->getVector3Fast(_PREHASH_TimeInfo, _PREHASH_SunAngVelocity, sun_ang_velocity);
LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec);
LL_DEBUGS("Windlight Sync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL;
gSky.setSunPhase(phase);
gSky.setSunTargetDirection(sun_direction, sun_ang_velocity);
if ( !(gSavedSettings.getBOOL("SkyOverrideSimSunPosition") || gSky.getOverrideSun()) )
{
gSky.setSunDirection(sun_direction, sun_ang_velocity);
}
}
void process_sound_trigger(LLMessageSystem *msg, void **)
{
if (!gAudiop) return;
U64 region_handle = 0;
F32 gain = 0;
LLUUID sound_id;
LLUUID owner_id;
LLUUID object_id;
LLUUID parent_id;
LLVector3 pos_local;
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_SoundID, sound_id);
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_OwnerID, owner_id);
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ObjectID, object_id);
msg->getUUIDFast(_PREHASH_SoundData, _PREHASH_ParentID, parent_id);
msg->getU64Fast(_PREHASH_SoundData, _PREHASH_Handle, region_handle);
msg->getVector3Fast(_PREHASH_SoundData, _PREHASH_Position, pos_local);
msg->getF32Fast(_PREHASH_SoundData, _PREHASH_Gain, gain);
// adjust sound location to true global coords
LLVector3d pos_global = from_region_handle(region_handle);
pos_global.mdV[VX] += pos_local.mV[VX];
pos_global.mdV[VY] += pos_local.mV[VY];
pos_global.mdV[VZ] += pos_local.mV[VZ];
// Don't play a trigger sound if you can't hear it due
// to parcel "local audio only" settings.
if (!LLViewerParcelMgr::getInstance()->canHearSound(pos_global)) return;
// Don't play sounds triggered by someone you muted.
if (LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagObjectSounds)) return;
// Don't play sounds from an object you muted
if (LLMuteList::getInstance()->isMuted(object_id)) return;
// Don't play sounds from an object whose parent you muted
if (parent_id.notNull()
&& LLMuteList::getInstance()->isMuted(parent_id))
{
return;
}
// Don't play sounds from a region with maturity above current agent maturity
if( !gAgent.canAccessMaturityInRegion( region_handle ) )
{
return;
}
// Don't play sounds from gestures if they are not enabled.
if (object_id == owner_id && !gSavedSettings.getBOOL("EnableGestureSounds"))
{
return;
}
gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global);
}
void process_preload_sound(LLMessageSystem *msg, void **user_data)
{
if (!gAudiop)
{
return;
}
LLUUID sound_id;
LLUUID object_id;
LLUUID owner_id;
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_SoundID, sound_id);
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_id);
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
LLViewerObject *objectp = gObjectList.findObject(object_id);
if (!objectp) return;
if (LLMuteList::getInstance()->isMuted(object_id)) return;
if (LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagObjectSounds)) return;
LLAudioSource *sourcep = objectp->getAudioSource(owner_id);
if (!sourcep) return;
LLAudioData *datap = gAudiop->getAudioData(sound_id);
// Note that I don't actually do any loading of the
// audio data into a buffer at this point, as it won't actually
// help us out.
// Don't play sounds from a region with maturity above current agent maturity
LLVector3d pos_global = objectp->getPositionGlobal();
if (gAgent.canAccessMaturityAtGlobal(pos_global))
{
// Add audioData starts a transfer internally.
sourcep->addAudioData(datap, FALSE);
}
}
void process_attached_sound(LLMessageSystem *msg, void **user_data)
{
F32 gain = 0;
LLUUID sound_id;
LLUUID object_id;
LLUUID owner_id;
U8 flags;
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_SoundID, sound_id);
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_id);
msg->getUUIDFast(_PREHASH_DataBlock, _PREHASH_OwnerID, owner_id);
msg->getF32Fast(_PREHASH_DataBlock, _PREHASH_Gain, gain);
msg->getU8Fast(_PREHASH_DataBlock, _PREHASH_Flags, flags);
LLViewerObject *objectp = gObjectList.findObject(object_id);
if (!objectp)
{
// we don't know about this object, just bail
return;
}
if (LLMuteList::getInstance()->isMuted(object_id)) return;
if (LLMuteList::getInstance()->isMuted(owner_id, LLMute::flagObjectSounds)) return;
// Don't play sounds from a region with maturity above current agent maturity
LLVector3d pos = objectp->getPositionGlobal();
if( !gAgent.canAccessMaturityAtGlobal(pos) )
{
return;
}
objectp->setAttachedSound(sound_id, owner_id, gain, flags);
}
void process_attached_sound_gain_change(LLMessageSystem *mesgsys, void **user_data)
{
F32 gain = 0;
LLUUID object_guid;
LLViewerObject *objectp = NULL;
mesgsys->getUUIDFast(_PREHASH_DataBlock, _PREHASH_ObjectID, object_guid);
if (!((objectp = gObjectList.findObject(object_guid))))
{
// we don't know about this object, just bail
return;
}
mesgsys->getF32Fast(_PREHASH_DataBlock, _PREHASH_Gain, gain);
objectp->adjustAudioGain(gain);
}
void process_health_message(LLMessageSystem *mesgsys, void **user_data)
{
F32 health;
mesgsys->getF32Fast(_PREHASH_HealthData, _PREHASH_Health, health);
if (gStatusBar)
{
gStatusBar->setHealth((S32)health);
}
}
void process_sim_stats(LLMessageSystem *msg, void **user_data)
{
S32 count = msg->getNumberOfBlocks("Stat");
for (S32 i = 0; i < count; ++i)
{
U32 stat_id;
F32 stat_value;
msg->getU32("Stat", "StatID", stat_id, i);
msg->getF32("Stat", "StatValue", stat_value, i);
switch (stat_id)
{
case LL_SIM_STAT_TIME_DILATION:
LLViewerStats::getInstance()->mSimTimeDilation.addValue(stat_value);
break;
case LL_SIM_STAT_FPS:
LLViewerStats::getInstance()->mSimFPS.addValue(stat_value);
break;
case LL_SIM_STAT_PHYSFPS:
LLViewerStats::getInstance()->mSimPhysicsFPS.addValue(stat_value);
break;
case LL_SIM_STAT_AGENTUPS:
LLViewerStats::getInstance()->mSimAgentUPS.addValue(stat_value);
break;
case LL_SIM_STAT_FRAMEMS:
LLViewerStats::getInstance()->mSimFrameMsec.addValue(stat_value);
break;
case LL_SIM_STAT_NETMS:
LLViewerStats::getInstance()->mSimNetMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SIMOTHERMS:
LLViewerStats::getInstance()->mSimSimOtherMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SIMPHYSICSMS:
LLViewerStats::getInstance()->mSimSimPhysicsMsec.addValue(stat_value);
break;
case LL_SIM_STAT_AGENTMS:
LLViewerStats::getInstance()->mSimAgentMsec.addValue(stat_value);
break;
case LL_SIM_STAT_IMAGESMS:
LLViewerStats::getInstance()->mSimImagesMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SCRIPTMS:
LLViewerStats::getInstance()->mSimScriptMsec.addValue(stat_value);
break;
case LL_SIM_STAT_NUMTASKS:
LLViewerStats::getInstance()->mSimObjects.addValue(stat_value);
break;
case LL_SIM_STAT_NUMTASKSACTIVE:
LLViewerStats::getInstance()->mSimActiveObjects.addValue(stat_value);
break;
case LL_SIM_STAT_NUMAGENTMAIN:
LLViewerStats::getInstance()->mSimMainAgents.addValue(stat_value);
break;
case LL_SIM_STAT_NUMAGENTCHILD:
LLViewerStats::getInstance()->mSimChildAgents.addValue(stat_value);
break;
case LL_SIM_STAT_NUMSCRIPTSACTIVE:
LLViewerStats::getInstance()->mSimActiveScripts.addValue(stat_value);
break;
case LL_SIM_STAT_SCRIPT_EPS:
LLViewerStats::getInstance()->mSimScriptEPS.addValue(stat_value);
break;
case LL_SIM_STAT_INPPS:
LLViewerStats::getInstance()->mSimInPPS.addValue(stat_value);
break;
case LL_SIM_STAT_OUTPPS:
LLViewerStats::getInstance()->mSimOutPPS.addValue(stat_value);
break;
case LL_SIM_STAT_PENDING_DOWNLOADS:
LLViewerStats::getInstance()->mSimPendingDownloads.addValue(stat_value);
break;
case LL_SIM_STAT_PENDING_UPLOADS:
LLViewerStats::getInstance()->mSimPendingUploads.addValue(stat_value);
break;
case LL_SIM_STAT_PENDING_LOCAL_UPLOADS:
LLViewerStats::getInstance()->mSimPendingLocalUploads.addValue(stat_value);
break;
case LL_SIM_STAT_TOTAL_UNACKED_BYTES:
LLViewerStats::getInstance()->mSimTotalUnackedBytes.addValue(stat_value / 1024.f);
break;
case LL_SIM_STAT_PHYSICS_PINNED_TASKS:
LLViewerStats::getInstance()->mPhysicsPinnedTasks.addValue(stat_value);
break;
case LL_SIM_STAT_PHYSICS_LOD_TASKS:
LLViewerStats::getInstance()->mPhysicsLODTasks.addValue(stat_value);
break;
case LL_SIM_STAT_SIMPHYSICSSTEPMS:
LLViewerStats::getInstance()->mSimSimPhysicsStepMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SIMPHYSICSSHAPEMS:
LLViewerStats::getInstance()->mSimSimPhysicsShapeUpdateMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SIMPHYSICSOTHERMS:
LLViewerStats::getInstance()->mSimSimPhysicsOtherMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SIMPHYSICSMEMORY:
LLViewerStats::getInstance()->mPhysicsMemoryAllocated.addValue(stat_value);
break;
case LL_SIM_STAT_SIMSPARETIME:
LLViewerStats::getInstance()->mSimSpareMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SIMSLEEPTIME:
LLViewerStats::getInstance()->mSimSleepMsec.addValue(stat_value);
break;
case LL_SIM_STAT_IOPUMPTIME:
LLViewerStats::getInstance()->mSimPumpIOMsec.addValue(stat_value);
break;
case LL_SIM_STAT_PCTSCRIPTSRUN:
LLViewerStats::getInstance()->mSimPctScriptsRun.addValue(stat_value);
break;
case LL_SIM_STAT_SIMAISTEPTIMEMS:
LLViewerStats::getInstance()->mSimSimAIStepMsec.addValue(stat_value);
break;
case LL_SIM_STAT_SKIPPEDAISILSTEPS_PS:
LLViewerStats::getInstance()->mSimSimSkippedSilhouetteSteps.addValue(stat_value);
break;
case LL_SIM_STAT_PCTSTEPPEDCHARACTERS:
LLViewerStats::getInstance()->mSimSimPctSteppedCharacters.addValue(stat_value);
break;
default:
// Used to be a commented out warning.
LL_DEBUGS("Messaging") << "Unknown stat id" << stat_id << LL_ENDL;
break;
}
}
/*
msg->getF32Fast(_PREHASH_Statistics, _PREHASH_PhysicsTimeDilation, time_dilation);
LLViewerStats::getInstance()->mSimTDStat.addValue(time_dilation);
// Process information
// { CpuUsage F32 }
// { SimMemTotal F32 }
// { SimMemRSS F32 }
// { ProcessUptime F32 }
F32 cpu_usage;
F32 sim_mem_total;
F32 sim_mem_rss;
F32 process_uptime;
msg->getF32Fast(_PREHASH_Statistics, _PREHASH_CpuUsage, cpu_usage);
msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemTotal, sim_mem_total);
msg->getF32Fast(_PREHASH_Statistics, _PREHASH_SimMemRSS, sim_mem_rss);
msg->getF32Fast(_PREHASH_Statistics, _PREHASH_ProcessUptime, process_uptime);
LLViewerStats::getInstance()->mSimCPUUsageStat.addValue(cpu_usage);
LLViewerStats::getInstance()->mSimMemTotalStat.addValue(sim_mem_total);
LLViewerStats::getInstance()->mSimMemRSSStat.addValue(sim_mem_rss);
*/
//
// Various hacks that aren't statistics, but are being handled here.
//
U32 max_tasks_per_region;
U64 region_flags;
msg->getU32("Region", "ObjectCapacity", max_tasks_per_region);
if (msg->has(_PREHASH_RegionInfo))
{
msg->getU64("RegionInfo", "RegionFlagsExtended", region_flags);
}
else
{
U32 flags = 0;
msg->getU32("Region", "RegionFlags", flags);
region_flags = flags;
}
LLViewerRegion* regionp = gAgent.getRegion();
if (regionp)
{
BOOL was_flying = gAgent.getFlying();
regionp->setRegionFlags(region_flags);
regionp->setMaxTasks(max_tasks_per_region);
// HACK: This makes agents drop from the sky if the region is
// set to no fly while people are still in the sim.
if (was_flying && regionp->getBlockFly())
{
gAgent.setFlying(gAgent.canFly());
}
}
}
void process_avatar_animation(LLMessageSystem *mesgsys, void **user_data)
{
LLUUID animation_id;
LLUUID uuid;
S32 anim_sequence_id;
LLVOAvatar *avatarp;
mesgsys->getUUIDFast(_PREHASH_Sender, _PREHASH_ID, uuid);
//clear animation flags
avatarp = (LLVOAvatar *)gObjectList.findObject(uuid);
if (!avatarp)
{
// no agent by this ID...error?
LL_WARNS("Messaging") << "Received animation state for unknown avatar" << uuid << LL_ENDL;
return;
}
S32 num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_AnimationList);
S32 num_source_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_AnimationSourceList);
avatarp->mSignaledAnimations.clear();
if (avatarp->isSelf())
{
LLUUID object_id;
for( S32 i = 0; i < num_blocks; i++ )
{
mesgsys->getUUIDFast(_PREHASH_AnimationList, _PREHASH_AnimID, animation_id, i);
mesgsys->getS32Fast(_PREHASH_AnimationList, _PREHASH_AnimSequenceID, anim_sequence_id, i);
LL_DEBUGS("Messaging") << "Anim sequence ID: " << anim_sequence_id << LL_ENDL;
avatarp->mSignaledAnimations[animation_id] = anim_sequence_id;
// *HACK: Disabling flying mode if it has been enabled shortly before the agent
// stand up animation is signaled. In this case we don't get a signal to start
// flying animation from server, the AGENT_CONTROL_FLY flag remains set but the
// avatar does not play flying animation, so we switch flying mode off.
// See LLAgent::setFlying(). This may cause "Stop Flying" button to blink.
// See EXT-2781.
if (animation_id == ANIM_AGENT_STANDUP && gAgent.getFlying())
{
gAgent.setFlying(FALSE);
}
if (i < num_source_blocks)
{
mesgsys->getUUIDFast(_PREHASH_AnimationSourceList, _PREHASH_ObjectID, object_id, i);
LLViewerObject* object = gObjectList.findObject(object_id);
if (object)
{
object->setFlagsWithoutUpdate(FLAGS_ANIM_SOURCE, TRUE);
BOOL anim_found = FALSE;
LLVOAvatar::AnimSourceIterator anim_it = avatarp->mAnimationSources.find(object_id);
for (;anim_it != avatarp->mAnimationSources.end(); ++anim_it)
{
if (anim_it->second == animation_id)
{
anim_found = TRUE;
break;
}
}
if (!anim_found)
{
avatarp->mAnimationSources.insert(LLVOAvatar::AnimationSourceMap::value_type(object_id, animation_id));
}
}
}
}
}
else
{
for( S32 i = 0; i < num_blocks; i++ )
{
mesgsys->getUUIDFast(_PREHASH_AnimationList, _PREHASH_AnimID, animation_id, i);
mesgsys->getS32Fast(_PREHASH_AnimationList, _PREHASH_AnimSequenceID, anim_sequence_id, i);
avatarp->mSignaledAnimations[animation_id] = anim_sequence_id;
}
}
if (num_blocks)
{
avatarp->processAnimationStateChanges();
}
}
void process_avatar_appearance(LLMessageSystem *mesgsys, void **user_data)
{
LLUUID uuid;
mesgsys->getUUIDFast(_PREHASH_Sender, _PREHASH_ID, uuid);
LLVOAvatar* avatarp = (LLVOAvatar *)gObjectList.findObject(uuid);
if (avatarp)
{
avatarp->processAvatarAppearance( mesgsys );
}
else
{
LL_WARNS("Messaging") << "avatar_appearance sent for unknown avatar " << uuid << LL_ENDL;
}
}
void process_camera_constraint(LLMessageSystem *mesgsys, void **user_data)
{
LLVector4 cameraCollidePlane;
mesgsys->getVector4Fast(_PREHASH_CameraCollidePlane, _PREHASH_Plane, cameraCollidePlane);
gAgentCamera.setCameraCollidePlane(cameraCollidePlane);
}
void near_sit_object(BOOL success, void *data)
{
if (success)
{
// Send message to sit on object
gMessageSystem->newMessageFast(_PREHASH_AgentSit);
gMessageSystem->nextBlockFast(_PREHASH_AgentData);
gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
gAgent.sendReliableMessage();
}
}
void process_avatar_sit_response(LLMessageSystem *mesgsys, void **user_data)
{
LLVector3 sitPosition;
LLQuaternion sitRotation;
LLUUID sitObjectID;
BOOL use_autopilot;
mesgsys->getUUIDFast(_PREHASH_SitObject, _PREHASH_ID, sitObjectID);
mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_AutoPilot, use_autopilot);
mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_SitPosition, sitPosition);
mesgsys->getQuatFast(_PREHASH_SitTransform, _PREHASH_SitRotation, sitRotation);
LLVector3 camera_eye;
mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_CameraEyeOffset, camera_eye);
LLVector3 camera_at;
mesgsys->getVector3Fast(_PREHASH_SitTransform, _PREHASH_CameraAtOffset, camera_at);
BOOL force_mouselook;
mesgsys->getBOOLFast(_PREHASH_SitTransform, _PREHASH_ForceMouselook, force_mouselook);
if (isAgentAvatarValid() && dist_vec_squared(camera_eye, camera_at) > CAMERA_POSITION_THRESHOLD_SQUARED)
{
gAgentCamera.setSitCamera(sitObjectID, camera_eye, camera_at);
}
gAgentCamera.setForceMouselook(force_mouselook);
// Forcing turning off flying here to prevent flying after pressing "Stand"
// to stand up from an object. See EXT-1655.
gAgent.setFlying(FALSE);
LLViewerObject* object = gObjectList.findObject(sitObjectID);
if (object)
{
LLVector3 sit_spot = object->getPositionAgent() + (sitPosition * object->getRotation());
if (!use_autopilot || isAgentAvatarValid() && gAgentAvatarp->isSitting() && gAgentAvatarp->getRoot() == object->getRoot())
{
//we're already sitting on this object, so don't autopilot
}
else
{
gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(sit_spot), "Sit", &sitRotation, near_sit_object, NULL, 0.5f);
}
}
else
{
LL_WARNS("Messaging") << "Received sit approval for unknown object " << sitObjectID << LL_ENDL;
}
}
void process_clear_follow_cam_properties(LLMessageSystem *mesgsys, void **user_data)
{
LLUUID source_id;
mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, source_id);
LLFollowCamMgr::removeFollowCamParams(source_id);
}
void process_set_follow_cam_properties(LLMessageSystem *mesgsys, void **user_data)
{
S32 type;
F32 value;
bool settingPosition = false;
bool settingFocus = false;
bool settingFocusOffset = false;
LLVector3 position;
LLVector3 focus;
LLVector3 focus_offset;
LLUUID source_id;
mesgsys->getUUIDFast(_PREHASH_ObjectData, _PREHASH_ObjectID, source_id);
LLViewerObject* objectp = gObjectList.findObject(source_id);
if (objectp)
{
objectp->setFlagsWithoutUpdate(FLAGS_CAMERA_SOURCE, TRUE);
}
S32 num_objects = mesgsys->getNumberOfBlocks("CameraProperty");
for (S32 block_index = 0; block_index < num_objects; block_index++)
{
mesgsys->getS32("CameraProperty", "Type", type, block_index);
mesgsys->getF32("CameraProperty", "Value", value, block_index);
switch(type)
{
case FOLLOWCAM_PITCH:
LLFollowCamMgr::setPitch(source_id, value);
break;
case FOLLOWCAM_FOCUS_OFFSET_X:
focus_offset.mV[VX] = value;
settingFocusOffset = true;
break;
case FOLLOWCAM_FOCUS_OFFSET_Y:
focus_offset.mV[VY] = value;
settingFocusOffset = true;
break;
case FOLLOWCAM_FOCUS_OFFSET_Z:
focus_offset.mV[VZ] = value;
settingFocusOffset = true;
break;
case FOLLOWCAM_POSITION_LAG:
LLFollowCamMgr::setPositionLag(source_id, value);
break;
case FOLLOWCAM_FOCUS_LAG:
LLFollowCamMgr::setFocusLag(source_id, value);
break;
case FOLLOWCAM_DISTANCE:
LLFollowCamMgr::setDistance(source_id, value);
break;
case FOLLOWCAM_BEHINDNESS_ANGLE:
LLFollowCamMgr::setBehindnessAngle(source_id, value);
break;
case FOLLOWCAM_BEHINDNESS_LAG:
LLFollowCamMgr::setBehindnessLag(source_id, value);
break;
case FOLLOWCAM_POSITION_THRESHOLD:
LLFollowCamMgr::setPositionThreshold(source_id, value);
break;
case FOLLOWCAM_FOCUS_THRESHOLD:
LLFollowCamMgr::setFocusThreshold(source_id, value);
break;
case FOLLOWCAM_ACTIVE:
//if 1, set using followcam,.
LLFollowCamMgr::setCameraActive(source_id, value != 0.f);
break;
case FOLLOWCAM_POSITION_X:
settingPosition = true;
position.mV[ 0 ] = value;
break;
case FOLLOWCAM_POSITION_Y:
settingPosition = true;
position.mV[ 1 ] = value;
break;
case FOLLOWCAM_POSITION_Z:
settingPosition = true;
position.mV[ 2 ] = value;
break;
case FOLLOWCAM_FOCUS_X:
settingFocus = true;
focus.mV[ 0 ] = value;
break;
case FOLLOWCAM_FOCUS_Y:
settingFocus = true;
focus.mV[ 1 ] = value;
break;
case FOLLOWCAM_FOCUS_Z:
settingFocus = true;
focus.mV[ 2 ] = value;
break;
case FOLLOWCAM_POSITION_LOCKED:
LLFollowCamMgr::setPositionLocked(source_id, value != 0.f);
break;
case FOLLOWCAM_FOCUS_LOCKED:
LLFollowCamMgr::setFocusLocked(source_id, value != 0.f);
break;
default:
break;
}
}
if ( settingPosition )
{
LLFollowCamMgr::setPosition(source_id, position);
}
if ( settingFocus )
{
LLFollowCamMgr::setFocus(source_id, focus);
}
if ( settingFocusOffset )
{
LLFollowCamMgr::setFocusOffset(source_id, focus_offset);
}
}
//end Ventrella
// Culled from newsim lltask.cpp
void process_name_value(LLMessageSystem *mesgsys, void **user_data)
{
std::string temp_str;
LLUUID id;
S32 i, num_blocks;
mesgsys->getUUIDFast(_PREHASH_TaskData, _PREHASH_ID, id);
LLViewerObject* object = gObjectList.findObject(id);
if (object)
{
num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_NameValueData);
for (i = 0; i < num_blocks; i++)
{
mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, temp_str, i);
LL_INFOS("Messaging") << "Added to object Name Value: " << temp_str << LL_ENDL;
object->addNVPair(temp_str);
}
}
else
{
LL_INFOS("Messaging") << "Can't find object " << id << " to add name value pair" << LL_ENDL;
}
}
void process_remove_name_value(LLMessageSystem *mesgsys, void **user_data)
{
std::string temp_str;
LLUUID id;
S32 i, num_blocks;
mesgsys->getUUIDFast(_PREHASH_TaskData, _PREHASH_ID, id);
LLViewerObject* object = gObjectList.findObject(id);
if (object)
{
num_blocks = mesgsys->getNumberOfBlocksFast(_PREHASH_NameValueData);
for (i = 0; i < num_blocks; i++)
{
mesgsys->getStringFast(_PREHASH_NameValueData, _PREHASH_NVPair, temp_str, i);
LL_INFOS("Messaging") << "Removed from object Name Value: " << temp_str << LL_ENDL;
object->removeNVPair(temp_str);
}
}
else
{
LL_INFOS("Messaging") << "Can't find object " << id << " to remove name value pair" << LL_ENDL;
}
}
void process_kick_user(LLMessageSystem *msg, void** /*user_data*/)
{
std::string message;
msg->getStringFast(_PREHASH_UserInfo, _PREHASH_Reason, message);
LLAppViewer::instance()->forceDisconnect(message);
}
/*
void process_user_list_reply(LLMessageSystem *msg, void **user_data)
{
LLUserList::processUserListReply(msg, user_data);
return;
char firstname[MAX_STRING+1];
char lastname[MAX_STRING+1];
U8 status;
S32 user_count;
user_count = msg->getNumberOfBlocks("UserBlock");
for (S32 i = 0; i < user_count; i++)
{
msg->getData("UserBlock", i, "FirstName", firstname);
msg->getData("UserBlock", i, "LastName", lastname);
msg->getData("UserBlock", i, "Status", &status);
if (status & 0x01)
{
dialog_friends_add_friend(buffer, TRUE);
}
else
{
dialog_friends_add_friend(buffer, FALSE);
}
}
dialog_friends_done_adding();
}
*/
// this is not handled in processUpdateMessage
/*
void process_time_dilation(LLMessageSystem *msg, void **user_data)
{
// get the time_dilation
U16 foo;
msg->getData("TimeDilation", "TimeDilation", &foo);
F32 time_dilation = ((F32) foo) / 65535.f;
// get the pointer to the right region
U32 ip = msg->getSenderIP();
U32 port = msg->getSenderPort();
LLViewerRegion *regionp = LLWorld::getInstance()->getRegion(ip, port);
if (regionp)
{
regionp->setTimeDilation(time_dilation);
}
}
*/
void process_money_balance_reply( LLMessageSystem* msg, void** )
{
S32 balance = 0;
S32 credit = 0;
S32 committed = 0;
std::string desc;
LLUUID tid;
msg->getUUID("MoneyData", "TransactionID", tid);
msg->getS32("MoneyData", "MoneyBalance", balance);
msg->getS32("MoneyData", "SquareMetersCredit", credit);
msg->getS32("MoneyData", "SquareMetersCommitted", committed);
msg->getStringFast(_PREHASH_MoneyData, _PREHASH_Description, desc);
LL_INFOS("Messaging") << "L$, credit, committed: " << balance << " " << credit << " "
<< committed << LL_ENDL;
if (gStatusBar)
{
gStatusBar->setBalance(balance);
gStatusBar->setLandCredit(credit);
gStatusBar->setLandCommitted(committed);
}
if (desc.empty()
|| !gSavedSettings.getBOOL("NotifyMoneyChange"))
{
// ...nothing to display
return;
}
// Suppress duplicate messages about the same transaction
static std::deque<LLUUID> recent;
if (std::find(recent.rbegin(), recent.rend(), tid) != recent.rend())
{
return;
}
// Once the 'recent' container gets large enough, chop some
// off the beginning.
const U32 MAX_LOOKBACK = 30;
const S32 POP_FRONT_SIZE = 12;
if(recent.size() > MAX_LOOKBACK)
{
LL_DEBUGS("Messaging") << "Removing oldest transaction records" << LL_ENDL;
recent.erase(recent.begin(), recent.begin() + POP_FRONT_SIZE);
}
//LL_DEBUGS("Messaging") << "Pushing back transaction " << tid << LL_ENDL;
recent.push_back(tid);
if (msg->has("TransactionInfo"))
{
// ...message has extended info for localization
process_money_balance_reply_extended(msg);
}
else
{
// Only old dev grids will not supply the TransactionInfo block,
// so we can just use the hard-coded English string.
LLSD args;
args["MESSAGE"] = desc;
LLNotificationsUtil::add("SystemMessage", args);
}
}
static std::string reason_from_transaction_type(S32 transaction_type,
const std::string& item_desc)
{
// *NOTE: The keys for the reason strings are unusual because
// an earlier version of the code used English language strings
// extracted from hard-coded server English descriptions.
// Keeping them so we don't have to re-localize them.
switch (transaction_type)
{
case TRANS_OBJECT_SALE:
{
LLStringUtil::format_map_t arg;
arg["ITEM"] = item_desc;
return LLTrans::getString("for item", arg);
}
case TRANS_LAND_SALE:
return LLTrans::getString("for a parcel of land");
case TRANS_LAND_PASS_SALE:
return LLTrans::getString("for a land access pass");
case TRANS_GROUP_LAND_DEED:
return LLTrans::getString("for deeding land");
case TRANS_GROUP_CREATE:
return LLTrans::getString("to create a group");
case TRANS_GROUP_JOIN:
return LLTrans::getString("to join a group");
case TRANS_UPLOAD_CHARGE:
return LLTrans::getString("to upload");
case TRANS_CLASSIFIED_CHARGE:
return LLTrans::getString("to publish a classified ad");
// These have no reason to display, but are expected and should not
// generate warnings
case TRANS_GIFT:
case TRANS_PAY_OBJECT:
case TRANS_OBJECT_PAYS:
return std::string();
default:
llwarns << "Unknown transaction type "
<< transaction_type << llendl;
return std::string();
}
}
static void money_balance_group_notify(const LLUUID& group_id,
const std::string& name,
bool is_group,
std::string notification,
LLSD args,
LLSD payload)
{
// Message uses name SLURLs, don't actually have to substitute in
// the name. We're just making sure it's available.
// Notification is either PaymentReceived or PaymentSent
LLNotificationsUtil::add(notification, args, payload);
}
static void money_balance_avatar_notify(const LLUUID& agent_id,
const LLAvatarName& av_name,
std::string notification,
LLSD args,
LLSD payload)
{
// Message uses name SLURLs, don't actually have to substitute in
// the name. We're just making sure it's available.
// Notification is either PaymentReceived or PaymentSent
LLNotificationsUtil::add(notification, args, payload);
}
static void process_money_balance_reply_extended(LLMessageSystem* msg)
{
// Added in server 1.40 and viewer 2.1, support for localization
// and agent ids for name lookup.
S32 transaction_type = 0;
LLUUID source_id;
BOOL is_source_group = FALSE;
LLUUID dest_id;
BOOL is_dest_group = FALSE;
S32 amount = 0;
std::string item_description;
BOOL success = FALSE;
msg->getS32("TransactionInfo", "TransactionType", transaction_type);
msg->getUUID("TransactionInfo", "SourceID", source_id);
msg->getBOOL("TransactionInfo", "IsSourceGroup", is_source_group);
msg->getUUID("TransactionInfo", "DestID", dest_id);
msg->getBOOL("TransactionInfo", "IsDestGroup", is_dest_group);
msg->getS32("TransactionInfo", "Amount", amount);
msg->getString("TransactionInfo", "ItemDescription", item_description);
msg->getBOOL("MoneyData", "TransactionSuccess", success);
LL_INFOS("Money") << "MoneyBalanceReply source " << source_id
<< " dest " << dest_id
<< " type " << transaction_type
<< " item " << item_description << LL_ENDL;
if (source_id.isNull() && dest_id.isNull())
{
// this is a pure balance update, no notification required
return;
}
std::string source_slurl;
if (is_source_group)
{
source_slurl =
LLSLURL( "group", source_id, "inspect").getSLURLString();
}
else
{
source_slurl =
LLSLURL( "agent", source_id, "completename").getSLURLString();
}
std::string dest_slurl;
if (is_dest_group)
{
dest_slurl =
LLSLURL( "group", dest_id, "inspect").getSLURLString();
}
else
{
dest_slurl =
LLSLURL( "agent", dest_id, "completename").getSLURLString();
}
std::string reason =
reason_from_transaction_type(transaction_type, item_description);
LLStringUtil::format_map_t args;
args["REASON"] = reason; // could be empty
args["AMOUNT"] = llformat("%d", amount);
// Need to delay until name looked up, so need to know whether or not
// is group
bool is_name_group = false;
LLUUID name_id;
std::string message;
std::string notification;
LLSD final_args;
LLSD payload;
bool you_paid_someone = (source_id == gAgentID);
if (you_paid_someone)
{
args["NAME"] = dest_slurl;
is_name_group = is_dest_group;
name_id = dest_id;
if (!reason.empty())
{
if (dest_id.notNull())
{
message = success ? LLTrans::getString("you_paid_ldollars", args) :
LLTrans::getString("you_paid_failure_ldollars", args);
}
else
{
// transaction fee to the system, eg, to create a group
message = success ? LLTrans::getString("you_paid_ldollars_no_name", args) :
LLTrans::getString("you_paid_failure_ldollars_no_name", args);
}
}
else
{
if (dest_id.notNull())
{
message = success ? LLTrans::getString("you_paid_ldollars_no_reason", args) :
LLTrans::getString("you_paid_failure_ldollars_no_reason", args);
}
else
{
// no target, no reason, you just paid money
message = success ? LLTrans::getString("you_paid_ldollars_no_info", args) :
LLTrans::getString("you_paid_failure_ldollars_no_info", args);
}
}
final_args["MESSAGE"] = message;
notification = success ? "PaymentSent" : "PaymentFailure";
}
else {
// ...someone paid you
args["NAME"] = source_slurl;
is_name_group = is_source_group;
name_id = source_id;
if (!reason.empty())
{
message = LLTrans::getString("paid_you_ldollars", args);
}
else {
message = LLTrans::getString("paid_you_ldollars_no_reason", args);
}
final_args["MESSAGE"] = message;
// make notification loggable
payload["from_id"] = source_id;
notification = "PaymentReceived";
}
// Despite using SLURLs, wait until the name is available before
// showing the notification, otherwise the UI layout is strange and
// the user sees a "Loading..." message
if (is_name_group)
{
gCacheName->getGroup(name_id,
boost::bind(&money_balance_group_notify,
_1, _2, _3,
notification, final_args, payload));
}
else
{
LLAvatarNameCache::get(name_id, boost::bind(&money_balance_avatar_notify, _1, _2, notification, final_args, payload));
}
}
bool handle_prompt_for_maturity_level_change_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option)
{
// set the preference to the maturity of the region we're calling
U8 preferredMaturity = static_cast<U8>(notification["payload"]["_region_access"].asInteger());
gSavedSettings.setU32("PreferredMaturity", static_cast<U32>(preferredMaturity));
}
return false;
}
bool handle_prompt_for_maturity_level_change_and_reteleport_callback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option)
{
// set the preference to the maturity of the region we're calling
U8 preferredMaturity = static_cast<U8>(notification["payload"]["_region_access"].asInteger());
gSavedSettings.setU32("PreferredMaturity", static_cast<U32>(preferredMaturity));
gAgent.setMaturityRatingChangeDuringTeleport(preferredMaturity);
gAgent.restartFailedTeleportRequest();
}
else
{
gAgent.clearTeleportRequest();
}
return false;
}
// some of the server notifications need special handling. This is where we do that.
bool handle_special_notification(std::string notificationID, LLSD& llsdBlock)
{
U8 regionAccess = static_cast<U8>(llsdBlock["_region_access"].asInteger());
std::string regionMaturity = LLViewerRegion::accessToString(regionAccess);
LLStringUtil::toLower(regionMaturity);
llsdBlock["REGIONMATURITY"] = regionMaturity;
bool returnValue = false;
LLNotificationPtr maturityLevelNotification;
std::string notifySuffix = "_Notify";
if (regionAccess == SIM_ACCESS_MATURE)
{
if (gAgent.isTeen())
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock);
returnValue = true;
notifySuffix = "_NotifyAdultsOnly";
}
else if (gAgent.prefersPG())
{
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
returnValue = true;
}
else if (LLStringUtil::compareStrings(notificationID, "RegionEntryAccessBlocked") == 0)
{
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock);
returnValue = true;
}
}
else if (regionAccess == SIM_ACCESS_ADULT)
{
if (!gAgent.isAdult())
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock);
returnValue = true;
notifySuffix = "_NotifyAdultsOnly";
}
else if (gAgent.prefersPG() || gAgent.prefersMature())
{
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
returnValue = true;
}
else if (LLStringUtil::compareStrings(notificationID, "RegionEntryAccessBlocked") == 0)
{
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock);
returnValue = true;
}
}
if ((maturityLevelNotification == NULL) || maturityLevelNotification->isIgnored())
{
// Given a simple notification if no maturityLevelNotification is set or it is ignore
LLNotificationsUtil::add(notificationID + notifySuffix, llsdBlock);
}
return returnValue;
}
// some of the server notifications need special handling. This is where we do that.
bool handle_teleport_access_blocked(LLSD& llsdBlock)
{
std::string notificationID("TeleportEntryAccessBlocked");
U8 regionAccess = static_cast<U8>(llsdBlock["_region_access"].asInteger());
std::string regionMaturity = LLViewerRegion::accessToString(regionAccess);
LLStringUtil::toLower(regionMaturity);
llsdBlock["REGIONMATURITY"] = regionMaturity;
bool returnValue = false;
LLNotificationPtr maturityLevelNotification;
std::string notifySuffix = "_Notify";
if (regionAccess == SIM_ACCESS_MATURE)
{
if (gAgent.isTeen())
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock);
returnValue = true;
notifySuffix = "_NotifyAdultsOnly";
}
else if (gAgent.prefersPG())
{
if (gAgent.hasRestartableFailedTeleportRequest())
{
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback);
returnValue = true;
}
else
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
returnValue = true;
}
}
else
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
returnValue = true;
}
}
else if (regionAccess == SIM_ACCESS_ADULT)
{
if (!gAgent.isAdult())
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_AdultsOnlyContent", llsdBlock);
returnValue = true;
notifySuffix = "_NotifyAdultsOnly";
}
else if (gAgent.prefersPG() || gAgent.prefersMature())
{
if (gAgent.hasRestartableFailedTeleportRequest())
{
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_ChangeAndReTeleport", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_and_reteleport_callback);
returnValue = true;
}
else
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_Change", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
returnValue = true;
}
}
else
{
gAgent.clearTeleportRequest();
maturityLevelNotification = LLNotificationsUtil::add(notificationID+"_PreferencesOutOfSync", llsdBlock, llsdBlock, handle_prompt_for_maturity_level_change_callback);
returnValue = true;
}
}
if ((maturityLevelNotification == NULL) || maturityLevelNotification->isIgnored())
{
// Given a simple notification if no maturityLevelNotification is set or it is ignore
LLNotificationsUtil::add(notificationID + notifySuffix, llsdBlock);
}
return returnValue;
}
bool attempt_standard_notification(LLMessageSystem* msgsystem)
{
// if we have additional alert data
if (msgsystem->has(_PREHASH_AlertInfo) && msgsystem->getNumberOfBlocksFast(_PREHASH_AlertInfo) > 0)
{
// notification was specified using the new mechanism, so we can just handle it here
std::string notificationID;
msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
if (!LLNotifications::getInstance()->templateExists(notificationID))
{
return false;
}
std::string llsdRaw;
LLSD llsdBlock;
msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, notificationID);
msgsystem->getStringFast(_PREHASH_AlertInfo, _PREHASH_ExtraParams, llsdRaw);
if (llsdRaw.length())
{
std::istringstream llsdData(llsdRaw);
if (!LLSDSerialize::deserialize(llsdBlock, llsdData, llsdRaw.length()))
{
llwarns << "attempt_standard_notification: Attempted to read notification parameter data into LLSD but failed:" << llsdRaw << llendl;
}
}
if (
(notificationID == "RegionEntryAccessBlocked") ||
(notificationID == "LandClaimAccessBlocked") ||
(notificationID == "LandBuyAccessBlocked")
)
{
/*---------------------------------------------------------------------
(Commented so a grep will find the notification strings, since
we construct them on the fly; if you add additional notifications,
please update the comment.)
Could throw any of the following notifications:
RegionEntryAccessBlocked
RegionEntryAccessBlocked_Notify
RegionEntryAccessBlocked_NotifyAdultsOnly
RegionEntryAccessBlocked_Change
RegionEntryAccessBlocked_AdultsOnlyContent
RegionEntryAccessBlocked_ChangeAndReTeleport
LandClaimAccessBlocked
LandClaimAccessBlocked_Notify
LandClaimAccessBlocked_NotifyAdultsOnly
LandClaimAccessBlocked_Change
LandClaimAccessBlocked_AdultsOnlyContent
LandBuyAccessBlocked
LandBuyAccessBlocked_Notify
LandBuyAccessBlocked_NotifyAdultsOnly
LandBuyAccessBlocked_Change
LandBuyAccessBlocked_AdultsOnlyContent
-----------------------------------------------------------------------*/
if (handle_special_notification(notificationID, llsdBlock))
{
return true;
}
}
// HACK -- handle callbacks for specific alerts.
if( notificationID == "HomePositionSet" )
{
// save the home location image to disk
std::string snap_filename = gDirUtilp->getLindenUserDir();
snap_filename += gDirUtilp->getDirDelimiter();
snap_filename += SCREEN_HOME_FILENAME;
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
}
if (notificationID == "RegionRestartMinutes" ||
notificationID == "RegionRestartSeconds")
{
S32 seconds;
if (notificationID == "RegionRestartMinutes")
{
seconds = 60 * static_cast<S32>(llsdBlock["MINUTES"].asInteger());
}
else
{
seconds = static_cast<S32>(llsdBlock["SECONDS"].asInteger());
}
LLFloaterRegionRestarting* floaterp = LLFloaterReg::findTypedInstance<LLFloaterRegionRestarting>("region_restarting");
if (floaterp)
{
LLFloaterRegionRestarting::updateTime(seconds);
}
else
{
LLSD params;
params["NAME"] = llsdBlock["NAME"];
params["SECONDS"] = (LLSD::Integer)seconds;
LLFloaterRegionRestarting* restarting_floater = dynamic_cast<LLFloaterRegionRestarting*>(LLFloaterReg::showInstance("region_restarting", params));
if(restarting_floater)
{
restarting_floater->center();
}
}
make_ui_sound("UISndRestart");
}
LLNotificationsUtil::add(notificationID, llsdBlock);
return true;
}
return false;
}
static void process_special_alert_messages(const std::string & message)
{
// Do special handling for alert messages. This is a legacy hack, and any actual displayed
// text should be altered in the notifications.xml files.
if ( message == "You died and have been teleported to your home location")
{
LLViewerStats::getInstance()->incStat(LLViewerStats::ST_KILLED_COUNT);
}
else if( message == "Home position set." )
{
// save the home location image to disk
std::string snap_filename = gDirUtilp->getLindenUserDir();
snap_filename += gDirUtilp->getDirDelimiter();
snap_filename += SCREEN_HOME_FILENAME;
gViewerWindow->saveSnapshot(snap_filename, gViewerWindow->getWindowWidthRaw(), gViewerWindow->getWindowHeightRaw(), FALSE, FALSE);
}
}
void process_agent_alert_message(LLMessageSystem* msgsystem, void** user_data)
{
// make sure the cursor is back to the usual default since the
// alert is probably due to some kind of error.
gViewerWindow->getWindow()->resetBusyCount();
std::string message;
msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, message);
process_special_alert_messages(message);
if (!attempt_standard_notification(msgsystem))
{
BOOL modal = FALSE;
msgsystem->getBOOL("AlertData", "Modal", modal);
process_alert_core(message, modal);
}
}
// The only difference between this routine and the previous is the fact that
// for this routine, the modal parameter is always false. Sadly, for the message
// handled by this routine, there is no "Modal" parameter on the message, and
// there's no API to tell if a message has the given parameter or not.
// So we can't handle the messages with the same handler.
void process_alert_message(LLMessageSystem *msgsystem, void **user_data)
{
// make sure the cursor is back to the usual default since the
// alert is probably due to some kind of error.
gViewerWindow->getWindow()->resetBusyCount();
std::string message;
msgsystem->getStringFast(_PREHASH_AlertData, _PREHASH_Message, message);
process_special_alert_messages(message);
if (!attempt_standard_notification(msgsystem))
{
BOOL modal = FALSE;
process_alert_core(message, modal);
}
}
bool handle_not_age_verified_alert(const std::string &pAlertName)
{
LLNotificationPtr notification = LLNotificationsUtil::add(pAlertName);
if ((notification == NULL) || notification->isIgnored())
{
LLNotificationsUtil::add(pAlertName + "_Notify");
}
return true;
}
bool handle_special_alerts(const std::string &pAlertName)
{
bool isHandled = false;
if (LLStringUtil::compareStrings(pAlertName, "NotAgeVerified") == 0)
{
isHandled = handle_not_age_verified_alert(pAlertName);
}
return isHandled;
}
void process_alert_core(const std::string& message, BOOL modal)
{
const std::string ALERT_PREFIX("ALERT: ");
const std::string NOTIFY_PREFIX("NOTIFY: ");
if (message.find(ALERT_PREFIX) == 0)
{
// Allow the server to spawn a named alert so that server alerts can be
// translated out of English.
std::string alert_name(message.substr(ALERT_PREFIX.length()));
if (!handle_special_alerts(alert_name))
{
LLNotificationsUtil::add(alert_name);
}
}
else if (message.find(NOTIFY_PREFIX) == 0)
{
// Allow the server to spawn a named notification so that server notifications can be
// translated out of English.
std::string notify_name(message.substr(NOTIFY_PREFIX.length()));
LLNotificationsUtil::add(notify_name);
}
else if (message[0] == '/')
{
// System message is important, show in upper-right box not tip
std::string text(message.substr(1));
LLSD args;
// *NOTE: If the text from the server ever changes this line will need to be adjusted.
std::string restart_cancelled = "Region restart cancelled.";
if (text.substr(0, restart_cancelled.length()) == restart_cancelled)
{
LLFloaterRegionRestarting::close();
}
std::string new_msg =LLNotifications::instance().getGlobalString(text);
args["MESSAGE"] = new_msg;
LLNotificationsUtil::add("SystemMessage", args);
}
else if (modal)
{
LLSD args;
std::string new_msg =LLNotifications::instance().getGlobalString(message);
args["ERROR_MESSAGE"] = new_msg;
LLNotificationsUtil::add("ErrorMessage", args);
}
else
{
// Hack fix for EXP-623 (blame fix on RN :)) to avoid a sim deploy
const std::string AUTOPILOT_CANCELED_MSG("Autopilot canceled");
if (message.find(AUTOPILOT_CANCELED_MSG) == std::string::npos )
{
LLSD args;
std::string new_msg =LLNotifications::instance().getGlobalString(message);
std::string localized_msg;
bool is_message_localized = LLTrans::findString(localized_msg, new_msg);
args["MESSAGE"] = is_message_localized ? localized_msg : new_msg;
LLNotificationsUtil::add("SystemMessageTip", args);
}
}
}
mean_collision_list_t gMeanCollisionList;
time_t gLastDisplayedTime = 0;
void handle_show_mean_events(void *)
{
LLFloaterReg::showInstance("bumps");
//LLFloaterBump::showInstance();
}
void mean_name_callback(const LLUUID &id, const std::string& full_name, bool is_group)
{
static const U32 max_collision_list_size = 20;
if (gMeanCollisionList.size() > max_collision_list_size)
{
mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
for (U32 i=0; i<max_collision_list_size; i++) iter++;
for_each(iter, gMeanCollisionList.end(), DeletePointer());
gMeanCollisionList.erase(iter, gMeanCollisionList.end());
}
for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
iter != gMeanCollisionList.end(); ++iter)
{
LLMeanCollisionData *mcd = *iter;
if (mcd->mPerp == id)
{
mcd->mFullName = full_name;
}
}
}
void process_mean_collision_alert_message(LLMessageSystem *msgsystem, void **user_data)
{
if (gAgent.inPrelude())
{
// In prelude, bumping is OK. This dialog is rather confusing to
// newbies, so we don't show it. Drop the packet on the floor.
return;
}
// make sure the cursor is back to the usual default since the
// alert is probably due to some kind of error.
gViewerWindow->getWindow()->resetBusyCount();
LLUUID perp;
U32 time;
U8 u8type;
EMeanCollisionType type;
F32 mag;
S32 i, num = msgsystem->getNumberOfBlocks(_PREHASH_MeanCollision);
for (i = 0; i < num; i++)
{
msgsystem->getUUIDFast(_PREHASH_MeanCollision, _PREHASH_Perp, perp);
msgsystem->getU32Fast(_PREHASH_MeanCollision, _PREHASH_Time, time);
msgsystem->getF32Fast(_PREHASH_MeanCollision, _PREHASH_Mag, mag);
msgsystem->getU8Fast(_PREHASH_MeanCollision, _PREHASH_Type, u8type);
type = (EMeanCollisionType)u8type;
BOOL b_found = FALSE;
for (mean_collision_list_t::iterator iter = gMeanCollisionList.begin();
iter != gMeanCollisionList.end(); ++iter)
{
LLMeanCollisionData *mcd = *iter;
if ((mcd->mPerp == perp) && (mcd->mType == type))
{
mcd->mTime = time;
mcd->mMag = mag;
b_found = TRUE;
break;
}
}
if (!b_found)
{
LLMeanCollisionData *mcd = new LLMeanCollisionData(gAgentID, perp, time, type, mag);
gMeanCollisionList.push_front(mcd);
gCacheName->get(perp, false, boost::bind(&mean_name_callback, _1, _2, _3));
}
}
}
void process_frozen_message(LLMessageSystem *msgsystem, void **user_data)
{
// make sure the cursor is back to the usual default since the
// alert is probably due to some kind of error.
gViewerWindow->getWindow()->resetBusyCount();
BOOL b_frozen;
msgsystem->getBOOL("FrozenData", "Data", b_frozen);
// TODO: make being frozen change view
if (b_frozen)
{
}
else
{
}
}
// do some extra stuff once we get our economy data
void process_economy_data(LLMessageSystem *msg, void** /*user_data*/)
{
LLGlobalEconomy::processEconomyData(msg, LLGlobalEconomy::Singleton::getInstance());
S32 upload_cost = LLGlobalEconomy::Singleton::getInstance()->getPriceUpload();
LL_INFOS_ONCE("Messaging") << "EconomyData message arrived; upload cost is L$" << upload_cost << LL_ENDL;
gMenuHolder->getChild<LLUICtrl>("Upload Image")->setLabelArg("[COST]", llformat("%d", upload_cost));
gMenuHolder->getChild<LLUICtrl>("Upload Sound")->setLabelArg("[COST]", llformat("%d", upload_cost));
gMenuHolder->getChild<LLUICtrl>("Upload Animation")->setLabelArg("[COST]", llformat("%d", upload_cost));
gMenuHolder->getChild<LLUICtrl>("Bulk Upload")->setLabelArg("[COST]", llformat("%d", upload_cost));
}
void notify_cautioned_script_question(const LLSD& notification, const LLSD& response, S32 orig_questions, BOOL granted)
{
// only continue if at least some permissions were requested
if (orig_questions)
{
// check to see if the person we are asking
// "'[OBJECTNAME]', an object owned by '[OWNERNAME]',
// located in [REGIONNAME] at [REGIONPOS],
// has been <granted|denied> permission to: [PERMISSIONS]."
LLUIString notice(LLTrans::getString(granted ? "ScriptQuestionCautionChatGranted" : "ScriptQuestionCautionChatDenied"));
// always include the object name and owner name
notice.setArg("[OBJECTNAME]", notification["payload"]["object_name"].asString());
notice.setArg("[OWNERNAME]", notification["payload"]["owner_name"].asString());
// try to lookup viewerobject that corresponds to the object that
// requested permissions (here, taskid->requesting object id)
BOOL foundpos = FALSE;
LLViewerObject* viewobj = gObjectList.findObject(notification["payload"]["task_id"].asUUID());
if (viewobj)
{
// found the viewerobject, get it's position in its region
LLVector3 objpos(viewobj->getPosition());
// try to lookup the name of the region the object is in
LLViewerRegion* viewregion = viewobj->getRegion();
if (viewregion)
{
// got the region, so include the region and 3d coordinates of the object
notice.setArg("[REGIONNAME]", viewregion->getName());
std::string formatpos = llformat("%.1f, %.1f,%.1f", objpos[VX], objpos[VY], objpos[VZ]);
notice.setArg("[REGIONPOS]", formatpos);
foundpos = TRUE;
}
}
if (!foundpos)
{
// unable to determine location of the object
notice.setArg("[REGIONNAME]", "(unknown region)");
notice.setArg("[REGIONPOS]", "(unknown position)");
}
// check each permission that was requested, and list each
// permission that has been flagged as a caution permission
BOOL caution = FALSE;
S32 count = 0;
std::string perms;
for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
{
if ((orig_questions & LSCRIPTRunTimePermissionBits[i]) && SCRIPT_QUESTION_IS_CAUTION[i])
{
count++;
caution = TRUE;
// add a comma before the permission description if it is not the first permission
// added to the list or the last permission to check
if ((count > 1) && (i < SCRIPT_PERMISSION_EOF))
{
perms.append(", ");
}
perms.append(LLTrans::getString(SCRIPT_QUESTIONS[i]));
}
}
notice.setArg("[PERMISSIONS]", perms);
// log a chat message as long as at least one requested permission
// is a caution permission
if (caution)
{
LLChat chat(notice.getString());
// LLFloaterChat::addChat(chat, FALSE, FALSE);
}
}
}
void script_question_mute(const LLUUID& item_id, const std::string& object_name);
bool unknown_script_question_cb(const LLSD& notification, const LLSD& response)
{
// Only care if they muted the object here.
if ( response["Mute"] ) // mute
{
LLUUID task_id = notification["payload"]["task_id"].asUUID();
script_question_mute(task_id,notification["payload"]["object_name"].asString());
}
return false;
}
bool script_question_cb(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLMessageSystem *msg = gMessageSystem;
S32 orig = notification["payload"]["questions"].asInteger();
S32 new_questions = orig;
if (response["Details"])
{
// respawn notification...
LLNotificationsUtil::add(notification["name"], notification["substitutions"], notification["payload"]);
// ...with description on top
LLNotificationsUtil::add("DebitPermissionDetails");
return false;
}
// check whether permissions were granted or denied
BOOL allowed = TRUE;
// the "yes/accept" button is the first button in the template, making it button 0
// if any other button was clicked, the permissions were denied
if (option != 0)
{
new_questions = 0;
allowed = FALSE;
}
LLUUID task_id = notification["payload"]["task_id"].asUUID();
LLUUID item_id = notification["payload"]["item_id"].asUUID();
// reply with the permissions granted or denied
msg->newMessageFast(_PREHASH_ScriptAnswerYes);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_Data);
msg->addUUIDFast(_PREHASH_TaskID, task_id);
msg->addUUIDFast(_PREHASH_ItemID, item_id);
msg->addS32Fast(_PREHASH_Questions, new_questions);
msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
// only log a chat message if caution prompts are enabled
if (gSavedSettings.getBOOL("PermissionsCautionEnabled"))
{
// log a chat message, if appropriate
notify_cautioned_script_question(notification, response, orig, allowed);
}
if ( response["Mute"] ) // mute
{
script_question_mute(task_id,notification["payload"]["object_name"].asString());
}
return false;
}
void script_question_mute(const LLUUID& task_id, const std::string& object_name)
{
LLMuteList::getInstance()->add(LLMute(task_id, object_name, LLMute::OBJECT));
// purge the message queue of any previously queued requests from the same source. DEV-4879
class OfferMatcher : public LLNotificationsUI::LLScreenChannel::Matcher
{
public:
OfferMatcher(const LLUUID& to_block) : blocked_id(to_block) {}
bool matches(const LLNotificationPtr notification) const
{
if (notification->getName() == "ScriptQuestionCaution"
|| notification->getName() == "ScriptQuestion"
|| notification->getName() == "UnknownScriptQuestion")
{
return (notification->getPayload()["task_id"].asUUID() == blocked_id);
}
return false;
}
private:
const LLUUID& blocked_id;
};
LLNotificationsUI::LLChannelManager::getInstance()->killToastsFromChannel(LLUUID(
gSavedSettings.getString("NotificationChannelUUID")), OfferMatcher(task_id));
}
static LLNotificationFunctorRegistration script_question_cb_reg_1("ScriptQuestion", script_question_cb);
static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestionCaution", script_question_cb);
static LLNotificationFunctorRegistration unknown_script_question_cb_reg("UnknownScriptQuestion", unknown_script_question_cb);
void process_script_question(LLMessageSystem *msg, void **user_data)
{
// *TODO: Translate owner name -> [FIRST] [LAST]
LLHost sender = msg->getSender();
LLUUID taskid;
LLUUID itemid;
S32 questions;
std::string object_name;
std::string owner_name;
// taskid -> object key of object requesting permissions
msg->getUUIDFast(_PREHASH_Data, _PREHASH_TaskID, taskid );
// itemid -> script asset key of script requesting permissions
msg->getUUIDFast(_PREHASH_Data, _PREHASH_ItemID, itemid );
msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectName, object_name);
msg->getStringFast(_PREHASH_Data, _PREHASH_ObjectOwner, owner_name);
msg->getS32Fast(_PREHASH_Data, _PREHASH_Questions, questions );
// Special case. If the objects are owned by this agent, throttle per-object instead
// of per-owner. It's common for residents to reset a ton of scripts that re-request
// permissions, as with tier boxes. UUIDs can't be valid agent names and vice-versa,
// so we'll reuse the same namespace for both throttle types.
std::string throttle_name = owner_name;
std::string self_name;
LLAgentUI::buildFullname( self_name );
if( owner_name == self_name )
{
throttle_name = taskid.getString();
}
// don't display permission requests if this object is muted
if (LLMuteList::getInstance()->isMuted(taskid)) return;
// throttle excessive requests from any specific user's scripts
typedef LLKeyThrottle<std::string> LLStringThrottle;
static LLStringThrottle question_throttle( LLREQUEST_PERMISSION_THROTTLE_LIMIT, LLREQUEST_PERMISSION_THROTTLE_INTERVAL );
switch (question_throttle.noteAction(throttle_name))
{
case LLStringThrottle::THROTTLE_NEWLY_BLOCKED:
LL_INFOS("Messaging") << "process_script_question throttled"
<< " owner_name:" << owner_name
<< LL_ENDL;
// Fall through
case LLStringThrottle::THROTTLE_BLOCKED:
// Escape altogether until we recover
return;
case LLStringThrottle::THROTTLE_OK:
break;
}
std::string script_question;
if (questions)
{
BOOL caution = FALSE;
S32 count = 0;
LLSD args;
args["OBJECTNAME"] = object_name;
args["NAME"] = LLCacheName::cleanFullName(owner_name);
S32 known_questions = 0;
BOOL has_not_only_debit = questions ^ LSCRIPTRunTimePermissionBits[SCRIPT_PERMISSION_DEBIT];
// check the received permission flags against each permission
for (S32 i = 0; i < SCRIPT_PERMISSION_EOF; i++)
{
if (questions & LSCRIPTRunTimePermissionBits[i])
{
count++;
known_questions |= LSCRIPTRunTimePermissionBits[i];
// check whether permission question should cause special caution dialog
caution |= (SCRIPT_QUESTION_IS_CAUTION[i]);
if (("ScriptTakeMoney" == SCRIPT_QUESTIONS[i]) && has_not_only_debit)
continue;
script_question += " " + LLTrans::getString(SCRIPT_QUESTIONS[i]) + "\n";
}
}
args["QUESTIONS"] = script_question;
if (known_questions != questions)
{ // This is in addition to the normal dialog.
LLSD payload;
payload["task_id"] = taskid;
payload["item_id"] = itemid;
payload["object_name"] = object_name;
args["DOWNLOADURL"] = LLTrans::getString("ViewerDownloadURL");
LLNotificationsUtil::add("UnknownScriptQuestion",args,payload);
}
if (known_questions)
{
LLSD payload;
payload["task_id"] = taskid;
payload["item_id"] = itemid;
payload["sender"] = sender.getIPandPort();
payload["questions"] = known_questions;
payload["object_name"] = object_name;
payload["owner_name"] = owner_name;
// check whether cautions are even enabled or not
if (gSavedSettings.getBOOL("PermissionsCautionEnabled"))
{
if (caution)
{
args["FOOTERTEXT"] = (count > 1) ? LLTrans::getString("AdditionalPermissionsRequestHeader") + "\n\n" + script_question : "";
}
// display the caution permissions prompt
LLNotificationsUtil::add(caution ? "ScriptQuestionCaution" : "ScriptQuestion", args, payload);
}
else
{
// fall back to default behavior if cautions are entirely disabled
LLNotificationsUtil::add("ScriptQuestion", args, payload);
}
}
}
}
void process_derez_container(LLMessageSystem *msg, void**)
{
LL_WARNS("Messaging") << "call to deprecated process_derez_container" << LL_ENDL;
}
void container_inventory_arrived(LLViewerObject* object,
LLInventoryObject::object_list_t* inventory,
S32 serial_num,
void* data)
{
LL_DEBUGS("Messaging") << "container_inventory_arrived()" << LL_ENDL;
if( gAgentCamera.cameraMouselook() )
{
gAgentCamera.changeCameraToDefault();
}
LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel();
if (inventory->size() > 2)
{
// create a new inventory category to put this in
LLUUID cat_id;
cat_id = gInventory.createNewCategory(gInventory.getRootFolderID(),
LLFolderType::FT_NONE,
LLTrans::getString("AcquiredItems"));
LLInventoryObject::object_list_t::const_iterator it = inventory->begin();
LLInventoryObject::object_list_t::const_iterator end = inventory->end();
for ( ; it != end; ++it)
{
if ((*it)->getType() != LLAssetType::AT_CATEGORY)
{
LLInventoryObject* obj = (LLInventoryObject*)(*it);
LLInventoryItem* item = (LLInventoryItem*)(obj);
LLUUID item_id;
item_id.generate();
time_t creation_date_utc = time_corrected();
LLPointer<LLViewerInventoryItem> new_item
= new LLViewerInventoryItem(item_id,
cat_id,
item->getPermissions(),
item->getAssetUUID(),
item->getType(),
item->getInventoryType(),
item->getName(),
item->getDescription(),
LLSaleInfo::DEFAULT,
item->getFlags(),
creation_date_utc);
new_item->updateServer(TRUE);
gInventory.updateItem(new_item);
}
}
gInventory.notifyObservers();
if(active_panel)
{
active_panel->setSelection(cat_id, TAKE_FOCUS_NO);
}
}
else if (inventory->size() == 2)
{
// we're going to get one fake root category as well as the
// one actual object
LLInventoryObject::object_list_t::iterator it = inventory->begin();
if ((*it)->getType() == LLAssetType::AT_CATEGORY)
{
++it;
}
LLInventoryItem* item = (LLInventoryItem*)((LLInventoryObject*)(*it));
const LLUUID category = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(item->getType()));
LLUUID item_id;
item_id.generate();
time_t creation_date_utc = time_corrected();
LLPointer<LLViewerInventoryItem> new_item
= new LLViewerInventoryItem(item_id, category,
item->getPermissions(),
item->getAssetUUID(),
item->getType(),
item->getInventoryType(),
item->getName(),
item->getDescription(),
LLSaleInfo::DEFAULT,
item->getFlags(),
creation_date_utc);
new_item->updateServer(TRUE);
gInventory.updateItem(new_item);
gInventory.notifyObservers();
if(active_panel)
{
active_panel->setSelection(item_id, TAKE_FOCUS_NO);
}
}
// we've got the inventory, now delete this object if this was a take
BOOL delete_object = (BOOL)(intptr_t)data;
LLViewerRegion *region = gAgent.getRegion();
if (delete_object && region)
{
gMessageSystem->newMessageFast(_PREHASH_ObjectDelete);
gMessageSystem->nextBlockFast(_PREHASH_AgentData);
gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
const U8 NO_FORCE = 0;
gMessageSystem->addU8Fast(_PREHASH_Force, NO_FORCE);
gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID());
gMessageSystem->sendReliable(region->getHost());
}
}
// method to format the time.
std::string formatted_time(const time_t& the_time)
{
std::string dateStr = "["+LLTrans::getString("LTimeWeek")+"] ["
+LLTrans::getString("LTimeMonth")+"] ["
+LLTrans::getString("LTimeDay")+"] ["
+LLTrans::getString("LTimeHour")+"]:["
+LLTrans::getString("LTimeMin")+"]:["
+LLTrans::getString("LTimeSec")+"] ["
+LLTrans::getString("LTimeYear")+"]";
LLSD substitution;
substitution["datetime"] = (S32) the_time;
LLStringUtil::format (dateStr, substitution);
return dateStr;
}
void process_teleport_failed(LLMessageSystem *msg, void**)
{
std::string reason;
std::string big_reason;
LLSD args;
// Let the interested parties know that teleport failed.
LLViewerParcelMgr::getInstance()->onTeleportFailed();
// if we have additional alert data
if (msg->has(_PREHASH_AlertInfo) && msg->getSizeFast(_PREHASH_AlertInfo, _PREHASH_Message) > 0)
{
// Get the message ID
msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_Message, reason);
big_reason = LLAgent::sTeleportErrorMessages[reason];
if ( big_reason.size() > 0 )
{ // Substitute verbose reason from the local map
args["REASON"] = big_reason;
}
else
{ // Nothing found in the map - use what the server returned in the original message block
msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason);
args["REASON"] = reason;
}
LLSD llsd_block;
std::string llsd_raw;
msg->getStringFast(_PREHASH_AlertInfo, _PREHASH_ExtraParams, llsd_raw);
if (llsd_raw.length())
{
std::istringstream llsd_data(llsd_raw);
if (!LLSDSerialize::deserialize(llsd_block, llsd_data, llsd_raw.length()))
{
llwarns << "process_teleport_failed: Attempted to read alert parameter data into LLSD but failed:" << llsd_raw << llendl;
}
else
{
// change notification name in this special case
if (handle_teleport_access_blocked(llsd_block))
{
if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
{
gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
}
return;
}
}
}
}
else
{
msg->getStringFast(_PREHASH_Info, _PREHASH_Reason, reason);
big_reason = LLAgent::sTeleportErrorMessages[reason];
if ( big_reason.size() > 0 )
{ // Substitute verbose reason from the local map
args["REASON"] = big_reason;
}
else
{ // Nothing found in the map - use what the server returned
args["REASON"] = reason;
}
}
LLNotificationsUtil::add("CouldNotTeleportReason", args);
if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
{
gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
}
}
void process_teleport_local(LLMessageSystem *msg,void**)
{
LLUUID agent_id;
msg->getUUIDFast(_PREHASH_Info, _PREHASH_AgentID, agent_id);
if (agent_id != gAgent.getID())
{
LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL;
return;
}
U32 location_id;
LLVector3 pos, look_at;
U32 teleport_flags;
msg->getU32Fast(_PREHASH_Info, _PREHASH_LocationID, location_id);
msg->getVector3Fast(_PREHASH_Info, _PREHASH_Position, pos);
msg->getVector3Fast(_PREHASH_Info, _PREHASH_LookAt, look_at);
msg->getU32Fast(_PREHASH_Info, _PREHASH_TeleportFlags, teleport_flags);
if( gAgent.getTeleportState() != LLAgent::TELEPORT_NONE )
{
if( gAgent.getTeleportState() == LLAgent::TELEPORT_LOCAL )
{
// To prevent TeleportStart messages re-activating the progress screen right
// after tp, keep the teleport state and let progress screen clear it after a short delay
// (progress screen is active but not visible) *TODO: remove when SVC-5290 is fixed
gTeleportDisplayTimer.reset();
gTeleportDisplay = TRUE;
}
else
{
gAgent.setTeleportState( LLAgent::TELEPORT_NONE );
}
}
// Sim tells us whether the new position is off the ground
if (teleport_flags & TELEPORT_FLAGS_IS_FLYING)
{
gAgent.setFlying(TRUE);
}
else
{
gAgent.setFlying(FALSE);
}
gAgent.setPositionAgent(pos);
gAgentCamera.slamLookAt(look_at);
if ( !(gAgent.getTeleportKeepsLookAt() && LLViewerJoystick::getInstance()->getOverrideCamera()) )
{
gAgentCamera.resetView(TRUE, TRUE);
}
// send camera update to new region
gAgentCamera.updateCamera();
send_agent_update(TRUE, TRUE);
// Let the interested parties know we've teleported.
// Vadim *HACK: Agent position seems to get reset (to render position?)
// on each frame, so we have to pass the new position manually.
LLViewerParcelMgr::getInstance()->onTeleportFinished(true, gAgent.getPosGlobalFromAgent(pos));
}
void send_simple_im(const LLUUID& to_id,
const std::string& message,
EInstantMessage dialog,
const LLUUID& id)
{
std::string my_name;
LLAgentUI::buildFullname(my_name);
send_improved_im(to_id,
my_name,
message,
IM_ONLINE,
dialog,
id,
NO_TIMESTAMP,
(U8*)EMPTY_BINARY_BUCKET,
EMPTY_BINARY_BUCKET_SIZE);
}
void send_group_notice(const LLUUID& group_id,
const std::string& subject,
const std::string& message,
const LLInventoryItem* item)
{
// Put this notice into an instant message form.
// This will mean converting the item to a binary bucket,
// and the subject/message into a single field.
std::string my_name;
LLAgentUI::buildFullname(my_name);
// Combine subject + message into a single string.
std::ostringstream subject_and_message;
// TODO: turn all existing |'s into ||'s in subject and message.
subject_and_message << subject << "|" << message;
// Create an empty binary bucket.
U8 bin_bucket[MAX_INVENTORY_BUFFER_SIZE];
U8* bucket_to_send = bin_bucket;
bin_bucket[0] = '\0';
S32 bin_bucket_size = EMPTY_BINARY_BUCKET_SIZE;
// If there is an item being sent, pack it into the binary bucket.
if (item)
{
LLSD item_def;
item_def["item_id"] = item->getUUID();
item_def["owner_id"] = item->getPermissions().getOwner();
std::ostringstream ostr;
LLSDSerialize::serialize(item_def, ostr, LLSDSerialize::LLSD_XML);
bin_bucket_size = ostr.str().copy(
(char*)bin_bucket, ostr.str().size());
bin_bucket[bin_bucket_size] = '\0';
}
else
{
bucket_to_send = (U8*) EMPTY_BINARY_BUCKET;
}
send_improved_im(
group_id,
my_name,
subject_and_message.str(),
IM_ONLINE,
IM_GROUP_NOTICE,
LLUUID::null,
NO_TIMESTAMP,
bucket_to_send,
bin_bucket_size);
}
void send_lures(const LLSD& notification, const LLSD& response)
{
std::string text = response["message"].asString();
LLSLURL slurl;
LLAgentUI::buildSLURL(slurl);
text.append("\r\n").append(slurl.getSLURLString());
LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_StartLure);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_Info);
msg->addU8Fast(_PREHASH_LureType, (U8)0); // sim will fill this in.
msg->addStringFast(_PREHASH_Message, text);
for(LLSD::array_const_iterator it = notification["payload"]["ids"].beginArray();
it != notification["payload"]["ids"].endArray();
++it)
{
LLUUID target_id = it->asUUID();
msg->nextBlockFast(_PREHASH_TargetData);
msg->addUUIDFast(_PREHASH_TargetID, target_id);
// Record the offer.
{
std::string target_name;
gCacheName->getFullName(target_id, target_name); // for im log filenames
LLSD args;
args["TO_NAME"] = LLSLURL("agent", target_id, "displayname").getSLURLString();;
LLSD payload;
//*TODO please rewrite all keys to the same case, lower or upper
payload["from_id"] = target_id;
payload["SUPPRESS_TOAST"] = true;
LLNotificationsUtil::add("TeleportOfferSent", args, payload);
// Add the recepient to the recent people list.
LLRecentPeople::instance().add(target_id);
}
}
gAgent.sendReliableMessage();
}
bool handle_lure_callback(const LLSD& notification, const LLSD& response)
{
static const unsigned OFFER_RECIPIENT_LIMIT = 250;
if(notification["payload"]["ids"].size() > OFFER_RECIPIENT_LIMIT)
{
// More than OFFER_RECIPIENT_LIMIT targets will overload the message
// producing an llerror.
LLSD args;
args["OFFERS"] = notification["payload"]["ids"].size();
args["LIMIT"] = static_cast<int>(OFFER_RECIPIENT_LIMIT);
LLNotificationsUtil::add("TooManyTeleportOffers", args);
return false;
}
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if(0 == option)
{
send_lures(notification, response);
}
return false;
}
void handle_lure(const LLUUID& invitee)
{
LLDynamicArray<LLUUID> ids;
ids.push_back(invitee);
handle_lure(ids);
}
// Prompt for a message to the invited user.
void handle_lure(const uuid_vec_t& ids)
{
if (ids.empty()) return;
if (!gAgent.getRegion()) return;
LLSD edit_args;
edit_args["REGION"] = gAgent.getRegion()->getName();
LLSD payload;
for (LLDynamicArray<LLUUID>::const_iterator it = ids.begin();
it != ids.end();
++it)
{
payload["ids"].append(*it);
}
if (gAgent.isGodlike())
{
LLNotificationsUtil::add("OfferTeleportFromGod", edit_args, payload, handle_lure_callback);
}
else
{
LLNotificationsUtil::add("OfferTeleport", edit_args, payload, handle_lure_callback);
}
}
bool teleport_request_callback(const LLSD& notification, const LLSD& response)
{
LLUUID from_id = notification["payload"]["from_id"].asUUID();
if(from_id.isNull())
{
llwarns << "from_id is NULL" << llendl;
return false;
}
std::string from_name;
gCacheName->getFullName(from_id, from_name);
if(LLMuteList::getInstance()->isMuted(from_id) && !LLMuteList::getInstance()->isLinden(from_name))
{
return false;
}
S32 option = 0;
if (response.isInteger())
{
option = response.asInteger();
}
else
{
option = LLNotificationsUtil::getSelectedOption(notification, response);
}
switch(option)
{
// Yes
case 0:
{
LLSD dummy_notification;
dummy_notification["payload"]["ids"][0] = from_id;
LLSD dummy_response;
dummy_response["message"] = response["message"];
send_lures(dummy_notification, dummy_response);
}
break;
// No
case 1:
default:
break;
}
return false;
}
static LLNotificationFunctorRegistration teleport_request_callback_reg("TeleportRequest", teleport_request_callback);
void send_improved_im(const LLUUID& to_id,
const std::string& name,
const std::string& message,
U8 offline,
EInstantMessage dialog,
const LLUUID& id,
U32 timestamp,
const U8* binary_bucket,
S32 binary_bucket_size)
{
pack_instant_message(
gMessageSystem,
gAgent.getID(),
FALSE,
gAgent.getSessionID(),
to_id,
name,
message,
offline,
dialog,
id,
0,
LLUUID::null,
gAgent.getPositionAgent(),
timestamp,
binary_bucket,
binary_bucket_size);
gAgent.sendReliableMessage();
}
void send_places_query(const LLUUID& query_id,
const LLUUID& trans_id,
const std::string& query_text,
U32 query_flags,
S32 category,
const std::string& sim_name)
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessage("PlacesQuery");
msg->nextBlock("AgentData");
msg->addUUID("AgentID", gAgent.getID());
msg->addUUID("SessionID", gAgent.getSessionID());
msg->addUUID("QueryID", query_id);
msg->nextBlock("TransactionData");
msg->addUUID("TransactionID", trans_id);
msg->nextBlock("QueryData");
msg->addString("QueryText", query_text);
msg->addU32("QueryFlags", query_flags);
msg->addS8("Category", (S8)category);
msg->addString("SimName", sim_name);
gAgent.sendReliableMessage();
}
void process_user_info_reply(LLMessageSystem* msg, void**)
{
LLUUID agent_id;
msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id);
if(agent_id != gAgent.getID())
{
LL_WARNS("Messaging") << "process_user_info_reply - "
<< "wrong agent id." << LL_ENDL;
}
BOOL im_via_email;
msg->getBOOLFast(_PREHASH_UserData, _PREHASH_IMViaEMail, im_via_email);
std::string email;
msg->getStringFast(_PREHASH_UserData, _PREHASH_EMail, email);
std::string dir_visibility;
msg->getString( "UserData", "DirectoryVisibility", dir_visibility);
LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email);
LLFloaterSnapshot::setAgentEmail(email);
}
//---------------------------------------------------------------------------
// Script Dialog
//---------------------------------------------------------------------------
const S32 SCRIPT_DIALOG_MAX_BUTTONS = 12;
const S32 SCRIPT_DIALOG_BUTTON_STR_SIZE = 24;
const S32 SCRIPT_DIALOG_MAX_MESSAGE_SIZE = 512;
const char* SCRIPT_DIALOG_HEADER = "Script Dialog:\n";
bool callback_script_dialog(const LLSD& notification, const LLSD& response)
{
LLNotificationForm form(notification["form"]);
std::string rtn_text;
S32 button_idx;
button_idx = LLNotification::getSelectedOption(notification, response);
if (response[TEXTBOX_MAGIC_TOKEN].isDefined())
{
if (response[TEXTBOX_MAGIC_TOKEN].isString())
rtn_text = response[TEXTBOX_MAGIC_TOKEN].asString();
else
rtn_text.clear(); // bool marks empty string
}
else
{
rtn_text = LLNotification::getSelectedOptionName(response);
}
// Button -2 = Mute
// Button -1 = Ignore - no processing needed for this button
// Buttons 0 and above = dialog choices
if (-2 == button_idx)
{
std::string object_name = notification["payload"]["object_name"].asString();
LLUUID object_id = notification["payload"]["object_id"].asUUID();
LLMute mute(object_id, object_name, LLMute::OBJECT);
if (LLMuteList::getInstance()->add(mute))
{
// This call opens the sidebar, displays the block list, and highlights the newly blocked
// object in the list so the user can see that their block click has taken effect.
LLPanelBlockedList::showPanelAndSelect(object_id);
}
}
if (0 <= button_idx)
{
LLMessageSystem* msg = gMessageSystem;
msg->newMessage("ScriptDialogReply");
msg->nextBlock("AgentData");
msg->addUUID("AgentID", gAgent.getID());
msg->addUUID("SessionID", gAgent.getSessionID());
msg->nextBlock("Data");
msg->addUUID("ObjectID", notification["payload"]["object_id"].asUUID());
msg->addS32("ChatChannel", notification["payload"]["chat_channel"].asInteger());
msg->addS32("ButtonIndex", button_idx);
msg->addString("ButtonLabel", rtn_text);
msg->sendReliable(LLHost(notification["payload"]["sender"].asString()));
}
return false;
}
static LLNotificationFunctorRegistration callback_script_dialog_reg_1("ScriptDialog", callback_script_dialog);
static LLNotificationFunctorRegistration callback_script_dialog_reg_2("ScriptDialogGroup", callback_script_dialog);
void process_script_dialog(LLMessageSystem* msg, void**)
{
S32 i;
LLSD payload;
LLUUID object_id;
msg->getUUID("Data", "ObjectID", object_id);
// For compability with OS grids first check for presence of extended packet before fetching data.
LLUUID owner_id;
if (gMessageSystem->getNumberOfBlocks("OwnerData") > 0)
{
msg->getUUID("OwnerData", "OwnerID", owner_id);
}
if (LLMuteList::getInstance()->isMuted(object_id) || LLMuteList::getInstance()->isMuted(owner_id))
{
return;
}
std::string message;
std::string first_name;
std::string last_name;
std::string object_name;
S32 chat_channel;
msg->getString("Data", "FirstName", first_name);
msg->getString("Data", "LastName", last_name);
msg->getString("Data", "ObjectName", object_name);
msg->getString("Data", "Message", message);
msg->getS32("Data", "ChatChannel", chat_channel);
// unused for now
LLUUID image_id;
msg->getUUID("Data", "ImageID", image_id);
payload["sender"] = msg->getSender().getIPandPort();
payload["object_id"] = object_id;
payload["chat_channel"] = chat_channel;
payload["object_name"] = object_name;
// build up custom form
S32 button_count = msg->getNumberOfBlocks("Buttons");
if (button_count > SCRIPT_DIALOG_MAX_BUTTONS)
{
llwarns << "Too many script dialog buttons - omitting some" << llendl;
button_count = SCRIPT_DIALOG_MAX_BUTTONS;
}
LLNotificationForm form;
for (i = 0; i < button_count; i++)
{
std::string tdesc;
msg->getString("Buttons", "ButtonLabel", tdesc, i);
form.addElement("button", std::string(tdesc));
}
LLSD args;
args["TITLE"] = object_name;
args["MESSAGE"] = message;
LLNotificationPtr notification;
if (!first_name.empty())
{
args["NAME"] = LLCacheName::buildFullName(first_name, last_name);
notification = LLNotifications::instance().add(
LLNotification::Params("ScriptDialog").substitutions(args).payload(payload).form_elements(form.asLLSD()));
}
else
{
args["GROUPNAME"] = last_name;
notification = LLNotifications::instance().add(
LLNotification::Params("ScriptDialogGroup").substitutions(args).payload(payload).form_elements(form.asLLSD()));
}
}
//---------------------------------------------------------------------------
std::vector<LLSD> gLoadUrlList;
bool callback_load_url(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option)
{
LLWeb::loadURL(notification["payload"]["url"].asString());
}
return false;
}
static LLNotificationFunctorRegistration callback_load_url_reg("LoadWebPage", callback_load_url);
// We've got the name of the person who owns the object hurling the url.
// Display confirmation dialog.
void callback_load_url_name(const LLUUID& id, const std::string& full_name, bool is_group)
{
std::vector<LLSD>::iterator it;
for (it = gLoadUrlList.begin(); it != gLoadUrlList.end(); )
{
LLSD load_url_info = *it;
if (load_url_info["owner_id"].asUUID() == id)
{
it = gLoadUrlList.erase(it);
std::string owner_name;
if (is_group)
{
owner_name = full_name + LLTrans::getString("Group");
}
else
{
owner_name = full_name;
}
// For legacy name-only mutes.
if (LLMuteList::getInstance()->isMuted(LLUUID::null, owner_name))
{
continue;
}
LLSD args;
args["URL"] = load_url_info["url"].asString();
args["MESSAGE"] = load_url_info["message"].asString();;
args["OBJECTNAME"] = load_url_info["object_name"].asString();
args["NAME"] = owner_name;
LLNotificationsUtil::add("LoadWebPage", args, load_url_info);
}
else
{
++it;
}
}
}
void process_load_url(LLMessageSystem* msg, void**)
{
LLUUID object_id;
LLUUID owner_id;
BOOL owner_is_group;
char object_name[256]; /* Flawfinder: ignore */
char message[256]; /* Flawfinder: ignore */
char url[256]; /* Flawfinder: ignore */
msg->getString("Data", "ObjectName", 256, object_name);
msg->getUUID( "Data", "ObjectID", object_id);
msg->getUUID( "Data", "OwnerID", owner_id);
msg->getBOOL( "Data", "OwnerIsGroup", owner_is_group);
msg->getString("Data", "Message", 256, message);
msg->getString("Data", "URL", 256, url);
LLSD payload;
payload["object_id"] = object_id;
payload["owner_id"] = owner_id;
payload["owner_is_group"] = owner_is_group;
payload["object_name"] = object_name;
payload["message"] = message;
payload["url"] = url;
// URL is safety checked in load_url above
// Check if object or owner is muted
if (LLMuteList::getInstance()->isMuted(object_id, object_name) ||
LLMuteList::getInstance()->isMuted(owner_id))
{
LL_INFOS("Messaging")<<"Ignoring load_url from muted object/owner."<<LL_ENDL;
return;
}
// Add to list of pending name lookups
gLoadUrlList.push_back(payload);
gCacheName->get(owner_id, owner_is_group,
boost::bind(&callback_load_url_name, _1, _2, _3));
}
void callback_download_complete(void** data, S32 result, LLExtStat ext_status)
{
std::string* filepath = (std::string*)data;
LLSD args;
args["DOWNLOAD_PATH"] = *filepath;
LLNotificationsUtil::add("FinishedRawDownload", args);
delete filepath;
}
void process_initiate_download(LLMessageSystem* msg, void**)
{
LLUUID agent_id;
msg->getUUID("AgentData", "AgentID", agent_id);
if (agent_id != gAgent.getID())
{
LL_WARNS("Messaging") << "Initiate download for wrong agent" << LL_ENDL;
return;
}
std::string sim_filename;
std::string viewer_filename;
msg->getString("FileData", "SimFilename", sim_filename);
msg->getString("FileData", "ViewerFilename", viewer_filename);
if (!gXferManager->validateFileForRequest(viewer_filename))
{
llwarns << "SECURITY: Unauthorized download to local file " << viewer_filename << llendl;
return;
}
gXferManager->requestFile(viewer_filename,
sim_filename,
LL_PATH_NONE,
msg->getSender(),
FALSE, // don't delete remote
callback_download_complete,
(void**)new std::string(viewer_filename));
}
void process_script_teleport_request(LLMessageSystem* msg, void**)
{
if (!gSavedSettings.getBOOL("ScriptsCanShowUI")) return;
std::string object_name;
std::string sim_name;
LLVector3 pos;
LLVector3 look_at;
msg->getString("Data", "ObjectName", object_name);
msg->getString("Data", "SimName", sim_name);
msg->getVector3("Data", "SimPosition", pos);
msg->getVector3("Data", "LookAt", look_at);
LLFloaterWorldMap* instance = LLFloaterWorldMap::getInstance();
if(instance)
{
llinfos << "Object named " << object_name
<< " is offering TP to region "
<< sim_name << " position " << pos
<< llendl;
instance->trackURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]);
LLFloaterReg::showInstance("world_map", "center");
}
// remove above two lines and replace with below line
// to re-enable parcel browser for llMapDestination()
// LLURLDispatcher::dispatch(LLSLURL::buildSLURL(sim_name, (S32)pos.mV[VX], (S32)pos.mV[VY], (S32)pos.mV[VZ]), FALSE);
}
void process_covenant_reply(LLMessageSystem* msg, void**)
{
LLUUID covenant_id, estate_owner_id;
std::string estate_name;
U32 covenant_timestamp;
msg->getUUID("Data", "CovenantID", covenant_id);
msg->getU32("Data", "CovenantTimestamp", covenant_timestamp);
msg->getString("Data", "EstateName", estate_name);
msg->getUUID("Data", "EstateOwnerID", estate_owner_id);
LLPanelEstateCovenant::updateEstateName(estate_name);
LLPanelLandCovenant::updateEstateName(estate_name);
LLPanelEstateInfo::updateEstateName(estate_name);
LLFloaterBuyLand::updateEstateName(estate_name);
std::string owner_name =
LLSLURL("agent", estate_owner_id, "inspect").getSLURLString();
LLPanelEstateCovenant::updateEstateOwnerName(owner_name);
LLPanelLandCovenant::updateEstateOwnerName(owner_name);
LLPanelEstateInfo::updateEstateOwnerName(owner_name);
LLFloaterBuyLand::updateEstateOwnerName(owner_name);
LLPanelPlaceProfile* panel = LLFloaterSidePanelContainer::getPanel<LLPanelPlaceProfile>("places", "panel_place_profile");
if (panel)
{
panel->updateEstateName(estate_name);
panel->updateEstateOwnerName(owner_name);
}
// standard message, not from system
std::string last_modified;
if (covenant_timestamp == 0)
{
last_modified = LLTrans::getString("covenant_last_modified")+LLTrans::getString("never_text");
}
else
{
last_modified = LLTrans::getString("covenant_last_modified")+"["
+LLTrans::getString("LTimeWeek")+"] ["
+LLTrans::getString("LTimeMonth")+"] ["
+LLTrans::getString("LTimeDay")+"] ["
+LLTrans::getString("LTimeHour")+"]:["
+LLTrans::getString("LTimeMin")+"]:["
+LLTrans::getString("LTimeSec")+"] ["
+LLTrans::getString("LTimeYear")+"]";
LLSD substitution;
substitution["datetime"] = (S32) covenant_timestamp;
LLStringUtil::format (last_modified, substitution);
}
LLPanelEstateCovenant::updateLastModified(last_modified);
LLPanelLandCovenant::updateLastModified(last_modified);
LLFloaterBuyLand::updateLastModified(last_modified);
// load the actual covenant asset data
const BOOL high_priority = TRUE;
if (covenant_id.notNull())
{
gAssetStorage->getEstateAsset(gAgent.getRegionHost(),
gAgent.getID(),
gAgent.getSessionID(),
covenant_id,
LLAssetType::AT_NOTECARD,
ET_Covenant,
onCovenantLoadComplete,
NULL,
high_priority);
}
else
{
std::string covenant_text;
if (estate_owner_id.isNull())
{
// mainland
covenant_text = LLTrans::getString("RegionNoCovenant");
}
else
{
covenant_text = LLTrans::getString("RegionNoCovenantOtherOwner");
}
LLPanelEstateCovenant::updateCovenantText(covenant_text, covenant_id);
LLPanelLandCovenant::updateCovenantText(covenant_text);
LLFloaterBuyLand::updateCovenantText(covenant_text, covenant_id);
if (panel)
{
panel->updateCovenantText(covenant_text);
}
}
}
void onCovenantLoadComplete(LLVFS *vfs,
const LLUUID& asset_uuid,
LLAssetType::EType type,
void* user_data, S32 status, LLExtStat ext_status)
{
LL_DEBUGS("Messaging") << "onCovenantLoadComplete()" << LL_ENDL;
std::string covenant_text;
if(0 == status)
{
LLVFile file(vfs, asset_uuid, type, LLVFile::READ);
S32 file_length = file.getSize();
std::vector<char> buffer(file_length+1);
file.read((U8*)&buffer[0], file_length);
// put a EOS at the end
buffer[file_length] = '\0';
if( (file_length > 19) && !strncmp( &buffer[0], "Linden text version", 19 ) )
{
LLViewerTextEditor::Params params;
params.name("temp");
params.max_text_length(file_length+1);
LLViewerTextEditor * editor = LLUICtrlFactory::create<LLViewerTextEditor> (params);
if( !editor->importBuffer( &buffer[0], file_length+1 ) )
{
LL_WARNS("Messaging") << "Problem importing estate covenant." << LL_ENDL;
covenant_text = "Problem importing estate covenant.";
}
else
{
// Version 0 (just text, doesn't include version number)
covenant_text = editor->getText();
}
delete editor;
}
else
{
LL_WARNS("Messaging") << "Problem importing estate covenant: Covenant file format error." << LL_ENDL;
covenant_text = "Problem importing estate covenant: Covenant file format error.";
}
}
else
{
LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status ||
LL_ERR_FILE_EMPTY == status)
{
covenant_text = "Estate covenant notecard is missing from database.";
}
else if (LL_ERR_INSUFFICIENT_PERMISSIONS == status)
{
covenant_text = "Insufficient permissions to view estate covenant.";
}
else
{
covenant_text = "Unable to load estate covenant at this time.";
}
LL_WARNS("Messaging") << "Problem loading notecard: " << status << LL_ENDL;
}
LLPanelEstateCovenant::updateCovenantText(covenant_text, asset_uuid);
LLPanelLandCovenant::updateCovenantText(covenant_text);
LLFloaterBuyLand::updateCovenantText(covenant_text, asset_uuid);
LLPanelPlaceProfile* panel = LLFloaterSidePanelContainer::getPanel<LLPanelPlaceProfile>("places", "panel_place_profile");
if (panel)
{
panel->updateCovenantText(covenant_text);
}
}
void process_feature_disabled_message(LLMessageSystem* msg, void**)
{
// Handle Blacklisted feature simulator response...
LLUUID agentID;
LLUUID transactionID;
std::string messageText;
msg->getStringFast(_PREHASH_FailureInfo,_PREHASH_ErrorMessage, messageText,0);
msg->getUUIDFast(_PREHASH_FailureInfo,_PREHASH_AgentID,agentID);
msg->getUUIDFast(_PREHASH_FailureInfo,_PREHASH_TransactionID,transactionID);
LL_WARNS("Messaging") << "Blacklisted Feature Response:" << messageText << LL_ENDL;
}
// ------------------------------------------------------------
// Message system exception callbacks
// ------------------------------------------------------------
void invalid_message_callback(LLMessageSystem* msg,
void*,
EMessageException exception)
{
LLAppViewer::instance()->badNetworkHandler();
}
// Please do not add more message handlers here. This file is huge.
// Put them in a file related to the functionality you are implementing.
void LLOfferInfo::forceResponse(InventoryOfferResponse response)
{
LLNotification::Params params("UserGiveItem");
params.functor.function(boost::bind(&LLOfferInfo::inventory_offer_callback, this, _1, _2));
LLNotifications::instance().forceResponse(params, response);
}
|