<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Guys,<BR>
 <BR>
Just in case you all missed it; there's a compromise between delegates and events : multicast delegates.<BR>
 <BR>
Right now, we're just adding delegates to an delegate handler and invoke it by the default behaviour - run them all, in no defined order, disregarding the result of the invocation;<BR>
 <BR>
If we want a bit more intelligent invocation, consider this:<BR>
 <BR>
---<BR>
 <BR><FONT size=2></FONT><FONT face="" color=#2b91af size=2><FONT size=2>
</FONT><FONT color=#0000ff size=2>delegate</FONT><FONT size=2> </FONT><FONT face="" color=#0000ff size=2>bool </FONT><FONT color=#2b91af size=2>CheckPermissionsHandler</FONT><FONT size=2>(</FONT><FONT face="" color=#2b91af size=2> LLUUID userId, object obj </FONT><FONT face="" size=2>);<BR>
</FONT> <BR>
CheckPermissionsHandler </FONT><FONT face="" size=2>handlerList = </FONT><FONT face="" color=#0000ff size=2>null</FONT><FONT face="" size=2>;</FONT><BR>
<FONT face="" size=2></FONT> <BR>
handlerList += myHandler1;<BR>
handlerList += myHandler2;<BR>
<FONT face="" size=2></FONT> <BR>
<FONT face="" size=2>bool hasRights = true;</FONT><BR>
<FONT face="" size=2> <BR>
</FONT><FONT face="" color=#0000ff size=2>foreach</FONT><FONT size=2> (</FONT><FONT face="" color=#2b91af size=2>CheckPermissionsHandler </FONT><FONT face="" size=2>handler </FONT><FONT color=#0000ff size=2>in</FONT><FONT face="" size=2> del.GetInvocationList())<BR>
{<BR>
   if( !handler(userId</FONT><FONT face="" size=2>, obj ) )</FONT><BR>
<FONT face="" size=2>   {</FONT><BR>
      hasRights = false;<BR>
<FONT face="" size=2>   }<BR>
}<BR></FONT>
 <BR>
return hasRights;<BR>
 <BR>
---<BR>
 <BR>
What this would do, is to broadcast a permissions check, and if anybody objects, return false.<BR>
 <BR>
I guess this is what you want.<BR>
<BR>/Stefan<BR><BR>
<HR id=stopSpelling>
> Date: Wed, 7 May 2008 20:38:58 +0100<BR>> From: jjustincc@googlemail.com<BR>> To: opensim-dev@lists.berlios.de<BR>> Subject: Re: [Opensim-dev] [Opensim-commits] r4554 - in trunk/OpenSim/Region: ClientStack/LindenUDP Environment/Interfaces Environment/Modules/World/Permissions Environment/Scenes<BR>> <BR>> Hi MingChen,<BR>> <BR>> Couldn't these external check hooks be added directly into the <BR>> PermissionsModule, rather than having the scene call the module, only <BR>> for the module to call back into the scene?<BR>> <BR>> <BR>> mingchen@opensimulator.org wrote:<BR>> > Author: mingchen<BR>> > Date: 2008-05-07 10:33:57 -0700 (Wed, 07 May 2008)<BR>> > New Revision: 4554<BR>> > <BR>> > Modified:<BR>> > trunk/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs<BR>> > trunk/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs<BR>> > trunk/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs<BR>> > trunk/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs<BR>> > trunk/OpenSim/Region/Environment/Scenes/Scene.cs<BR>> > trunk/OpenSim/Region/Environment/Scenes/SceneBase.cs<BR>> > Log:<BR>> > *Added SceneExternalChecks.cs that is used to manage checking the results of multiple functions that register with the class and return the result (usually true/false) based on those results. This is useful for module wanting to put their opinion in decisions such as 'can the user rez this object?'<BR>> > <BR>> > Modified: trunk/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs<BR>> > ===================================================================<BR>> > --- trunk/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs 2008-05-07 16:48:29 UTC (rev 4553)<BR>> > +++ trunk/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs 2008-05-07 17:33:57 UTC (rev 4554)<BR>> > @@ -4047,6 +4047,9 @@<BR>> > //RayEnd: <61.97724, 141.995, 92.58341> <BR>> > //RayTargetID: 00000000-0000-0000-0000-000000000000<BR>> > <BR>> > + //Check to see if adding the prim is allowed; useful for any module wanting to restrict the<BR>> > + //object from rezing initially<BR>> > + <BR>> > handlerAddPrim = OnAddPrim;<BR>> > if (handlerAddPrim != null)<BR>> > handlerAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);<BR>> > <BR>> > Modified: trunk/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs<BR>> > ===================================================================<BR>> > --- trunk/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs 2008-05-07 16:48:29 UTC (rev 4553)<BR>> > +++ trunk/OpenSim/Region/Environment/Interfaces/IScenePermissions.cs 2008-05-07 17:33:57 UTC (rev 4554)<BR>> > @@ -34,9 +34,9 @@<BR>> > bool BypassPermissions { get; set; }<BR>> > <BR>> > #region Object Permissions<BR>> > +<BR>> > + bool CanRezObject(LLUUID user, LLVector3 position, int count);<BR>> > <BR>> > - bool CanRezObject(LLUUID user, LLVector3 position);<BR>> > - <BR>> > /// <summary><BR>> > /// Permissions check - can user delete an object?<BR>> > /// </summary><BR>> > <BR>> > Modified: trunk/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs<BR>> > ===================================================================<BR>> > --- trunk/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs 2008-05-07 16:48:29 UTC (rev 4553)<BR>> > +++ trunk/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs 2008-05-07 17:33:57 UTC (rev 4554)<BR>> > @@ -140,12 +140,21 @@<BR>> > return false;<BR>> > }<BR>> > <BR>> > - public virtual bool CanRezObject(LLUUID user, LLVector3 position)<BR>> > + public virtual bool CanRezObject(LLUUID user, LLVector3 position, int objectCount)<BR>> > {<BR>> > bool permission = false;<BR>> > <BR>> > + <BR>> > +<BR>> > string reason = "Insufficient permission";<BR>> > <BR>> > + //Perform ExternalChecks first!<BR>> > + bool results = m_scene.ExternalChecks.ExternalChecksCanRezObject(objectCount, user, position);<BR>> > + if (results == false)<BR>> > + {<BR>> > + return false;<BR>> > + }<BR>> > +<BR>> > ILandObject land = m_scene.LandChannel.GetLandObject(position.X, position.Y);<BR>> > if (land == null) return false;<BR>> > <BR>> > <BR>> > Modified: trunk/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs<BR>> > ===================================================================<BR>> > --- trunk/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs 2008-05-07 16:48:29 UTC (rev 4553)<BR>> > +++ trunk/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs 2008-05-07 17:33:57 UTC (rev 4554)<BR>> > @@ -1267,10 +1267,7 @@<BR>> > RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), <BR>> > BypassRayCast, bRayEndIsIntersection,true,scale, false);<BR>> > <BR>> > - if (!Permissions.CanRezObject(remoteClient.AgentId, pos) && !attachment)<BR>> > - {<BR>> > - return null; <BR>> > - }<BR>> > + <BR>> > <BR>> > // Rez object<BR>> > CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);<BR>> > @@ -1288,6 +1285,11 @@<BR>> > {<BR>> > string xmlData = Helpers.FieldToUTF8String(rezAsset.Data); <BR>> > SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);<BR>> > + if (!Permissions.CanRezObject(remoteClient.AgentId, pos, group.Children.Count) && !attachment)<BR>> > + {<BR>> > + return null;<BR>> > + }<BR>> > +<BR>> > group.ResetIDs();<BR>> > AddEntity(group);<BR>> > <BR>> > @@ -1361,10 +1363,6 @@<BR>> > {<BR>> > LLUUID ownerID = item.OwnerID;<BR>> > <BR>> > - if (!Permissions.CanRezObject(ownerID, pos))<BR>> > - {<BR>> > - return null;<BR>> > - }<BR>> > <BR>> > AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false);<BR>> > <BR>> > @@ -1372,6 +1370,11 @@<BR>> > {<BR>> > string xmlData = Helpers.FieldToUTF8String(rezAsset.Data);<BR>> > SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);<BR>> > +<BR>> > + if (!Permissions.CanRezObject(ownerID, pos, group.Children.Count))<BR>> > + {<BR>> > + return null;<BR>> > + }<BR>> > group.ResetIDs();<BR>> > AddEntity(group);<BR>> > <BR>> > <BR>> > Modified: trunk/OpenSim/Region/Environment/Scenes/Scene.cs<BR>> > ===================================================================<BR>> > --- trunk/OpenSim/Region/Environment/Scenes/Scene.cs 2008-05-07 16:48:29 UTC (rev 4553)<BR>> > +++ trunk/OpenSim/Region/Environment/Scenes/Scene.cs 2008-05-07 17:33:57 UTC (rev 4554)<BR>> > @@ -241,6 +241,7 @@<BR>> > m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;<BR>> > <BR>> > m_eventManager = new EventManager();<BR>> > + m_externalChecks = new SceneExternalChecks(this);<BR>> > <BR>> > //Bind Storage Manager functions to some land manager functions for this scene<BR>> > EventManager.OnLandObjectAdded +=<BR>> > @@ -829,7 +830,7 @@<BR>> > {<BR>> > ForEachScenePresence(delegate(ScenePresence presence) { whatToDo(presence.ControllingClient); });<BR>> > }<BR>> > -<BR>> > + <BR>> > /// <summary><BR>> > /// <BR>> > /// </summary><BR>> > @@ -1244,7 +1245,7 @@<BR>> > <BR>> > LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection, true, new LLVector3(0.5f,0.5f,0.5f), false);<BR>> > <BR>> > - if (Permissions.CanRezObject(ownerID, pos))<BR>> > + if (Permissions.CanRezObject(ownerID, pos, 1))<BR>> > {<BR>> > // rez ON the ground, not IN the ground<BR>> > pos.Z += 0.25F;<BR>> > @@ -3217,5 +3218,7 @@<BR>> > return visualParams;<BR>> > }<BR>> > #endregion<BR>> > +<BR>> > +<BR>> > }<BR>> > }<BR>> > <BR>> > Modified: trunk/OpenSim/Region/Environment/Scenes/SceneBase.cs<BR>> > ===================================================================<BR>> > --- trunk/OpenSim/Region/Environment/Scenes/SceneBase.cs 2008-05-07 16:48:29 UTC (rev 4553)<BR>> > +++ trunk/OpenSim/Region/Environment/Scenes/SceneBase.cs 2008-05-07 17:33:57 UTC (rev 4554)<BR>> > @@ -71,6 +71,12 @@<BR>> > get { return m_eventManager; }<BR>> > }<BR>> > <BR>> > +<BR>> > + protected SceneExternalChecks m_externalChecks;<BR>> > + public SceneExternalChecks ExternalChecks<BR>> > + {<BR>> > + get { return m_externalChecks; }<BR>> > + }<BR>> > <BR>> > protected string m_datastore;<BR>> > <BR>> > <BR>> > _______________________________________________<BR>> > Opensim-commits mailing list<BR>> > Opensim-commits@lists.berlios.de<BR>> > https://lists.berlios.de/mailman/listinfo/opensim-commits<BR>> > <BR>> <BR>> <BR>> -- <BR>> justincc<BR>> Justin Clark-Casey<BR>> http://justincc.wordpress.com<BR>> _______________________________________________<BR>> Opensim-dev mailing list<BR>> Opensim-dev@lists.berlios.de<BR>> https://lists.berlios.de/mailman/listinfo/opensim-dev<BR><BR></body>
</html>