Friends rights under control.

slimupdates
Diva Canto 2010-03-01 21:32:55 -08:00
parent cfaf087b89
commit c6a5ff26ff
4 changed files with 41 additions and 72 deletions

View File

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

View File

@ -196,6 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
{ {
UUID fromID = UUID.Zero; UUID fromID = UUID.Zero;
UUID toID = UUID.Zero; UUID toID = UUID.Zero;
int rights = 0, userFlags = 0;
if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID"))
return FailureResult(); return FailureResult();
@ -206,8 +207,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (!UUID.TryParse(request["ToID"].ToString(), out toID)) if (!UUID.TryParse(request["ToID"].ToString(), out toID))
return FailureResult(); return FailureResult();
// !!! if (!Int32.TryParse(request["UserFlags"].ToString(), out userFlags))
if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0)) return FailureResult();
if (!Int32.TryParse(request["Rights"].ToString(), out rights))
return FailureResult();
if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, userFlags, rights))
return SuccessResult(); return SuccessResult();
return FailureResult(); return FailureResult();

View File

@ -99,7 +99,7 @@ namespace OpenSim.Services.Connectors.Friends
return Call(region, sendData); return Call(region, sendData);
} }
public bool GrantRights(GridRegion region, UUID userID, UUID friendID) public bool GrantRights(GridRegion region, UUID userID, UUID friendID, int userFlags, int rights)
{ {
Dictionary<string, object> sendData = new Dictionary<string, object>(); Dictionary<string, object> sendData = new Dictionary<string, object>();
//sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
@ -108,6 +108,8 @@ namespace OpenSim.Services.Connectors.Friends
sendData["FromID"] = userID.ToString(); sendData["FromID"] = userID.ToString();
sendData["ToID"] = friendID.ToString(); sendData["ToID"] = friendID.ToString();
sendData["UserFlags"] = userFlags.ToString();
sendData["Rights"] = rights.ToString();
return Call(region, sendData); return Call(region, sendData);
} }

View File

@ -32,13 +32,17 @@ using System.Collections.Generic;
namespace OpenSim.Services.Interfaces namespace OpenSim.Services.Interfaces
{ {
public struct FriendInfo public class FriendInfo
{ {
public UUID PrincipalID; public UUID PrincipalID;
public string Friend; public string Friend;
public int MyFlags; public int MyFlags;
public int TheirFlags; public int TheirFlags;
public FriendInfo()
{
}
public FriendInfo(Dictionary<string, object> kvp) public FriendInfo(Dictionary<string, object> kvp)
{ {
PrincipalID = UUID.Zero; PrincipalID = UUID.Zero;