diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 9f6414b420..6da55580f6 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1729,7 +1729,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController GridRegion home = m_app.SceneManager.CurrentOrFirstScene.GridService.GetRegionByPosition(scopeID, (int)(regX * Constants.RegionSize), (int)(regY * Constants.RegionSize)); if (home != null) - m_app.SceneManager.CurrentOrFirstScene.PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + m_app.SceneManager.CurrentOrFirstScene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); } else { diff --git a/OpenSim/Data/IGridUserData.cs b/OpenSim/Data/IGridUserData.cs index bd7a435391..e15a1f88a5 100644 --- a/OpenSim/Data/IGridUserData.cs +++ b/OpenSim/Data/IGridUserData.cs @@ -37,6 +37,11 @@ namespace OpenSim.Data { public string UserID; public Dictionary Data; + + public GridUserData() + { + Data = new Dictionary(); + } } /// @@ -44,7 +49,7 @@ namespace OpenSim.Data /// public interface IGridUserData { - GridUserData GetGridUserData(string userID); - bool StoreGridUserData(GridUserData data); + GridUserData Get(string userID); + bool Store(GridUserData data); } } \ No newline at end of file diff --git a/OpenSim/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs index 71d0e31a1f..b871f5636c 100644 --- a/OpenSim/Data/IPresenceData.cs +++ b/OpenSim/Data/IPresenceData.cs @@ -50,10 +50,8 @@ namespace OpenSim.Data PresenceData Get(UUID sessionID); void LogoutRegionAgents(UUID regionID); - bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt); - bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt); + bool ReportAgent(UUID sessionID, UUID regionID); PresenceData[] Get(string field, string data); - void Prune(string userID); bool Delete(string field, string val); } } diff --git a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs index 9993720a04..1870273616 100644 --- a/OpenSim/Data/MSSQL/MSSQLGridUserData.cs +++ b/OpenSim/Data/MSSQL/MSSQLGridUserData.cs @@ -46,11 +46,11 @@ namespace OpenSim.Data.MSSQL private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public MSSQLGridUserData(string connectionString, string realm) : - base(connectionString, realm, "UserGrid") + base(connectionString, realm, "GridUserStore") { } - public GridUserData GetGridUserData(string userID) + public GridUserData Get(string userID) { GridUserData[] ret = Get("UserID", userID); @@ -60,9 +60,5 @@ namespace OpenSim.Data.MSSQL return ret[0]; } - public bool StoreGridUserData(GridUserData data) - { - return Store(data); - } } } diff --git a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs index 5a4ad3a358..e7b3d9c367 100644 --- a/OpenSim/Data/MSSQL/MSSQLPresenceData.cs +++ b/OpenSim/Data/MSSQL/MSSQLPresenceData.cs @@ -67,7 +67,7 @@ namespace OpenSim.Data.MSSQL using (SqlCommand cmd = new SqlCommand()) { - cmd.CommandText = String.Format("UPDATE {0} SET Online='false' WHERE [RegionID]=@RegionID", m_Realm); + cmd.CommandText = String.Format("DELETE FROM {0} WHERE [RegionID]=@RegionID", m_Realm); cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); cmd.Connection = conn; @@ -76,8 +76,7 @@ namespace OpenSim.Data.MSSQL } } - public bool ReportAgent(UUID sessionID, UUID regionID, string position, - string lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { PresenceData[] pd = Get("SessionID", sessionID.ToString()); if (pd.Length == 0) @@ -88,16 +87,11 @@ namespace OpenSim.Data.MSSQL { cmd.CommandText = String.Format(@"UPDATE {0} SET - [RegionID] = @RegionID, - [Position] = @Position, - [LookAt] = @LookAt, - [Online] = 'true' + [RegionID] = @RegionID WHERE [SessionID] = @SessionID", m_Realm); cmd.Parameters.Add(m_database.CreateParameter("@SessionID", sessionID.ToString())); cmd.Parameters.Add(m_database.CreateParameter("@RegionID", regionID.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@Position", position.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@LookAt", lookAt.ToString())); cmd.Connection = conn; conn.Open(); if (cmd.ExecuteNonQuery() == 0) @@ -106,65 +100,5 @@ namespace OpenSim.Data.MSSQL return true; } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - PresenceData[] pd = Get("UserID", userID); - if (pd.Length == 0) - return false; - - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) - { - - cmd.CommandText = String.Format(@"UPDATE {0} SET - [HomeRegionID] = @HomeRegionID, - [HomePosition] = @HomePosition, - [HomeLookAt] = @HomeLookAt - WHERE [UserID] = @UserID", m_Realm); - - cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID)); - cmd.Parameters.Add(m_database.CreateParameter("@HomeRegionID", regionID.ToString())); - cmd.Parameters.Add(m_database.CreateParameter("@HomePosition", position)); - cmd.Parameters.Add(m_database.CreateParameter("@HomeLookAt", lookAt)); - cmd.Connection = conn; - conn.Open(); - if (cmd.ExecuteNonQuery() == 0) - return false; - } - return true; - } - - public void Prune(string userID) - { - using (SqlConnection conn = new SqlConnection(m_ConnectionString)) - using (SqlCommand cmd = new SqlCommand()) - { - cmd.CommandText = String.Format("SELECT * from {0} WHERE [UserID] = @UserID", m_Realm); - - cmd.Parameters.Add(m_database.CreateParameter("@UserID", userID)); - cmd.Connection = conn; - conn.Open(); - - using (SqlDataReader reader = cmd.ExecuteReader()) - { - List deleteSessions = new List(); - int online = 0; - - while (reader.Read()) - { - if (bool.Parse(reader["Online"].ToString())) - online++; - else - deleteSessions.Add(new UUID(reader["SessionID"].ToString())); - } - - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); - - foreach (UUID s in deleteSessions) - Delete("SessionID", s.ToString()); - } - } - } } } diff --git a/OpenSim/Data/MySQL/MySQLGridUserData.cs b/OpenSim/Data/MySQL/MySQLGridUserData.cs index df29ecdc2d..a9ce94d33c 100644 --- a/OpenSim/Data/MySQL/MySQLGridUserData.cs +++ b/OpenSim/Data/MySQL/MySQLGridUserData.cs @@ -44,9 +44,9 @@ namespace OpenSim.Data.MySQL { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "UserGrid") {} + public MySQLGridUserData(string connectionString, string realm) : base(connectionString, realm, "GridUserStore") {} - public GridUserData GetGridUserData(string userID) + public GridUserData Get(string userID) { GridUserData[] ret = Get("UserID", userID); @@ -56,9 +56,6 @@ namespace OpenSim.Data.MySQL return ret[0]; } - public bool StoreGridUserData(GridUserData data) - { - return Store(data); - } + } } \ No newline at end of file diff --git a/OpenSim/Data/MySQL/MySQLPresenceData.cs b/OpenSim/Data/MySQL/MySQLPresenceData.cs index 143dbe38cb..71caa1aa2a 100644 --- a/OpenSim/Data/MySQL/MySQLPresenceData.cs +++ b/OpenSim/Data/MySQL/MySQLPresenceData.cs @@ -65,15 +65,14 @@ namespace OpenSim.Data.MySQL { MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set Online='false' where `RegionID`=?RegionID", m_Realm); + cmd.CommandText = String.Format("delete from {0} where `RegionID`=?RegionID", m_Realm); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); ExecuteNonQuery(cmd); } - public bool ReportAgent(UUID sessionID, UUID regionID, string position, - string lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { PresenceData[] pd = Get("SessionID", sessionID.ToString()); if (pd.Length == 0) @@ -81,12 +80,10 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand(); - cmd.CommandText = String.Format("update {0} set RegionID=?RegionID, Position=?Position, LookAt=?LookAt, Online='true' where `SessionID`=?SessionID", m_Realm); + cmd.CommandText = String.Format("update {0} set RegionID=?RegionID where `SessionID`=?SessionID", m_Realm); cmd.Parameters.AddWithValue("?SessionID", sessionID.ToString()); cmd.Parameters.AddWithValue("?RegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?Position", position.ToString()); - cmd.Parameters.AddWithValue("?LookAt", lookAt.ToString()); if (ExecuteNonQuery(cmd) == 0) return false; @@ -94,62 +91,5 @@ namespace OpenSim.Data.MySQL return true; } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - PresenceData[] pd = Get("UserID", userID); - if (pd.Length == 0) - return false; - - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("update {0} set HomeRegionID=?HomeRegionID, HomePosition=?HomePosition, HomeLookAt=?HomeLookAt where UserID=?UserID", m_Realm); - - cmd.Parameters.AddWithValue("?UserID", userID); - cmd.Parameters.AddWithValue("?HomeRegionID", regionID.ToString()); - cmd.Parameters.AddWithValue("?HomePosition", position); - cmd.Parameters.AddWithValue("?HomeLookAt", lookAt); - - if (ExecuteNonQuery(cmd) == 0) - return false; - - return true; - } - - public void Prune(string userID) - { - MySqlCommand cmd = new MySqlCommand(); - - cmd.CommandText = String.Format("select * from {0} where UserID=?UserID", m_Realm); - - cmd.Parameters.AddWithValue("?UserID", userID); - - using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) - { - dbcon.Open(); - - cmd.Connection = dbcon; - - using (IDataReader reader = cmd.ExecuteReader()) - { - List deleteSessions = new List(); - int online = 0; - - while (reader.Read()) - { - if (bool.Parse(reader["Online"].ToString())) - online++; - else - deleteSessions.Add(new UUID(reader["SessionID"].ToString())); - } - - // Leave one session behind so that we can pick up details such as home location - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); - - foreach (UUID s in deleteSessions) - Delete("SessionID", s.ToString()); - } - } - } } } diff --git a/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql b/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql new file mode 100644 index 0000000000..ce4ab96e97 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_GridUserStore.sql @@ -0,0 +1,17 @@ +BEGIN; + +CREATE TABLE `GridUser` ( + `UserID` VARCHAR(255) NOT NULL, + `HomeRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LastRegionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + `LastPosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `LastLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>', + `Online` CHAR(5) NOT NULL DEFAULT 'false', + `Login` CHAR(16) NOT NULL DEFAULT '0', + `Logout` CHAR(16) NOT NULL DEFAULT '0', + PRIMARY KEY (`UserID`) +) ENGINE=InnoDB; + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/001_Presence.sql b/OpenSim/Data/MySQL/Resources/001_Presence.sql index b8abaf7dc7..84fa05794c 100644 --- a/OpenSim/Data/MySQL/Resources/001_Presence.sql +++ b/OpenSim/Data/MySQL/Resources/001_Presence.sql @@ -4,12 +4,10 @@ CREATE TABLE `Presence` ( `UserID` VARCHAR(255) NOT NULL, `RegionID` CHAR(36) NOT NULL, `SessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', - `Online` CHAR(5) NOT NULL DEFAULT 'false', - `Login` CHAR(16) NOT NULL DEFAULT '0', - `Logout` CHAR(16) NOT NULL DEFAULT '0', - `Position` CHAR(64) NOT NULL DEFAULT '<0,0,0>', - `LookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>' + `SecureSessionID` CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000' ) ENGINE=InnoDB; +CREATE UNIQUE INDEX SessionID ON Presence(SessionID); +CREATE INDEX UserID ON Presence(UserID); + COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_Presence.sql b/OpenSim/Data/MySQL/Resources/002_Presence.sql deleted file mode 100644 index e65f105477..0000000000 --- a/OpenSim/Data/MySQL/Resources/002_Presence.sql +++ /dev/null @@ -1,7 +0,0 @@ -BEGIN; - -ALTER TABLE Presence ADD COLUMN `HomeRegionID` CHAR(36) NOT NULL; -ALTER TABLE Presence ADD COLUMN `HomePosition` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; -ALTER TABLE Presence ADD COLUMN `HomeLookAt` CHAR(64) NOT NULL DEFAULT '<0,0,0>'; - -COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/003_Presence.sql b/OpenSim/Data/MySQL/Resources/003_Presence.sql deleted file mode 100644 index 0efefa81bf..0000000000 --- a/OpenSim/Data/MySQL/Resources/003_Presence.sql +++ /dev/null @@ -1,6 +0,0 @@ -BEGIN; - -CREATE UNIQUE INDEX SessionID ON Presence(SessionID); -CREATE INDEX UserID ON Presence(UserID); - -COMMIT; diff --git a/OpenSim/Data/Null/NullPresenceData.cs b/OpenSim/Data/Null/NullPresenceData.cs index b98b5c92b5..91f1cc561e 100644 --- a/OpenSim/Data/Null/NullPresenceData.cs +++ b/OpenSim/Data/Null/NullPresenceData.cs @@ -96,45 +96,20 @@ namespace OpenSim.Data.Null m_presenceData.Remove(u); } - public bool ReportAgent(UUID sessionID, UUID regionID, string position, string lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { if (Instance != this) - return Instance.ReportAgent(sessionID, regionID, position, lookAt); + return Instance.ReportAgent(sessionID, regionID); if (m_presenceData.ContainsKey(sessionID)) { m_presenceData[sessionID].RegionID = regionID; - m_presenceData[sessionID].Data["Position"] = position; - m_presenceData[sessionID].Data["LookAt"] = lookAt; return true; } return false; } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - if (Instance != this) - return Instance.SetHomeLocation(userID, regionID, position, lookAt); - - bool foundone = false; - foreach (PresenceData p in m_presenceData.Values) - { - if (p.UserID == userID) - { -// m_log.DebugFormat( -// "[NULL PRESENCE DATA]: Setting home location {0} {1} {2} for {3}", -// regionID, position, lookAt, p.UserID); - - p.Data["HomeRegionID"] = regionID.ToString(); - p.Data["HomePosition"] = position.ToString(); - p.Data["HomeLookAt"] = lookAt.ToString(); - foundone = true; - } - } - - return foundone; - } public PresenceData[] Get(string field, string data) { @@ -193,39 +168,6 @@ namespace OpenSim.Data.Null return presences.ToArray(); } - public void Prune(string userID) - { - if (Instance != this) - { - Instance.Prune(userID); - return; - } - -// m_log.DebugFormat("[NULL PRESENCE DATA]: Prune called for {0}", userID); - - List deleteSessions = new List(); - int online = 0; - - foreach (KeyValuePair kvp in m_presenceData) - { -// m_log.DebugFormat("Online: {0}", kvp.Value.Data["Online"]); - - bool on = false; - if (bool.TryParse(kvp.Value.Data["Online"], out on) && on) - online++; - else - deleteSessions.Add(kvp.Key); - } - -// m_log.DebugFormat("[NULL PRESENCE DATA]: online [{0}], deleteSession.Count [{1}]", online, deleteSessions.Count); - - // Leave one session behind so that we can pick up details such as home location - if (online == 0 && deleteSessions.Count > 0) - deleteSessions.RemoveAt(0); - - foreach (UUID s in deleteSessions) - m_presenceData.Remove(s); - } public bool Delete(string field, string data) { diff --git a/OpenSim/Data/SQLite/Resources/001_GridUserStore.sql b/OpenSim/Data/SQLite/Resources/001_GridUserStore.sql new file mode 100644 index 0000000000..1a24613275 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/001_GridUserStore.sql @@ -0,0 +1,16 @@ +BEGIN TRANSACTION; + +CREATE TABLE GridUser ( + UserID VARCHAR(255) primary key, + HomeRegionID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + HomePosition CHAR(64) NOT NULL DEFAULT '<0,0,0>', + HomeLookAt CHAR(64) NOT NULL DEFAULT '<0,0,0>', + LastRegionID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', + LastPosition CHAR(64) NOT NULL DEFAULT '<0,0,0>', + LastLookAt CHAR(64) NOT NULL DEFAULT '<0,0,0>', + Online CHAR(5) NOT NULL DEFAULT 'false', + Login CHAR(16) NOT NULL DEFAULT '0', + Logout CHAR(16) NOT NULL DEFAULT '0' +) ; + +COMMIT; diff --git a/OpenSim/Data/SQLite/SQLiteGridUserData.cs b/OpenSim/Data/SQLite/SQLiteGridUserData.cs new file mode 100644 index 0000000000..1bb5ed87d6 --- /dev/null +++ b/OpenSim/Data/SQLite/SQLiteGridUserData.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Data; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Data.SQLite +{ + /// + /// A SQL Interface for user grid data + /// + public class SQLiteGridUserData : SQLiteGenericTableHandler, IGridUserData + { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public SQLiteGridUserData(string connectionString, string realm) + : base(connectionString, realm, "GridUserStore") {} + + public new GridUserData Get(string userID) + { + GridUserData[] ret = Get("UserID", userID); + + if (ret.Length == 0) + return null; + + return ret[0]; + } + + + } +} \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index f2b03e4177..ef37f63622 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -526,11 +526,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); - OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); + //OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId); + GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString()); - if (pinfo != null) + if (uinfo != null) { - GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID); + GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); if (regionInfo == null) { // can't find the Home region: Tell viewer and abort @@ -539,7 +540,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } // a little eekie that this goes back to Scene and with a forced cast, will fix that at some point... ((Scene)(client.Scene)).RequestTeleportLocation( - client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt, + client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); } } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 28593fc8d8..137dfec13b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason); if (success) // Log them out of this grid - m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); + m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID); return success; } @@ -238,6 +238,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { if (obj.IsLoggingOut) { + object sp = null; + if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp)) + { + if (((ScenePresence)sp).IsChildAgent) + return; + } + AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 0a5ff3f982..ee070756fd 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -59,9 +59,11 @@ - + + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs new file mode 100644 index 0000000000..6c01927c5e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs @@ -0,0 +1,116 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; +using log4net; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser +{ + public class ActivityDetector + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IGridUserService m_GridUserService; + private Scene m_aScene; + + public ActivityDetector(IGridUserService guservice) + { + m_GridUserService = guservice; + m_log.DebugFormat("[ACTIVITY DETECTOR]: starting "); + } + + public void AddRegion(Scene scene) + { + // For now the only events we listen to are these + // But we could trigger the position update more often + scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; + scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnAvatarEnteringNewParcel += OnEnteringNewParcel; + + if (m_aScene == null) + m_aScene = scene; + } + + public void RemoveRegion(Scene scene) + { + scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; + scene.EventManager.OnNewClient -= OnNewClient; + } + + public void OnMakeRootAgent(ScenePresence sp) + { + m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); + + m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + } + + public void OnNewClient(IClientAPI client) + { + client.OnConnectionClosed += OnConnectionClose; + } + + public void OnConnectionClose(IClientAPI client) + { + if (client.IsLoggingOut) + { + object sp = null; + Vector3 position = new Vector3(128, 128, 0); + Vector3 lookat = new Vector3(0, 1, 0); + + if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) + { + if (sp is ScenePresence) + { + if (((ScenePresence)sp).IsChildAgent) + return; + + position = ((ScenePresence)sp).AbsolutePosition; + lookat = ((ScenePresence)sp).Lookat; + } + } + m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); + m_GridUserService.LoggedOut(client.AgentId.ToString(), client.Scene.RegionInfo.RegionID, position, lookat); + } + + } + + void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID) + { + // TODO: grab the parcel ID from ILandModule + // and send that along + m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + } + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs index d5fae232d6..d914a576e1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs @@ -41,13 +41,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser { public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); - private IGridUserService m_service; + private IGridUserService m_GridUserService; + + private ActivityDetector m_ActivityDetector; private bool m_Enabled = false; - public Type ReplaceableInterface + #region ISharedRegionModule + + public Type ReplaceableInterface { get { return null; } } @@ -68,7 +74,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser IConfig userConfig = source.Configs["GridUserService"]; if (userConfig == null) { - m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from ini files"); + m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from OpenSim.ini"); return; } @@ -81,15 +87,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser } Object[] args = new Object[] { source }; - m_service = ServerUtils.LoadPlugin(serviceDll, args); + m_GridUserService = ServerUtils.LoadPlugin(serviceDll, args); - if (m_service == null) + if (m_GridUserService == null) { - m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: Can't load GridUser service"); + m_log.ErrorFormat( + "[LOCAL GRID USER SERVICE CONNECTOR]: Cannot load user account service specified as {0}", serviceDll); return; } + + m_ActivityDetector = new ActivityDetector(this); + m_Enabled = true; - m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local GridUser connector enabled"); + + m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local grid user connector enabled"); } } } @@ -111,29 +122,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser if (!m_Enabled) return; - scene.RegisterModuleInterface(m_service); + scene.RegisterModuleInterface(m_GridUserService); + m_ActivityDetector.AddRegion(scene); } public void RemoveRegion(Scene scene) { if (!m_Enabled) return; + + scene.UnregisterModuleInterface(this); + m_ActivityDetector.RemoveRegion(scene); } public void RegionLoaded(Scene scene) { if (!m_Enabled) return; + + m_log.InfoFormat("[LOCAL GRID USER SERVICE CONNECTOR]: Enabled local grid user for region {0}", scene.RegionInfo.RegionName); + } + + #endregion + + #region IGridUserService + + public GridUserInfo LoggedIn(string userID) + { + return m_GridUserService.LoggedIn(userID); + } + + public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + { + return m_GridUserService.LoggedOut(userID, regionID, lastPosition, lastLookAt); + } + + public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) + { + return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt); + } + + public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + { + return m_GridUserService.SetLastPosition(userID, regionID, lastPosition, lastLookAt); } public GridUserInfo GetGridUserInfo(string userID) { - return m_service.GetGridUserInfo(userID); - } - - public bool StoreGridUserInfo(GridUserInfo info) - { - return m_service.StoreGridUserInfo(info); + return m_GridUserService.GetGridUserInfo(userID); } + + #endregion + } -} \ No newline at end of file +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs new file mode 100644 index 0000000000..e3e2e619c1 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs @@ -0,0 +1,153 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Reflection; + +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser +{ + public class RemoteGridUserServicesConnector : ISharedRegionModule, IGridUserService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region ISharedRegionModule + + private bool m_Enabled = false; + + private ActivityDetector m_ActivityDetector; + private IGridUserService m_RemoteConnector; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteGridUserServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("GridUserServices", ""); + if (name == Name) + { + m_RemoteConnector = new GridUserServicesConnector(source); + + m_Enabled = true; + + m_ActivityDetector = new ActivityDetector(this); + + m_log.Info("[REMOTE GRID USER CONNECTOR]: Remote grid user enabled"); + } + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + m_ActivityDetector.AddRegion(scene); + + m_log.InfoFormat("[REMOTE GRID USER CONNECTOR]: Enabled remote grid user for region {0}", scene.RegionInfo.RegionName); + + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_ActivityDetector.RemoveRegion(scene); + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region IGridUserService + + public GridUserInfo LoggedIn(string userID) + { + m_log.Warn("[REMOTE GRID USER CONNECTOR]: LoggedIn not implemented at the simulators"); + return null; + } + + public bool LoggedOut(string userID, UUID region, Vector3 position, Vector3 lookat) + { + return m_RemoteConnector.LoggedOut(userID, region, position, lookat); + } + + + public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return m_RemoteConnector.SetHome(userID, regionID, position, lookAt); + } + + public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return m_RemoteConnector.SetLastPosition(userID, regionID, position, lookAt); + } + + public GridUserInfo GetGridUserInfo(string userID) + { + return m_RemoteConnector.GetGridUserInfo(userID); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index c402a3face..49dd633be4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -167,9 +167,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return false; } - public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) + public bool LogoutAgent(UUID sessionID) { - return m_PresenceService.LogoutAgent(sessionID, position, lookat); + return m_PresenceService.LogoutAgent(sessionID); } @@ -178,9 +178,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_PresenceService.LogoutRegionAgents(regionID); } - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { - return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); + return m_PresenceService.ReportAgent(sessionID, regionID); } public PresenceInfo GetAgent(UUID sessionID) @@ -193,11 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_PresenceService.GetAgents(userIDs); } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt); - } - #endregion } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 7a75a89f4c..62b8278b22 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnMakeRootAgent(ScenePresence sp) { m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName); - m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID); } public void OnNewClient(IClientAPI client) @@ -85,19 +85,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence if (client.IsLoggingOut) { object sp = null; - Vector3 position = new Vector3(128, 128, 0); - Vector3 lookat = new Vector3(0, 1, 0); - if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) { if (sp is ScenePresence) { - position = ((ScenePresence)sp).AbsolutePosition; - lookat = ((ScenePresence)sp).Lookat; + if (((ScenePresence)sp).IsChildAgent) + return; } } - m_PresenceService.LogoutAgent(client.SessionId, position, lookat); + m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName); + m_PresenceService.LogoutAgent(client.SessionId); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index 5f3666e323..bf4e9abf0d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -127,9 +127,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return false; } - public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) + public bool LogoutAgent(UUID sessionID) { - return m_RemoteConnector.LogoutAgent(sessionID, position, lookat); + return m_RemoteConnector.LogoutAgent(sessionID); } @@ -138,9 +138,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_RemoteConnector.LogoutRegionAgents(regionID); } - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { - return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); + return m_RemoteConnector.ReportAgent(sessionID, regionID); } public PresenceInfo GetAgent(UUID sessionID) @@ -153,11 +153,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_RemoteConnector.GetAgents(userIDs); } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt); - } - #endregion } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index 63a28fc255..ef910f4c26 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -90,27 +90,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests PresenceInfo result = m_LocalConnector.GetAgent(session1); Assert.IsNotNull(result, "Retrieved GetAgent is null"); Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match"); - Assert.IsTrue(result.Online, "Agent just logged in but is offline"); UUID region1 = UUID.Random(); - bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); + bool r = m_LocalConnector.ReportAgent(session1, region1); Assert.IsTrue(r, "First ReportAgent returned false"); result = m_LocalConnector.GetAgent(session1); Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)"); UUID region2 = UUID.Random(); - r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero); + r = m_LocalConnector.ReportAgent(session1, region2); Assert.IsTrue(r, "Second ReportAgent returned false"); result = m_LocalConnector.GetAgent(session1); Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)"); - r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY); + r = m_LocalConnector.LogoutAgent(session1); Assert.IsTrue(r, "LogoutAgent returned false"); result = m_LocalConnector.GetAgent(session1); - Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); - Assert.IsFalse(result.Online, "Agent is reported to be Online after logout"); + Assert.IsNull(result, "Agent session is still stored after logout"); - r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); + r = m_LocalConnector.ReportAgent(session1, region1); Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0ca5948603..2197ced8eb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -318,7 +318,18 @@ namespace OpenSim.Region.Framework.Scenes return m_AvatarService; } } - + + protected IGridUserService m_GridUserService; + public IGridUserService GridUserService + { + get + { + if (m_GridUserService == null) + m_GridUserService = RequestModuleInterface(); + return m_GridUserService; + } + } + protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; public IAttachmentsModule AttachmentsModule { get; set; } @@ -1334,8 +1345,8 @@ namespace OpenSim.Region.Framework.Scenes if (defaultRegions != null && defaultRegions.Count >= 1) home = defaultRegions[0]; - if (PresenceService != null && home != null) - PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + if (GridUserService != null && home != null) + GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); else m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", first, last); @@ -3123,7 +3134,7 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) { - if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) + if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); else @@ -3577,7 +3588,7 @@ namespace OpenSim.Region.Framework.Scenes OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); - if (pinfo == null || (pinfo != null && pinfo.Online == false)) + if (pinfo == null) { reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); return false; diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 932943c081..53022ad6b4 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs @@ -257,7 +257,6 @@ namespace PrimMesher public int uv2; public int uv3; - public Face(int v1, int v2, int v3) { primFace = 0; @@ -630,6 +629,9 @@ namespace PrimMesher internal int numOuterVerts = 0; internal int numHollowVerts = 0; + internal int outerFaceNumber = -1; + internal int hollowFaceNumber = -1; + internal bool calcVertexNormals = false; internal int bottomFaceNumber = 0; internal int numPrimFaces = 0; @@ -936,10 +938,10 @@ namespace PrimMesher if (calcVertexNormals && hasProfileCut) { + int lastOuterVertIndex = this.numOuterVerts - 1; + if (hasHollow) { - int lastOuterVertIndex = this.numOuterVerts - 1; - this.cut1CoordIndices.Add(0); this.cut1CoordIndices.Add(this.coords.Count - 1); @@ -955,6 +957,12 @@ namespace PrimMesher else { + this.cut1CoordIndices.Add(0); + this.cut1CoordIndices.Add(1); + + this.cut2CoordIndices.Add(lastOuterVertIndex); + this.cut2CoordIndices.Add(0); + this.cutNormal1.X = this.vertexNormals[1].Y; this.cutNormal1.Y = -this.vertexNormals[1].X; @@ -979,11 +987,14 @@ namespace PrimMesher // I know it's ugly but so is the whole concept of prim face numbers int faceNum = 1; // start with outer faces + this.outerFaceNumber = faceNum; + int startVert = hasProfileCut && !hasHollow ? 1 : 0; if (startVert > 0) this.faceNumbers.Add(-1); for (int i = 0; i < this.numOuterVerts - 1; i++) - this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); + //this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); + this.faceNumbers.Add(sides < 5 && i < sides ? faceNum++ : faceNum); //if (!hasHollow && !hasProfileCut) // this.bottomFaceNumber = faceNum++; @@ -993,12 +1004,15 @@ namespace PrimMesher if (sides > 4 && (hasHollow || hasProfileCut)) faceNum++; + if (sides < 5 && (hasHollow || hasProfileCut) && this.numOuterVerts < sides) + faceNum++; + if (hasHollow) { for (int i = 0; i < this.numHollowVerts; i++) this.faceNumbers.Add(faceNum); - faceNum++; + this.hollowFaceNumber = faceNum++; } //if (hasProfileCut || hasHollow) // this.bottomFaceNumber = faceNum++; @@ -1006,11 +1020,11 @@ namespace PrimMesher if (hasHollow && hasProfileCut) this.faceNumbers.Add(faceNum++); + for (int i = 0; i < this.faceNumbers.Count; i++) if (this.faceNumbers[i] == -1) this.faceNumbers[i] = faceNum++; - this.numPrimFaces = faceNum; } @@ -1455,11 +1469,15 @@ namespace PrimMesher public float revolutions = 1.0f; public int stepsPerRevolution = 24; + private int profileOuterFaceNumber = -1; + private int profileHollowFaceNumber = -1; + private bool hasProfileCut = false; private bool hasHollow = false; public bool calcVertexNormals = false; private bool normalsProcessed = false; public bool viewerMode = false; + public bool sphereMode = false; public int numPrimFaces = 0; @@ -1491,10 +1509,35 @@ namespace PrimMesher s += "\nradius...............: " + this.radius.ToString(); s += "\nrevolutions..........: " + this.revolutions.ToString(); s += "\nstepsPerRevolution...: " + this.stepsPerRevolution.ToString(); + s += "\nsphereMode...........: " + this.sphereMode.ToString(); + s += "\nhasProfileCut........: " + this.hasProfileCut.ToString(); + s += "\nhasHollow............: " + this.hasHollow.ToString(); + s += "\nviewerMode...........: " + this.viewerMode.ToString(); return s; } + public int ProfileOuterFaceNumber + { + get { return profileOuterFaceNumber; } + } + + public int ProfileHollowFaceNumber + { + get { return profileHollowFaceNumber; } + } + + public bool HasProfileCut + { + get { return hasProfileCut; } + } + + public bool HasHollow + { + get { return hasHollow; } + } + + /// /// Constructs a PrimMesh object and creates the profile for extrusion. /// @@ -1531,8 +1574,12 @@ namespace PrimMesher if (hollow < 0.0f) this.hollow = 0.0f; - this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); - this.hasHollow = (this.hollow > 0.001f); + //if (sphereMode) + // this.hasProfileCut = this.profileEnd - this.profileStart < 0.4999f; + //else + // //this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); + // this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f; + //this.hasHollow = (this.hollow > 0.001f); } /// @@ -1540,6 +1587,8 @@ namespace PrimMesher /// public void Extrude(PathType pathType) { + bool needEndFaces = false; + this.coords = new List(); this.faces = new List(); @@ -1565,6 +1614,12 @@ namespace PrimMesher steps = (int)(steps * 4.5 * length); } + if (sphereMode) + this.hasProfileCut = this.profileEnd - this.profileStart < 0.4999f; + else + //this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); + this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f; + this.hasHollow = (this.hollow > 0.001f); float twistBegin = this.twistBegin / 360.0f * twoPi; float twistEnd = this.twistEnd / 360.0f * twoPi; @@ -1634,6 +1689,32 @@ namespace PrimMesher this.numPrimFaces = profile.numPrimFaces; + //profileOuterFaceNumber = profile.faceNumbers[0]; + //if (!needEndFaces) + // profileOuterFaceNumber--; + //profileOuterFaceNumber = needEndFaces ? 1 : 0; + + + //if (hasHollow) + //{ + // if (needEndFaces) + // profileHollowFaceNumber = profile.faceNumbers[profile.numOuterVerts + 1]; + // else + // profileHollowFaceNumber = profile.faceNumbers[profile.numOuterVerts] - 1; + //} + + + profileOuterFaceNumber = profile.outerFaceNumber; + if (!needEndFaces) + profileOuterFaceNumber--; + + if (hasHollow) + { + profileHollowFaceNumber = profile.hollowFaceNumber; + if (!needEndFaces) + profileHollowFaceNumber--; + } + int cut1Vert = -1; int cut2Vert = -1; if (hasProfileCut) @@ -1673,7 +1754,7 @@ namespace PrimMesher path.Create(pathType, steps); - bool needEndFaces = false; + if (pathType == PathType.Circular) { needEndFaces = false; @@ -1761,7 +1842,7 @@ namespace PrimMesher int startVert = coordsLen + 1; int endVert = this.coords.Count; - if (sides < 5 || this.hasProfileCut || hollow > 0.0f) + if (sides < 5 || this.hasProfileCut || this.hasHollow) startVert--; for (int i = startVert; i < endVert; i++) @@ -1813,11 +1894,13 @@ namespace PrimMesher u1 -= (int)u1; if (u2 < 0.1f) u2 = 1.0f; + //this.profileOuterFaceNumber = primFaceNum; } else if (whichVert > profile.coords.Count - profile.numHollowVerts - 1) { u1 *= 2.0f; u2 *= 2.0f; + //this.profileHollowFaceNumber = primFaceNum; } } diff --git a/OpenSim/Region/Physics/Meshing/SculptMap.cs b/OpenSim/Region/Physics/Meshing/SculptMap.cs new file mode 100644 index 0000000000..d2d71deade --- /dev/null +++ b/OpenSim/Region/Physics/Meshing/SculptMap.cs @@ -0,0 +1,176 @@ +/* + * Copyright (c) Contributors + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// to build without references to System.Drawing, comment this out +#define SYSTEM_DRAWING + +using System; +using System.Collections.Generic; +using System.Text; + +#if SYSTEM_DRAWING +using System.Drawing; +using System.Drawing.Imaging; + +namespace PrimMesher +{ + public class SculptMap + { + public int width; + public int height; + public byte[] redBytes; + public byte[] greenBytes; + public byte[] blueBytes; + + public SculptMap() + { + } + + public SculptMap(Bitmap bm, int lod) + { + int bmW = bm.Width; + int bmH = bm.Height; + + if (bmW == 0 || bmH == 0) + throw new Exception("SculptMap: bitmap has no data"); + + int numLodPixels = lod * 2 * lod * 2; // (32 * 2)^2 = 64^2 pixels for default sculpt map image + + bool needsScaling = false; + + width = bmW; + height = bmH; + while (width * height > numLodPixels) + { + width >>= 1; + height >>= 1; + needsScaling = true; + } + + + + try + { + if (needsScaling) + bm = ScaleImage(bm, width, height, + System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor); + } + + catch (Exception e) + { + throw new Exception("Exception in ScaleImage(): e: " + e.ToString()); + } + + if (width * height > lod * lod) + { + width >>= 1; + height >>= 1; + } + + int numBytes = (width + 1) * (height + 1); + redBytes = new byte[numBytes]; + greenBytes = new byte[numBytes]; + blueBytes = new byte[numBytes]; + + int byteNdx = 0; + + try + { + for (int y = 0; y <= height; y++) + { + for (int x = 0; x <= width; x++) + { + int bmY = y < height ? y * 2 : y * 2 - 1; + int bmX = x < width ? x * 2 : x * 2 - 1; + Color c = bm.GetPixel(bmX, bmY); + + redBytes[byteNdx] = c.R; + greenBytes[byteNdx] = c.G; + blueBytes[byteNdx] = c.B; + + ++byteNdx; + } + } + } + catch (Exception e) + { + throw new Exception("Caught exception processing byte arrays in SculptMap(): e: " + e.ToString()); + } + + width++; + height++; + } + + public List> ToRows(bool mirror) + { + int numRows = height; + int numCols = width; + + List> rows = new List>(numRows); + + float pixScale = 1.0f / 255; + + int rowNdx, colNdx; + int smNdx = 0; + + for (rowNdx = 0; rowNdx < numRows; rowNdx++) + { + List row = new List(numCols); + for (colNdx = 0; colNdx < numCols; colNdx++) + { + if (mirror) + row.Add(new Coord(-(redBytes[smNdx] * pixScale - 0.5f), (greenBytes[smNdx] * pixScale - 0.5f), blueBytes[smNdx] * pixScale - 0.5f)); + else + row.Add(new Coord(redBytes[smNdx] * pixScale - 0.5f, greenBytes[smNdx] * pixScale - 0.5f, blueBytes[smNdx] * pixScale - 0.5f)); + + ++smNdx; + } + rows.Add(row); + } + return rows; + } + + private Bitmap ScaleImage(Bitmap srcImage, int destWidth, int destHeight, + System.Drawing.Drawing2D.InterpolationMode interpMode) + { + Bitmap scaledImage = new Bitmap(srcImage, destWidth, destHeight); + scaledImage.SetResolution(96.0f, 96.0f); + + Graphics grPhoto = Graphics.FromImage(scaledImage); + grPhoto.InterpolationMode = interpMode; + + grPhoto.DrawImage(srcImage, + new Rectangle(0, 0, destWidth, destHeight), + new Rectangle(0, 0, srcImage.Width, srcImage.Height), + GraphicsUnit.Pixel); + + grPhoto.Dispose(); + return scaledImage; + } + } +} +#endif diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index ebc5be61b1..6aa8fe49a3 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -53,50 +53,6 @@ namespace PrimMesher public enum SculptType { sphere = 1, torus = 2, plane = 3, cylinder = 4 }; #if SYSTEM_DRAWING - private Bitmap ScaleImage(Bitmap srcImage, float scale, bool removeAlpha) - { - int sourceWidth = srcImage.Width; - int sourceHeight = srcImage.Height; - int sourceX = 0; - int sourceY = 0; - - int destX = 0; - int destY = 0; - int destWidth = (int)(srcImage.Width * scale); - int destHeight = (int)(srcImage.Height * scale); - - Bitmap scaledImage; - - if (removeAlpha) - { - if (srcImage.PixelFormat == PixelFormat.Format32bppArgb) - for (int y = 0; y < srcImage.Height; y++) - for (int x = 0; x < srcImage.Width; x++) - { - Color c = srcImage.GetPixel(x, y); - srcImage.SetPixel(x, y, Color.FromArgb(255, c.R, c.G, c.B)); - } - - scaledImage = new Bitmap(destWidth, destHeight, - PixelFormat.Format24bppRgb); - } - else - scaledImage = new Bitmap(srcImage, destWidth, destHeight); - - scaledImage.SetResolution(96.0f, 96.0f); - - Graphics grPhoto = Graphics.FromImage(scaledImage); - grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low; - - grPhoto.DrawImage(srcImage, - new Rectangle(destX, destY, destWidth, destHeight), - new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight), - GraphicsUnit.Pixel); - - grPhoto.Dispose(); - return scaledImage; - } - public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode) { @@ -106,6 +62,7 @@ namespace PrimMesher return sculptMesh; } + public SculptMesh(string fileName, int sculptType, int lod, int viewerMode, int mirror, int invert) { Bitmap bitmap = (Bitmap)Bitmap.FromFile(fileName); @@ -296,36 +253,53 @@ namespace PrimMesher return rows; } + private List> bitmap2CoordsSampled(Bitmap bitmap, int scale, bool mirror) + { + int numRows = bitmap.Height / scale; + int numCols = bitmap.Width / scale; + List> rows = new List>(numRows); + + float pixScale = 1.0f / 256.0f; + + int imageX, imageY = 0; + + int rowNdx, colNdx; + + for (rowNdx = 0; rowNdx <= numRows; rowNdx++) + { + List row = new List(numCols); + imageY = rowNdx * scale; + if (rowNdx == numRows) imageY--; + for (colNdx = 0; colNdx <= numCols; colNdx++) + { + imageX = colNdx * scale; + if (colNdx == numCols) imageX--; + + Color c = bitmap.GetPixel(imageX, imageY); + if (c.A != 255) + { + bitmap.SetPixel(imageX, imageY, Color.FromArgb(255, c.R, c.G, c.B)); + c = bitmap.GetPixel(imageX, imageY); + } + + if (mirror) + row.Add(new Coord(-(c.R * pixScale - 0.5f), c.G * pixScale - 0.5f, c.B * pixScale - 0.5f)); + else + row.Add(new Coord(c.R * pixScale - 0.5f, c.G * pixScale - 0.5f, c.B * pixScale - 0.5f)); + + } + rows.Add(row); + } + return rows; + } + void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert) { - coords = new List(); - faces = new List(); - normals = new List(); - uvs = new List(); - - sculptType = (SculptType)(((int)sculptType) & 0x07); - - if (mirror) - if (sculptType == SculptType.plane) - invert = !invert; - - float sculptBitmapLod = (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height); - - float sourceScaleFactor = (float)(lod) / sculptBitmapLod; - - float fScale = 1.0f / sourceScaleFactor; - - int iScale = (int)fScale; - if (iScale < 1) iScale = 1; - if (iScale > 2 && iScale % 2 == 0) - _SculptMesh(bitmap2Coords(ScaleImage(sculptBitmap, 64.0f / sculptBitmapLod, true), 64 / lod, mirror), sculptType, viewerMode, mirror, invert); - else - _SculptMesh(bitmap2Coords(sculptBitmap, iScale, mirror), sculptType, viewerMode, mirror, invert); + _SculptMesh(new SculptMap(sculptBitmap, lod).ToRows(mirror), sculptType, viewerMode, mirror, invert); } #endif - void _SculptMesh(List> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert) { coords = new List(); @@ -349,8 +323,18 @@ namespace PrimMesher if (sculptType != SculptType.plane) { - for (int rowNdx = 0; rowNdx < rows.Count; rowNdx++) - rows[rowNdx].Add(rows[rowNdx][0]); + if (rows.Count % 2 == 0) + { + for (int rowNdx = 0; rowNdx < rows.Count; rowNdx++) + rows[rowNdx].Add(rows[rowNdx][0]); + } + else + { + int lastIndex = rows[0].Count - 1; + + for (int i = 0; i < rows.Count; i++) + rows[i][0] = rows[i][lastIndex]; + } } Coord topPole = rows[0][width / 2]; @@ -358,23 +342,41 @@ namespace PrimMesher if (sculptType == SculptType.sphere) { - int count = rows[0].Count; - List topPoleRow = new List(count); - List bottomPoleRow = new List(count); - - for (int i = 0; i < count; i++) + if (rows.Count % 2 == 0) { - topPoleRow.Add(topPole); - bottomPoleRow.Add(bottomPole); + int count = rows[0].Count; + List topPoleRow = new List(count); + List bottomPoleRow = new List(count); + + for (int i = 0; i < count; i++) + { + topPoleRow.Add(topPole); + bottomPoleRow.Add(bottomPole); + } + rows.Insert(0, topPoleRow); + rows.Add(bottomPoleRow); + } + else + { + int count = rows[0].Count; + + List topPoleRow = rows[0]; + List bottomPoleRow = rows[rows.Count - 1]; + + for (int i = 0; i < count; i++) + { + topPoleRow[i] = topPole; + bottomPoleRow[i] = bottomPole; + } } - rows.Insert(0, topPoleRow); - rows.Add(bottomPoleRow); } - else if (sculptType == SculptType.torus) + + if (sculptType == SculptType.torus) rows.Add(rows[0]); int coordsDown = rows.Count; int coordsAcross = rows[0].Count; + int lastColumn = coordsAcross - 1; float widthUnit = 1.0f / (coordsAcross - 1); float heightUnit = 1.0f / (coordsDown - 1); diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs new file mode 100644 index 0000000000..66f35e3bdc --- /dev/null +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerConnector.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using Nini.Config; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Server.Handlers.Base; + +namespace OpenSim.Server.Handlers.GridUser +{ + public class GridUserServiceConnector : ServiceConnector + { + private IGridUserService m_GridUserService; + private string m_ConfigName = "GridUserService"; + + public GridUserServiceConnector(IConfigSource config, IHttpServer server, string configName) : + base(config, server, configName) + { + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string service = serverConfig.GetString("LocalServiceModule", + String.Empty); + + if (service == String.Empty) + throw new Exception("No LocalServiceModule in config file"); + + Object[] args = new Object[] { config }; + m_GridUserService = ServerUtils.LoadPlugin(service, args); + + server.AddStreamHandler(new GridUserServerPostHandler(m_GridUserService)); + } + } +} diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs new file mode 100644 index 0000000000..f8fa42967f --- /dev/null +++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs @@ -0,0 +1,278 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using Nini.Config; +using log4net; +using System; +using System.Reflection; +using System.IO; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Xml; +using System.Xml.Serialization; +using System.Collections.Generic; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenMetaverse; + +namespace OpenSim.Server.Handlers.GridUser +{ + public class GridUserServerPostHandler : BaseStreamHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private IGridUserService m_GridUserService; + + public GridUserServerPostHandler(IGridUserService service) : + base("POST", "/griduser") + { + m_GridUserService = service; + } + + public override byte[] Handle(string path, Stream requestData, + OSHttpRequest httpRequest, OSHttpResponse httpResponse) + { + StreamReader sr = new StreamReader(requestData); + string body = sr.ReadToEnd(); + sr.Close(); + body = body.Trim(); + + //m_log.DebugFormat("[XXX]: query String: {0}", body); + string method = string.Empty; + try + { + Dictionary request = + ServerUtils.ParseQueryString(body); + + if (!request.ContainsKey("METHOD")) + return FailureResult(); + + method = request["METHOD"].ToString(); + + switch (method) + { + case "loggedin": + return LoggedIn(request); + case "loggedout": + return LoggedOut(request); + case "sethome": + return SetHome(request); + case "setposition": + return SetPosition(request); + case "getgriduserinfo": + return GetGridUserInfo(request); + } + m_log.DebugFormat("[GRID USER HANDLER]: unknown method request: {0}", method); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID USER HANDLER]: Exception in method {0}: {1}", method, e); + } + + return FailureResult(); + + } + + byte[] LoggedIn(Dictionary request) + { + string user = String.Empty; + + if (!request.ContainsKey("UserID")) + return FailureResult(); + + user = request["UserID"].ToString(); + + GridUserInfo guinfo = m_GridUserService.LoggedIn(user); + + Dictionary result = new Dictionary(); + result["result"] = guinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID USER HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + + } + + byte[] LoggedOut(Dictionary request) + { + string userID = string.Empty; + UUID regionID = UUID.Zero; + Vector3 position = Vector3.Zero; + Vector3 lookat = Vector3.Zero; + + if (!UnpackArgs(request, out userID, out regionID, out position, out lookat)) + return FailureResult(); + + if (m_GridUserService.LoggedOut(userID, regionID, position, lookat)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] SetHome(Dictionary request) + { + string user = string.Empty; + UUID region = UUID.Zero; + Vector3 position = new Vector3(128, 128, 70); + Vector3 look = Vector3.Zero; + + if (!UnpackArgs(request, out user, out region, out position, out look)) + return FailureResult(); + + if (m_GridUserService.SetHome(user, region, position, look)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] SetPosition(Dictionary request) + { + string user = string.Empty; + UUID region = UUID.Zero; + Vector3 position = new Vector3(128, 128, 70); + Vector3 look = Vector3.Zero; + + if (!request.ContainsKey("UserID") || !request.ContainsKey("RegionID")) + return FailureResult(); + + if (!UnpackArgs(request, out user, out region, out position, out look)) + return FailureResult(); + + if (m_GridUserService.SetLastPosition(user, region, position, look)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] GetGridUserInfo(Dictionary request) + { + string user = String.Empty; + + if (!request.ContainsKey("UserID")) + return FailureResult(); + + user = request["UserID"].ToString(); + + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(user); + + Dictionary result = new Dictionary(); + result["result"] = guinfo.ToKeyValuePairs(); + + string xmlString = ServerUtils.BuildXmlResponse(result); + //m_log.DebugFormat("[GRID USER HANDLER]: resp string: {0}", xmlString); + UTF8Encoding encoding = new UTF8Encoding(); + return encoding.GetBytes(xmlString); + + } + + private bool UnpackArgs(Dictionary request, out string user, out UUID region, out Vector3 position, out Vector3 lookAt) + { + user = string.Empty; + region = UUID.Zero; + position = new Vector3(128, 128, 70); + lookAt = Vector3.Zero; + + if (!request.ContainsKey("UserID") || !request.ContainsKey("RegionID")) + return false; + + user = request["UserID"].ToString(); + + if (!UUID.TryParse(request["RegionID"].ToString(), out region)) + return false; + + if (request.ContainsKey("Position")) + Vector3.TryParse(request["Position"].ToString(), out position); + + if (request.ContainsKey("LookAt")) + Vector3.TryParse(request["LookAt"].ToString(), out lookAt); + + return true; + } + + + private byte[] SuccessResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "result", ""); + result.AppendChild(doc.CreateTextNode("Success")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] FailureResult() + { + XmlDocument doc = new XmlDocument(); + + XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, + "", ""); + + doc.AppendChild(xmlnode); + + XmlElement rootElement = doc.CreateElement("", "ServerResponse", + ""); + + doc.AppendChild(rootElement); + + XmlElement result = doc.CreateElement("", "result", ""); + result.AppendChild(doc.CreateTextNode("Failure")); + + rootElement.AppendChild(result); + + return DocToBytes(doc); + } + + private byte[] DocToBytes(XmlDocument doc) + { + MemoryStream ms = new MemoryStream(); + XmlTextWriter xw = new XmlTextWriter(ms, null); + xw.Formatting = Formatting.Indented; + doc.WriteTo(xw); + xw.Flush(); + + return ms.ToArray(); + } + + + } +} diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs index 4ebf93329c..3104917f83 100644 --- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs @@ -90,8 +90,6 @@ namespace OpenSim.Server.Handlers.Presence return GetAgent(request); case "getagents": return GetAgents(request); - case "sethome": - return SetHome(request); } m_log.DebugFormat("[PRESENCE HANDLER]: unknown method request: {0}", method); } @@ -140,12 +138,7 @@ namespace OpenSim.Server.Handlers.Presence if (!UUID.TryParse(request["SessionID"].ToString(), out session)) return FailureResult(); - if (request.ContainsKey("Position") && request["Position"] != null) - Vector3.TryParse(request["Position"].ToString(), out position); - if (request.ContainsKey("LookAt") && request["Position"] != null) - Vector3.TryParse(request["LookAt"].ToString(), out lookat); - - if (m_PresenceService.LogoutAgent(session, position, lookat)) + if (m_PresenceService.LogoutAgent(session)) return SuccessResult(); return FailureResult(); @@ -171,8 +164,6 @@ namespace OpenSim.Server.Handlers.Presence { UUID session = UUID.Zero; UUID region = UUID.Zero; - Vector3 position = new Vector3(128, 128, 70); - Vector3 look = Vector3.Zero; if (!request.ContainsKey("SessionID") || !request.ContainsKey("RegionID")) return FailureResult(); @@ -183,13 +174,7 @@ namespace OpenSim.Server.Handlers.Presence if (!UUID.TryParse(request["RegionID"].ToString(), out region)) return FailureResult(); - if (request.ContainsKey("position")) - Vector3.TryParse(request["position"].ToString(), out position); - - if (request.ContainsKey("lookAt")) - Vector3.TryParse(request["lookAt"].ToString(), out look); - - if (m_PresenceService.ReportAgent(session, region, position, look)) + if (m_PresenceService.ReportAgent(session, region)) { return SuccessResult(); } @@ -318,31 +303,5 @@ namespace OpenSim.Server.Handlers.Presence return ms.ToArray(); } - byte[] SetHome(Dictionary request) - { - UUID region = UUID.Zero; - Vector3 position = new Vector3(128, 128, 70); - Vector3 look = Vector3.Zero; - - if (!request.ContainsKey("UserID") || !request.ContainsKey("RegionID")) - return FailureResult(); - - string user = request["UserID"].ToString(); - - if (!UUID.TryParse(request["RegionID"].ToString(), out region)) - return FailureResult(); - - if (request.ContainsKey("position")) - Vector3.TryParse(request["position"].ToString(), out position); - - if (request.ContainsKey("lookAt")) - Vector3.TryParse(request["lookAt"].ToString(), out look); - - if (m_PresenceService.SetHomeLocation(user, region, position, look)) - return SuccessResult(); - - return FailureResult(); - } - } } diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs index 0e8506706c..b4500a5f55 100644 --- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs +++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs @@ -25,14 +25,206 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using log4net; using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Server.Base; +using OpenMetaverse; namespace OpenSim.Services.Connectors { - public class GridUserServiceConnector + public class GridUserServicesConnector : IGridUserService { - public GridUserServiceConnector() + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private string m_ServerURI = String.Empty; + + public GridUserServicesConnector() { } + + public GridUserServicesConnector(string serverURI) + { + m_ServerURI = serverURI.TrimEnd('/'); + } + + public GridUserServicesConnector(IConfigSource source) + { + Initialise(source); + } + + public virtual void Initialise(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridUserService"]; + if (gridConfig == null) + { + m_log.Error("[GRID USER CONNECTOR]: GridUserService missing from OpenSim.ini"); + throw new Exception("GridUser connector init error"); + } + + string serviceURI = gridConfig.GetString("GridUserServerURI", + String.Empty); + + if (serviceURI == String.Empty) + { + m_log.Error("[GRID USER CONNECTOR]: No Server URI named in section GridUserService"); + throw new Exception("GridUser connector init error"); + } + m_ServerURI = serviceURI; + } + + + #region IPresenceService + + + public GridUserInfo LoggedIn(string userID) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "loggedin"; + + sendData["UserID"] = userID; + + return Get(sendData); + + } + + public bool LoggedOut(string userID, UUID region, Vector3 position, Vector3 lookat) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "loggedout"; + + return Set(sendData, userID, region, position, lookat); + } + + public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "sethome"; + + return Set(sendData, userID, regionID, position, lookAt); + } + + public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "setposition"; + + return Set(sendData, userID, regionID, position, lookAt); + } + + public GridUserInfo GetGridUserInfo(string userID) + { + Dictionary sendData = new Dictionary(); + //sendData["SCOPEID"] = scopeID.ToString(); + sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); + sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); + sendData["METHOD"] = "getgriduserinfo"; + + sendData["UserID"] = userID; + + return Get(sendData); + } + + #endregion + + protected bool Set(Dictionary sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt) + { + sendData["UserID"] = userID; + sendData["RegionID"] = regionID.ToString(); + sendData["Position"] = position.ToString(); + sendData["LookAt"] = lookAt.ToString(); + + string reqString = ServerUtils.BuildQueryString(sendData); + // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString); + try + { + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/griduser", + reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData.ContainsKey("result")) + { + if (replyData["result"].ToString().ToLower() == "success") + return true; + else + return false; + } + else + m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition reply data does not contain result field"); + + } + else + m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition received empty reply"); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message); + } + + return false; + } + + protected GridUserInfo Get(Dictionary sendData) + { + string reqString = ServerUtils.BuildQueryString(sendData); + // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString); + try + { + string reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/griduser", + reqString); + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + GridUserInfo guinfo = null; + + if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) + { + if (replyData["result"] is Dictionary) + { + guinfo = new GridUserInfo((Dictionary)replyData["result"]); + } + } + + return guinfo; + + } + else + m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply"); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message); + } + + return null; + + } + } } diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs index 23621b7387..41ebeaf05e 100644 --- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs @@ -132,7 +132,7 @@ namespace OpenSim.Services.Connectors } - public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) + public bool LogoutAgent(UUID sessionID) { Dictionary sendData = new Dictionary(); //sendData["SCOPEID"] = scopeID.ToString(); @@ -141,8 +141,6 @@ namespace OpenSim.Services.Connectors sendData["METHOD"] = "logout"; sendData["SessionID"] = sessionID.ToString(); - sendData["Position"] = position.ToString(); - sendData["LookAt"] = lookat.ToString(); string reqString = ServerUtils.BuildQueryString(sendData); // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); @@ -220,7 +218,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { Dictionary sendData = new Dictionary(); //sendData["SCOPEID"] = scopeID.ToString(); @@ -230,8 +228,6 @@ namespace OpenSim.Services.Connectors sendData["SessionID"] = sessionID.ToString(); sendData["RegionID"] = regionID.ToString(); - sendData["position"] = position.ToString(); - sendData["lookAt"] = lookAt.ToString(); string reqString = ServerUtils.BuildQueryString(sendData); // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); @@ -371,52 +367,6 @@ namespace OpenSim.Services.Connectors } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - Dictionary sendData = new Dictionary(); - //sendData["SCOPEID"] = scopeID.ToString(); - sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); - sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); - sendData["METHOD"] = "sethome"; - - sendData["UserID"] = userID; - sendData["RegionID"] = regionID.ToString(); - sendData["position"] = position.ToString(); - sendData["lookAt"] = lookAt.ToString(); - - string reqString = ServerUtils.BuildQueryString(sendData); - // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); - try - { - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/presence", - reqString); - if (reply != string.Empty) - { - Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - - if (replyData.ContainsKey("result")) - { - if (replyData["result"].ToString().ToLower() == "success") - return true; - else - return false; - } - else - m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation reply data does not contain result field"); - - } - else - m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation received empty reply"); - } - catch (Exception e) - { - m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message); - } - - return false; - } - #endregion } diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index c324272093..e48b7de3bf 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -51,7 +51,7 @@ namespace OpenSim.Services.Connectors.SimianGrid /// message routing) to the SimianGrid backend /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class SimianPresenceServiceConnector : IPresenceService, ISharedRegionModule + public class SimianPresenceServiceConnector : IPresenceService, IGridUserService, ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger( @@ -73,6 +73,7 @@ namespace OpenSim.Services.Connectors.SimianGrid if (!String.IsNullOrEmpty(m_serverUrl)) { scene.RegisterModuleInterface(this); + scene.RegisterModuleInterface(this); scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler; scene.EventManager.OnNewClient += NewClientHandler; @@ -86,6 +87,7 @@ namespace OpenSim.Services.Connectors.SimianGrid if (!String.IsNullOrEmpty(m_serverUrl)) { scene.UnregisterModuleInterface(this); + scene.UnregisterModuleInterface(this); scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler; scene.EventManager.OnNewClient -= NewClientHandler; @@ -151,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid return success; } - public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt) + public bool LogoutAgent(UUID sessionID) { m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); @@ -189,7 +191,12 @@ namespace OpenSim.Services.Connectors.SimianGrid return success; } - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) + { + return ReportAgent(sessionID, regionID, Vector3.Zero, Vector3.Zero); + } + + protected bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) { //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID); @@ -261,7 +268,23 @@ namespace OpenSim.Services.Connectors.SimianGrid return presences.ToArray(); } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) + #endregion IPresenceService + + #region IGridUserService + + public GridUserInfo LoggedIn(string userID) + { + // never implemented at the sim + return null; + } + + public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + { + // Not needed for simian grid, event handler is doing it + return true; + } + + public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) { m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); @@ -281,7 +304,35 @@ namespace OpenSim.Services.Connectors.SimianGrid return success; } - #endregion IPresenceService + public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + { + // Not needed for simian grid, presence detection is doing it + return true; + } + + public GridUserInfo GetGridUserInfo(string user) + { + m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); + + UUID userID = new UUID(user); + m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); + + NameValueCollection requestArgs = new NameValueCollection + { + { "RequestMethod", "GetUser" }, + { "UserID", userID.ToString() } + }; + + OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); + if (userResponse["Success"].AsBoolean()) + return ResponseToGridUserInfo(userResponse); + else + m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString()); + + return null; + } + + #endregion #region Presence Detection @@ -325,7 +376,7 @@ namespace OpenSim.Services.Connectors.SimianGrid SetLastLocation(client.SessionId); } - LogoutAgent(client.SessionId, Vector3.Zero, Vector3.UnitX); + LogoutAgent(client.SessionId); } } @@ -478,6 +529,31 @@ namespace OpenSim.Services.Connectors.SimianGrid return info; } + private GridUserInfo ResponseToGridUserInfo(OSDMap userResponse) + { + if (userResponse != null && userResponse["User"] is OSDMap) + { + + GridUserInfo info = new GridUserInfo(); + + info.Online = true; + info.UserID = userResponse["UserID"].AsUUID().ToString(); + info.LastRegionID = userResponse["SceneID"].AsUUID(); + info.LastPosition = userResponse["ScenePosition"].AsVector3(); + info.LastLookAt = userResponse["SceneLookAt"].AsVector3(); + + OSDMap user = (OSDMap)userResponse["User"]; + + info.Login = user["LastLoginDate"].AsDate(); + info.Logout = user["LastLogoutDate"].AsDate(); + DeserializeLocation(user["HomeLocation"].AsString(), out info.HomeRegionID, out info.HomePosition, out info.HomeLookAt); + + return info; + } + + return null; + } + private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt) { return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}"; diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 26f211b5d9..3af7ef9d3f 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -59,7 +59,7 @@ namespace OpenSim.Services.HypergridService static bool m_Initialized = false; - protected static IPresenceService m_PresenceService; + protected static IGridUserService m_GridUserService; protected static IGridService m_GridService; protected static GatekeeperServiceConnector m_GatekeeperConnector; @@ -74,14 +74,14 @@ namespace OpenSim.Services.HypergridService throw new Exception(String.Format("No section UserAgentService in config file")); string gridService = serverConfig.GetString("GridService", String.Empty); - string presenceService = serverConfig.GetString("PresenceService", String.Empty); + string gridUserService = serverConfig.GetString("GridUserService", String.Empty); - if (gridService == string.Empty || presenceService == string.Empty) + if (gridService == string.Empty || gridUserService == string.Empty) throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function.")); Object[] args = new Object[] { config }; m_GridService = ServerUtils.LoadPlugin(gridService, args); - m_PresenceService = ServerUtils.LoadPlugin(presenceService, args); + m_GridUserService = ServerUtils.LoadPlugin(gridUserService, args); m_GatekeeperConnector = new GatekeeperServiceConnector(); m_Initialized = true; @@ -95,15 +95,14 @@ namespace OpenSim.Services.HypergridService m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID); GridRegion home = null; - PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); - if (presences != null && presences.Length > 0) + GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); + if (uinfo != null) { - UUID homeID = presences[0].HomeRegionID; - if (homeID != UUID.Zero) + if (uinfo.HomeRegionID != UUID.Zero) { - home = m_GridService.GetRegionByUUID(UUID.Zero, homeID); - position = presences[0].HomePosition; - lookAt = presences[0].HomeLookAt; + home = m_GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); + position = uinfo.HomePosition; + lookAt = uinfo.HomeLookAt; } if (home == null) { diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs index a7c2c6f014..e629dffda4 100644 --- a/OpenSim/Services/Interfaces/IGridUserService.cs +++ b/OpenSim/Services/Interfaces/IGridUserService.cs @@ -37,39 +37,79 @@ namespace OpenSim.Services.Interfaces public class GridUserInfo { public string UserID; + public UUID HomeRegionID; public Vector3 HomePosition; public Vector3 HomeLookAt; + public UUID LastRegionID; + public Vector3 LastPosition; + public Vector3 LastLookAt; + + public bool Online; + public DateTime Login; + public DateTime Logout; + public GridUserInfo() {} public GridUserInfo(Dictionary kvp) { if (kvp.ContainsKey("UserID")) UserID = kvp["UserID"].ToString(); + if (kvp.ContainsKey("HomeRegionID")) UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID); if (kvp.ContainsKey("HomePosition")) Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition); if (kvp.ContainsKey("HomeLookAt")) Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt); + + if (kvp.ContainsKey("LastRegionID")) + UUID.TryParse(kvp["LastRegionID"].ToString(), out HomeRegionID); + if (kvp.ContainsKey("LastPosition")) + Vector3.TryParse(kvp["LastPosition"].ToString(), out LastPosition); + if (kvp.ContainsKey("LastLookAt")) + Vector3.TryParse(kvp["LastLookAt"].ToString(), out LastLookAt); + + if (kvp.ContainsKey("Login")) + DateTime.TryParse(kvp["Login"].ToString(), out Login); + if (kvp.ContainsKey("Logout")) + DateTime.TryParse(kvp["Logout"].ToString(), out Logout); + if (kvp.ContainsKey("Online")) + Boolean.TryParse(kvp["Online"].ToString(), out Online); + } public Dictionary ToKeyValuePairs() { Dictionary result = new Dictionary(); result["UserID"] = UserID; + result["HomeRegionID"] = HomeRegionID.ToString(); result["HomePosition"] = HomePosition.ToString(); result["HomeLookAt"] = HomeLookAt.ToString(); + result["LastRegionID"] = LastRegionID.ToString(); + result["LastPosition"] = LastPosition.ToString(); + result["LastLookAt"] = LastLookAt.ToString(); + + result["Online"] = Online.ToString(); + result["Login"] = Login.ToString(); + result["Logout"] = Logout.ToString(); + + return result; } } public interface IGridUserService { + GridUserInfo LoggedIn(string userID); + bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); + + bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt); + bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt); + GridUserInfo GetGridUserInfo(string userID); - bool StoreGridUserInfo(GridUserInfo info); } } \ No newline at end of file diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs index b4c18592cd..abbae2c559 100644 --- a/OpenSim/Services/Interfaces/IPresenceService.cs +++ b/OpenSim/Services/Interfaces/IPresenceService.cs @@ -55,23 +55,6 @@ namespace OpenSim.Services.Interfaces UserID = kvp["UserID"].ToString(); if (kvp.ContainsKey("RegionID")) UUID.TryParse(kvp["RegionID"].ToString(), out RegionID); - if (kvp.ContainsKey("login")) - DateTime.TryParse(kvp["login"].ToString(), out Login); - if (kvp.ContainsKey("logout")) - DateTime.TryParse(kvp["logout"].ToString(), out Logout); - if (kvp.ContainsKey("lookAt")) - Vector3.TryParse(kvp["lookAt"].ToString(), out LookAt); - if (kvp.ContainsKey("online")) - Boolean.TryParse(kvp["online"].ToString(), out Online); - if (kvp.ContainsKey("position")) - Vector3.TryParse(kvp["position"].ToString(), out Position); - if (kvp.ContainsKey("HomeRegionID")) - UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID); - if (kvp.ContainsKey("HomePosition")) - Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition); - if (kvp.ContainsKey("HomeLookAt")) - Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt); - } public Dictionary ToKeyValuePairs() @@ -79,14 +62,6 @@ namespace OpenSim.Services.Interfaces Dictionary result = new Dictionary(); result["UserID"] = UserID; result["RegionID"] = RegionID.ToString(); - result["online"] = Online.ToString(); - result["login"] = Login.ToString(); - result["logout"] = Logout.ToString(); - result["position"] = Position.ToString(); - result["lookAt"] = LookAt.ToString(); - result["HomeRegionID"] = HomeRegionID.ToString(); - result["HomePosition"] = HomePosition.ToString(); - result["HomeLookAt"] = HomeLookAt.ToString(); return result; } @@ -115,11 +90,10 @@ namespace OpenSim.Services.Interfaces public interface IPresenceService { bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID); - bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt); + bool LogoutAgent(UUID sessionID); bool LogoutRegionAgents(UUID regionID); - bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt); - bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt); + bool ReportAgent(UUID sessionID, UUID regionID); PresenceInfo GetAgent(UUID sessionID); PresenceInfo[] GetAgents(string[] userIDs); diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 0cd8f5bad5..dc5ca518a5 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -220,7 +220,7 @@ namespace OpenSim.Services.LLLoginService SetDefaultValues(); } - public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, + public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo, GridRegion destination, List invSkel, FriendInfo[] friendsList, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, string message, GridRegion home, IPEndPoint clientIP) @@ -288,7 +288,7 @@ namespace OpenSim.Services.LLLoginService } } - private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) + private void FillOutHomeData(GridUserInfo pinfo, GridRegion home) { int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize; if (home != null) diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 9efdd11747..398fe4f67c 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -53,6 +53,7 @@ namespace OpenSim.Services.LLLoginService private static bool Initialized = false; protected IUserAccountService m_UserAccountService; + protected IGridUserService m_GridUserService; protected IAuthenticationService m_AuthenticationService; protected IInventoryService m_InventoryService; protected IGridService m_GridService; @@ -82,6 +83,7 @@ namespace OpenSim.Services.LLLoginService throw new Exception(String.Format("No section LoginService in config file")); string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty); + string gridUserService = m_LoginServerConfig.GetString("GridUserService", String.Empty); string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty); string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty); string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty); @@ -105,8 +107,10 @@ namespace OpenSim.Services.LLLoginService Object[] args = new Object[] { config }; m_UserAccountService = ServerUtils.LoadPlugin(accountService, args); + m_GridUserService = ServerUtils.LoadPlugin(gridUserService, args); m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); m_InventoryService = ServerUtils.LoadPlugin(invService, args); + if (gridService != string.Empty) m_GridService = ServerUtils.LoadPlugin(gridService, args); if (presenceService != string.Empty) @@ -277,8 +281,6 @@ namespace OpenSim.Services.LLLoginService // // Login the presence // - PresenceInfo presence = null; - GridRegion home = null; if (m_PresenceService != null) { success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); @@ -287,17 +289,24 @@ namespace OpenSim.Services.LLLoginService m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); return LLFailedLoginResponse.GridProblem; } - - // Get the updated presence info - presence = m_PresenceService.GetAgent(session); - - // Get the home region - if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) - { - home = m_GridService.GetRegionByUUID(scopeID, presence.HomeRegionID); - } } + // + // Change Online status and get the home region + // + GridRegion home = null; + GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString()); + if (guinfo != null && (guinfo.HomeRegionID != UUID.Zero) && m_GridService != null) + { + home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID); + } + if (guinfo == null) + { + // something went wrong, make something up, so that we don't have to test this anywhere else + guinfo = new GridUserInfo(); + guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30); + } + // // Find the destination region/grid // @@ -305,10 +314,10 @@ namespace OpenSim.Services.LLLoginService Vector3 position = Vector3.Zero; Vector3 lookAt = Vector3.Zero; GridRegion gatekeeper = null; - GridRegion destination = FindDestination(account, scopeID, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt); + GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt); if (destination == null) { - m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); + m_PresenceService.LogoutAgent(session); m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); return LLFailedLoginResponse.GridProblem; } @@ -330,7 +339,7 @@ namespace OpenSim.Services.LLLoginService if (aCircuit == null) { - m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); + m_PresenceService.LogoutAgent(session); m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); return LLFailedLoginResponse.AuthorizationProblem; @@ -346,7 +355,7 @@ namespace OpenSim.Services.LLLoginService // // Finally, fill out the response and return it // - LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, friendsList, m_LibraryService, + LLLoginResponse response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client."); @@ -356,12 +365,12 @@ namespace OpenSim.Services.LLLoginService { m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace); if (m_PresenceService != null) - m_PresenceService.LogoutAgent(session, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + m_PresenceService.LogoutAgent(session); return LLFailedLoginResponse.InternalError; } } - protected GridRegion FindDestination(UserAccount account, UUID scopeID, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt) + protected GridRegion FindDestination(UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, GridRegion home, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt) { m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); @@ -383,7 +392,7 @@ namespace OpenSim.Services.LLLoginService bool tryDefaults = false; - if (pinfo.HomeRegionID.Equals(UUID.Zero)) + if (home == null) { m_log.WarnFormat( "[LLOGIN SERVICE]: User {0} {1} tried to login to a 'home' start location but they have none set", @@ -393,16 +402,10 @@ namespace OpenSim.Services.LLLoginService } else { - region = m_GridService.GetRegionByUUID(scopeID, pinfo.HomeRegionID); + region = home; - if (null == region) - { - m_log.WarnFormat( - "[LLOGIN SERVICE]: User {0} {1} has a recorded home region of {2} but this cannot be found by the grid service", - account.FirstName, account.LastName, pinfo.HomeRegionID); - - tryDefaults = true; - } + position = pinfo.HomePosition; + lookAt = pinfo.HomeLookAt; } if (tryDefaults) @@ -438,7 +441,7 @@ namespace OpenSim.Services.LLLoginService GridRegion region = null; - if (pinfo.RegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.RegionID)) == null) + if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null) { List defaults = m_GridService.GetDefaultRegions(scopeID); if (defaults != null && defaults.Count > 0) @@ -460,8 +463,8 @@ namespace OpenSim.Services.LLLoginService } else { - position = pinfo.Position; - lookAt = pinfo.LookAt; + position = pinfo.LastPosition; + lookAt = pinfo.LastLookAt; } return region; diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index ea8d673c1f..7e7e98e417 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -54,8 +54,6 @@ namespace OpenSim.Services.PresenceService public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { - m_Database.Prune(userID); - PresenceData[] d = m_Database.Get("UserID", userID); PresenceData data = new PresenceData(); @@ -65,24 +63,6 @@ namespace OpenSim.Services.PresenceService data.SessionID = sessionID; data.Data = new Dictionary(); data.Data["SecureSessionID"] = secureSessionID.ToString(); - data.Data["Online"] = "true"; - data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); - if (d != null && d.Length > 0) - { - data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; - data.Data["HomePosition"] = d[0].Data["HomePosition"]; - data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; - data.Data["Position"] = d[0].Data["Position"]; - data.Data["LookAt"] = d[0].Data["LookAt"]; - - data.RegionID = d[0].RegionID; - } - else - { - data.Data["HomeRegionID"] = UUID.Zero.ToString(); - data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString(); - data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString(); - } m_Database.Store(data); @@ -91,28 +71,10 @@ namespace OpenSim.Services.PresenceService return true; } - public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) + public bool LogoutAgent(UUID sessionID) { - PresenceData data = m_Database.Get(sessionID); - if (data == null) - return false; - - PresenceData[] d = m_Database.Get("UserID", data.UserID); - - m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length); - if (d.Length > 1) - { - m_Database.Delete("UserID", data.UserID); - } - - data.Data["Online"] = "false"; - data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); - data.Data["Position"] = position.ToString(); - data.Data["LookAt"] = lookat.ToString(); - - m_Database.Store(data); - - return true; + m_log.DebugFormat("[PRESENCE SERVICE]: Session {0} logout", sessionID); + return m_Database.Delete("SessionID", sessionID.ToString()); } public bool LogoutRegionAgents(UUID regionID) @@ -123,7 +85,7 @@ namespace OpenSim.Services.PresenceService } - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + public bool ReportAgent(UUID sessionID, UUID regionID) { m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); try @@ -134,14 +96,7 @@ namespace OpenSim.Services.PresenceService if (pdata.Data == null) return false; - if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false")) - { - m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online"); - return false; - } - - return m_Database.ReportAgent(sessionID, regionID, - position.ToString(), lookAt.ToString()); + return m_Database.ReportAgent(sessionID, regionID); } catch (Exception e) { @@ -160,22 +115,10 @@ namespace OpenSim.Services.PresenceService ret.UserID = data.UserID; ret.RegionID = data.RegionID; - if (data.Data.ContainsKey("Online")) - ret.Online = bool.Parse(data.Data["Online"]); - if (data.Data.ContainsKey("Login")) - ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"])); - if (data.Data.ContainsKey("Logout")) - ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); if (data.Data.ContainsKey("Position")) ret.Position = Vector3.Parse(data.Data["Position"]); if (data.Data.ContainsKey("LookAt")) ret.LookAt = Vector3.Parse(data.Data["LookAt"]); - if (data.Data.ContainsKey("HomeRegionID")) - ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]); - if (data.Data.ContainsKey("HomePosition")) - ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]); - if (data.Data.ContainsKey("HomeLookAt")) - ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]); return ret; } @@ -195,16 +138,8 @@ namespace OpenSim.Services.PresenceService ret.UserID = d.UserID; ret.RegionID = d.RegionID; - ret.Online = bool.Parse(d.Data["Online"]); - ret.Login = Util.ToDateTime(Convert.ToInt32( - d.Data["Login"])); - ret.Logout = Util.ToDateTime(Convert.ToInt32( - d.Data["Logout"])); ret.Position = Vector3.Parse(d.Data["Position"]); ret.LookAt = Vector3.Parse(d.Data["LookAt"]); - ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]); - ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]); - ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); info.Add(ret); } @@ -214,9 +149,5 @@ namespace OpenSim.Services.PresenceService return info.ToArray(); } - public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) - { - return m_Database.SetHomeLocation(userID, regionID, position, lookAt); - } } } diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index c6e33bbbfe..697ba639d2 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs @@ -31,6 +31,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Data; using OpenSim.Services.Interfaces; +using OpenSim.Framework; using OpenSim.Framework.Console; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -50,27 +51,109 @@ namespace OpenSim.Services.UserAccountService public GridUserInfo GetGridUserInfo(string userID) { - GridUserData d = m_Database.GetGridUserData(userID); - + GridUserData d = m_Database.Get(userID); + + if (d == null) + return null; + GridUserInfo info = new GridUserInfo(); info.UserID = d.UserID; info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); + info.LastRegionID = new UUID(d.Data["LastRegionID"]); + info.LastPosition = Vector3.Parse(d.Data["LastPosition"]); + info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]); + + info.Online = bool.Parse(d.Data["Online"]); + info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"])); + info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"])); + return info; } - - public bool StoreGridUserInfo(GridUserInfo info) + + public GridUserInfo LoggedIn(string userID) + { + m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); + GridUserData d = m_Database.Get(userID); + + if (d == null) + { + d = new GridUserData(); + d.UserID = userID; + } + + d.Data["Online"] = true.ToString(); + d.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); + + m_Database.Store(d); + + return GetGridUserInfo(userID); + } + + public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + { + m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); + GridUserData d = m_Database.Get(userID); + + if (d == null) + { + d = new GridUserData(); + d.UserID = userID; + } + + d.Data["Online"] = false.ToString(); + d.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); + d.Data["LastRegionID"] = regionID.ToString(); + d.Data["LastPosition"] = lastPosition.ToString(); + d.Data["LastLookAt"] = lastLookAt.ToString(); + + return m_Database.Store(d); + } + + protected bool StoreGridUserInfo(GridUserInfo info) { GridUserData d = new GridUserData(); - d.Data["UserID"] = info.UserID; d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); d.Data["HomePosition"] = info.HomePosition.ToString(); d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); - return m_Database.StoreGridUserData(d); + return m_Database.Store(d); + } + + public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) + { + GridUserData d = m_Database.Get(userID); + if (d == null) + { + d = new GridUserData(); + d.UserID = userID; + } + + d.Data["HomeRegionID"] = homeID.ToString(); + d.Data["HomePosition"] = homePosition.ToString(); + d.Data["HomeLookAt"] = homeLookAt.ToString(); + + return m_Database.Store(d); + } + + public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) + { + //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); + GridUserData d = m_Database.Get(userID); + if (d == null) + { + d = new GridUserData(); + d.UserID = userID; + } + + d.Data["LastRegionID"] = regionID.ToString(); + d.Data["LastPosition"] = lastPosition.ToString(); + d.Data["LastLookAt"] = lastLookAt.ToString(); + + return m_Database.Store(d); } } } \ No newline at end of file diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 35e2826a71..6923293154 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -46,7 +46,7 @@ namespace OpenSim.Services.UserAccountService protected IGridService m_GridService; protected IAuthenticationService m_AuthenticationService; - protected IPresenceService m_PresenceService; + protected IGridUserService m_GridUserService; protected IInventoryService m_InventoryService; public UserAccountService(IConfigSource config) @@ -69,9 +69,9 @@ namespace OpenSim.Services.UserAccountService if (authServiceDll != string.Empty) m_AuthenticationService = LoadPlugin(authServiceDll, new Object[] { config }); - string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty); + string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty); if (presenceServiceDll != string.Empty) - m_PresenceService = LoadPlugin(presenceServiceDll, new Object[] { config }); + m_GridUserService = LoadPlugin(presenceServiceDll, new Object[] { config }); string invServiceDll = userConfig.GetString("InventoryService", string.Empty); if (invServiceDll != string.Empty) @@ -333,8 +333,8 @@ namespace OpenSim.Services.UserAccountService if (defaultRegions != null && defaultRegions.Count >= 1) home = defaultRegions[0]; - if (m_PresenceService != null && home != null) - m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + if (m_GridUserService != null && home != null) + m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); else m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", firstName, lastName); diff --git a/OpenSim/Tests/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Clients/Presence/PresenceClient.cs index 4f959f6547..0f6b80e209 100644 --- a/OpenSim/Tests/Clients/Presence/PresenceClient.cs +++ b/OpenSim/Tests/Clients/Presence/PresenceClient.cs @@ -77,7 +77,7 @@ namespace OpenSim.Tests.Clients.PresenceClient pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); System.Console.WriteLine("\n"); - success = m_Connector.ReportAgent(session1, region1, new Vector3(128, 128, 128), new Vector3(4, 5, 6)); + success = m_Connector.ReportAgent(session1, region1); if (success) m_log.InfoFormat("[PRESENCE CLIENT]: Successfully reported session {0} in region {1}", user1, region1); else @@ -90,20 +90,7 @@ namespace OpenSim.Tests.Clients.PresenceClient pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); System.Console.WriteLine("\n"); - success = m_Connector.SetHomeLocation(user1.ToString(), region1, new Vector3(128, 128, 128), new Vector3(4, 5, 6)); - if (success) - m_log.InfoFormat("[PRESENCE CLIENT]: Successfully set home for user {0} in region {1}", user1, region1); - else - m_log.InfoFormat("[PRESENCE CLIENT]: failed to set home for user {0}", user1); - pinfo = m_Connector.GetAgent(session1); - if (pinfo == null) - m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for third time", user1); - else - m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", - pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); - - System.Console.WriteLine("\n"); - success = m_Connector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY); + success = m_Connector.LogoutAgent(session1); if (success) m_log.InfoFormat("[PRESENCE CLIENT]: Successfully logged out user {0}", user1); else @@ -116,7 +103,7 @@ namespace OpenSim.Tests.Clients.PresenceClient pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); System.Console.WriteLine("\n"); - success = m_Connector.ReportAgent(session1, UUID.Random(), Vector3.Zero, Vector3.Zero); + success = m_Connector.ReportAgent(session1, UUID.Random()); if (success) m_log.InfoFormat("[PRESENCE CLIENT]: Report agent succeeded, but this is wrong"); else diff --git a/README.txt b/README.txt index f1a71beadf..e19e58ecad 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,6 @@ Welcome to OpenSim! -== OVERVIEW == +=== OVERVIEW === OpenSim is a BSD Licensed Open Source project to develop a functioning virtual worlds server platform capable of supporting multiple clients @@ -10,12 +10,12 @@ C#, and can run under Mono or the Microsoft .NET runtimes. This is considered an alpha release. Some stuff works, a lot doesn't. If it breaks, you get to keep *both* pieces. -== Compiling OpenSim == +=== Compiling OpenSim === Please see BUILDING.txt if you downloaded a source distribution and need to build OpenSim before running it. -== Running OpenSim on Windows == +=== Running OpenSim on Windows === We recommend that you run OpenSim from a command prompt on Windows in order to capture any errors, though you can also run it by double-clicking @@ -28,7 +28,7 @@ To run OpenSim from a command prompt Now see the "Configuring OpenSim" section -== Running OpenSim on Linux == +=== Running OpenSim on Linux === You will need Mono >= 2.4.2 to run OpenSim. On some Linux distributions you may need to install additional packages. See http://opensimulator.org/wiki/Dependencies @@ -41,7 +41,7 @@ To run OpenSim, from the unpacked distribution type: Now see the "Configuring OpenSim" section -== Configuring OpenSim == +=== Configuring OpenSim === When OpenSim starts for the first time, you will be prompted with a series of questions that look something like: @@ -69,14 +69,14 @@ Helpful resources: * http://opensimulator.org/wiki/Configuring_Regions * http://opensimulator.org/wiki/Mysql-config -== Connecting to your OpenSim == +=== Connecting to your OpenSim === By default your sim will be running on http://127.0.0.1:9000. To use your OpenSim add -loginuri http://127.0.0.1:9000 to your second life client (running on the same machine as your OpenSim). To login, use the same avatar details that you gave to the "create user" console command. -== Bug reports == +=== Bug reports === In the likely event of bugs biting you (err, your OpenSim) we encourage you to see whether the problem has already been reported on @@ -97,10 +97,11 @@ mantis"). Useful information to include: mono --debug OpenSim.exe -== More Information on OpenSim == +=== More Information on OpenSim === More extensive information on building, running, and configuring OpenSim, as well as how to report bugs, and participate in the OpenSim project can always be found at http://opensimulator.org. Thanks for trying OpenSim, we hope it is a pleasant experience. + \ No newline at end of file diff --git a/bin/Robust.HG.ini.example b/bin/Robust.HG.ini.example index d8145af2db..9af1e4cdf3 100644 --- a/bin/Robust.HG.ini.example +++ b/bin/Robust.HG.ini.example @@ -11,7 +11,7 @@ ;; [Startup] -ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryServiceInConnector,8002/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8003/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,8002/OpenSim.Server.Handlers.dll:AssetServiceConnector" +ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryServiceInConnector,8002/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8003/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector,8002/OpenSim.Server.Handlers.dll:GatekeeperServiceInConnector,8002/OpenSim.Server.Handlers.dll:UserAgentServerConnector,HGInventoryService@8002/OpenSim.Server.Handlers.dll:XInventoryInConnector,8002/OpenSim.Server.Handlers.dll:AssetServiceConnector" ; * This is common for all services, it's the network setup for the entire ; * server instance, if none if specified above @@ -93,6 +93,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" +[GridUserService] + ; for the server connector + LocalServiceModule = "OpenSim.Services.UserAccountService.dll:GridUserService" + [PresenceService] ; for the server connector LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" @@ -114,6 +118,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" ; for the service UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" @@ -196,7 +201,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 [UserAgentService] LocalServiceModule = "OpenSim.Services.HypergridService.dll:UserAgentService" ;; for the service - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" GridService = "OpenSim.Services.GridService.dll:GridService" ;; The interface that local users get when they are in other grids. diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index ae3a53c635..502a8e656a 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -11,7 +11,7 @@ ; * [Startup] -ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8002/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector" +ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003/OpenSim.Server.Handlers.dll:XInventoryInConnector,8002/OpenSim.Server.Handlers.dll:FreeswitchServerConnector,8003/OpenSim.Server.Handlers.dll:GridServiceConnector,8002/OpenSim.Server.Handlers.dll:GridInfoServerInConnector,8003/OpenSim.Server.Handlers.dll:AuthenticationServiceConnector,8002/OpenSim.Server.Handlers.dll:OpenIdServerConnector,8003/OpenSim.Server.Handlers.dll:AvatarServiceConnector,8002/OpenSim.Server.Handlers.dll:LLLoginServiceInConnector,8003/OpenSim.Server.Handlers.dll:PresenceServiceConnector,8003/OpenSim.Server.Handlers.dll:UserAccountServiceConnector,8003/OpenSim.Server.Handlers.dll:GridUserServiceConnector,8003/OpenSim.Server.Handlers.dll:FriendsServiceConnector" ; * This is common for all services, it's the network setup for the entire ; * server instance, if none if specified above @@ -95,6 +95,10 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" +[GridUserService] + ; for the server connector + LocalServiceModule = "OpenSim.Services.UserAccountService.dll:GridUserService" + [PresenceService] ; for the server connector LocalServiceModule = "OpenSim.Services.PresenceService.dll:PresenceService" @@ -116,6 +120,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" ; for the service UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index 4767cbc847..9a75f19845 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini @@ -8,21 +8,24 @@ Include-Common = "config-include/GridCommon.ini" [Modules] - AssetServices = "RemoteAssetServicesConnector" - InventoryServices = "RemoteXInventoryServicesConnector" - GridServices = "RemoteGridServicesConnector" - AvatarServices = "RemoteAvatarServicesConnector" - NeighbourServices = "RemoteNeighbourServicesConnector" - AuthenticationServices = "RemoteAuthenticationServicesConnector" - PresenceServices = "RemotePresenceServicesConnector" - UserAccountServices = "RemoteUserAccountServicesConnector" - SimulationServices = "RemoteSimulationConnectorModule" - EntityTransferModule = "BasicEntityTransferModule" - InventoryAccessModule = "BasicInventoryAccessModule" - LandServiceInConnector = true - NeighbourServiceInConnector = true - SimulationServiceInConnector = true - LibraryModule = true + AssetServices = "RemoteAssetServicesConnector" + InventoryServices = "RemoteXInventoryServicesConnector" + GridServices = "RemoteGridServicesConnector" + AvatarServices = "RemoteAvatarServicesConnector" + NeighbourServices = "RemoteNeighbourServicesConnector" + AuthenticationServices = "RemoteAuthenticationServicesConnector" + AuthorizationServices = "RemoteAuthorizationServicesConnector" + PresenceServices = "RemotePresenceServicesConnector" + UserAccountServices = "RemoteUserAccountServicesConnector" + GridUserServices = "RemoteGridUserServicesConnector" + SimulationServices = "RemoteSimulationConnectorModule" + EntityTransferModule = "BasicEntityTransferModule" + InventoryAccessModule = "BasicInventoryAccessModule" + + LandServiceInConnector = true + NeighbourServiceInConnector = true + SimulationServiceInConnector = true + LibraryModule = true [GridService] diff --git a/bin/config-include/GridCommon.ini.example b/bin/config-include/GridCommon.ini.example index 6e27694cd6..88ac5e2dbf 100644 --- a/bin/config-include/GridCommon.ini.example +++ b/bin/config-include/GridCommon.ini.example @@ -40,6 +40,12 @@ ; UserAccountServerURI = "http://mygridserver.com:8003" +[GridUserService] + ; + ; change this to your grid-wide user accounts server + ; + GridUserServerURI = "http://mygridserver.com:8003" + [AuthenticationService] ; ; change this to your grid-wide authentication server diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index 1e24f88749..1adc2d8068 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -8,22 +8,24 @@ Include-Common = "config-include/GridCommon.ini" [Modules] - AssetServices = "HGAssetBroker" - InventoryServices = "HGInventoryBroker" - GridServices = "RemoteGridServicesConnector" - AvatarServices = "RemoteAvatarServicesConnector" - NeighbourServices = "RemoteNeighbourServicesConnector" - AuthenticationServices = "RemoteAuthenticationServicesConnector" - AuthorizationServices = "LocalAuthorizationServicesConnector" - PresenceServices = "RemotePresenceServicesConnector" - UserAccountServices = "RemoteUserAccountServicesConnector" - SimulationServices = "RemoteSimulationConnectorModule" - EntityTransferModule = "HGEntityTransferModule" - InventoryAccessModule = "HGInventoryAccessModule" - LandServiceInConnector = true - NeighbourServiceInConnector = true - SimulationServiceInConnector = true - LibraryModule = true + AssetServices = "HGAssetBroker" + InventoryServices = "HGInventoryBroker" + GridServices = "RemoteGridServicesConnector" + AvatarServices = "RemoteAvatarServicesConnector" + NeighbourServices = "RemoteNeighbourServicesConnector" + AuthenticationServices = "RemoteAuthenticationServicesConnector" + AuthorizationServices = "RemoteAuthorizationServicesConnector" + PresenceServices = "RemotePresenceServicesConnector" + UserAccountServices = "RemoteUserAccountServicesConnector" + GridUserServices = "RemoteGridUserServicesConnector" + SimulationServices = "RemoteSimulationConnectorModule" + EntityTransferModule = "HGEntityTransferModule" + InventoryAccessModule = "HGInventoryAccessModule" + + LandServiceInConnector = true + NeighbourServiceInConnector = true + SimulationServiceInConnector = true + LibraryModule = true [AssetService] LocalGridAssetService = "OpenSim.Services.Connectors.dll:AssetServicesConnector" diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini index 027b4ea66e..6b7dc50b7f 100644 --- a/bin/config-include/Standalone.ini +++ b/bin/config-include/Standalone.ini @@ -17,8 +17,9 @@ AvatarServices = "LocalAvatarServicesConnector" EntityTransferModule = "BasicEntityTransferModule" InventoryAccessModule = "BasicInventoryAccessModule" - LibraryModule = true - LLLoginServiceInConnector = true + + LibraryModule = true + LLLoginServiceInConnector = true [AssetService] LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" @@ -54,7 +55,7 @@ ;; These are for creating new accounts AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" @@ -70,6 +71,7 @@ [LoginService] LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 35e6f207eb..130e210a77 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -5,25 +5,27 @@ ;; [Modules] - AssetServices = "HGAssetBroker" - InventoryServices = "HGInventoryBroker" - NeighbourServices = "LocalNeighbourServicesConnector" - AuthenticationServices = "LocalAuthenticationServicesConnector" - GridServices = "LocalGridServicesConnector" - PresenceServices = "LocalPresenceServicesConnector" - UserAccountServices = "LocalUserAccountServicesConnector" - SimulationServices = "RemoteSimulationConnectorModule" - AvatarServices = "LocalAvatarServicesConnector" - EntityTransferModule = "HGEntityTransferModule" - InventoryAccessModule = "HGInventoryAccessModule" - InventoryServiceInConnector = true - AssetServiceInConnector = true - HypergridServiceInConnector = true - NeighbourServiceInConnector = true - LibraryModule = true - LLLoginServiceInConnector = true - AuthenticationServiceInConnector = true - SimulationServiceInConnector = true + AssetServices = "HGAssetBroker" + InventoryServices = "HGInventoryBroker" + NeighbourServices = "LocalNeighbourServicesConnector" + AuthenticationServices = "LocalAuthenticationServicesConnector" + GridServices = "LocalGridServicesConnector" + PresenceServices = "LocalPresenceServicesConnector" + UserAccountServices = "LocalUserAccountServicesConnector" + GridUserServices = "LocalGridUserServicesConnector" + SimulationServices = "RemoteSimulationConnectorModule" + AvatarServices = "LocalAvatarServicesConnector" + EntityTransferModule = "HGEntityTransferModule" + InventoryAccessModule = "HGInventoryAccessModule" + + InventoryServiceInConnector = true + AssetServiceInConnector = true + HypergridServiceInConnector = true + NeighbourServiceInConnector = true + LibraryModule = true + LLLoginServiceInConnector = true + AuthenticationServiceInConnector = true + SimulationServiceInConnector = true [AssetService] LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" @@ -68,10 +70,10 @@ [UserAccountService] LocalServiceModule = "OpenSim.Services.UserAccountService.dll:UserAccountService" - ConnectionString = "URI=file:userprofiles.db,version=3" + ;; These are for creating new accounts by the service AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" @@ -83,15 +85,16 @@ Connector = "OpenSim.Services.FriendsService.dll" [LoginService] - LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" - UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" - UserAgentService = "OpenSim.Services.HypergridService.dll:UserAgentService" - AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" - InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" - GridService = "OpenSim.Services.GridService.dll:GridService" - AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" - FriendsService = "OpenSim.Services.FriendsService.dll:FriendsService" + LocalServiceModule = "OpenSim.Services.LLLoginService.dll:LLLoginService" + UserAccountService = "OpenSim.Services.UserAccountService.dll:UserAccountService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" + UserAgentService = "OpenSim.Services.HypergridService.dll:UserAgentService" + AuthenticationService = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" + InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" + PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" + GridService = "OpenSim.Services.GridService.dll:GridService" + AvatarService = "OpenSim.Services.AvatarService.dll:AvatarService" + FriendsService = "OpenSim.Services.FriendsService.dll:FriendsService" [GatekeeperService] LocalServiceModule = "OpenSim.Services.HypergridService.dll:GatekeeperService" @@ -106,7 +109,7 @@ [UserAgentService] LocalServiceModule = "OpenSim.Services.HypergridService.dll:UserAgentService" ;; for the service - PresenceService = "OpenSim.Services.PresenceService.dll:PresenceService" + GridUserService = "OpenSim.Services.UserAccountService.dll:GridUserService" GridService = "OpenSim.Services.GridService.dll:GridService" ;; The interface that local users get when they are in other grids diff --git a/bin/config-include/storage/SQLiteStandalone.ini b/bin/config-include/storage/SQLiteStandalone.ini index ed88a8a182..fe814d7022 100644 --- a/bin/config-include/storage/SQLiteStandalone.ini +++ b/bin/config-include/storage/SQLiteStandalone.ini @@ -17,6 +17,9 @@ [UserAccountService] ConnectionString = "URI=file:userprofiles.db,version=3" +[GridUserService] + ConnectionString = "URI=file:griduser.db,version=3" + [FriendsService] ConnectionString = "URI=file:friends.db,version=3"