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) public void AddCapsHandler(UUID agentId)
{ {
int flags = 0; int flags = m_scene.GetUserFlags(agentId);
ScenePresence sp;
if (m_scene.TryGetScenePresence(agentId, out sp))
{
flags = sp.UserFlags;
}
if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
return; return;

View File

@ -141,11 +141,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
#region IUserAccountService #region IUserAccountService
public UserAccount GetUserAccount(UUID scopeID, UUID userID) public UserAccount GetUserAccount(UUID scopeID, UUID userID)
{
return GetUserAccount(scopeID, userID, true);
}
public UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache)
{
UserAccount account;
if (useCache)
{ {
bool inCache = false; bool inCache = false;
UserAccount account = m_Cache.Get(userID, out inCache); account = m_Cache.Get(userID, out inCache);
if (inCache) if (inCache)
return account; return account;
}
account = m_UserService.GetUserAccount(scopeID, userID); account = m_UserService.GetUserAccount(scopeID, userID);
m_Cache.Cache(userID, account); 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 // If the user is banned, we won't let any of their objects
// enter. Period. // enter. Period.
// //
int flags = 0; int flags = GetUserFlags(sceneObject.OwnerID);
ScenePresence sp;
if (TryGetScenePresence(sceneObject.OwnerID, out sp))
{
flags = sp.UserFlags;
}
if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
{ {
m_log.Info("[INTERREGION]: Denied prim crossing for " + m_log.Info("[INTERREGION]: Denied prim crossing for " +
@ -2480,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart RootPrim = sceneObject.RootPart; SceneObjectPart RootPrim = sceneObject.RootPart;
// Fix up attachment Parent Local ID // Fix up attachment Parent Local ID
sp = GetScenePresence(sceneObject.OwnerID); ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
if (sp != null) if (sp != null)
{ {
@ -2554,7 +2547,22 @@ namespace OpenSim.Region.Framework.Scenes
} }
return 2; // StateSource.PrimCrossing 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 #endregion
#region Add/Remove Avatar Methods #region Add/Remove Avatar Methods
@ -3625,12 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_regInfo.EstateSettings != null) if (m_regInfo.EstateSettings != null)
{ {
int flags = 0; int flags = GetUserFlags(agent.AgentID);
ScenePresence sp;
if (TryGetScenePresence(agent.AgentID, out sp))
{
flags = sp.UserFlags;
}
if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags)) if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags))
{ {
//Add some more info to help users //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. // We have to wait until the viewer contacts this region after receiving EAC.
// That calls AddNewClient, which finally creates the ScenePresence // That calls AddNewClient, which finally creates the ScenePresence
int flags = 0; int flags = GetUserFlags(cAgentData.AgentID);
ScenePresence sp;
if (TryGetScenePresence(cAgentData.AgentID, out sp))
{
flags = sp.UserFlags;
}
if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
{ {
m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); 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) public UserAccount GetUserAccount(UUID scopeID, UUID userID)
{
return GetUserAccount(scopeID, userID, true);
}
public UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache)
{ {
// Cache check // Cache check
UserAccount account; UserAccount account;

View File

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

View File

@ -80,6 +80,11 @@ namespace OpenSim.Services.HypergridService
return GetUser(userID.ToString()); 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) public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
{ {
return null; return null;

View File

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

View File

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