aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-08-16 12:15:14 -0400
committerTeravus Ovares (Dan Olivares)2009-08-16 12:15:14 -0400
commitacc14c472deeb92e0436ac38d16e3f6e049bc546 (patch)
treeb31fd0fd1992c1ea6cad2cc1123ab2422953372f /OpenSim/Region/OptionalModules/Scripting/Minimodule
parent* ShortVersion, another attempt at fixing the test thread death that randomly... (diff)
parent* Implements ISecurityCredential member on SPAvatar, SPAvatarAttachment (diff)
downloadopensim-SC_OLD-acc14c472deeb92e0436ac38d16e3f6e049bc546.zip
opensim-SC_OLD-acc14c472deeb92e0436ac38d16e3f6e049bc546.tar.gz
opensim-SC_OLD-acc14c472deeb92e0436ac38d16e3f6e049bc546.tar.bz2
opensim-SC_OLD-acc14c472deeb92e0436ac38d16e3f6e049bc546.tar.xz
Merge branch 'master' of ssh://MyConnection/var/git/opensim
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs36
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs13
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs15
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs10
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs22
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs114
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs62
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs14
11 files changed, 251 insertions, 52 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs
new file mode 100644
index 0000000..533d176
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ISecurityCredential.cs
@@ -0,0 +1,36 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
29{
30 public interface ISecurityCredential
31 {
32 ISocialEntity owner { get; }
33 bool CanEditObject(IObject target);
34 bool CanEditTerrain(int x, int y);
35 }
36} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs
index 849e3ca..03c1e95 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatar.cs
@@ -32,19 +32,6 @@ using OpenMetaverse;
32 32
33namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 33namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
34{ 34{
35 public interface IAvatarAttachment
36 {
37 //// <value>
38 /// Describes where on the avatar the attachment is located
39 /// </value>
40 int Location { get ; }
41
42 //// <value>
43 /// Accessor to the rez'ed asset, representing the attachment
44 /// </value>
45 IObject Asset { get; }
46 }
47
48 public interface IAvatar : IEntity 35 public interface IAvatar : IEntity
49 { 36 {
50 //// <value> 37 //// <value>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
new file mode 100644
index 0000000..22b4605
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
@@ -0,0 +1,15 @@
1namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
2{
3 public interface IAvatarAttachment
4 {
5 //// <value>
6 /// Describes where on the avatar the attachment is located
7 /// </value>
8 int Location { get ; }
9
10 //// <value>
11 /// Accessor to the rez'ed asset, representing the attachment
12 /// </value>
13 IObject Asset { get; }
14 }
15} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs
index 6415250..19f7210 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs
@@ -212,6 +212,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
212 bool Bright { get; set; } // SetPrimParms(FULLBRIGHT) 212 bool Bright { get; set; } // SetPrimParms(FULLBRIGHT)
213 double Bloom { get; set; } // SetPrimParms(GLOW) 213 double Bloom { get; set; } // SetPrimParms(GLOW)
214 bool Shiny { get; set; } // SetPrimParms(SHINY) 214 bool Shiny { get; set; } // SetPrimParms(SHINY)
215 bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECIATE IN FAVOUR OF UUID?] 215 bool BumpMap { get; set; } // SetPrimParms(BUMPMAP) [DEPRECATE IN FAVOUR OF UUID?]
216 } 216 }
217} 217}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 5ed9af3..6daae29 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -166,8 +166,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
166 166
167 public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host) 167 public void GetGlobalEnvironment(uint localID, out IWorld world, out IHost host)
168 { 168 {
169 world = new World(m_scene); 169 // UUID should be changed to object owner.
170 host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions), m_microthreads); 170 UUID owner = m_scene.RegionInfo.MasterAvatarAssignedUUID;
171 SEUser securityUser = new SEUser(owner, "Name Unassigned");
172 SecurityCredential creds = new SecurityCredential(securityUser, m_scene);
173
174 world = new World(m_scene, creds);
175 host = new Host(new SOPObject(m_scene, localID, creds), m_scene, new ExtensionHandler(m_extensions),
176 m_microthreads);
171 } 177 }
172 178
173 public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID) 179 public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID)
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs
index 4638ad0..6ba5ccf 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs
@@ -40,10 +40,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
40 { 40 {
41 private readonly Scene m_scene; 41 private readonly Scene m_scene;
42 private readonly IEnumerator<EntityBase> m_sogEnum; 42 private readonly IEnumerator<EntityBase> m_sogEnum;
43 private readonly ISecurityCredential m_security;
43 44
44 public IObjEnum(Scene scene) 45 public IObjEnum(Scene scene, ISecurityCredential security)
45 { 46 {
46 m_scene = scene; 47 m_scene = scene;
48 m_security = security;
47 m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); 49 m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator();
48 } 50 }
49 51
@@ -66,7 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
66 { 68 {
67 get 69 get
68 { 70 {
69 return new SOPObject(m_scene, m_sogEnum.Current.LocalId); 71 return new SOPObject(m_scene, m_sogEnum.Current.LocalId, m_security);
70 } 72 }
71 } 73 }
72 74
@@ -79,17 +81,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
79 public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor 81 public class ObjectAccessor : System.MarshalByRefObject, IObjectAccessor
80 { 82 {
81 private readonly Scene m_scene; 83 private readonly Scene m_scene;
84 private readonly ISecurityCredential m_security;
82 85
83 public ObjectAccessor(Scene scene) 86 public ObjectAccessor(Scene scene, ISecurityCredential security)
84 { 87 {
85 m_scene = scene; 88 m_scene = scene;
89 m_security = security;
86 } 90 }
87 91
88 public IObject this[int index] 92 public IObject this[int index]
89 { 93 {
90 get 94 get
91 { 95 {
92 return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); 96 return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId, m_security);
93 } 97 }
94 } 98 }
95 99
@@ -97,7 +101,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
97 { 101 {
98 get 102 get
99 { 103 {
100 return new SOPObject(m_scene, m_scene.Entities[index].LocalId); 104 return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security);
101 } 105 }
102 } 106 }
103 107
@@ -105,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
105 { 109 {
106 get 110 get
107 { 111 {
108 return new SOPObject(m_scene, m_scene.Entities[index].LocalId); 112 return new SOPObject(m_scene, m_scene.Entities[index].LocalId, m_security);
109 } 113 }
110 } 114 }
111 115
@@ -117,20 +121,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
117 public IObject Create(Vector3 position, Quaternion rotation) 121 public IObject Create(Vector3 position, Quaternion rotation)
118 { 122 {
119 123
120 SceneObjectGroup sog = m_scene.AddNewPrim(m_scene.RegionInfo.MasterAvatarAssignedUUID, 124 SceneObjectGroup sog = m_scene.AddNewPrim(m_security.owner.GlobalID,
121 UUID.Zero, 125 UUID.Zero,
122 position, 126 position,
123 rotation, 127 rotation,
124 PrimitiveBaseShape.CreateBox()); 128 PrimitiveBaseShape.CreateBox());
125 129
126 IObject ret = new SOPObject(m_scene, sog.LocalId); 130 IObject ret = new SOPObject(m_scene, sog.LocalId, m_security);
127 131
128 return ret; 132 return ret;
129 } 133 }
130 134
131 public IEnumerator<IObject> GetEnumerator() 135 public IEnumerator<IObject> GetEnumerator()
132 { 136 {
133 return new IObjEnum(m_scene); 137 return new IObjEnum(m_scene, m_security);
134 } 138 }
135 139
136 IEnumerator IEnumerable.GetEnumerator() 140 IEnumerator IEnumerable.GetEnumerator()
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index bc26389..35b0a0f 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Security;
30using OpenMetaverse; 31using OpenMetaverse;
31using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -42,13 +43,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
42 { 43 {
43 private readonly Scene m_rootScene; 44 private readonly Scene m_rootScene;
44 private readonly uint m_localID; 45 private readonly uint m_localID;
46 private readonly ISecurityCredential m_security;
45 47
48 [Obsolete("Replace with 'credential' constructor [security]")]
46 public SOPObject(Scene rootScene, uint localID) 49 public SOPObject(Scene rootScene, uint localID)
47 { 50 {
48 m_rootScene = rootScene; 51 m_rootScene = rootScene;
49 m_localID = localID; 52 m_localID = localID;
50 } 53 }
51 54
55 public SOPObject(Scene rootScene, uint localID, ISecurityCredential credential)
56 {
57 m_rootScene = rootScene;
58 m_localID = localID;
59 m_security = credential;
60 }
61
52 /// <summary> 62 /// <summary>
53 /// This needs to run very, very quickly. 63 /// This needs to run very, very quickly.
54 /// It is utilized in nearly every property and method. 64 /// It is utilized in nearly every property and method.
@@ -59,6 +69,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
59 return m_rootScene.GetSceneObjectPart(m_localID); 69 return m_rootScene.GetSceneObjectPart(m_localID);
60 } 70 }
61 71
72 private bool CanEdit()
73 {
74 if(!m_security.CanEditObject(this))
75 {
76 throw new SecurityException("Insufficient Permission to edit object with UUID [" + GetSOP().UUID + "]");
77 }
78 return true;
79 }
80
62 #region OnTouch 81 #region OnTouch
63 82
64 private event OnTouchDelegate _OnTouch; 83 private event OnTouchDelegate _OnTouch;
@@ -68,14 +87,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
68 { 87 {
69 add 88 add
70 { 89 {
71 if (!_OnTouchActive) 90 if (CanEdit())
72 { 91 {
73 GetSOP().Flags |= PrimFlags.Touch; 92 if (!_OnTouchActive)
74 _OnTouchActive = true; 93 {
75 m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab; 94 GetSOP().Flags |= PrimFlags.Touch;
95 _OnTouchActive = true;
96 m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab;
97 }
98
99 _OnTouch += value;
76 } 100 }
77
78 _OnTouch += value;
79 } 101 }
80 remove 102 remove
81 { 103 {
@@ -95,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
95 if (_OnTouchActive && m_localID == localID) 117 if (_OnTouchActive && m_localID == localID)
96 { 118 {
97 TouchEventArgs e = new TouchEventArgs(); 119 TouchEventArgs e = new TouchEventArgs();
98 e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId); 120 e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId, m_security);
99 e.TouchBiNormal = surfaceArgs.Binormal; 121 e.TouchBiNormal = surfaceArgs.Binormal;
100 e.TouchMaterialIndex = surfaceArgs.FaceIndex; 122 e.TouchMaterialIndex = surfaceArgs.FaceIndex;
101 e.TouchNormal = surfaceArgs.Normal; 123 e.TouchNormal = surfaceArgs.Normal;
@@ -130,13 +152,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
130 public string Name 152 public string Name
131 { 153 {
132 get { return GetSOP().Name; } 154 get { return GetSOP().Name; }
133 set { GetSOP().Name = value; } 155 set
156 {
157 if (CanEdit())
158 GetSOP().Name = value;
159 }
134 } 160 }
135 161
136 public string Description 162 public string Description
137 { 163 {
138 get { return GetSOP().Description; } 164 get { return GetSOP().Description; }
139 set { GetSOP().Description = value; } 165 set
166 {
167 if (CanEdit())
168 GetSOP().Description = value;
169 }
140 } 170 }
141 171
142 public IObject[] Children 172 public IObject[] Children
@@ -151,7 +181,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
151 int i = 0; 181 int i = 0;
152 foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) 182 foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
153 { 183 {
154 rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); 184 rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId, m_security);
155 } 185 }
156 186
157 return rets; 187 return rets;
@@ -160,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
160 190
161 public IObject Root 191 public IObject Root
162 { 192 {
163 get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } 193 get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId, m_security); }
164 } 194 }
165 195
166 public IObjectMaterial[] Materials 196 public IObjectMaterial[] Materials
@@ -182,7 +212,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
182 public Vector3 Scale 212 public Vector3 Scale
183 { 213 {
184 get { return GetSOP().Scale; } 214 get { return GetSOP().Scale; }
185 set { GetSOP().Scale = value; } 215 set
216 {
217 if (CanEdit())
218 GetSOP().Scale = value;
219 }
186 } 220 }
187 221
188 public Quaternion WorldRotation 222 public Quaternion WorldRotation
@@ -202,15 +236,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
202 get { return GetSOP().AbsolutePosition; } 236 get { return GetSOP().AbsolutePosition; }
203 set 237 set
204 { 238 {
205 SceneObjectPart pos = GetSOP(); 239 if (CanEdit())
206 pos.UpdateOffSet(value - pos.AbsolutePosition); 240 {
241 SceneObjectPart pos = GetSOP();
242 pos.UpdateOffSet(value - pos.AbsolutePosition);
243 }
207 } 244 }
208 } 245 }
209 246
210 public Vector3 OffsetPosition 247 public Vector3 OffsetPosition
211 { 248 {
212 get { return GetSOP().OffsetPosition; } 249 get { return GetSOP().OffsetPosition; }
213 set { GetSOP().OffsetPosition = value; } 250 set
251 {
252 if (CanEdit())
253 {
254 GetSOP().OffsetPosition = value;
255 }
256 }
214 } 257 }
215 258
216 public Vector3 SitTarget 259 public Vector3 SitTarget
@@ -310,8 +353,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
310 353
311 public void Say(string msg) 354 public void Say(string msg)
312 { 355 {
313 SceneObjectPart sop = GetSOP(); 356 if (!CanEdit())
357 return;
314 358
359 SceneObjectPart sop = GetSOP();
315 m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false); 360 m_rootScene.SimChat(msg, ChatTypeEnum.Say, sop.AbsolutePosition, sop.Name, sop.UUID, false);
316 } 361 }
317 362
@@ -503,6 +548,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
503 } 548 }
504 set 549 set
505 { 550 {
551 if (!CanEdit())
552 return;
553
506 GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); 554 GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z);
507 } 555 }
508 } 556 }
@@ -516,6 +564,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
516 } 564 }
517 set 565 set
518 { 566 {
567 if (!CanEdit())
568 return;
569
519 GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); 570 GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
520 } 571 }
521 } 572 }
@@ -529,6 +580,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
529 } 580 }
530 set 581 set
531 { 582 {
583 if (!CanEdit())
584 return;
585
532 GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); 586 GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z);
533 } 587 }
534 } 588 }
@@ -551,27 +605,44 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
551 } 605 }
552 set 606 set
553 { 607 {
608 if (!CanEdit())
609 return;
610
554 GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); 611 GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z);
555 } 612 }
556 } 613 }
557 614
558 public bool FloatOnWater 615 public bool FloatOnWater
559 { 616 {
560 set { GetSOP().PhysActor.FloatOnWater = value; } 617 set
618 {
619 if (!CanEdit())
620 return;
621 GetSOP().PhysActor.FloatOnWater = value;
622 }
561 } 623 }
562 624
563 public void AddForce(Vector3 force, bool pushforce) 625 public void AddForce(Vector3 force, bool pushforce)
564 { 626 {
627 if (!CanEdit())
628 return;
629
565 GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); 630 GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce);
566 } 631 }
567 632
568 public void AddAngularForce(Vector3 force, bool pushforce) 633 public void AddAngularForce(Vector3 force, bool pushforce)
569 { 634 {
635 if (!CanEdit())
636 return;
637
570 GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); 638 GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce);
571 } 639 }
572 640
573 public void SetMomentum(Vector3 momentum) 641 public void SetMomentum(Vector3 momentum)
574 { 642 {
643 if (!CanEdit())
644 return;
645
575 GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); 646 GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z));
576 } 647 }
577 648
@@ -586,6 +657,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
586 get { return m_sculptMap; } 657 get { return m_sculptMap; }
587 set 658 set
588 { 659 {
660 if (!CanEdit())
661 return;
662
589 m_sculptMap = value; 663 m_sculptMap = value;
590 SetPrimitiveSculpted(SculptMap, (byte) SculptType); 664 SetPrimitiveSculpted(SculptMap, (byte) SculptType);
591 } 665 }
@@ -598,6 +672,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
598 get { return m_sculptType; } 672 get { return m_sculptType; }
599 set 673 set
600 { 674 {
675 if(!CanEdit())
676 return;
677
601 m_sculptType = value; 678 m_sculptType = value;
602 SetPrimitiveSculpted(SculptMap, (byte) SculptType); 679 SetPrimitiveSculpted(SculptMap, (byte) SculptType);
603 } 680 }
@@ -654,6 +731,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
654 731
655 public void Play(UUID asset, double volume) 732 public void Play(UUID asset, double volume)
656 { 733 {
734 if (!CanEdit())
735 return;
736
657 GetSOP().SendSound(asset.ToString(), volume, true, 0); 737 GetSOP().SendSound(asset.ToString(), volume, true, 0);
658 } 738 }
659 739
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
index ce2d339..4600836 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
@@ -42,11 +42,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
42 { 42 {
43 private readonly Scene m_rootScene; 43 private readonly Scene m_rootScene;
44 private readonly UUID m_ID; 44 private readonly UUID m_ID;
45 private readonly ISecurityCredential m_security;
45 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 47
47 public SPAvatar(Scene scene, UUID ID) 48 public SPAvatar(Scene scene, UUID ID, ISecurityCredential security)
48 { 49 {
49 m_rootScene = scene; 50 m_rootScene = scene;
51 m_security = security;
50 m_ID = ID; 52 m_ID = ID;
51 } 53 }
52 54
@@ -84,7 +86,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
84 foreach (DictionaryEntry element in internalAttachments) 86 foreach (DictionaryEntry element in internalAttachments)
85 { 87 {
86 Hashtable attachInfo = (Hashtable)element.Value; 88 Hashtable attachInfo = (Hashtable)element.Value;
87 attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int)element.Key, new UUID((string)attachInfo["item"]), new UUID((string)attachInfo["asset"]))); 89 attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key,
90 new UUID((string) attachInfo["item"]),
91 new UUID((string) attachInfo["asset"]), m_security));
88 } 92 }
89 } 93 }
90 94
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs
index 9b684fe..570459a 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs
@@ -39,10 +39,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
39 private readonly int m_location; 39 private readonly int m_location;
40 //private readonly UUID m_itemId; 40 //private readonly UUID m_itemId;
41 private readonly UUID m_assetId; 41 private readonly UUID m_assetId;
42
43 private readonly ISecurityCredential m_security;
42 44
43 public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId) 45 public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId, ISecurityCredential security)
44 { 46 {
45 m_rootScene = rootScene; 47 m_rootScene = rootScene;
48 m_security = security;
46 //m_parent = self; 49 //m_parent = self;
47 m_location = location; 50 m_location = location;
48 //m_itemId = itemId; 51 //m_itemId = itemId;
@@ -55,7 +58,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
55 { 58 {
56 get 59 get
57 { 60 {
58 return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId); 61 return new SOPObject(m_rootScene, m_rootScene.GetSceneObjectPart(m_assetId).LocalId, m_security);
59 } 62 }
60 } 63 }
61 } 64 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs
new file mode 100644
index 0000000..bc7f6cb
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SecurityCredential.cs
@@ -0,0 +1,62 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenMetaverse;
32using OpenSim.Region.Framework.Scenes;
33
34namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
35{
36 class SecurityCredential : ISecurityCredential
37 {
38 private readonly ISocialEntity m_owner;
39 private readonly Scene m_scene;
40
41 public SecurityCredential(ISocialEntity m_owner, Scene m_scene)
42 {
43 this.m_owner = m_owner;
44 this.m_scene = m_scene;
45 }
46
47 public ISocialEntity owner
48 {
49 get { return m_owner; }
50 }
51
52 public bool CanEditObject(IObject target)
53 {
54 return m_scene.Permissions.CanEditObject(target.GlobalID, m_owner.GlobalID);
55 }
56
57 public bool CanEditTerrain(int x, int y)
58 {
59 return m_scene.Permissions.CanTerraformLand(m_owner.GlobalID, new Vector3(x, y, 0));
60 }
61 }
62}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
index 1ec4a33..da5ea0d 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
@@ -37,15 +37,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
37 public class World : System.MarshalByRefObject, IWorld, IWorldAudio 37 public class World : System.MarshalByRefObject, IWorld, IWorldAudio
38 { 38 {
39 private readonly Scene m_internalScene; 39 private readonly Scene m_internalScene;
40 private readonly ISecurityCredential m_security;
40 private readonly Heightmap m_heights; 41 private readonly Heightmap m_heights;
41 42
42 private readonly ObjectAccessor m_objs; 43 private readonly ObjectAccessor m_objs;
43 44
44 public World(Scene internalScene) 45 public World(Scene internalScene, ISecurityCredential securityCredential)
45 { 46 {
47 m_security = securityCredential;
46 m_internalScene = internalScene; 48 m_internalScene = internalScene;
47 m_heights = new Heightmap(m_internalScene); 49 m_heights = new Heightmap(m_internalScene);
48 m_objs = new ObjectAccessor(m_internalScene); 50 m_objs = new ObjectAccessor(m_internalScene, securityCredential);
49 } 51 }
50 52
51 #region Events 53 #region Events
@@ -84,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
84 if (_OnNewUser != null) 86 if (_OnNewUser != null)
85 { 87 {
86 NewUserEventArgs e = new NewUserEventArgs(); 88 NewUserEventArgs e = new NewUserEventArgs();
87 e.Avatar = new SPAvatar(m_internalScene, presence.UUID); 89 e.Avatar = new SPAvatar(m_internalScene, presence.UUID, m_security);
88 _OnNewUser(this, e); 90 _OnNewUser(this, e);
89 } 91 }
90 } 92 }
@@ -144,7 +146,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
144 if (chat.Sender == null && chat.SenderObject != null) 146 if (chat.Sender == null && chat.SenderObject != null)
145 { 147 {
146 ChatEventArgs e = new ChatEventArgs(); 148 ChatEventArgs e = new ChatEventArgs();
147 e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId); 149 e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security);
148 e.Text = chat.Message; 150 e.Text = chat.Message;
149 151
150 _OnChat(this, e); 152 _OnChat(this, e);
@@ -154,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
154 if (chat.Sender != null && chat.SenderObject == null) 156 if (chat.Sender != null && chat.SenderObject == null)
155 { 157 {
156 ChatEventArgs e = new ChatEventArgs(); 158 ChatEventArgs e = new ChatEventArgs();
157 e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID); 159 e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security);
158 e.Text = chat.Message; 160 e.Text = chat.Message;
159 161
160 _OnChat(this, e); 162 _OnChat(this, e);
@@ -207,7 +209,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
207 for (int i = 0; i < ents.Count; i++) 209 for (int i = 0; i < ents.Count; i++)
208 { 210 {
209 EntityBase ent = ents[i]; 211 EntityBase ent = ents[i];
210 rets[i] = new SPAvatar(m_internalScene, ent.UUID); 212 rets[i] = new SPAvatar(m_internalScene, ent.UUID, m_security);
211 } 213 }
212 214
213 return rets; 215 return rets;