More work on GrantRights. Still not right.
parent
b8d89ac6da
commit
cfaf087b89
|
@ -566,43 +566,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
if (!m_Friends.ContainsKey(remoteClient.AgentId))
|
if (!m_Friends.ContainsKey(remoteClient.AgentId))
|
||||||
return;
|
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];
|
UserFriendData fd = m_Friends[remoteClient.AgentId];
|
||||||
|
FriendInfo friend = new FriendInfo();
|
||||||
|
foreach (FriendInfo fi in fd.Friends)
|
||||||
|
if (fi.Friend == target.ToString())
|
||||||
|
friend = fi;
|
||||||
|
|
||||||
|
if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it
|
||||||
|
{
|
||||||
FriendsService.StoreFriend(requester, target.ToString(), rights);
|
FriendsService.StoreFriend(requester, target.ToString(), rights);
|
||||||
|
|
||||||
foreach (FriendInfo fi in fd.Friends)
|
bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0;
|
||||||
|
if (!onlineBitChanged)
|
||||||
{
|
{
|
||||||
if (fi.Friend == target.ToString())
|
remoteClient.SendChangeUserRights(requester, target, rights);
|
||||||
{
|
}
|
||||||
IClientAPI friendClient = LocateClientObject(target);
|
|
||||||
|
|
||||||
int delta = rights ^ fi.MyFlags;
|
// Try local
|
||||||
if ((delta & ~1) != 0)
|
if (LocalGrantRights(requester, target, friend.MyFlags, rights))
|
||||||
{
|
|
||||||
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;
|
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);
|
||||||
|
@ -614,6 +625,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
m_FriendsSimConnector.GrantRights(region, requester, target);
|
m_FriendsSimConnector.GrantRights(region, requester, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Local
|
#region Local
|
||||||
|
|
||||||
|
@ -681,12 +693,55 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool LocalGrantRights()
|
public bool LocalGrantRights(UUID userID, UUID friendID, int myFlags, int rights)
|
||||||
{
|
{
|
||||||
// TODO
|
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 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)
|
public bool LocalStatusNotification(UUID userID, UUID friendID, bool online)
|
||||||
{
|
{
|
||||||
IClientAPI friendClient = LocateClientObject(friendID);
|
IClientAPI friendClient = LocateClientObject(friendID);
|
||||||
|
|
|
@ -34,6 +34,7 @@ using System.Xml;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Server.Base;
|
using OpenSim.Server.Base;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
|
using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
@ -205,7 +206,8 @@ 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 (m_FriendsModule.LocalGrantRights(/* ??? */))
|
// !!!
|
||||||
|
if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0))
|
||||||
return SuccessResult();
|
return SuccessResult();
|
||||||
|
|
||||||
return FailureResult();
|
return FailureResult();
|
||||||
|
|
Loading…
Reference in New Issue