From 6b27587bc7631d6fd083f3b4f752d9ddcfda4830 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 16:25:08 -0800 Subject: 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 :/ --- .../Agent/Capabilities/CapabilitiesModule.cs | 7 +--- .../LocalUserAccountServiceConnector.cs | 17 ++++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 42 +++++++++++----------- .../SimianUserAccountServiceConnector.cs | 5 +++ .../UserAccounts/UserAccountServiceConnector.cs | 5 +++ .../Services/HypergridService/UserAccountCache.cs | 5 +++ OpenSim/Services/Interfaces/IUserAccountService.cs | 1 + .../UserAccountService/UserAccountService.cs | 5 +++ 8 files changed, 55 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs index cbc2fd6..5c5cb70 100644 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs @@ -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; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 9ecbcc6..54340e6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -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); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2ca82ca..99248c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -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); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 801b424..fe4e2bf 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs @@ -131,6 +131,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; if (m_accountCache.TryGetValue(userID, out account)) diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs index 205a4aa..c21b250 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs @@ -113,6 +113,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 sendData = new Dictionary(); //sendData["SCOPEID"] = scopeID.ToString(); diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs index e0a3e61..bbc531e 100644 --- a/OpenSim/Services/HypergridService/UserAccountCache.cs +++ b/OpenSim/Services/HypergridService/UserAccountCache.cs @@ -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; diff --git a/OpenSim/Services/Interfaces/IUserAccountService.cs b/OpenSim/Services/Interfaces/IUserAccountService.cs index a91aa0f..21be98c 100644 --- a/OpenSim/Services/Interfaces/IUserAccountService.cs +++ b/OpenSim/Services/Interfaces/IUserAccountService.cs @@ -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); diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index cbd6f35..b914668 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -208,6 +208,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; if (scopeID != UUID.Zero) -- cgit v1.1