diff --git a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations index 32b85ee8c1..440d076630 100644 --- a/OpenSim/Data/MySQL/Resources/GridUserStore.migrations +++ b/OpenSim/Data/MySQL/Resources/GridUserStore.migrations @@ -17,3 +17,11 @@ CREATE TABLE `GridUser` ( ) ENGINE=InnoDB; COMMIT; + +:VERSION 2 # -------------------------- + +BEGIN; + +ALTER TABLE `GridUser` ADD COLUMN TOS CHAR(36); + +COMMIT; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs index b0edce7a91..dd8a8ef2bb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs @@ -68,8 +68,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser // m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); if (sp.PresenceType != PresenceType.Npc) + { + string userid = sp.Scene.UserManagementModule.GetUserUUI(sp.UUID); m_GridUserService.SetLastPosition( - sp.UUID.ToString(), UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + } } public void OnNewClient(IClientAPI client) @@ -83,8 +86,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser return; // m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); + string userId = client.AgentId.ToString(); + if (client.Scene is Scene) + { + Scene s = (Scene)client.Scene; + userId = s.UserManagementModule.GetUserUUI(client.AgentId); + } m_GridUserService.LoggedOut( - client.AgentId.ToString(), client.SessionId, client.Scene.RegionInfo.RegionID, + userId, client.SessionId, client.Scene.RegionInfo.RegionID, client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs index badb5527fa..04acf6732f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs @@ -44,6 +44,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private const int KEEPTIME = 30; // 30 secs + private ExpiringCache m_Infos = new ExpiringCache(); + #region ISharedRegionModule private bool m_Enabled = false; @@ -128,23 +131,60 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser public bool LoggedOut(string userID, UUID sessionID, UUID region, Vector3 position, Vector3 lookat) { + if (m_Infos.Contains(userID)) + m_Infos.Remove(userID); + return m_RemoteConnector.LoggedOut(userID, sessionID, region, position, lookat); } public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) { - return m_RemoteConnector.SetHome(userID, regionID, position, lookAt); + if (m_RemoteConnector.SetHome(userID, regionID, position, lookAt)) + { + // Update the cache too + GridUserInfo info = null; + if (m_Infos.TryGetValue(userID, out info)) + { + info.HomeRegionID = regionID; + info.HomePosition = position; + info.HomeLookAt = lookAt; + } + return true; + } + + return false; } public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { - return m_RemoteConnector.SetLastPosition(userID, sessionID, regionID, position, lookAt); + if (m_RemoteConnector.SetLastPosition(userID, sessionID, regionID, position, lookAt)) + { + // Update the cache too + GridUserInfo info = null; + if (m_Infos.TryGetValue(userID, out info)) + { + info.LastRegionID = regionID; + info.LastPosition = position; + info.LastLookAt = lookAt; + } + return true; + } + + return false; } public GridUserInfo GetGridUserInfo(string userID) { - return m_RemoteConnector.GetGridUserInfo(userID); + GridUserInfo info = null; + if (m_Infos.TryGetValue(userID, out info)) + return info; + + info = m_RemoteConnector.GetGridUserInfo(userID); + + m_Infos.AddOrUpdate(userID, info, KEEPTIME); + + return info; } public GridUserInfo[] GetGridUserInfo(string[] userID) diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs index 0a52bfaae4..620ed3aa99 100644 --- a/OpenSim/Services/Interfaces/IGridUserService.cs +++ b/OpenSim/Services/Interfaces/IGridUserService.cs @@ -50,6 +50,8 @@ namespace OpenSim.Services.Interfaces public DateTime Login; public DateTime Logout; + public string TOS = string.Empty; + public GridUserInfo() {} public GridUserInfo(Dictionary kvp) @@ -78,6 +80,11 @@ namespace OpenSim.Services.Interfaces if (kvp.ContainsKey("Online")) Boolean.TryParse(kvp["Online"].ToString(), out Online); + if (kvp.ContainsKey("TOS")) + TOS = kvp["TOS"].ToString(); + else + TOS = string.Empty; + } public Dictionary ToKeyValuePairs() @@ -97,6 +104,7 @@ namespace OpenSim.Services.Interfaces result["Login"] = Login.ToString(); result["Logout"] = Logout.ToString(); + result["TOS"] = TOS; return result; } diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index ac3d8fda44..8eae859c14 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs @@ -70,6 +70,8 @@ namespace OpenSim.Services.UserAccountService info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); + info.TOS = d.Data["TOS"]; + return info; } diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 3ec4bab23c..a602dcc60b 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -917,6 +917,34 @@ ;# {InitialTerrain} {} {Initial terrain type} {pinhead-island flat} pinhead-island ; InitialTerrain = "pinhead-island" +[TOSModule] + ;; Terms of Service module. It requires an external web script. Unless you + ;; have that in place, don't enable this module. + + ;# {Enabled} {} {Enable TOS facilities} {true false} false + ; Enabled = false + + ;; Should local users be shown the TOS on first login? + ;# {ShowToLocalUsers} {} {Show TOS to local users} {true false} false + ; ShowToLocalUsers = false + ;; Should foreign users be shown the TOS on first HG login? + ;# {ShowToForeignUsers} {} {Show TOS to foreign users} {true false} true + ; ShowToForeignUsers = true + + ;; Tell the users what this is about + ; Message = "Please read and agree to the Terms of Service" + + ;; How much time do the users have to accept the TOS before they get kicked out? + ;; (in minutes) + ; Timeout = 5 + + ;; This page should have Accept/Decline links somewhere + ;; that affect the GridUsers table. If you don't have such + ;; script in place, don't use the TOSModule + ;# {TOS_URL} {} {The URL for the TOS page} {} + TOS_URL = "http://mygrid.com/tos" + + [Architecture] ;# {Include-Architecture} {} {Choose one of the following architectures} {config-include/Standalone.ini config-include/StandaloneHypergrid.ini config-include/Grid.ini config-include/GridHypergrid.ini config-include/SimianGrid.ini config-include/HyperSimianGrid.ini} config-include/Standalone.ini ;; Uncomment one of the following includes as required. For instance, to create a standalone OpenSim, diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 315ffbe800..744187baa7 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -1624,6 +1624,10 @@ [Terrain] InitialTerrain = "pinhead-island" +[TOSModule] + ;; Enable TOS facilities + Enabled = false + ;; ;; If you are using a simian grid frontend you can enable ;; this module to upload tile images for the mapping fn