From cfaf087b89d8d90322a4a86237c246534c26f961 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Mar 2010 09:23:33 -0800 Subject: More work on GrantRights. Still not right. --- OpenSim/Framework/PrimitiveBaseShape.cs | 68 +++++----- .../CoreModules/Avatar/Friends/FriendsModule.cs | 141 ++++++++++++++------- .../Avatar/Friends/FriendsRequestHandler.cs | 4 +- 3 files changed, 135 insertions(+), 78 deletions(-) diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index b88f162..6a38278 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -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] diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7ec4a9c..61116a7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -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; + if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it + { + FriendsService.StoreFriend(requester, target.ToString(), rights); + + bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0; + if (!onlineBitChanged) + { + remoteClient.SendChangeUserRights(requester, target, rights); } - } - 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); + // 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) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index e7b74a9..140660b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs @@ -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(); -- cgit v1.1