aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
blob: 0e018e8c4a8e878215c190b15dff132be49d4a91 (plain)
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
/*
 * Copyright (c) Contributors, http://opensimulator.org/
 * See CONTRIBUTORS.TXT for a full list of copyright holders.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSim Project nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;

namespace OpenSim.Region.Environment.Scenes
{
    public class SceneExternalChecks
    {
        private Scene m_scene;

        public SceneExternalChecks(Scene scene)
        {
            m_scene = scene;
        }

        #region Object Permission Checks

        public delegate uint GenerateClientFlags(UUID userID, UUID objectIDID);
        private List<GenerateClientFlags> GenerateClientFlagsCheckFunctions = new List<GenerateClientFlags>();

        public void addGenerateClientFlags(GenerateClientFlags delegateFunc)
        {
            if (!GenerateClientFlagsCheckFunctions.Contains(delegateFunc))
                GenerateClientFlagsCheckFunctions.Add(delegateFunc);
        }

        public void removeGenerateClientFlags(GenerateClientFlags delegateFunc)
        {
            if (GenerateClientFlagsCheckFunctions.Contains(delegateFunc))
                GenerateClientFlagsCheckFunctions.Remove(delegateFunc);
        }

        public uint ExternalChecksGenerateClientFlags(UUID userID, UUID objectID)
        {
            SceneObjectPart part=m_scene.GetSceneObjectPart(objectID);

            if (part == null)
                return 0;

            // libomv will moan about PrimFlags.ObjectYouOfficer being
            // obsolete...
            #pragma warning disable 0612
            uint perms=part.GetEffectiveObjectFlags() |
                (uint)PrimFlags.ObjectModify |
                (uint)PrimFlags.ObjectCopy |
                (uint)PrimFlags.ObjectMove |
                (uint)PrimFlags.ObjectTransfer |
                (uint)PrimFlags.ObjectYouOwner |
                (uint)PrimFlags.ObjectAnyOwner |
                (uint)PrimFlags.ObjectOwnerModify |
                (uint)PrimFlags.ObjectYouOfficer;
            #pragma warning restore 0612

            foreach (GenerateClientFlags check in GenerateClientFlagsCheckFunctions)
            {
                perms &= check(userID, objectID);
            }
            return perms;
        }

        public delegate void SetBypassPermissions(bool value);
        private List<SetBypassPermissions> SetBypassPermissionsCheckFunctions = new List<SetBypassPermissions>();

        public void addSetBypassPermissions(SetBypassPermissions delegateFunc)
        {
            if (!SetBypassPermissionsCheckFunctions.Contains(delegateFunc))
                SetBypassPermissionsCheckFunctions.Add(delegateFunc);
        }

        public void removeSetBypassPermissions(SetBypassPermissions delegateFunc)
        {
            if (SetBypassPermissionsCheckFunctions.Contains(delegateFunc))
                SetBypassPermissionsCheckFunctions.Remove(delegateFunc);
        }

        public void ExternalChecksSetBypassPermissions(bool value)
        {
            foreach (SetBypassPermissions check in SetBypassPermissionsCheckFunctions)
            {
                check(value);
            }
        }

        public delegate bool BypassPermissions();
        private List<BypassPermissions> BypassPermissionsCheckFunctions = new List<BypassPermissions>();

        public void addBypassPermissions(BypassPermissions delegateFunc)
        {
            if (!BypassPermissionsCheckFunctions.Contains(delegateFunc))
                BypassPermissionsCheckFunctions.Add(delegateFunc);
        }

        public void removeBypassPermissions(BypassPermissions delegateFunc)
        {
            if (BypassPermissionsCheckFunctions.Contains(delegateFunc))
                BypassPermissionsCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksBypassPermissions()
        {
            foreach (BypassPermissions check in BypassPermissionsCheckFunctions)
            {
                if (check() == false)
                {
                    return false;
                }
            }
            return true;
        }

        public delegate bool PropagatePermissions();
        private List<PropagatePermissions> PropagatePermissionsCheckFunctions = new List<PropagatePermissions>();

        public void addPropagatePermissions(PropagatePermissions delegateFunc)
        {
            if (!PropagatePermissionsCheckFunctions.Contains(delegateFunc))
                PropagatePermissionsCheckFunctions.Add(delegateFunc);
        }

        public void removePropagatePermissions(PropagatePermissions delegateFunc)
        {
            if (PropagatePermissionsCheckFunctions.Contains(delegateFunc))
                PropagatePermissionsCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksPropagatePermissions()
        {
            foreach (PropagatePermissions check in PropagatePermissionsCheckFunctions)
            {
                if (check() == false)
                {
                    return false;
                }
            }
            return true;
        }

        #region REZ OBJECT
        public delegate bool CanRezObject(int objectCount, UUID owner, Vector3 objectPosition, Scene scene);
        private List<CanRezObject> CanRezObjectCheckFunctions = new List<CanRezObject>();

        public void addCheckRezObject(CanRezObject delegateFunc)
        {
            if (!CanRezObjectCheckFunctions.Contains(delegateFunc))
                CanRezObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckRezObject(CanRezObject delegateFunc)
        {
            if (CanRezObjectCheckFunctions.Contains(delegateFunc))
                CanRezObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanRezObject(int objectCount, UUID owner, Vector3 objectPosition)
        {
            foreach (CanRezObject check in CanRezObjectCheckFunctions)
            {
                if (check(objectCount, owner,objectPosition, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region DELETE OBJECT
        public delegate bool CanDeleteObject(UUID objectID, UUID deleter, Scene scene);
        private List<CanDeleteObject> CanDeleteObjectCheckFunctions = new List<CanDeleteObject>();

        public void addCheckDeleteObject(CanDeleteObject delegateFunc)
        {
            if (!CanDeleteObjectCheckFunctions.Contains(delegateFunc))
                CanDeleteObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckDeleteObject(CanDeleteObject delegateFunc)
        {
            if (CanDeleteObjectCheckFunctions.Contains(delegateFunc))
                CanDeleteObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanDeleteObject(UUID objectID, UUID deleter)
        {
            foreach (CanDeleteObject check in CanDeleteObjectCheckFunctions)
            {
                if (check(objectID,deleter,m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region TAKE OBJECT
        public delegate bool CanTakeObject(UUID objectID, UUID stealer, Scene scene);
        private List<CanTakeObject> CanTakeObjectCheckFunctions = new List<CanTakeObject>();

        public void addCheckTakeObject(CanTakeObject delegateFunc)
        {
            if (!CanTakeObjectCheckFunctions.Contains(delegateFunc))
                CanTakeObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckTakeObject(CanTakeObject delegateFunc)
        {
            if (CanTakeObjectCheckFunctions.Contains(delegateFunc))
                CanTakeObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanTakeObject(UUID objectID, UUID AvatarTakingUUID)
        {
            foreach (CanTakeObject check in CanTakeObjectCheckFunctions)
            {
                if (check(objectID, AvatarTakingUUID, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region TAKE COPY OBJECT
        public delegate bool CanTakeCopyObject(UUID objectID, UUID userID, Scene inScene);
        private List<CanTakeCopyObject> CanTakeCopyObjectCheckFunctions = new List<CanTakeCopyObject>();

        public void addCheckTakeCopyObject(CanTakeCopyObject delegateFunc)
        {
            if (!CanTakeCopyObjectCheckFunctions.Contains(delegateFunc))
                CanTakeCopyObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckTakeCopyObject(CanTakeCopyObject delegateFunc)
        {
            if (CanTakeCopyObjectCheckFunctions.Contains(delegateFunc))
                CanTakeCopyObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanTakeCopyObject(UUID objectID, UUID userID)
        {
            foreach (CanTakeCopyObject check in CanTakeCopyObjectCheckFunctions)
            {
                if (check(objectID,userID,m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region DUPLICATE OBJECT
        public delegate bool CanDuplicateObject(int objectCount, UUID objectID, UUID owner, Scene scene, Vector3 objectPosition);
        private List<CanDuplicateObject> CanDuplicateObjectCheckFunctions = new List<CanDuplicateObject>();

        public void addCheckDuplicateObject(CanDuplicateObject delegateFunc)
        {
            if (!CanDuplicateObjectCheckFunctions.Contains(delegateFunc))
                CanDuplicateObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckDuplicateObject(CanDuplicateObject delegateFunc)
        {
            if (CanDuplicateObjectCheckFunctions.Contains(delegateFunc))
                CanDuplicateObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanDuplicateObject(int objectCount, UUID objectID, UUID owner, Vector3 objectPosition)
        {
            foreach (CanDuplicateObject check in CanDuplicateObjectCheckFunctions)
            {
                if (check(objectCount, objectID, owner, m_scene, objectPosition) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region EDIT OBJECT
        public delegate bool CanEditObject(UUID objectID, UUID editorID, Scene scene);
        private List<CanEditObject> CanEditObjectCheckFunctions = new List<CanEditObject>();

        public void addCheckEditObject(CanEditObject delegateFunc)
        {
            if (!CanEditObjectCheckFunctions.Contains(delegateFunc))
                CanEditObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckEditObject(CanEditObject delegateFunc)
        {
            if (CanEditObjectCheckFunctions.Contains(delegateFunc))
                CanEditObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanEditObject(UUID objectID, UUID editorID)
        {
            foreach (CanEditObject check in CanEditObjectCheckFunctions)
            {
                if (check(objectID, editorID, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        public delegate bool CanEditObjectInventory(UUID objectID, UUID editorID, Scene scene);
        private List<CanEditObjectInventory> CanEditObjectInventoryCheckFunctions = new List<CanEditObjectInventory>();

        public void addCheckEditObjectInventory(CanEditObjectInventory delegateFunc)
        {
            if (!CanEditObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanEditObjectInventoryCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckEditObjectInventory(CanEditObjectInventory delegateFunc)
        {
            if (CanEditObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanEditObjectInventoryCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanEditObjectInventory(UUID objectID, UUID editorID)
        {
            foreach (CanEditObjectInventory check in CanEditObjectInventoryCheckFunctions)
            {
                if (check(objectID, editorID, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region MOVE OBJECT
        public delegate bool CanMoveObject(UUID objectID, UUID moverID, Scene scene);
        private List<CanMoveObject> CanMoveObjectCheckFunctions = new List<CanMoveObject>();

        public void addCheckMoveObject(CanMoveObject delegateFunc)
        {
            if (!CanMoveObjectCheckFunctions.Contains(delegateFunc))
                CanMoveObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckMoveObject(CanMoveObject delegateFunc)
        {
            if (CanMoveObjectCheckFunctions.Contains(delegateFunc))
                CanMoveObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanMoveObject(UUID objectID, UUID moverID)
        {
            foreach (CanMoveObject check in CanMoveObjectCheckFunctions)
            {
                if (check(objectID,moverID,m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region OBJECT ENTRY
        public delegate bool CanObjectEntry(UUID objectID, Vector3 newPoint, Scene scene);
        private List<CanObjectEntry> CanObjectEntryCheckFunctions = new List<CanObjectEntry>();

        public void addCheckObjectEntry(CanObjectEntry delegateFunc)
        {
            if (!CanObjectEntryCheckFunctions.Contains(delegateFunc))
                CanObjectEntryCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckObjectEntry(CanObjectEntry delegateFunc)
        {
            if (CanObjectEntryCheckFunctions.Contains(delegateFunc))
                CanObjectEntryCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanObjectEntry(UUID objectID, Vector3 newPoint)
        {
            foreach (CanObjectEntry check in CanObjectEntryCheckFunctions)
            {
                if (check(objectID, newPoint, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region RETURN OBJECT
        public delegate bool CanReturnObject(UUID objectID, UUID returnerID, Scene scene);
        private List<CanReturnObject> CanReturnObjectCheckFunctions = new List<CanReturnObject>();

        public void addCheckReturnObject(CanReturnObject delegateFunc)
        {
            if (!CanReturnObjectCheckFunctions.Contains(delegateFunc))
                CanReturnObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckReturnObject(CanReturnObject delegateFunc)
        {
            if (CanReturnObjectCheckFunctions.Contains(delegateFunc))
                CanReturnObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanReturnObject(UUID objectID, UUID returnerID)
        {
            foreach (CanReturnObject check in CanReturnObjectCheckFunctions)
            {
                if (check(objectID,returnerID,m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region INSTANT MESSAGE
        public delegate bool CanInstantMessage(UUID user, UUID target, Scene startScene);
        private List<CanInstantMessage> CanInstantMessageCheckFunctions = new List<CanInstantMessage>();

        public void addCheckInstantMessage(CanInstantMessage delegateFunc)
        {
            if (!CanInstantMessageCheckFunctions.Contains(delegateFunc))
                CanInstantMessageCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckInstantMessage(CanInstantMessage delegateFunc)
        {
            if (CanInstantMessageCheckFunctions.Contains(delegateFunc))
                CanInstantMessageCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanInstantMessage(UUID user, UUID target)
        {
            foreach (CanInstantMessage check in CanInstantMessageCheckFunctions)
            {
                if (check(user, target, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region INVENTORY TRANSFER
        public delegate bool CanInventoryTransfer(UUID user, UUID target, Scene startScene);
        private List<CanInventoryTransfer> CanInventoryTransferCheckFunctions = new List<CanInventoryTransfer>();

        public void addCheckInventoryTransfer(CanInventoryTransfer delegateFunc)
        {
            if (!CanInventoryTransferCheckFunctions.Contains(delegateFunc))
                CanInventoryTransferCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckInventoryTransfer(CanInventoryTransfer delegateFunc)
            {
                if (CanInventoryTransferCheckFunctions.Contains(delegateFunc))
                    CanInventoryTransferCheckFunctions.Remove(delegateFunc);
            }

        public bool ExternalChecksCanInventoryTransfer(UUID user, UUID target)
        {
            foreach (CanInventoryTransfer check in CanInventoryTransferCheckFunctions)
            {
                if (check(user, target, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region VIEW SCRIPT
        public delegate bool CanViewScript(UUID script, UUID objectID, UUID user, Scene scene);
        private List<CanViewScript> CanViewScriptCheckFunctions = new List<CanViewScript>();

        public void addCheckViewScript(CanViewScript delegateFunc)
        {
            if (!CanViewScriptCheckFunctions.Contains(delegateFunc))
                CanViewScriptCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckViewScript(CanViewScript delegateFunc)
        {
            if (CanViewScriptCheckFunctions.Contains(delegateFunc))
                CanViewScriptCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanViewScript(UUID script, UUID objectID, UUID user)
        {
            foreach (CanViewScript check in CanViewScriptCheckFunctions)
            {
                if (check(script, objectID, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        public delegate bool CanViewNotecard(UUID script, UUID objectID, UUID user, Scene scene);
        private List<CanViewNotecard> CanViewNotecardCheckFunctions = new List<CanViewNotecard>();

        public void addCheckViewNotecard(CanViewNotecard delegateFunc)
        {
            if (!CanViewNotecardCheckFunctions.Contains(delegateFunc))
                CanViewNotecardCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckViewNotecard(CanViewNotecard delegateFunc)
        {
            if (CanViewNotecardCheckFunctions.Contains(delegateFunc))
                CanViewNotecardCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanViewNotecard(UUID script, UUID objectID, UUID user)
        {
            foreach (CanViewNotecard check in CanViewNotecardCheckFunctions)
            {
                if (check(script, objectID, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region EDIT SCRIPT
        public delegate bool CanEditScript(UUID script, UUID objectID, UUID user, Scene scene);
        private List<CanEditScript> CanEditScriptCheckFunctions = new List<CanEditScript>();

        public void addCheckEditScript(CanEditScript delegateFunc)
        {
            if (!CanEditScriptCheckFunctions.Contains(delegateFunc))
                CanEditScriptCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckEditScript(CanEditScript delegateFunc)
        {
            if (CanEditScriptCheckFunctions.Contains(delegateFunc))
                CanEditScriptCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanEditScript(UUID script, UUID objectID, UUID user)
        {
            foreach (CanEditScript check in CanEditScriptCheckFunctions)
            {
                if (check(script, objectID, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        public delegate bool CanEditNotecard(UUID notecard, UUID objectID, UUID user, Scene scene);
        private List<CanEditNotecard> CanEditNotecardCheckFunctions = new List<CanEditNotecard>();

        public void addCheckEditNotecard(CanEditNotecard delegateFunc)
        {
            if (!CanEditNotecardCheckFunctions.Contains(delegateFunc))
                CanEditNotecardCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckEditNotecard(CanEditNotecard delegateFunc)
        {
            if (CanEditNotecardCheckFunctions.Contains(delegateFunc))
                CanEditNotecardCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanEditNotecard(UUID script, UUID objectID, UUID user)
            {
                foreach (CanEditNotecard check in CanEditNotecardCheckFunctions)
                {
                    if (check(script, objectID, user, m_scene) == false)
                    {
                        return false;
                    }
                }
                return true;
            }

        #endregion

        #region RUN SCRIPT (When Script Placed in Object)
        public delegate bool CanRunScript(UUID script, UUID objectID, UUID user, Scene scene);
        private List<CanRunScript> CanRunScriptCheckFunctions = new List<CanRunScript>();

        public void addCheckRunScript(CanRunScript delegateFunc)
        {
            if (!CanRunScriptCheckFunctions.Contains(delegateFunc))
                CanRunScriptCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckRunScript(CanRunScript delegateFunc)
        {
            if (CanRunScriptCheckFunctions.Contains(delegateFunc))
                CanRunScriptCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanRunScript(UUID script, UUID objectID, UUID user)
        {
            foreach (CanRunScript check in CanRunScriptCheckFunctions)
            {
                if (check(script, objectID, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region START SCRIPT (When Script run box is Checked after placed in object)
        public delegate bool CanStartScript(UUID script, UUID user, Scene scene);
        private List<CanStartScript> CanStartScriptCheckFunctions = new List<CanStartScript>();

        public void addCheckStartScript(CanStartScript delegateFunc)
        {
            if (!CanStartScriptCheckFunctions.Contains(delegateFunc))
                CanStartScriptCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckStartScript(CanStartScript delegateFunc)
        {
            if (CanStartScriptCheckFunctions.Contains(delegateFunc))
                CanStartScriptCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanStartScript(UUID script, UUID user)
        {
            foreach (CanStartScript check in CanStartScriptCheckFunctions)
            {
                if (check(script, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region STOP SCRIPT (When Script run box is unchecked after placed in object)
        public delegate bool CanStopScript(UUID script, UUID user, Scene scene);
        private List<CanStopScript> CanStopScriptCheckFunctions = new List<CanStopScript>();

        public void addCheckStopScript(CanStopScript delegateFunc)
        {
            if (!CanStopScriptCheckFunctions.Contains(delegateFunc))
                CanStopScriptCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckStopScript(CanStopScript delegateFunc)
        {
            if (CanStopScriptCheckFunctions.Contains(delegateFunc))
                CanStopScriptCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanStopScript(UUID script, UUID user)
        {
            foreach (CanStopScript check in CanStopScriptCheckFunctions)
            {
                if (check(script, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region RESET SCRIPT
        public delegate bool CanResetScript(UUID script, UUID user, Scene scene);
        private List<CanResetScript> CanResetScriptCheckFunctions = new List<CanResetScript>();

        public void addCheckResetScript(CanResetScript delegateFunc)
        {
            if (!CanResetScriptCheckFunctions.Contains(delegateFunc))
                CanResetScriptCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckResetScript(CanResetScript delegateFunc)
        {
            if (CanResetScriptCheckFunctions.Contains(delegateFunc))
                CanResetScriptCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanResetScript(UUID script, UUID user)
        {
            foreach (CanResetScript check in CanResetScriptCheckFunctions)
            {
                if (check(script, user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region TERRAFORM LAND
        public delegate bool CanTerraformLand(UUID user, Vector3 position, Scene requestFromScene);
        private List<CanTerraformLand> CanTerraformLandCheckFunctions = new List<CanTerraformLand>();

        public void addCheckTerraformLand(CanTerraformLand delegateFunc)
        {
            if (!CanTerraformLandCheckFunctions.Contains(delegateFunc))
                CanTerraformLandCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckTerraformLand(CanTerraformLand delegateFunc)
        {
            if (CanTerraformLandCheckFunctions.Contains(delegateFunc))
                CanTerraformLandCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanTerraformLand(UUID user, Vector3 pos)
        {
            foreach (CanTerraformLand check in CanTerraformLandCheckFunctions)
            {
                if (check(user, pos, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region RUN CONSOLE COMMAND
        public delegate bool CanRunConsoleCommand(UUID user, Scene requestFromScene);
        private List<CanRunConsoleCommand> CanRunConsoleCommandCheckFunctions = new List<CanRunConsoleCommand>();

        public void addCheckRunConsoleCommand(CanRunConsoleCommand delegateFunc)
        {
            if (!CanRunConsoleCommandCheckFunctions.Contains(delegateFunc))
                CanRunConsoleCommandCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckRunConsoleCommand(CanRunConsoleCommand delegateFunc)
        {
            if (CanRunConsoleCommandCheckFunctions.Contains(delegateFunc))
                CanRunConsoleCommandCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanRunConsoleCommand(UUID user)
        {
            foreach (CanRunConsoleCommand check in CanRunConsoleCommandCheckFunctions)
            {
                if (check(user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        #region CAN ISSUE ESTATE COMMAND
        public delegate bool CanIssueEstateCommand(UUID user, Scene requestFromScene, bool ownerCommand);
        private List<CanIssueEstateCommand> CanIssueEstateCommandCheckFunctions = new List<CanIssueEstateCommand>();

        public void addCheckIssueEstateCommand(CanIssueEstateCommand delegateFunc)
        {
            if (!CanIssueEstateCommandCheckFunctions.Contains(delegateFunc))
                CanIssueEstateCommandCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckIssueEstateCommand(CanIssueEstateCommand delegateFunc)
        {
            if (CanIssueEstateCommandCheckFunctions.Contains(delegateFunc))
                CanIssueEstateCommandCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanIssueEstateCommand(UUID user, bool ownerCommand)
        {
            foreach (CanIssueEstateCommand check in CanIssueEstateCommandCheckFunctions)
            {
                if (check(user, m_scene, ownerCommand) == false)
                {
                    return false;
                }
            }
            return true;
        }
        #endregion

        #region CAN BE GODLIKE
        public delegate bool CanBeGodLike(UUID user, Scene requestFromScene);
        private List<CanBeGodLike> CanBeGodLikeCheckFunctions = new List<CanBeGodLike>();

        public void addCheckBeGodLike(CanBeGodLike delegateFunc)
        {
            if (!CanBeGodLikeCheckFunctions.Contains(delegateFunc))
                CanBeGodLikeCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckBeGodLike(CanBeGodLike delegateFunc)
        {
            if (CanBeGodLikeCheckFunctions.Contains(delegateFunc))
                CanBeGodLikeCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanBeGodLike(UUID user)
        {
            foreach (CanBeGodLike check in CanBeGodLikeCheckFunctions)
            {
                if (check(user, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }
        #endregion

        #region EDIT PARCEL
        public delegate bool CanEditParcel(UUID user, ILandObject parcel, Scene scene);
        private List<CanEditParcel> CanEditParcelCheckFunctions = new List<CanEditParcel>();

        public void addCheckEditParcel(CanEditParcel delegateFunc)
        {
            if (!CanEditParcelCheckFunctions.Contains(delegateFunc))
                CanEditParcelCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckEditParcel(CanEditParcel delegateFunc)
        {
            if (CanEditParcelCheckFunctions.Contains(delegateFunc))
                CanEditParcelCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanEditParcel(UUID user, ILandObject parcel)
        {
            foreach (CanEditParcel check in CanEditParcelCheckFunctions)
            {
                if (check(user, parcel, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }
        #endregion

        #region SELL PARCEL
        public delegate bool CanSellParcel(UUID user, ILandObject parcel, Scene scene);
        private List<CanSellParcel> CanSellParcelCheckFunctions = new List<CanSellParcel>();

        public void addCheckSellParcel(CanSellParcel delegateFunc)
        {
            if (!CanSellParcelCheckFunctions.Contains(delegateFunc))
                CanSellParcelCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckSellParcel(CanSellParcel delegateFunc)
        {
            if (CanSellParcelCheckFunctions.Contains(delegateFunc))
                CanSellParcelCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanSellParcel(UUID user, ILandObject parcel)
        {
            foreach (CanSellParcel check in CanSellParcelCheckFunctions)
            {
                if (check(user, parcel, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }
        #endregion

        #region ABANDON PARCEL
        public delegate bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene);
        private List<CanAbandonParcel> CanAbandonParcelCheckFunctions = new List<CanAbandonParcel>();

        public void addCheckAbandonParcel(CanAbandonParcel delegateFunc)
        {
            if (!CanAbandonParcelCheckFunctions.Contains(delegateFunc))
                CanAbandonParcelCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckAbandonParcel(CanAbandonParcel delegateFunc)
        {
            if (CanAbandonParcelCheckFunctions.Contains(delegateFunc))
                CanAbandonParcelCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanAbandonParcel(UUID user, ILandObject parcel)
        {
            foreach (CanAbandonParcel check in CanAbandonParcelCheckFunctions)
            {
                if (check(user, parcel, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }
        #endregion

        public delegate bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene);
        private List<CanReclaimParcel> CanReclaimParcelCheckFunctions = new List<CanReclaimParcel>();

        public void addCheckReclaimParcel(CanReclaimParcel delegateFunc)
        {
            if (!CanReclaimParcelCheckFunctions.Contains(delegateFunc))
                CanReclaimParcelCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckReclaimParcel(CanReclaimParcel delegateFunc)
        {
            if (CanReclaimParcelCheckFunctions.Contains(delegateFunc))
                CanReclaimParcelCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanReclaimParcel(UUID user, ILandObject parcel)
        {
            foreach (CanReclaimParcel check in CanReclaimParcelCheckFunctions)
            {
                if (check(user, parcel, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }
        public delegate bool CanBuyLand(UUID user, ILandObject parcel, Scene scene);
        private List<CanBuyLand> CanBuyLandCheckFunctions = new List<CanBuyLand>();

        public void addCheckCanBuyLand(CanBuyLand delegateFunc)
        {
            if (!CanBuyLandCheckFunctions.Contains(delegateFunc))
                CanBuyLandCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanBuyLand(CanBuyLand delegateFunc)
        {
            if (CanBuyLandCheckFunctions.Contains(delegateFunc))
                CanBuyLandCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanBuyLand(UUID user, ILandObject parcel)
        {
            foreach (CanBuyLand check in CanBuyLandCheckFunctions)
            {
                if (check(user, parcel, m_scene) == false)
                {
                    return false;
                }
            }
            return true;
        }

        public delegate bool CanLinkObject(UUID user, UUID objectID);
        private List<CanLinkObject> CanLinkObjectCheckFunctions = new List<CanLinkObject>();

        public void addCheckCanLinkObject(CanLinkObject delegateFunc)
        {
            if (!CanLinkObjectCheckFunctions.Contains(delegateFunc))
                CanLinkObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanLinkObject(CanLinkObject delegateFunc)
        {
            if (CanLinkObjectCheckFunctions.Contains(delegateFunc))
                CanLinkObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanLinkObject(UUID user, UUID objectID)
            {
                foreach (CanLinkObject check in CanLinkObjectCheckFunctions)
                {
                    if (check(user, objectID) == false)
                    {
                        return false;
                    }
                }
                return true;
            }

        public delegate bool CanDelinkObject(UUID user, UUID objectID);
        private List<CanDelinkObject> CanDelinkObjectCheckFunctions = new List<CanDelinkObject>();

        public void addCheckCanDelinkObject(CanDelinkObject delegateFunc)
        {
            if (!CanDelinkObjectCheckFunctions.Contains(delegateFunc))
                CanDelinkObjectCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanDelinkObject(CanDelinkObject delegateFunc)
        {
            if (CanDelinkObjectCheckFunctions.Contains(delegateFunc))
                CanDelinkObjectCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanDelinkObject(UUID user, UUID objectID)
        {
            foreach (CanDelinkObject check in CanDelinkObjectCheckFunctions)
            {
                if (check(user, objectID) == false)
                {
                    return false;
                }
            }
            return true;
        }

        #endregion

        public delegate bool CanCreateObjectInventory(int invType, UUID objectID, UUID userID);
        private List<CanCreateObjectInventory> CanCreateObjectInventoryCheckFunctions 
            = new List<CanCreateObjectInventory>();

        
        public void addCheckCanCreateObjectInventory(CanCreateObjectInventory delegateFunc)
        {
            if (!CanCreateObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanCreateObjectInventoryCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanCreateObjectInventory(CanCreateObjectInventory delegateFunc)
        {
            if (CanCreateObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanCreateObjectInventoryCheckFunctions.Remove(delegateFunc);
        }

        /// <summary>
        /// Check whether the specified user is allowed to directly create the given inventory type in a prim's
        /// inventory (e.g. the New Script button in the 1.21 Linden Lab client).  This permission check does not 
        /// apply to existing items that are being dragged in to that prim's inventory.
        /// </summary>
        /// <param name="invType"></param>
        /// <param name="objectID"></param>
        /// <param name="userID"></param>
        /// <returns></returns>         
        public bool ExternalChecksCanCreateObjectInventory(int invType, UUID objectID, UUID userID)
        {
            foreach (CanCreateObjectInventory check in CanCreateObjectInventoryCheckFunctions)
            {
                if (check(invType, objectID, userID) == false)
                {
                    return false;
                }
            }
            
            return true;
        }

        public delegate bool CanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID);
        private List<CanCopyObjectInventory> CanCopyObjectInventoryCheckFunctions = new List<CanCopyObjectInventory>();

        public void addCheckCanCopyObjectInventory(CanCopyObjectInventory delegateFunc)
        {
            if (!CanCopyObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanCopyObjectInventoryCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanCopyObjectInventory(CanCopyObjectInventory delegateFunc)
        {
            if (CanCopyObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanCopyObjectInventoryCheckFunctions.Remove(delegateFunc);
        }
       
        public bool ExternalChecksCanCopyObjectInventory(UUID itemID, UUID objectID, UUID userID)
        {
            foreach (CanCopyObjectInventory check in CanCopyObjectInventoryCheckFunctions)
            {
                if (check(itemID, objectID, userID) == false)
                {
                    return false;
                }
            }
            return true;
        }

        public delegate bool CanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID);
        private List<CanDeleteObjectInventory> CanDeleteObjectInventoryCheckFunctions 
            = new List<CanDeleteObjectInventory>();

        public void addCheckCanDeleteObjectInventory(CanDeleteObjectInventory delegateFunc)
        {
            if (!CanDeleteObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanDeleteObjectInventoryCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanDeleteObjectInventory(CanDeleteObjectInventory delegateFunc)
        {
            if (CanDeleteObjectInventoryCheckFunctions.Contains(delegateFunc))
                CanDeleteObjectInventoryCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanDeleteObjectInventory(UUID itemID, UUID objectID, UUID userID)
        {
            foreach (CanDeleteObjectInventory check in CanDeleteObjectInventoryCheckFunctions)
            {
                if (check(itemID, objectID, userID) == false)
                {
                    return false;
                }
            }
            
            return true;
        }

        public delegate bool CanTeleport(UUID userID);
        private List<CanTeleport> CanTeleportCheckFunctions = new List<CanTeleport>();

        public void addCheckCanTeleport(CanTeleport delegateFunc)
        {
            if (!CanTeleportCheckFunctions.Contains(delegateFunc))
                CanTeleportCheckFunctions.Add(delegateFunc);
        }

        public void removeCheckCanTeleport(CanTeleport delegateFunc)
        {
            if (CanTeleportCheckFunctions.Contains(delegateFunc))
                CanTeleportCheckFunctions.Remove(delegateFunc);
        }

        public bool ExternalChecksCanTeleport(UUID userID)
        {
            foreach (CanTeleport check in CanTeleportCheckFunctions)
            {
                if (check(userID) == false)
                {
                    return false;
                }
            }
            return true;
        }
    }
}