Merge branch 'master' into careminster-presence-refactor

avinationmerge
Melanie 2010-06-11 17:46:29 +01:00
commit aa2f5bdd77
5 changed files with 122 additions and 96 deletions

View File

@ -221,8 +221,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
client.OnGrantUserRights += OnGrantUserRights;
client.OnLogout += OnLogout;
lock (m_Friends)
{
if (m_Friends.ContainsKey(client.AgentId))
@ -241,11 +239,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
m_Friends.Add(client.AgentId, newFriends);
}
//StatusChange(client.AgentId, true);
}
private void OnClientClosed(UUID agentID, Scene scene)
{
ScenePresence sp = scene.GetScenePresence(agentID);
if (sp != null && !sp.IsChildAgent)
// do this for root agents closing out
StatusChange(agentID, false);
lock (m_Friends)
if (m_Friends.ContainsKey(agentID))
{
@ -256,23 +258,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
}
}
private void OnLogout(IClientAPI client)
{
StatusChange(client.AgentId, false);
m_Friends.Remove(client.AgentId);
}
private void OnMakeRootAgent(ScenePresence sp)
{
UUID agentID = sp.ControllingClient.AgentId;
if (m_Friends.ContainsKey(agentID))
{
if (m_Friends[agentID].RegionID == UUID.Zero)
{
m_Friends[agentID].Friends =
// This is probably an overkill, but just
// to make sure we have the latest and greatest
// friends list -- always pull OnMakeRoot
m_Friends[agentID].Friends =
m_FriendsService.GetFriends(agentID);
}
m_Friends[agentID].RegionID =
sp.ControllingClient.Scene.RegionInfo.RegionID;
}
@ -438,56 +435,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
/// <param name="online"></param>
private void StatusChange(UUID agentID, bool online)
{
//m_log.DebugFormat("[FRIENDS]: StatusChange {0}", online);
if (m_Friends.ContainsKey(agentID))
{
//m_log.DebugFormat("[FRIENDS]: # of friends: {0}", m_Friends[agentID].Friends.Length);
List<FriendInfo> friendList = new List<FriendInfo>();
foreach (FriendInfo fi in m_Friends[agentID].Friends)
{
if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1))
friendList.Add(fi);
}
/*
foreach (FriendInfo fi in friendList)
{
// Notify about this user status
StatusNotify(fi, agentID, online);
}
*/
StatusNotifyMass(friendList, agentID, online);
}
}
private void StatusNotifyMass(List<FriendInfo> friendList, UUID userID, bool online)
{
int fct = friendList.Count;
string[] friendIDs = new string[fct];
int notlocal = 0;
for (int x = 0 ; x < fct ; x++)
{
UUID friendID = UUID.Zero;
if (UUID.TryParse(friendList[x].Friend, out friendID))
Util.FireAndForget(delegate
{
if (!LocalStatusNotification(userID, friendID, online))
foreach (FriendInfo fi in friendList)
{
friendIDs[notlocal++] = friendID.ToString();
//m_log.DebugFormat("[FRIENDS]: Notifying {0}", fi.PrincipalID);
// Notify about this user status
StatusNotify(fi, agentID, online);
}
}
}
PresenceInfo[] friendSessions = PresenceService.GetAgents(friendIDs);
for (int x = 0; x < friendSessions.GetLength(0); x++)
{
if (friendIDs.Length <= x)
continue;
PresenceInfo friendSession = friendSessions[x];
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
m_FriendsSimConnector.StatusNotify(region, userID, new UUID(friendIDs[x]), online);
}
});
}
else
m_log.WarnFormat("[FRIENDS]: {0} not found in cache", agentID);
}
private void StatusNotify(FriendInfo friend, UUID userID, bool online)
@ -504,16 +474,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() });
if (friendSessions != null && friendSessions.Length > 0)
{
PresenceInfo friendSession = friendSessions[0];
PresenceInfo friendSession = null;
foreach (PresenceInfo pinfo in friendSessions)
if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad
{
friendSession = pinfo;
break;
}
if (friendSession != null)
{
GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
//m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName);
m_FriendsSimConnector.StatusNotify(region, userID, friendID, online);
}
}
// Friend is not online. Ignore.
}
else
m_log.WarnFormat("[FRIENDS]: Error parsing friend ID {0}", friend.Friend);
}
private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
@ -800,7 +780,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
IClientAPI friendClient = LocateClientObject(friendID);
if (friendClient != null)
{
//m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online);
//m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
// the friend in this sim as root agent
if (online)
friendClient.SendAgentOnline(new UUID[] { userID });

View File

@ -3485,11 +3485,27 @@ namespace OpenSim.Region.Framework.Scenes
agent.AgentID, agent.circuitcode, teleportFlags);
reason = String.Empty;
if (!VerifyUserPresence(agent, out reason))
try
{
if (!VerifyUserPresence(agent, out reason))
return false;
}
catch (Exception e)
{
m_log.DebugFormat("[CONNECTION BEGIN]: Exception verifying presence {0}", e.Message);
return false;
}
if (!AuthorizeUser(agent, out reason))
try
{
if (!AuthorizeUser(agent, out reason))
return false;
}
catch (Exception e)
{
m_log.DebugFormat("[CONNECTION BEGIN]: Exception authorizing user {0}", e.Message);
return false;
}
m_log.InfoFormat(
"[CONNECTION BEGIN]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})",
@ -3699,14 +3715,19 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
if (m_regInfo.EstateSettings != null)
{
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
reason = String.Format("Denied access to region {0}: You have been banned from that region.",
RegionInfo.RegionName);
return false;
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
{
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
reason = String.Format("Denied access to region {0}: You have been banned from that region.",
RegionInfo.RegionName);
return false;
}
}
else
m_log.ErrorFormat("[CONNECTION BEGIN]: Estate Settings is null!");
IGroupsModule groupsModule =
RequestModuleInterface<IGroupsModule>();
@ -3718,21 +3739,31 @@ namespace OpenSim.Region.Framework.Scenes
GroupMembershipData[] GroupMembership =
groupsModule.GetMembershipData(agent.AgentID);
for (int i = 0; i < GroupMembership.Length; i++)
agentGroups.Add(GroupMembership[i].GroupID);
if (GroupMembership != null)
{
for (int i = 0; i < GroupMembership.Length; i++)
agentGroups.Add(GroupMembership[i].GroupID);
}
else
m_log.ErrorFormat("[CONNECTION BEGIN]: GroupMembership is null!");
}
bool groupAccess = false;
UUID[] estateGroups = m_regInfo.EstateSettings.EstateGroups;
foreach (UUID group in estateGroups)
if (estateGroups != null)
{
if (agentGroups.Contains(group))
foreach (UUID group in estateGroups)
{
groupAccess = true;
break;
if (agentGroups.Contains(group))
{
groupAccess = true;
break;
}
}
}
else
m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
if (!m_regInfo.EstateSettings.PublicAccess &&
!m_regInfo.EstateSettings.HasAccess(agent.AgentID) &&

View File

@ -54,13 +54,13 @@ using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
namespace OpenSim.Region.ScriptEngine.Shared.Api
{
[Serializable]
public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi
{
internal IScriptEngine m_ScriptEngine;
internal SceneObjectPart m_host;
internal uint m_localID;
internal UUID m_itemID;
internal bool m_CMFunctionsEnabled = false;
internal bool m_LSFunctionsEnabled = false;
internal IScriptModuleComms m_comms = null;
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
@ -70,12 +70,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_localID = localID;
m_itemID = itemID;
if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
m_CMFunctionsEnabled = true;
if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
m_LSFunctionsEnabled = true;
m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
if (m_comms == null)
m_CMFunctionsEnabled = false;
m_LSFunctionsEnabled = false;
}
public override Object InitializeLifetimeService()
@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Dumps an error message on the debug console.
//
internal void CMShoutError(string message)
internal void LSShoutError(string message)
{
if (message.Length > 1023)
message = message.Substring(0, 1023);
@ -116,11 +116,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// Get the current Windlight scene
/// </summary>
/// <returns>List of windlight parameters</returns>
public LSL_List cmGetWindlightScene(LSL_List rules)
public LSL_List lsGetWindlightScene(LSL_List rules)
{
if (!m_CMFunctionsEnabled)
if (!m_LSFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
LSShoutError("LightShare functions are not enabled.");
return new LSL_List();
}
m_host.AddScriptLPS(1);
@ -440,16 +440,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightScene(LSL_List rules)
public int lsSetWindlightScene(LSL_List rules)
{
if (!m_CMFunctionsEnabled)
if (!m_LSFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
LSShoutError("LightShare functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
return 0;
}
int success = 0;
@ -462,7 +462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
CMShoutError("Windlight module is disabled");
LSShoutError("Windlight module is disabled");
return 0;
}
return success;
@ -472,16 +472,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
{
if (!m_CMFunctionsEnabled)
if (!m_LSFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
LSShoutError("LightShare functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
return 0;
}
int success = 0;
@ -494,7 +494,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else
{
CMShoutError("Windlight module is disabled");
LSShoutError("Windlight module is disabled");
return 0;
}
return success;

View File

@ -38,11 +38,11 @@ using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{
public interface ICM_Api
public interface ILS_Api
{
// Windlight Functions
LSL_List cmGetWindlightScene(LSL_List rules);
int cmSetWindlightScene(LSL_List rules);
int cmSetWindlightSceneTargeted(LSL_List rules, key target);
LSL_List lsGetWindlightScene(LSL_List rules);
int lsSetWindlightScene(LSL_List rules);
int lsSetWindlightSceneTargeted(LSL_List rules, key target);
}
}

View File

@ -48,29 +48,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
public partial class ScriptBaseClass : MarshalByRefObject
{
public ICM_Api m_CM_Functions;
public ILS_Api m_LS_Functions;
public void ApiTypeCM(IScriptApi api)
public void ApiTypeLS(IScriptApi api)
{
if (!(api is ICM_Api))
if (!(api is ILS_Api))
return;
m_CM_Functions = (ICM_Api)api;
m_LS_Functions = (ILS_Api)api;
}
public LSL_List lsGetWindlightScene(LSL_List rules)
{
return m_LS_Functions.lsGetWindlightScene(rules);
}
public int lsSetWindlightScene(LSL_List rules)
{
return m_LS_Functions.lsSetWindlightScene(rules);
}
public int lsSetWindlightSceneTargeted(LSL_List rules, key target)
{
return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
}
public LSL_List cmGetWindlightScene(LSL_List rules)
{
return m_CM_Functions.cmGetWindlightScene(rules);
return m_LS_Functions.lsGetWindlightScene(rules);
}
public int cmSetWindlightScene(LSL_List rules)
{
return m_CM_Functions.cmSetWindlightScene(rules);
return m_LS_Functions.lsSetWindlightScene(rules);
}
public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
{
return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
return m_LS_Functions.lsSetWindlightSceneTargeted(rules, target);
}
}
}