[Opensim-dev] C# tip of the day Was:[Opensim-commits] r4554

Justin Clark-Casey jjustincc at googlemail.com
Thu May 8 20:25:00 UTC 2008


Okay, I'm sorry, I take that back MingChen - on thinking a bit further 
on what I read you're not doing what I thought you were doing :).  Not 
enough sleep today, which leaves me a bit tetchy and too ready to jump 
to conclusions.

Anyway, I'm sure you won't mind further code changes in the future if 
there does turn out to be a neater way to do things.


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


-- 
justincc
Justin Clark-Casey
http://justincc.wordpress.com



More information about the Opensim-dev mailing list