Add a "useCached" parameter to GetUserAccount. Add a function to Scene to get the user flags. It has to be here due to access restrictions :/

avinationmerge
Tom 2011-01-26 16:25:08 -08:00
parent 3ecf712e4d
commit 6b27587bc7
8 changed files with 55 additions and 32 deletions

View File

@ -88,12 +88,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
public void AddCapsHandler(UUID agentId)
{
int flags = 0;
ScenePresence sp;
if (m_scene.TryGetScenePresence(agentId, out sp))
{
flags = sp.UserFlags;
}
int flags = m_scene.GetUserFlags(agentId);
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
return;

View File

@ -142,10 +142,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
public UserAccount GetUserAccount(UUID scopeID, UUID userID)
{
bool inCache = false;
UserAccount account = m_Cache.Get(userID, out inCache);
if (inCache)
return account;
return GetUserAccount(scopeID, userID, true);
}
public UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache)
{
UserAccount account;
if (useCache)
{
bool inCache = false;
account = m_Cache.Get(userID, out inCache);
if (inCache)
return account;
}
account = m_UserService.GetUserAccount(scopeID, userID);
m_Cache.Cache(userID, account);

View File

@ -2443,14 +2443,7 @@ namespace OpenSim.Region.Framework.Scenes
// If the user is banned, we won't let any of their objects
// enter. Period.
//
int flags = 0;
ScenePresence sp;
if (TryGetScenePresence(sceneObject.OwnerID, out sp))
{
flags = sp.UserFlags;
}
int flags = GetUserFlags(sceneObject.OwnerID);
if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
{
m_log.Info("[INTERREGION]: Denied prim crossing for " +
@ -2480,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart RootPrim = sceneObject.RootPart;
// Fix up attachment Parent Local ID
sp = GetScenePresence(sceneObject.OwnerID);
ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
if (sp != null)
{
@ -2554,7 +2547,22 @@ namespace OpenSim.Region.Framework.Scenes
}
return 2; // StateSource.PrimCrossing
}
public int GetUserFlags(UUID user)
{
//Unfortunately the SP approach means that the value is cached until region is restarted
/*
ScenePresence sp;
if (TryGetScenePresence(user, out sp))
{
return sp.UserFlags;
}
else
{
*/
UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user, false);
return uac.UserFlags;
//}
}
#endregion
#region Add/Remove Avatar Methods
@ -3625,12 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_regInfo.EstateSettings != null)
{
int flags = 0;
ScenePresence sp;
if (TryGetScenePresence(agent.AgentID, out sp))
{
flags = sp.UserFlags;
}
int flags = GetUserFlags(agent.AgentID);
if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags))
{
//Add some more info to help users
@ -3836,12 +3839,7 @@ namespace OpenSim.Region.Framework.Scenes
// We have to wait until the viewer contacts this region after receiving EAC.
// That calls AddNewClient, which finally creates the ScenePresence
int flags = 0;
ScenePresence sp;
if (TryGetScenePresence(cAgentData.AgentID, out sp))
{
flags = sp.UserFlags;
}
int flags = GetUserFlags(cAgentData.AgentID);
if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
{
m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);

View File

@ -130,6 +130,11 @@ namespace OpenSim.Services.Connectors.SimianGrid
}
public UserAccount GetUserAccount(UUID scopeID, UUID userID)
{
return GetUserAccount(scopeID, userID, true);
}
public UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache)
{
// Cache check
UserAccount account;

View File

@ -112,6 +112,11 @@ namespace OpenSim.Services.Connectors
}
public virtual UserAccount GetUserAccount(UUID scopeID, UUID userID)
{
return GetUserAccount(scopeID, userID, true);
}
public virtual UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache)
{
//m_log.DebugFormat("[ACCOUNTS CONNECTOR]: GetUserAccount {0}", userID);
Dictionary<string, object> sendData = new Dictionary<string, object>();

View File

@ -80,6 +80,11 @@ namespace OpenSim.Services.HypergridService
return GetUser(userID.ToString());
}
public UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache)
{
return GetUser(userID.ToString());
}
public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
{
return null;

View File

@ -143,6 +143,7 @@ namespace OpenSim.Services.Interfaces
public interface IUserAccountService
{
UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache);
UserAccount GetUserAccount(UUID scopeID, UUID userID);
UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName);
UserAccount GetUserAccount(UUID scopeID, string Email);

View File

@ -207,6 +207,11 @@ namespace OpenSim.Services.UserAccountService
}
public UserAccount GetUserAccount(UUID scopeID, UUID principalID)
{
return GetUserAccount(scopeID, principalID, true);
}
public UserAccount GetUserAccount(UUID scopeID, UUID principalID, bool useCache)
{
UserAccountData[] d;