More work on GrantRights. Still not right.

slimupdates
Diva Canto 2010-03-01 09:23:33 -08:00
parent b8d89ac6da
commit cfaf087b89
3 changed files with 136 additions and 79 deletions

View File

@ -186,40 +186,40 @@ namespace OpenSim.Framework
PCode = (byte)PCodeEnum.Primitive;
ExtraParams = new byte[1];
m_textureEntry = DEFAULT_TEXTURE;
}
public PrimitiveBaseShape(Primitive prim)
{
PCode = (byte)prim.PrimData.PCode;
ExtraParams = new byte[1];
State = prim.PrimData.State;
PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd);
PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX);
PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY);
PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX);
PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY);
PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew);
ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin);
ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd);
Scale = prim.Scale;
PathCurve = (byte)prim.PrimData.PathCurve;
ProfileCurve = (byte)prim.PrimData.ProfileCurve;
ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow);
PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset);
PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions);
PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX);
PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY);
PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist);
PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin);
m_textureEntry = prim.Textures.GetBytes();
SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None);
SculptData = prim.Sculpt.GetBytes();
SculptTexture = prim.Sculpt.SculptTexture;
SculptType = (byte)prim.Sculpt.Type;
}
public PrimitiveBaseShape(Primitive prim)
{
PCode = (byte)prim.PrimData.PCode;
ExtraParams = new byte[1];
State = prim.PrimData.State;
PathBegin = Primitive.PackBeginCut(prim.PrimData.PathBegin);
PathEnd = Primitive.PackEndCut(prim.PrimData.PathEnd);
PathScaleX = Primitive.PackPathScale(prim.PrimData.PathScaleX);
PathScaleY = Primitive.PackPathScale(prim.PrimData.PathScaleY);
PathShearX = (byte)Primitive.PackPathShear(prim.PrimData.PathShearX);
PathShearY = (byte)Primitive.PackPathShear(prim.PrimData.PathShearY);
PathSkew = Primitive.PackPathTwist(prim.PrimData.PathSkew);
ProfileBegin = Primitive.PackBeginCut(prim.PrimData.ProfileBegin);
ProfileEnd = Primitive.PackEndCut(prim.PrimData.ProfileEnd);
Scale = prim.Scale;
PathCurve = (byte)prim.PrimData.PathCurve;
ProfileCurve = (byte)prim.PrimData.ProfileCurve;
ProfileHollow = Primitive.PackProfileHollow(prim.PrimData.ProfileHollow);
PathRadiusOffset = Primitive.PackPathTwist(prim.PrimData.PathRadiusOffset);
PathRevolutions = Primitive.PackPathRevolutions(prim.PrimData.PathRevolutions);
PathTaperX = Primitive.PackPathTaper(prim.PrimData.PathTaperX);
PathTaperY = Primitive.PackPathTaper(prim.PrimData.PathTaperY);
PathTwist = Primitive.PackPathTwist(prim.PrimData.PathTwist);
PathTwistBegin = Primitive.PackPathTwist(prim.PrimData.PathTwistBegin);
m_textureEntry = prim.Textures.GetBytes();
SculptEntry = (prim.Sculpt.Type != OpenMetaverse.SculptType.None);
SculptData = prim.Sculpt.GetBytes();
SculptTexture = prim.Sculpt.SculptTexture;
SculptType = (byte)prim.Sculpt.Type;
}
[XmlIgnore]

View File

@ -566,52 +566,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (!m_Friends.ContainsKey(remoteClient.AgentId))
return;
m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target);
// Let's find the friend in this user's friend list
UserFriendData fd = m_Friends[remoteClient.AgentId];
FriendsService.StoreFriend(requester, target.ToString(), rights);
FriendInfo friend = new FriendInfo();
foreach (FriendInfo fi in fd.Friends)
{
if (fi.Friend == target.ToString())
{
IClientAPI friendClient = LocateClientObject(target);
friend = fi;
int delta = rights ^ fi.MyFlags;
if ((delta & ~1) != 0)
{
remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1);
//
// Notify the friend
//
if (friendClient != null)
{
friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1);
}
}
if ((delta & 1) != 0)
{
if (friendClient != null)
{
if ((rights & 1) != 0)
friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) } );
else
friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) } );
}
}
if (friendClient != null) // Local, we're done
return;
}
}
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() });
PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
if (friendSession != null)
if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
// TODO: You might want to send the delta to save the lookup
// on the other end!!
m_FriendsSimConnector.GrantRights(region, requester, target);
FriendsService.StoreFriend(requester, target.ToString(), rights);
bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0;
if (!onlineBitChanged)
{
remoteClient.SendChangeUserRights(requester, target, rights);
}
// Try local
if (LocalGrantRights(requester, target, friend.MyFlags, rights))
return;
//int delta = rights ^ friend.MyFlags;
//if ((delta & ~1) != 0)
//{
// //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1);
// //
// // Notify the friend
// //
// if (friendClient != null)
// {
// friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1);
// }
//}
//if ((delta & 1) != 0)
//{
// if (friendClient != null)
// {
// if ((rights & 1) != 0)
// friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) });
// else
// friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) });
// }
//}
//if (friendClient != null) // Local, we're done
// return;
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() });
PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions);
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
// TODO: You might want to send the delta to save the lookup
// on the other end!!
m_FriendsSimConnector.GrantRights(region, requester, target);
}
}
}
@ -681,10 +693,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
return false;
}
public bool LocalGrantRights()
public bool LocalGrantRights(UUID userID, UUID friendID, int myFlags, int rights)
{
// TODO
return true;
m_log.DebugFormat("XXX Trying to locate {0}", friendID);
IClientAPI friendClient = LocateClientObject(friendID);
if (friendClient != null)
{
bool onlineBitChanged = ((rights ^ myFlags) & (int)FriendRights.CanSeeOnline) == 0;
if (!onlineBitChanged)
friendClient.SendChangeUserRights(userID, friendID, rights);
else
{
if ((rights & (int)FriendRights.CanSeeOnline) == 1)
friendClient.SendAgentOnline(new UUID[] { new UUID(userID) });
else
friendClient.SendAgentOffline(new UUID[] { new UUID(userID) });
}
return true;
}
return false;
//int delta = rights ^ friend.MyFlags;
//if ((delta & ~1) != 0)
//{
// //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1);
// //
// // Notify the friend
// //
// if (friendClient != null)
// {
// friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1);
// }
//}
//if ((delta & 1) != 0)
//{
// if (friendClient != null)
// {
// if ((rights & 1) != 0)
// friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) });
// else
// friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) });
// }
//}
//if (friendClient != null) // Local, we're done
// return;
}
public bool LocalStatusNotification(UUID userID, UUID friendID, bool online)

View File

@ -34,6 +34,7 @@ using System.Xml;
using OpenSim.Framework;
using OpenSim.Server.Base;
using OpenSim.Framework.Servers.HttpServer;
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
using OpenMetaverse;
using log4net;
@ -205,7 +206,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (!UUID.TryParse(request["ToID"].ToString(), out toID))
return FailureResult();
if (m_FriendsModule.LocalGrantRights(/* ??? */))
// !!!
if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0))
return SuccessResult();
return FailureResult();