From ad8ee180900b83954718178be916f1278a30f46a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Dec 2009 08:38:05 -0800 Subject: First pass at the local connector for presence. No cache yet. Just the connector to the local service and a presence detector object. --- .../Presence/LocalPresenceServiceConnector.cs | 187 +++++++++++++++++++++ .../Presence/PresenceDetector.cs | 79 +++++++++ 2 files changed, 266 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs new file mode 100644 index 0000000..0012f0a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -0,0 +1,187 @@ +/* + * 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 PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence +{ + public class LocalPresenceServiceConnector : ISharedRegionModule, IPresenceService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region ISharedRegionModule + + private bool m_Enabled = false; + private bool m_Initialized = false; + + private PresenceDetector m_PresenceDetector; + private IPresenceService m_PresenceService; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalPresenceServiceConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("PresenceServices", ""); + if (name == Name) + { + IConfig inventoryConfig = source.Configs["PresenceService"]; + if (inventoryConfig == null) + { + m_log.Error("[LOCAL PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); + return; + } + + string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section InventoryService"); + return; + } + + Object[] args = new Object[] { source }; + m_log.DebugFormat("[LOCAL PRESENCE CONNECTOR]: Service dll = {0}", serviceDll); + + m_PresenceService = ServerUtils.LoadPlugin(serviceDll, args); + + if (m_PresenceService == null) + { + m_log.Error("[LOCAL PRESENCE CONNECTOR]: Can't load presence service"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + //Init(source); + + m_PresenceDetector = new PresenceDetector(this); + + m_Enabled = true; + m_log.Info("[LOCAL PRESENCE CONNECTOR]: Local presence connector enabled"); + } + } + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + // m_log.DebugFormat( + // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); + + scene.RegisterModuleInterface(this); + m_PresenceDetector.AddRegion(scene); + + m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); + + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_PresenceDetector.RemoveRegion(scene); + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region IPresenceService + + public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) + { + m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); + return false; + } + + public bool LogoutAgent(UUID sessionID) + { + return m_PresenceService.LogoutAgent(sessionID); + } + + + public bool LogoutRegionAgents(UUID regionID) + { + return m_PresenceService.LogoutRegionAgents(regionID); + } + + public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt); + } + + public PresenceInfo GetAgent(UUID sessionID) + { + return m_PresenceService.GetAgent(sessionID); + } + + public PresenceInfo[] GetAgents(UUID[] principalIDs) + { + return m_PresenceService.GetAgents(principalIDs); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs new file mode 100644 index 0000000..150728f --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -0,0 +1,79 @@ +/* + * 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 OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence +{ + public class PresenceDetector + { + private IPresenceService m_PresenceService; + + public PresenceDetector(IPresenceService presenceservice) + { + m_PresenceService = presenceservice; + } + + public void AddRegion(Scene scene) + { + scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; + scene.EventManager.OnNewClient += OnNewClient; + + m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); + } + + public void RemoveRegion(Scene scene) + { + scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent; + scene.EventManager.OnNewClient -= OnNewClient; + + m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); + } + + public void OnMakeRootAgent(ScenePresence sp) + { + m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); + } + + public void OnNewClient(IClientAPI client) + { + client.OnLogout += OnLogout; + } + + public void OnLogout(IClientAPI client) + { + client.OnLogout -= OnLogout; + m_PresenceService.LogoutAgent(client.SessionId); + } + } +} -- cgit v1.1 From b8dfccb2272e12942f5364fa327ffd721292d8ad Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Dec 2009 16:07:16 -0800 Subject: Changed GetAgents to take string[] instead of UUID[] --- .../ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 0012f0a..24362c7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence if (serviceDll == String.Empty) { - m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section InventoryService"); + m_log.Error("[LOCAL PRESENCE CONNECTOR]: No LocalServiceModule named in section PresenceService"); return; } @@ -176,7 +176,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_PresenceService.GetAgent(sessionID); } - public PresenceInfo[] GetAgents(UUID[] principalIDs) + public PresenceInfo[] GetAgents(string[] principalIDs) { return m_PresenceService.GetAgents(principalIDs); } -- cgit v1.1 From eebddcd5e693a4b56af326546d4222bd594286e0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 01:24:15 +0000 Subject: Change FriendsModule, InstantMessageModule, MessageTransferModule, MuteListModule, OfflineMessageModule, PresenceModule, InventoryTransferModule and LureModule to new style. Reduce FriendsModule and PresenceModule to shells. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 1064 +------------------- .../Avatar/InstantMessage/InstantMessageModule.cs | 60 +- .../Avatar/InstantMessage/MessageTransferModule.cs | 55 +- .../Avatar/InstantMessage/MuteListModule.cs | 68 +- .../Avatar/InstantMessage/OfflineMessageModule.cs | 78 +- .../Avatar/InstantMessage/PresenceModule.cs | 381 +------ .../Inventory/Transfer/InventoryTransferModule.cs | 56 +- .../Region/CoreModules/Avatar/Lure/LureModule.cs | 64 +- .../Resources/CoreModulePlugin.addin.xml | 8 + 9 files changed, 281 insertions(+), 1553 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index d6a82ef..f5d30b7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -44,1088 +44,50 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.Friends { - /* - This module handles adding/removing friends, and the the presence - notification process for login/logoff of friends. - - The presence notification works as follows: - - After the user initially connects to a region (so we now have a UDP - connection to work with), this module fetches the friends of user - (those are cached), their on-/offline status, and info about the - region they are in from the MessageServer. - - (*) It then informs the user about the on-/offline status of her friends. - - It then informs all online friends currently on this region-server about - user's new online status (this will save some network traffic, as local - messages don't have to be transferred inter-region, and it will be all - that has to be done in Standalone Mode). - - For the rest of the online friends (those not on this region-server), - this module uses the provided region-information to map users to - regions, and sends one notification to every region containing the - friends to inform on that server. - - The region-server will handle that in the following way: - - If it finds the friend, it informs her about the user being online. - - If it doesn't find the friend (maybe she TPed away in the meantime), - it stores that information. - - After it processed all friends, it returns the list of friends it - couldn't find. - - If this list isn't empty, the FriendsModule re-requests information - about those online friends that have been missed and starts at (*) - again until all friends have been found, or until it tried 3 times - (to prevent endless loops due to some uncaught error). - - NOTE: Online/Offline notifications don't need to be sent on region change. - - We implement two XMLRpc handlers here, handling all the inter-region things - we have to handle: - - On-/Offline-Notifications (bulk) - - Terminate Friendship messages (single) - */ - - public class FriendsModule : IRegionModule, IFriendsModule + public class FriendsModule : ISharedRegionModule, IFriendsModule { - private class Transaction + public void Initialise(IConfigSource config) { - public UUID agentID; - public string agentName; - public uint count; - - public Transaction(UUID agentID, string agentName) - { - this.agentID = agentID; - this.agentName = agentName; - this.count = 1; - } - } - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private Cache m_friendLists = new Cache(CacheFlags.AllowUpdate); - - private Dictionary m_rootAgents = new Dictionary(); - - private Dictionary m_pendingCallingcardRequests = new Dictionary(); - - private Scene m_initialScene; // saves a lookup if we don't have a specific scene - private Dictionary m_scenes = new Dictionary(); - private IMessageTransferModule m_TransferModule = null; - - private IGridService m_gridServices = null; - - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) - { - lock (m_scenes) - { - if (m_scenes.Count == 0) - { - MainServer.Instance.AddXmlRPCHandler("presence_update_bulk", processPresenceUpdateBulk); - MainServer.Instance.AddXmlRPCHandler("terminate_friend", processTerminateFriend); - m_friendLists.DefaultTTL = new TimeSpan(1, 0, 0); // store entries for one hour max - m_initialScene = scene; - } - - if (!m_scenes.ContainsKey(scene.RegionInfo.RegionHandle)) - m_scenes[scene.RegionInfo.RegionHandle] = scene; - } - - scene.RegisterModuleInterface(this); - - scene.EventManager.OnNewClient += OnNewClient; - scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; - scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; - scene.EventManager.OnMakeChildAgent += MakeChildAgent; - scene.EventManager.OnClientClosed += ClientClosed; } public void PostInitialise() { - if (m_scenes.Count > 0) - { - m_TransferModule = m_initialScene.RequestModuleInterface(); - m_gridServices = m_initialScene.GridService; - } - if (m_TransferModule == null) - m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); - } - - public void Close() - { - } - - public string Name - { - get { return "FriendsModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - #region IInterregionFriendsComms - - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - List tpdAway = new List(); - - // destRegionHandle is a region on another server - uint x = 0, y = 0; - Utils.LongToUInts(destRegionHandle, out x, out y); - GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); - if (info != null) - { - string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; - - Hashtable reqParams = new Hashtable(); - reqParams["agentID"] = agentId.ToString(); - reqParams["agentOnline"] = online; - int count = 0; - foreach (UUID uuid in friends) - { - reqParams["friendID_" + count++] = uuid.ToString(); - } - reqParams["friendCount"] = count; - - IList parameters = new ArrayList(); - parameters.Add(reqParams); - try - { - XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters); - XmlRpcResponse response = request.Send(httpServer, 5000); - Hashtable respData = (Hashtable)response.Value; - - count = (int)respData["friendCount"]; - for (int i = 0; i < count; ++i) - { - UUID uuid; - if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid); - } - } - catch (WebException e) - { - // Ignore connect failures, simulators come and go - // - if (!e.Message.Contains("ConnectFailure")) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - } - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - } - } - else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle); - - return tpdAway; - } - - public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) - { - // destRegionHandle is a region on another server - uint x = 0, y = 0; - Utils.LongToUInts(destRegionHandle, out x, out y); - GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); - if (info == null) - { - m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); - return false; // region not found??? - } - - string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; - - Hashtable reqParams = new Hashtable(); - reqParams["agentID"] = agentID.ToString(); - reqParams["friendID"] = exFriendID.ToString(); - - IList parameters = new ArrayList(); - parameters.Add(reqParams); - try - { - XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters); - XmlRpcResponse response = request.Send(httpServer, 5000); - Hashtable respData = (Hashtable)response.Value; - - return (bool)respData["success"]; - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - return false; - } - } - - #endregion - - #region Incoming XMLRPC messages - /// - /// Receive presence information changes about clients in other regions. - /// - /// - /// - public XmlRpcResponse processPresenceUpdateBulk(XmlRpcRequest req, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)req.Params[0]; - - List friendsNotHere = new List(); - - // this is called with the expectation that all the friends in the request are on this region-server. - // But as some time passed since we checked (on the other region-server, via the MessagingServer), - // some of the friends might have teleported away. - // Actually, even now, between this line and the sending below, some people could TP away. So, - // we'll have to lock the m_rootAgents list for the duration to prevent/delay that. - lock (m_rootAgents) - { - List friendsHere = new List(); - - try - { - UUID agentID = new UUID((string)requestData["agentID"]); - bool agentOnline = (bool)requestData["agentOnline"]; - int count = (int)requestData["friendCount"]; - for (int i = 0; i < count; ++i) - { - UUID uuid; - if (UUID.TryParse((string)requestData["friendID_" + i], out uuid)) - { - if (m_rootAgents.ContainsKey(uuid)) friendsHere.Add(GetRootPresenceFromAgentID(uuid)); - else friendsNotHere.Add(uuid); - } - } - - // now send, as long as they are still here... - UUID[] agentUUID = new UUID[] { agentID }; - if (agentOnline) - { - foreach (ScenePresence agent in friendsHere) - { - agent.ControllingClient.SendAgentOnline(agentUUID); - } - } - else - { - foreach (ScenePresence agent in friendsHere) - { - agent.ControllingClient.SendAgentOffline(agentUUID); - } - } - } - catch(Exception e) - { - m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e); - } - } - - // no need to lock anymore; if TPs happen now, worst case is that we have an additional agent in this region, - // which should be caught on the next iteration... - Hashtable result = new Hashtable(); - int idx = 0; - foreach (UUID uuid in friendsNotHere) - { - result["friendID_" + idx++] = uuid.ToString(); - } - result["friendCount"] = idx; - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - - return response; - } - - public XmlRpcResponse processTerminateFriend(XmlRpcRequest req, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)req.Params[0]; - - bool success = false; - - UUID agentID; - UUID friendID; - if (requestData.ContainsKey("agentID") && UUID.TryParse((string)requestData["agentID"], out agentID) && - requestData.ContainsKey("friendID") && UUID.TryParse((string)requestData["friendID"], out friendID)) - { - // try to find it and if it is there, prevent it to vanish before we sent the message - lock (m_rootAgents) - { - if (m_rootAgents.ContainsKey(agentID)) - { - m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", friendID, agentID); - GetRootPresenceFromAgentID(agentID).ControllingClient.SendTerminateFriend(friendID); - success = true; - } - } - } - - // return whether we were successful - Hashtable result = new Hashtable(); - result["success"] = success; - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - return response; - } - - #endregion - - #region Scene events - - private void OnNewClient(IClientAPI client) - { - // All friends establishment protocol goes over instant message - // There's no way to send a message from the sim - // to a user to 'add a friend' without causing dialog box spam - - // Subscribe to instant messages - client.OnInstantMessage += OnInstantMessage; - - // Friend list management - client.OnApproveFriendRequest += OnApproveFriendRequest; - client.OnDenyFriendRequest += OnDenyFriendRequest; - client.OnTerminateFriendship += OnTerminateFriendship; - - // ... calling card handling... - client.OnOfferCallingCard += OnOfferCallingCard; - client.OnAcceptCallingCard += OnAcceptCallingCard; - client.OnDeclineCallingCard += OnDeclineCallingCard; - - // we need this one exactly once per agent session (see comments in the handler below) - client.OnEconomyDataRequest += OnEconomyDataRequest; - - // if it leaves, we want to know, too - client.OnLogout += OnLogout; - client.OnGrantUserRights += GrantUserFriendRights; - - } - - private void ClientClosed(UUID AgentId, Scene scene) - { - // agent's client was closed. As we handle logout in OnLogout, this here has only to handle - // TPing away (root agent is closed) or TPing/crossing in a region far enough away (client - // agent is closed). - // NOTE: In general, this doesn't mean that the agent logged out, just that it isn't around - // in one of the regions here anymore. - lock (m_rootAgents) - { - if (m_rootAgents.ContainsKey(AgentId)) - { - m_rootAgents.Remove(AgentId); - } - } - } - - private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) - { - lock (m_rootAgents) - { - m_rootAgents[avatar.UUID] = avatar.RegionHandle; - // Claim User! my user! Mine mine mine! - } - } - - private void MakeChildAgent(ScenePresence avatar) - { - lock (m_rootAgents) - { - if (m_rootAgents.ContainsKey(avatar.UUID)) - { - // only delete if the region matches. As this is a shared module, the avatar could be - // root agent in another region on this server. - if (m_rootAgents[avatar.UUID] == avatar.RegionHandle) - { - m_rootAgents.Remove(avatar.UUID); -// m_log.Debug("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); - } - } - } - } - #endregion - - private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) - { - ScenePresence returnAgent = null; - lock (m_scenes) - { - ScenePresence queryagent = null; - foreach (Scene scene in m_scenes.Values) - { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) - { - if (!queryagent.IsChildAgent) - { - returnAgent = queryagent; - break; - } - } - } - } - return returnAgent; - } - - private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) - { - ScenePresence returnAgent = null; - lock (m_scenes) - { - ScenePresence queryagent = null; - foreach (Scene scene in m_scenes.Values) - { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) - { - returnAgent = queryagent; - break; - } - } - } - return returnAgent; - } - - public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) - { - CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId); - - if (userInfo != null) - { - GridInstantMessage msg = new GridInstantMessage( - toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId, - (byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero); - - FriendshipOffered(msg); - } - else - { - m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId); - } - } - - #region FriendRequestHandling - - private void OnInstantMessage(IClientAPI client, GridInstantMessage im) - { - // Friend Requests go by Instant Message.. using the dialog param - // https://wiki.secondlife.com/wiki/ImprovedInstantMessage - - if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38 - { - // fromAgentName is the *destination* name (the friend we offer friendship to) - ScenePresence initiator = GetAnyPresenceFromAgentID(new UUID(im.fromAgentID)); - im.fromAgentName = initiator != null ? initiator.Name : "(hippo)"; - - FriendshipOffered(im); - } - else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 - { - FriendshipAccepted(client, im); - } - else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40 - { - FriendshipDeclined(client, im); - } - } - - /// - /// Invoked when a user offers a friendship. - /// - /// - /// - /// - private void FriendshipOffered(GridInstantMessage im) - { - // this is triggered by the initiating agent: - // A local agent offers friendship to some possibly remote friend. - // A IM is triggered, processed here and sent to the friend (possibly in a remote region). - - m_log.DebugFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}", - im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline); - - // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text. - // For interoperability, we have to clear that - if (Util.isUUID(im.message)) im.message = ""; - - // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless. - // we have to look up the agent name on friendship-approval, though. - im.imSessionID = im.fromAgentID; - - if (m_TransferModule != null) - { - // Send it to whoever is the destination. - // If new friend is local, it will send an IM to the viewer. - // If new friend is remote, it will cause a OnGridInstantMessage on the remote server - m_TransferModule.SendInstantMessage( - im, - delegate(bool success) - { - m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - } - - /// - /// Invoked when a user accepts a friendship offer. - /// - /// - /// - private void FriendshipAccepted(IClientAPI client, GridInstantMessage im) - { - m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", - client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); - } - - /// - /// Invoked when a user declines a friendship offer. - /// - /// May not currently be used - see OnDenyFriendRequest() instead - /// - /// - private void FriendshipDeclined(IClientAPI client, GridInstantMessage im) - { - UUID fromAgentID = new UUID(im.fromAgentID); - UUID toAgentID = new UUID(im.toAgentID); - - // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator - // toAgentID is initiator, fromAgentID declined friendship - m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})", - client != null ? client.AgentId.ToString() : "", - fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); - - // Send the decline to whoever is the destination. - GridInstantMessage msg - = new GridInstantMessage( - client.Scene, fromAgentID, client.Name, toAgentID, - im.dialog, im.message, im.offline != 0, im.Position); - - // If new friend is local, it will send an IM to the viewer. - // If new friend is remote, it will cause a OnGridInstantMessage on the remote server - m_TransferModule.SendInstantMessage(msg, - delegate(bool success) { - m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - - private void OnGridInstantMessage(GridInstantMessage msg) - { - // This event won't be raised unless we have that agent, - // so we can depend on the above not trying to send - // via grid again - //m_log.DebugFormat("[FRIEND]: Got GridIM from {0}, to {1}, imSession {2}, message {3}, dialog {4}", - // msg.fromAgentID, msg.toAgentID, msg.imSessionID, msg.message, msg.dialog); - - if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered || - msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted || - msg.dialog == (byte)InstantMessageDialog.FriendshipDeclined) - { - // this should succeed as we *know* the root agent is here. - m_TransferModule.SendInstantMessage(msg, - delegate(bool success) { - //m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - - if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted) - { - // for accept friendship, we have to do a bit more - ApproveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName); - } - } - - private void ApproveFriendship(UUID fromAgentID, UUID toAgentID, string fromName) - { - m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}", - fromAgentID, fromName, toAgentID); - - // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now. - lock (m_friendLists) - { - m_friendLists.Invalidate(fromAgentID.ToString()); - m_friendLists.Invalidate(toAgentID.ToString()); - } - - // now send presence update and add a calling card for the new friend - - ScenePresence initiator = GetAnyPresenceFromAgentID(toAgentID); - if (initiator == null) - { - // quite wrong. Shouldn't happen. - m_log.WarnFormat("[FRIEND]: Coudn't find initiator of friend request {0}", toAgentID); - return; - } - - m_log.DebugFormat("[FRIEND]: Tell {0} that {1} is online", - initiator.Name, fromName); - // tell initiator that friend is online - initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID }); - - // find the folder for the friend... - //InventoryFolderImpl folder = - // initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard); - IInventoryService invService = initiator.Scene.InventoryService; - InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard); - if (folder != null) - { - // ... and add the calling card - CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); - } } - private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) + public void AddRegion(Scene scene) { - m_log.DebugFormat("[FRIEND]: Got approve friendship from {0} {1}, agentID {2}, tid {3}", - client.Name, client.AgentId, agentID, friendID); - - // store the new friend persistently for both avatars - m_initialScene.StoreAddFriendship(friendID, agentID, (uint) FriendRights.CanSeeOnline); - - // The cache entries aren't valid anymore either, as we just added a friend to both sides. - lock (m_friendLists) - { - m_friendLists.Invalidate(agentID.ToString()); - m_friendLists.Invalidate(friendID.ToString()); - } - - // if it's a local friend, we don't have to do the lookup - ScenePresence friendPresence = GetAnyPresenceFromAgentID(friendID); - - if (friendPresence != null) - { - m_log.Debug("[FRIEND]: Local agent detected."); - - // create calling card - CreateCallingCard(client, friendID, callingCardFolders[0], friendPresence.Name); - - // local message means OnGridInstantMessage won't be triggered, so do the work here. - friendPresence.ControllingClient.SendInstantMessage( - new GridInstantMessage(client.Scene, agentID, - client.Name, friendID, - (byte)InstantMessageDialog.FriendshipAccepted, - agentID.ToString(), false, Vector3.Zero)); - ApproveFriendship(agentID, friendID, client.Name); - } - else - { - m_log.Debug("[FRIEND]: Remote agent detected."); - - // fetch the friend's name for the calling card. - CachedUserInfo info = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(friendID); - - // create calling card - CreateCallingCard(client, friendID, callingCardFolders[0], - info.UserProfile.FirstName + " " + info.UserProfile.SurName); - - // Compose (remote) response to friend. - GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, - (byte)InstantMessageDialog.FriendshipAccepted, - agentID.ToString(), false, Vector3.Zero); - if (m_TransferModule != null) - { - m_TransferModule.SendInstantMessage(msg, - delegate(bool success) { - m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - } - - // tell client that new friend is online - client.SendAgentOnline(new UUID[] { friendID }); } - private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) + public void RegionLoaded(Scene scene) { - m_log.DebugFormat("[FRIEND]: Got deny friendship from {0} {1}, agentID {2}, tid {3}", - client.Name, client.AgentId, agentID, friendID); - - // Compose response to other agent. - GridInstantMessage msg = new GridInstantMessage(client.Scene, agentID, client.Name, friendID, - (byte)InstantMessageDialog.FriendshipDeclined, - agentID.ToString(), false, Vector3.Zero); - // send decline to initiator - if (m_TransferModule != null) - { - m_TransferModule.SendInstantMessage(msg, - delegate(bool success) { - m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } } - private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) + public void RemoveRegion(Scene scene) { - // client.AgentId == agentID! - - // this removes the friends from the stored friendlists. After the next login, they will be gone... - m_initialScene.StoreRemoveFriendship(agentID, exfriendID); - - // ... now tell the two involved clients that they aren't friends anymore. - - // I don't know why we have to tell , as this was caused by her, but that's how it works in SL... - client.SendTerminateFriend(exfriendID); - - // now send the friend, if online - ScenePresence presence = GetAnyPresenceFromAgentID(exfriendID); - if (presence != null) - { - m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", agentID, exfriendID); - presence.ControllingClient.SendTerminateFriend(agentID); - } - else - { - // retry 3 times, in case the agent TPed from the last known region... - for (int retry = 0; retry < 3; ++retry) - { - // wasn't sent, so ex-friend wasn't around on this region-server. Fetch info and try to send - UserAgentData data = m_initialScene.CommsManager.UserService.GetAgentByUUID(exfriendID); - - if (null == data) - break; - - if (!data.AgentOnline) - { - m_log.DebugFormat("[FRIEND]: {0} is offline, so not sending TerminateFriend", exfriendID); - break; // if ex-friend isn't online, we don't need to send - } - - m_log.DebugFormat("[FRIEND]: Sending remote terminate friend {0} to agent {1}@{2}", - agentID, exfriendID, data.Handle); - - // try to send to foreign region, retry if it fails (friend TPed away, for example) - if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; - } - } - - // clean up cache: FriendList is wrong now... - lock (m_friendLists) - { - m_friendLists.Invalidate(agentID.ToString()); - m_friendLists.Invalidate(exfriendID.ToString()); - } } - #endregion - - #region CallingCards - - private void OnOfferCallingCard(IClientAPI client, UUID destID, UUID transactionID) - { - m_log.DebugFormat("[CALLING CARD]: got offer from {0} for {1}, transaction {2}", - client.AgentId, destID, transactionID); - // This might be slightly wrong. On a multi-region server, we might get the child-agent instead of the root-agent - // (or the root instead of the child) - ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); - if (destAgent == null) - { - client.SendAlertMessage("The person you have offered a card to can't be found anymore."); - return; - } - - lock (m_pendingCallingcardRequests) - { - m_pendingCallingcardRequests[transactionID] = client.AgentId; - } - // inform the destination agent about the offer - destAgent.ControllingClient.SendOfferCallingCard(client.AgentId, transactionID); - } - - private void CreateCallingCard(IClientAPI client, UUID creator, UUID folder, string name) - { - InventoryItemBase item = new InventoryItemBase(); - item.AssetID = UUID.Zero; - item.AssetType = (int)AssetType.CallingCard; - item.BasePermissions = (uint)PermissionMask.Copy; - item.CreationDate = Util.UnixTimeSinceEpoch(); - item.CreatorId = creator.ToString(); - item.CurrentPermissions = item.BasePermissions; - item.Description = ""; - item.EveryOnePermissions = (uint)PermissionMask.None; - item.Flags = 0; - item.Folder = folder; - item.GroupID = UUID.Zero; - item.GroupOwned = false; - item.ID = UUID.Random(); - item.InvType = (int)InventoryType.CallingCard; - item.Name = name; - item.NextPermissions = item.EveryOnePermissions; - item.Owner = client.AgentId; - item.SalePrice = 10; - item.SaleType = (byte)SaleType.Not; - ((Scene)client.Scene).AddInventoryItem(client, item); - } - - private void OnAcceptCallingCard(IClientAPI client, UUID transactionID, UUID folderID) - { - m_log.DebugFormat("[CALLING CARD]: User {0} ({1} {2}) accepted tid {3}, folder {4}", - client.AgentId, - client.FirstName, client.LastName, - transactionID, folderID); - UUID destID; - lock (m_pendingCallingcardRequests) - { - if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) - { - m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", - client.Name); - return; - } - // else found pending calling card request with that transaction. - m_pendingCallingcardRequests.Remove(transactionID); - } - - - ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); - // inform sender of the card that destination declined the offer - if (destAgent != null) destAgent.ControllingClient.SendAcceptCallingCard(transactionID); - - // put a calling card into the inventory of receiver - CreateCallingCard(client, destID, folderID, destAgent.Name); - } - - private void OnDeclineCallingCard(IClientAPI client, UUID transactionID) + public void Close() { - m_log.DebugFormat("[CALLING CARD]: User {0} (ID:{1}) declined card, tid {2}", - client.Name, client.AgentId, transactionID); - UUID destID; - lock (m_pendingCallingcardRequests) - { - if (!m_pendingCallingcardRequests.TryGetValue(transactionID, out destID)) - { - m_log.WarnFormat("[CALLING CARD]: Got a AcceptCallingCard from {0} without an offer before.", - client.Name); - return; - } - // else found pending calling card request with that transaction. - m_pendingCallingcardRequests.Remove(transactionID); - } - - ScenePresence destAgent = GetAnyPresenceFromAgentID(destID); - // inform sender of the card that destination declined the offer - if (destAgent != null) destAgent.ControllingClient.SendDeclineCallingCard(transactionID); } - /// - /// Send presence information about a client to other clients in both this region and others. - /// - /// - /// - /// - private void SendPresenceState(IClientAPI client, List friendList, bool iAmOnline) + public string Name { - //m_log.DebugFormat("[FRIEND]: {0} logged {1}; sending presence updates", client.Name, iAmOnline ? "in" : "out"); - - if (friendList == null || friendList.Count == 0) - { - //m_log.DebugFormat("[FRIEND]: {0} doesn't have friends.", client.Name); - return; // nothing we can do if she doesn't have friends... - } - - // collect sets of friendIDs; to send to (online and offline), and to receive from - // TODO: If we ever switch to .NET >= 3, replace those Lists with HashSets. - // I can't believe that we have Dictionaries, but no Sets, considering Java introduced them years ago... - List friendIDsToSendTo = new List(); - List candidateFriendIDsToReceive = new List(); - - foreach (FriendListItem item in friendList) - { - if (((item.FriendListOwnerPerms | item.FriendPerms) & (uint)FriendRights.CanSeeOnline) != 0) - { - // friend is allowed to see my presence => add - if ((item.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0) - friendIDsToSendTo.Add(item.Friend); - - if ((item.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) - candidateFriendIDsToReceive.Add(item.Friend); - } - } - - // we now have a list of "interesting" friends (which we have to find out on-/offline state for), - // friends we want to send our online state to (if *they* are online, too), and - // friends we want to receive online state for (currently unknown whether online or not) - - // as this processing might take some time and friends might TP away, we try up to three times to - // reach them. Most of the time, we *will* reach them, and this loop won't loop - int retry = 0; - do - { - // build a list of friends to look up region-information and on-/offline-state for - List friendIDsToLookup = new List(friendIDsToSendTo); - foreach (UUID uuid in candidateFriendIDsToReceive) - { - if (!friendIDsToLookup.Contains(uuid)) friendIDsToLookup.Add(uuid); - } - - m_log.DebugFormat( - "[FRIEND]: {0} to lookup, {1} to send to, {2} candidates to receive from for agent {3}", - friendIDsToLookup.Count, friendIDsToSendTo.Count, candidateFriendIDsToReceive.Count, client.Name); - - // we have to fetch FriendRegionInfos, as the (cached) FriendListItems don't - // necessarily contain the correct online state... - Dictionary friendRegions = m_initialScene.GetFriendRegionInfos(friendIDsToLookup); - m_log.DebugFormat( - "[FRIEND]: Found {0} regionInfos for {1} friends of {2}", - friendRegions.Count, friendIDsToLookup.Count, client.Name); - - // argument for SendAgentOn/Offline; we shouldn't generate that repeatedly within loops. - UUID[] agentArr = new UUID[] { client.AgentId }; - - // first, send to friend presence state to me, if I'm online... - if (iAmOnline) - { - List friendIDsToReceive = new List(); - - for (int i = candidateFriendIDsToReceive.Count - 1; i >= 0; --i) - { - UUID uuid = candidateFriendIDsToReceive[i]; - FriendRegionInfo info; - if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) - { - friendIDsToReceive.Add(uuid); - } - } - - m_log.DebugFormat( - "[FRIEND]: Sending {0} online friends to {1}", friendIDsToReceive.Count, client.Name); - - if (friendIDsToReceive.Count > 0) - client.SendAgentOnline(friendIDsToReceive.ToArray()); - - // clear them for a possible second iteration; we don't have to repeat this - candidateFriendIDsToReceive.Clear(); - } - - // now, send my presence state to my friends - for (int i = friendIDsToSendTo.Count - 1; i >= 0; --i) - { - UUID uuid = friendIDsToSendTo[i]; - FriendRegionInfo info; - if (friendRegions.TryGetValue(uuid, out info) && info != null && info.isOnline) - { - // any client is good enough, root or child... - ScenePresence agent = GetAnyPresenceFromAgentID(uuid); - if (agent != null) - { - //m_log.DebugFormat("[FRIEND]: Found local agent {0}", agent.Name); - - // friend is online and on this server... - if (iAmOnline) agent.ControllingClient.SendAgentOnline(agentArr); - else agent.ControllingClient.SendAgentOffline(agentArr); - - // done, remove it - friendIDsToSendTo.RemoveAt(i); - } - } - else - { - //m_log.DebugFormat("[FRIEND]: Friend {0} ({1}) is offline; not sending.", uuid, i); - - // friend is offline => no need to try sending - friendIDsToSendTo.RemoveAt(i); - } - } - - m_log.DebugFormat("[FRIEND]: Have {0} friends to contact via inter-region comms.", friendIDsToSendTo.Count); - - // we now have all the friends left that are online (we think), but not on this region-server - if (friendIDsToSendTo.Count > 0) - { - // sort them into regions - Dictionary> friendsInRegion = new Dictionary>(); - foreach (UUID uuid in friendIDsToSendTo) - { - ulong handle = friendRegions[uuid].regionHandle; // this can't fail as we filtered above already - List friends; - if (!friendsInRegion.TryGetValue(handle, out friends)) - { - friends = new List(); - friendsInRegion[handle] = friends; - } - friends.Add(uuid); - } - m_log.DebugFormat("[FRIEND]: Found {0} regions to send to.", friendRegions.Count); - - // clear uuids list and collect missed friends in it for the next retry - friendIDsToSendTo.Clear(); - - // send bulk updates to the region - foreach (KeyValuePair> pair in friendsInRegion) - { - //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line", - // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off"); - - friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); - } - } - // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them. - // In most cases, it will be empty, and it won't loop here. But sometimes, we have to work harder and try again... - } - while (++retry < 3 && friendIDsToSendTo.Count > 0); + get { return "FriendsModule"; } } - private void OnEconomyDataRequest(UUID agentID) + public Type ReplaceableInterface { - // KLUDGE: This is the only way I found to get a message (only) after login was completed and the - // client is connected enough to receive UDP packets). - // This packet seems to be sent only once, just after connection was established to the first - // region after login. - // We use it here to trigger a presence update; the old update-on-login was never be heard by - // the freshly logged in viewer, as it wasn't connected to the region at that time. - // TODO: Feel free to replace this by a better solution if you find one. - - // get the agent. This should work every time, as we just got a packet from it - //ScenePresence agent = GetRootPresenceFromAgentID(agentID); - // KLUDGE 2: As this is sent quite early, the avatar isn't here as root agent yet. So, we have to cheat a bit - ScenePresence agent = GetAnyPresenceFromAgentID(agentID); - - // just to be paranoid... - if (agent == null) - { - m_log.ErrorFormat("[FRIEND]: Got a packet from agent {0} who can't be found anymore!?", agentID); - return; - } - - List fl; - lock (m_friendLists) - { - fl = (List)m_friendLists.Get(agent.ControllingClient.AgentId.ToString(), - m_initialScene.GetFriendList); - } - - // tell everyone that we are online - SendPresenceState(agent.ControllingClient, fl, true); + get { return null; } } - private void OnLogout(IClientAPI remoteClient) + public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, + string offerMessage) { - List fl; - lock (m_friendLists) - { - fl = (List)m_friendLists.Get(remoteClient.AgentId.ToString(), - m_initialScene.GetFriendList); - } - - // tell everyone that we are offline - SendPresenceState(remoteClient, fl, false); - } - private void GrantUserFriendRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) - { - ((Scene)remoteClient.Scene).CommsManager.UpdateUserFriendPerms(requester, target, (uint)rights); } public List GetUserFriends(UUID agentID) { - List fl; - lock (m_friendLists) - { - fl = (List)m_friendLists.Get(agentID.ToString(), - m_initialScene.GetFriendList); - } - - return fl; + return null; } } - #endregion } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 9a68749..ab141eb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs @@ -24,6 +24,7 @@ * (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 log4net; @@ -36,9 +37,10 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { - public class InstantMessageModule : IRegionModule + public class InstantMessageModule : ISharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); /// /// Is this module enabled? @@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private IMessageTransferModule m_TransferModule = null; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { if (config.Configs["Messaging"] != null) { @@ -62,6 +64,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } m_enabled = true; + } + + public void AddRegion(Scene scene) + { + if (!m_enabled) + return; lock (m_scenes) { @@ -74,6 +82,39 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } } + public void RegionLoaded(Scene scene) + { + if (!m_enabled) + return; + + if (m_TransferModule == null) + { + m_TransferModule = + scene.RequestModuleInterface(); + + if (m_TransferModule == null) + { + m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!"); + scene.EventManager.OnClientConnect -= OnClientConnect; + scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; + + m_scenes.Clear(); + m_enabled = false; + } + } + } + + public void RemoveRegion(Scene scene) + { + if (!m_enabled) + return; + + lock (m_scenes) + { + m_scenes.Remove(scene); + } + } + void OnClientConnect(IClientCore client) { IClientIM clientIM; @@ -85,15 +126,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage public void PostInitialise() { - if (!m_enabled) - return; - - m_TransferModule = - m_scenes[0].RequestModuleInterface(); - - if (m_TransferModule == null) - m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ - "IM will not work!"); } public void Close() @@ -105,9 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage get { return "InstantMessageModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } #endregion diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index e5159b3..b5019f1 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -40,18 +40,17 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { - public class MessageTransferModule : IRegionModule, IMessageTransferModule + public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - // private bool m_Enabled = false; - protected bool m_Gridmode = false; + private bool m_Enabled = false; protected List m_Scenes = new List(); protected Dictionary m_UserRegionMap = new Dictionary(); public event UndeliveredMessage OnUndeliveredMessage; - public virtual void Initialise(Scene scene, IConfigSource config) + public virtual void Initialise(IConfigSource config) { IConfig cnf = config.Configs["Messaging"]; if (cnf != null && cnf.GetString( @@ -62,20 +61,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return; } - cnf = config.Configs["Startup"]; - if (cnf != null) - m_Gridmode = cnf.GetBoolean("gridmode", false); + MainServer.Instance.AddXmlRPCHandler( + "grid_instant_message", processXMLRPCGridInstantMessage); - // m_Enabled = true; + m_Enabled = true; + } + + public virtual void AddRegion(Scene scene) + { + if (!m_Enabled) + return; lock (m_Scenes) { - if (m_Scenes.Count == 0) - { - MainServer.Instance.AddXmlRPCHandler( - "grid_instant_message", processXMLRPCGridInstantMessage); - } - m_log.Debug("[MESSAGE TRANSFER]: Message transfer module active"); scene.RegisterModuleInterface(this); m_Scenes.Add(scene); @@ -86,6 +84,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { } + public virtual void RegionLoaded(Scene scene) + { + } + + public virtual void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + lock(m_Scenes) + { + m_Scenes.Remove(scene); + } + } + public virtual void Close() { } @@ -95,9 +108,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage get { return "MessageTransferModule"; } } - public virtual bool IsSharedModule + public virtual Type ReplaceableInterface { - get { return true; } + get { return null; } } public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) @@ -148,15 +161,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } } - if (m_Gridmode) - { - //m_log.DebugFormat("[INSTANT MESSAGE]: Delivering via grid"); - // Still here, try send via Grid - SendGridInstantMessageViaXMLRPC(im, result); - return; - } - - HandleUndeliveredMessage(im, result); + SendGridInstantMessageViaXMLRPC(im, result); return; } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 2d4a635..1ff5865 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs @@ -39,7 +39,7 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.MuteList { - public class MuteListModule : IRegionModule + public class MuteListModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -47,11 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList private List m_SceneList = new List(); private string m_RestURL = String.Empty; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - if (!enabled) - return; - IConfig cnf = config.Configs["Messaging"]; if (cnf == null) { @@ -59,39 +56,53 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList return; } - if (cnf != null && cnf.GetString( - "MuteListModule", "None") != + if (cnf != null && cnf.GetString("MuteListModule", "None") != "MuteListModule") { enabled = false; return; } + m_RestURL = cnf.GetString("MuteListURL", ""); + if (m_RestURL == "") + { + m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); + enabled = false; + return; + } + } + + public void AddRegion(Scene scene) + { + if (!enabled) + return; + lock (m_SceneList) { - if (m_SceneList.Count == 0) - { - m_RestURL = cnf.GetString("MuteListURL", ""); - if (m_RestURL == "") - { - m_log.Error("[MUTE LIST] Module was enabled, but no URL is given, disabling"); - enabled = false; - return; - } - } - if (!m_SceneList.Contains(scene)) - m_SceneList.Add(scene); + m_SceneList.Add(scene); scene.EventManager.OnNewClient += OnNewClient; } } - public void PostInitialise() + public void RegionLoaded(Scene scene) + { + } + + public void RemoveRegion(Scene scene) { if (!enabled) return; - if (m_SceneList.Count == 0) + lock (m_SceneList) + { + m_SceneList.Remove(scene); + } + } + + public void PostInitialise() + { + if (!enabled) return; m_log.Debug("[MUTE LIST] Mute list enabled"); @@ -102,26 +113,15 @@ namespace OpenSim.Region.CoreModules.Avatar.MuteList get { return "MuteListModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } public void Close() { } -// private IClientAPI FindClient(UUID agentID) -// { -// foreach (Scene s in m_SceneList) -// { -// ScenePresence presence = s.GetScenePresence(agentID); -// if (presence != null && !presence.IsChildAgent) -// return presence.ControllingClient; -// } -// return null; -// } - private void OnNewClient(IClientAPI client) { client.OnMuteListRequest += OnMuteListRequest; diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 1614b70..a835c52 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs @@ -40,78 +40,88 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { - public class OfflineMessageModule : IRegionModule + public class OfflineMessageModule : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool enabled = true; private List m_SceneList = new List(); private string m_RestURL = String.Empty; + IMessageTransferModule m_TransferModule = null; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - if (!enabled) - return; - IConfig cnf = config.Configs["Messaging"]; if (cnf == null) { enabled = false; return; } - if (cnf != null && cnf.GetString( - "OfflineMessageModule", "None") != + if (cnf != null && cnf.GetString("OfflineMessageModule", "None") != "OfflineMessageModule") { enabled = false; return; } + m_RestURL = cnf.GetString("OfflineMessageURL", ""); + if (m_RestURL == "") + { + m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); + enabled = false; + return; + } + } + + public void AddRegion(Scene scene) + { + if (!enabled) + return; + lock (m_SceneList) { - if (m_SceneList.Count == 0) - { - m_RestURL = cnf.GetString("OfflineMessageURL", ""); - if (m_RestURL == "") - { - m_log.Error("[OFFLINE MESSAGING] Module was enabled, but no URL is given, disabling"); - enabled = false; - return; - } - } - if (!m_SceneList.Contains(scene)) - m_SceneList.Add(scene); + m_SceneList.Add(scene); scene.EventManager.OnNewClient += OnNewClient; } } - public void PostInitialise() + public void RegionLoaded(Scene scene) { if (!enabled) return; - if (m_SceneList.Count == 0) - return; - - IMessageTransferModule trans = m_SceneList[0].RequestModuleInterface(); - if (trans == null) + if (m_TransferModule == null) { - enabled = false; - - lock (m_SceneList) + m_TransferModule = scene.RequestModuleInterface(); + if (m_TransferModule == null) { - foreach (Scene s in m_SceneList) - s.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnNewClient -= OnNewClient; + enabled = false; m_SceneList.Clear(); + + m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); } + m_TransferModule.OnUndeliveredMessage += UndeliveredMessage; + } + } - m_log.Error("[OFFLINE MESSAGING] No message transfer module is enabled. Diabling offline messages"); + public void RemoveRegion(Scene scene) + { + if (!enabled) return; + + lock (m_SceneList) + { + m_SceneList.Remove(scene); } + } - trans.OnUndeliveredMessage += UndeliveredMessage; + public void PostInitialise() + { + if (!enabled) + return; m_log.Debug("[OFFLINE MESSAGING] Offline messages enabled"); } @@ -121,9 +131,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage get { return "OfflineMessageModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } public void Close() diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index f5ab454..267a90a 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -24,6 +24,7 @@ * (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; using System.Collections.Generic; using System.Net; @@ -39,404 +40,54 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { - public class PresenceModule : IRegionModule, IPresenceModule + public class PresenceModule : ISharedRegionModule, IPresenceModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled = false; - private bool m_Gridmode = false; - - // some default scene for doing things that aren't connected to a specific scene. Avoids locking. - private Scene m_initialScene; - - private List m_Scenes = new List(); - - // we currently are only interested in root-agents. If the root isn't here, we don't know the region the - // user is in, so we have to ask the messaging server anyway. - private Dictionary m_RootAgents = - new Dictionary(); + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); public event PresenceChange OnPresenceChange; public event BulkPresenceData OnBulkPresenceData; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - lock (m_Scenes) - { - // This is a shared module; Initialise will be called for every region on this server. - // Only check config once for the first region. - if (m_Scenes.Count == 0) - { - IConfig cnf = config.Configs["Messaging"]; - if (cnf != null && cnf.GetString( - "PresenceModule", "PresenceModule") != - "PresenceModule") - return; - - cnf = config.Configs["Startup"]; - if (cnf != null) - m_Gridmode = cnf.GetBoolean("gridmode", false); - - m_Enabled = true; - - m_initialScene = scene; - } - - if (m_Gridmode) - NotifyMessageServerOfStartup(scene); - - m_Scenes.Add(scene); - } - - scene.RegisterModuleInterface(this); - - scene.EventManager.OnNewClient += OnNewClient; - scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; - scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; } - public void PostInitialise() + public void AddRegion(Scene scene) { } - public void Close() + public void RegionLoaded(Scene scene) { - if (!m_Gridmode || !m_Enabled) - return; - - if (OnPresenceChange != null) - { - lock (m_RootAgents) - { - // on shutdown, users are kicked, too - foreach (KeyValuePair pair in m_RootAgents) - { - OnPresenceChange(new PresenceInfo(pair.Key, UUID.Zero)); - } - } - } - - lock (m_Scenes) - { - foreach (Scene scene in m_Scenes) - NotifyMessageServerOfShutdown(scene); - } } - public string Name + public void RemoveRegion(Scene scene) { - get { return "PresenceModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - public void RequestBulkPresenceData(UUID[] users) - { - if (OnBulkPresenceData != null) - { - PresenceInfo[] result = new PresenceInfo[users.Length]; - if (m_Gridmode) - { - // first check the local information - List uuids = new List(); // the uuids to check remotely - List indices = new List(); // just for performance. - lock (m_RootAgents) - { - for (int i = 0; i < uuids.Count; ++i) - { - Scene scene; - if (m_RootAgents.TryGetValue(users[i], out scene)) - { - result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); - } - else - { - uuids.Add(users[i]); - indices.Add(i); - } - } - } - - // now we have filtered out all the local root agents. The rest we have to request info about - Dictionary infos = m_initialScene.GetFriendRegionInfos(uuids); - for (int i = 0; i < uuids.Count; ++i) - { - FriendRegionInfo info; - if (infos.TryGetValue(uuids[i], out info) && info.isOnline) - { - UUID regionID = info.regionID; - if (regionID == UUID.Zero) - { - // TODO this is the old messaging-server protocol; only the regionHandle is available. - // Fetch region-info to get the id - uint x = 0, y = 0; - Utils.LongToUInts(info.regionHandle, out x, out y); - GridRegion regionInfo = m_initialScene.GridService.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, - (int)x, (int)y); - regionID = regionInfo.RegionID; - } - result[indices[i]] = new PresenceInfo(uuids[i], regionID); - } - else result[indices[i]] = new PresenceInfo(uuids[i], UUID.Zero); - } - } - else - { - // in standalone mode, we have all the info locally available. - lock (m_RootAgents) - { - for (int i = 0; i < users.Length; ++i) - { - Scene scene; - if (m_RootAgents.TryGetValue(users[i], out scene)) - { - result[i] = new PresenceInfo(users[i], scene.RegionInfo.RegionID); - } - else - { - result[i] = new PresenceInfo(users[i], UUID.Zero); - } - } - } - } - - // tell everyone - OnBulkPresenceData(result); - } - } - - // new client doesn't mean necessarily that user logged in, it just means it entered one of the - // the regions on this server - public void OnNewClient(IClientAPI client) - { - client.OnConnectionClosed += OnConnectionClosed; - client.OnLogout += OnLogout; - - // KLUDGE: See handler for details. - client.OnEconomyDataRequest += OnEconomyDataRequest; } - // connection closed just means *one* client connection has been closed. It doesn't mean that the - // user has logged off; it might have just TPed away. - public void OnConnectionClosed(IClientAPI client) - { - // TODO: Have to think what we have to do here... - // Should we just remove the root from the list (if scene matches)? - if (!(client.Scene is Scene)) - return; - Scene scene = (Scene)client.Scene; - - lock (m_RootAgents) - { - Scene rootScene; - if (!(m_RootAgents.TryGetValue(client.AgentId, out rootScene)) || scene != rootScene) - return; - - m_RootAgents.Remove(client.AgentId); - } - - // Should it have logged off, we'll do the logout part in OnLogout, even if no root is stored - // anymore. It logged off, after all... - } - - // Triggered when the user logs off. - public void OnLogout(IClientAPI client) - { - if (!(client.Scene is Scene)) - return; - Scene scene = (Scene)client.Scene; - - // On logout, we really remove the client from rootAgents, even if the scene doesn't match - lock (m_RootAgents) - { - if (m_RootAgents.ContainsKey(client.AgentId)) m_RootAgents.Remove(client.AgentId); - } - - // now inform the messaging server and anyone who is interested - NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); - if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(client.AgentId, UUID.Zero)); - } - - public void OnSetRootAgentScene(UUID agentID, Scene scene) - { - // OnSetRootAgentScene can be called from several threads at once (with different agentID). - // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without - // correct locking). - lock (m_RootAgents) - { - Scene rootScene; - if (m_RootAgents.TryGetValue(agentID, out rootScene) && scene == rootScene) - { - return; - } - m_RootAgents[agentID] = scene; - } - - // inform messaging server that agent changed the region - Util.FireAndForget( - delegate(object o) - { - NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); - } - ); - } - - private void OnEconomyDataRequest(UUID agentID) + public void PostInitialise() { - // KLUDGE: This is the only way I found to get a message (only) after login was completed and the - // client is connected enough to receive UDP packets. - // This packet seems to be sent only once, just after connection was established to the first - // region after login. - // We use it here to trigger a presence update; the old update-on-login was never be heard by - // the freshly logged in viewer, as it wasn't connected to the region at that time. - // TODO: Feel free to replace this by a better solution if you find one. - - // get the agent. This should work every time, as we just got a packet from it - ScenePresence agent = null; - lock (m_Scenes) - { - foreach (Scene scene in m_Scenes) - { - agent = scene.GetScenePresence(agentID); - if (agent != null) break; - } - } - - // just to be paranoid... - if (agent == null) - { - m_log.ErrorFormat("[PRESENCE]: Got a packet from agent {0} who can't be found anymore!?", agentID); - return; - } - - // we are a bit premature here, but the next packet will switch this child agent to root. - if (OnPresenceChange != null) OnPresenceChange(new PresenceInfo(agentID, agent.Scene.RegionInfo.RegionID)); } - public void OnMakeChildAgent(ScenePresence agent) + public void Close() { - // OnMakeChildAgent can be called from several threads at once (with different agent). - // Concurrent access to m_RootAgents is prone to failure on multi-core/-processor systems without - // correct locking). - lock (m_RootAgents) - { - Scene rootScene; - if (m_RootAgents.TryGetValue(agent.UUID, out rootScene) && agent.Scene == rootScene) - { - m_RootAgents.Remove(agent.UUID); - } - } - // don't notify the messaging-server; either this agent just had been downgraded and another one will be upgraded - // to root momentarily (which will notify the messaging-server), or possibly it will be closed in a moment, - // which will update the messaging-server, too. } - private void NotifyMessageServerOfStartup(Scene scene) + public string Name { - Hashtable xmlrpcdata = new Hashtable(); - xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(xmlrpcdata); - try - { - XmlRpcRequest UpRequest = new XmlRpcRequest("region_startup", SendParams); - XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); - - Hashtable responseData = (Hashtable)resp.Value; - if (responseData == null || (!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); - } - } - catch (WebException) - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); - } + get { return "PresenceModule"; } } - private void NotifyMessageServerOfShutdown(Scene scene) + public Type ReplaceableInterface { - if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) - return; - - Hashtable xmlrpcdata = new Hashtable(); - xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(xmlrpcdata); - try - { - XmlRpcRequest DownRequest = new XmlRpcRequest("region_shutdown", SendParams); - XmlRpcResponse resp = DownRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); - - Hashtable responseData = (Hashtable)resp.Value; - if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); - } - } - catch (WebException) - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of region shutdown for region {0}", scene.RegionInfo.RegionName); - } + get { return null; } } - private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) + public void RequestBulkPresenceData(UUID[] users) { - if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) - return; - - Hashtable xmlrpcdata = new Hashtable(); - xmlrpcdata["AgentID"] = agentID.ToString(); - xmlrpcdata["RegionUUID"] = region.ToString(); - xmlrpcdata["RegionHandle"] = regionHandle.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(xmlrpcdata); - try - { - XmlRpcRequest LocationRequest = new XmlRpcRequest("agent_location", SendParams); - XmlRpcResponse resp = LocationRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); - - Hashtable responseData = (Hashtable)resp.Value; - if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); - } - } - catch (WebException) - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent location for {0}", agentID.ToString()); - } } - private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) + public void OnNewClient(IClientAPI client) { - if (m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL == string.Empty) - return; - - Hashtable xmlrpcdata = new Hashtable(); - xmlrpcdata["AgentID"] = agentID.ToString(); - xmlrpcdata["RegionUUID"] = region.ToString(); - xmlrpcdata["RegionHandle"] = regionHandle.ToString(); - ArrayList SendParams = new ArrayList(); - SendParams.Add(xmlrpcdata); - try - { - XmlRpcRequest LeavingRequest = new XmlRpcRequest("agent_leaving", SendParams); - XmlRpcResponse resp = LeavingRequest.Send(m_Scenes[0].CommsManager.NetworkServersInfo.MessagingURL, 5000); - - Hashtable responseData = (Hashtable)resp.Value; - if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); - } - } - catch (WebException) - { - m_log.ErrorFormat("[PRESENCE]: Failed to notify message server of agent leaving for {0}", agentID.ToString()); - } } } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index d9a021f..55d4f14 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -39,7 +39,7 @@ using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer { - public class InventoryTransferModule : IInventoryTransferModule, IRegionModule + public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -50,10 +50,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer new Dictionary(); private IMessageTransferModule m_TransferModule = null; + private bool m_Enabled = true; #region IRegionModule Members - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { if (config.Configs["Messaging"] != null) { @@ -62,29 +63,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer if (config.Configs["Messaging"].GetString( "InventoryTransferModule", "InventoryTransferModule") != "InventoryTransferModule") + { + m_Enabled = false; return; + } } + } - if (!m_Scenelist.Contains(scene)) - { - m_Scenelist.Add(scene); + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; - scene.RegisterModuleInterface(this); + m_Scenelist.Add(scene); - scene.EventManager.OnNewClient += OnNewClient; - scene.EventManager.OnClientClosed += ClientLoggedOut; - scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; - } + scene.RegisterModuleInterface(this); + + scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnClientClosed += ClientLoggedOut; + scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; } - public void PostInitialise() + public void RegionLoaded(Scene scene) { - if (m_Scenelist.Count > 0) + if (m_TransferModule == null) { m_TransferModule = m_Scenelist[0].RequestModuleInterface(); if (m_TransferModule == null) + { m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only"); + m_Enabled = false; + + m_Scenelist.Clear(); + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnClientClosed -= ClientLoggedOut; + scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; + } } + + } + + public void RemoveRegion(Scene scene) + { + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnClientClosed -= ClientLoggedOut; + scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; + m_Scenelist.Remove(scene); + } + + public void PostInitialise() + { } public void Close() @@ -96,9 +124,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer get { return "InventoryModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } #endregion diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 261bd6c..d1d7df2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs @@ -37,34 +37,72 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.CoreModules.Avatar.Lure { - public class LureModule : IRegionModule + public class LureModule : ISharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); private readonly List m_scenes = new List(); private IMessageTransferModule m_TransferModule = null; + private bool m_Enabled = true; - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { if (config.Configs["Messaging"] != null) { if (config.Configs["Messaging"].GetString( "LureModule", "LureModule") != "LureModule") - return; + m_Enabled = false; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; lock (m_scenes) { - if (!m_scenes.Contains(scene)) + m_scenes.Add(scene); + scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnIncomingInstantMessage += + OnGridInstantMessage; + } + } + + public void RegionLoaded(Scene scene) + { + if (m_TransferModule == null) + { + m_TransferModule = + scene.RequestModuleInterface(); + + if (m_TransferModule == null) { - m_scenes.Add(scene); - scene.EventManager.OnNewClient += OnNewClient; - scene.EventManager.OnIncomingInstantMessage += + m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ + "lures will not work!"); + + m_Enabled = false; + m_scenes.Clear(); + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; } } + + } + + public void RemoveRegion(Scene scene) + { + lock (m_scenes) + { + m_scenes.Remove(scene); + scene.EventManager.OnNewClient -= OnNewClient; + scene.EventManager.OnIncomingInstantMessage -= + OnGridInstantMessage; + } } void OnNewClient(IClientAPI client) @@ -76,12 +114,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure public void PostInitialise() { - m_TransferModule = - m_scenes[0].RequestModuleInterface(); - - if (m_TransferModule == null) - m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+ - "lures will not work!"); } public void Close() @@ -93,9 +125,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure get { return "LureModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return true; } + get { return null; } } public void OnInstantMessage(IClientAPI client, GridInstantMessage im) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index beb2307..40a13f4 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -17,6 +17,14 @@ + + + + + + + + -- cgit v1.1 From 3a953dfc986c70287feb7e08b3ef7bbfc9e02f9e Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 01:56:30 +0000 Subject: This is somewhat major-like..... Change the intialization order of Application plugins so that MainServer.Instance gets assigned before RegionModulesController loads the new style shared modules. This is needed because otherwise no new style shared module could register a HTTP method.... if it breaks, you get to keep both pieces --- .../CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | 8 +++++--- .../Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index b5019f1..2d4b421 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -61,9 +61,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return; } - MainServer.Instance.AddXmlRPCHandler( - "grid_instant_message", processXMLRPCGridInstantMessage); - m_Enabled = true; } @@ -82,6 +79,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage public virtual void PostInitialise() { + if (!m_Enabled) + return; + + MainServer.Instance.AddXmlRPCHandler( + "grid_instant_message", processXMLRPCGridInstantMessage); } public virtual void RegionLoaded(Scene scene) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 1ff5865..24cbaeb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs @@ -37,7 +37,7 @@ using OpenSim.Framework.Client; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -namespace OpenSim.Region.CoreModules.Avatar.MuteList +namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { public class MuteListModule : ISharedRegionModule { -- cgit v1.1 From 3ef513e863097bdccffa8c84283ab8ffc0915a8f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 27 Dec 2009 20:34:42 -0800 Subject: Presence remote connector and handler. Presence HG Broker. Nothing tested, just compiles. --- .../Presence/HGPresenceBroker.cs | 256 +++++++++++++++++++++ .../Presence/LocalPresenceServiceConnector.cs | 1 - .../Presence/RemotePresenceServiceConnector.cs | 158 +++++++++++++ 3 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs new file mode 100644 index 0000000..0d913bc --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs @@ -0,0 +1,256 @@ +/* + * 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 PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence +{ + public class HGPresenceBroker : ISharedRegionModule, IPresenceService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region ISharedRegionModule + + private bool m_Enabled = false; + + private PresenceDetector m_PresenceDetector; + private IPresenceService m_GridService; + private IPresenceService m_HGService; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "HGPresenceBroker"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("PresenceServices", ""); + if (name == Name) + { + //m_RemoteConnector = new InventoryServicesConnector(source); + + m_Enabled = true; + + m_PresenceDetector = new PresenceDetector(this); + + + IConfig pConfig = source.Configs["PresenceService"]; + if (pConfig == null) + { + m_log.Error("[HG PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); + return; + } + + string localDll = pConfig.GetString("LocalGridPresenceService", + String.Empty); + string HGDll = pConfig.GetString("HypergridPresenceService", + String.Empty); + + if (localDll == String.Empty) + { + m_log.Error("[HG PRESENCE CONNECTOR]: No LocalGridPresenceService named in section PresenceService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + if (HGDll == String.Empty) + { + m_log.Error("[HG PRESENCE CONNECTOR]: No HypergridPresenceService named in section PresenceService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + Object[] args = new Object[] { source }; + m_GridService = ServerUtils.LoadPlugin(localDll, args); + + m_HGService = ServerUtils.LoadPlugin(HGDll, args); + // no. This will be: + // m_HGService = new HGPresenceServiceConnector(); + + if (m_GridService == null) + { + m_log.Error("[HG PRESENCE CONNECTOR]: Can't load local presence service"); + return; + } + if (m_HGService == null) + { + m_log.Error("[HG PRESENCE CONNECTOR]: Can't load hypergrid presence service"); + return; + } + + m_log.Info("[HG PRESENCE CONNECTOR]: Hypergrid presence enabled"); + } + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + m_PresenceDetector.AddRegion(scene); + + m_log.InfoFormat("[HG PRESENCE CONNECTOR]: Enabled hypergrid presence for region {0}", scene.RegionInfo.RegionName); + + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_PresenceDetector.RemoveRegion(scene); + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region IPresenceService + + public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) + { + m_log.Warn("[HG PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); + return false; + } + + public bool LogoutAgent(UUID sessionID) + { + return m_GridService.LogoutAgent(sessionID); + } + + + public bool LogoutRegionAgents(UUID regionID) + { + return m_GridService.LogoutRegionAgents(regionID); + } + + public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return m_GridService.ReportAgent(sessionID, regionID, position, lookAt); + } + + public PresenceInfo GetAgent(UUID sessionID) + { + return m_GridService.GetAgent(sessionID); + } + + public PresenceInfo[] GetAgents(string[] principalIDs) + { + Dictionary> triage = new Dictionary>(); + List presences = new List(); + + foreach (string s in principalIDs) + { + string url = string.Empty; + string uuid = UUID.Zero.ToString(); + StringToUrlAndUUID(s, out url, out uuid); + if (triage.ContainsKey(url)) + triage[url].Add(uuid); + else + { + List list = new List(); + list.Add(uuid); + triage.Add(url, list); + } + } + + foreach (KeyValuePair> kvp in triage) + { + if (kvp.Key == "local") + { + PresenceInfo[] pinfos = m_GridService.GetAgents(kvp.Value.ToArray()); + presences.AddRange(pinfos); + } + else + { + PresenceInfo[] pinfos = m_HGService.GetAgents(/*kvp.Key,*/ kvp.Value.ToArray()); + presences.AddRange(pinfos); + } + } + + return presences.ToArray(); + } + + #endregion + + private void StringToUrlAndUUID(string id, out string url, out string uuid) + { + url = String.Empty; + uuid = String.Empty; + + Uri uri; + + if (Uri.TryCreate(id, UriKind.Absolute, out uri) && + uri.Scheme == Uri.UriSchemeHttp) + { + url = "http://" + uri.Authority; + uuid = uri.LocalPath.Trim(new char[] { '/' }); + } + else + { + url = "local"; + uuid = id; + } + } + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 24362c7..510e9cb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -47,7 +47,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence #region ISharedRegionModule private bool m_Enabled = false; - private bool m_Initialized = false; private PresenceDetector m_PresenceDetector; private IPresenceService m_PresenceService; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs new file mode 100644 index 0000000..eacf467 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -0,0 +1,158 @@ +/* + * 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 PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence +{ + public class RemotePresenceServiceConnector : ISharedRegionModule, IPresenceService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + #region ISharedRegionModule + + private bool m_Enabled = false; + + private PresenceDetector m_PresenceDetector; + private IPresenceService m_RemoteConnector; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemotePresenceServiceConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("PresenceServices", ""); + if (name == Name) + { + //m_RemoteConnector = new PresenceServicesConnector(source); + + m_Enabled = true; + + m_PresenceDetector = new PresenceDetector(this); + + m_log.Info("[INVENTORY CONNECTOR]: Remote presence enabled"); + } + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + m_PresenceDetector.AddRegion(scene); + + m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); + + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_PresenceDetector.RemoveRegion(scene); + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region IPresenceService + + public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) + { + m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); + return false; + } + + public bool LogoutAgent(UUID sessionID) + { + return m_RemoteConnector.LogoutAgent(sessionID); + } + + + public bool LogoutRegionAgents(UUID regionID) + { + return m_RemoteConnector.LogoutRegionAgents(regionID); + } + + public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) + { + return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt); + } + + public PresenceInfo GetAgent(UUID sessionID) + { + return m_RemoteConnector.GetAgent(sessionID); + } + + public PresenceInfo[] GetAgents(string[] principalIDs) + { + return m_RemoteConnector.GetAgents(principalIDs); + } + + #endregion + + } +} -- cgit v1.1 From 531f998ed2151f31dce4fe5a0ef1c2f03389b712 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Dec 2009 07:16:43 -0800 Subject: * Deleted HGPresenceBroker, since it won't be needed * Linked the remote presence module to the corresponding remote connector --- .../Presence/HGPresenceBroker.cs | 256 --------------------- .../Presence/RemotePresenceServiceConnector.cs | 3 +- 2 files changed, 2 insertions(+), 257 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs deleted file mode 100644 index 0d913bc..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/HGPresenceBroker.cs +++ /dev/null @@ -1,256 +0,0 @@ -/* - * 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 PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; - -using OpenMetaverse; -using log4net; -using Nini.Config; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence -{ - public class HGPresenceBroker : ISharedRegionModule, IPresenceService - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - #region ISharedRegionModule - - private bool m_Enabled = false; - - private PresenceDetector m_PresenceDetector; - private IPresenceService m_GridService; - private IPresenceService m_HGService; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "HGPresenceBroker"; } - } - - public void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("PresenceServices", ""); - if (name == Name) - { - //m_RemoteConnector = new InventoryServicesConnector(source); - - m_Enabled = true; - - m_PresenceDetector = new PresenceDetector(this); - - - IConfig pConfig = source.Configs["PresenceService"]; - if (pConfig == null) - { - m_log.Error("[HG PRESENCE CONNECTOR]: PresenceService missing from OpenSim.ini"); - return; - } - - string localDll = pConfig.GetString("LocalGridPresenceService", - String.Empty); - string HGDll = pConfig.GetString("HypergridPresenceService", - String.Empty); - - if (localDll == String.Empty) - { - m_log.Error("[HG PRESENCE CONNECTOR]: No LocalGridPresenceService named in section PresenceService"); - //return; - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } - - if (HGDll == String.Empty) - { - m_log.Error("[HG PRESENCE CONNECTOR]: No HypergridPresenceService named in section PresenceService"); - //return; - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } - - Object[] args = new Object[] { source }; - m_GridService = ServerUtils.LoadPlugin(localDll, args); - - m_HGService = ServerUtils.LoadPlugin(HGDll, args); - // no. This will be: - // m_HGService = new HGPresenceServiceConnector(); - - if (m_GridService == null) - { - m_log.Error("[HG PRESENCE CONNECTOR]: Can't load local presence service"); - return; - } - if (m_HGService == null) - { - m_log.Error("[HG PRESENCE CONNECTOR]: Can't load hypergrid presence service"); - return; - } - - m_log.Info("[HG PRESENCE CONNECTOR]: Hypergrid presence enabled"); - } - } - - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(this); - m_PresenceDetector.AddRegion(scene); - - m_log.InfoFormat("[HG PRESENCE CONNECTOR]: Enabled hypergrid presence for region {0}", scene.RegionInfo.RegionName); - - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - - m_PresenceDetector.RemoveRegion(scene); - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - } - - #endregion - - #region IPresenceService - - public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) - { - m_log.Warn("[HG PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); - return false; - } - - public bool LogoutAgent(UUID sessionID) - { - return m_GridService.LogoutAgent(sessionID); - } - - - public bool LogoutRegionAgents(UUID regionID) - { - return m_GridService.LogoutRegionAgents(regionID); - } - - public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) - { - return m_GridService.ReportAgent(sessionID, regionID, position, lookAt); - } - - public PresenceInfo GetAgent(UUID sessionID) - { - return m_GridService.GetAgent(sessionID); - } - - public PresenceInfo[] GetAgents(string[] principalIDs) - { - Dictionary> triage = new Dictionary>(); - List presences = new List(); - - foreach (string s in principalIDs) - { - string url = string.Empty; - string uuid = UUID.Zero.ToString(); - StringToUrlAndUUID(s, out url, out uuid); - if (triage.ContainsKey(url)) - triage[url].Add(uuid); - else - { - List list = new List(); - list.Add(uuid); - triage.Add(url, list); - } - } - - foreach (KeyValuePair> kvp in triage) - { - if (kvp.Key == "local") - { - PresenceInfo[] pinfos = m_GridService.GetAgents(kvp.Value.ToArray()); - presences.AddRange(pinfos); - } - else - { - PresenceInfo[] pinfos = m_HGService.GetAgents(/*kvp.Key,*/ kvp.Value.ToArray()); - presences.AddRange(pinfos); - } - } - - return presences.ToArray(); - } - - #endregion - - private void StringToUrlAndUUID(string id, out string url, out string uuid) - { - url = String.Empty; - uuid = String.Empty; - - Uri uri; - - if (Uri.TryCreate(id, UriKind.Absolute, out uri) && - uri.Scheme == Uri.UriSchemeHttp) - { - url = "http://" + uri.Authority; - uuid = uri.LocalPath.Trim(new char[] { '/' }); - } - else - { - url = "local"; - uuid = id; - } - } - - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index eacf467..d75ed51 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -32,6 +32,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; using OpenMetaverse; @@ -69,7 +70,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence string name = moduleConfig.GetString("PresenceServices", ""); if (name == Name) { - //m_RemoteConnector = new PresenceServicesConnector(source); + m_RemoteConnector = new PresenceServicesConnector(source); m_Enabled = true; -- cgit v1.1 From f43a64805251dfbb2e24abc481b8b59c062d452e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Dec 2009 09:22:35 -0800 Subject: * Added the new modules to Resources, making them active. * Added their configs to standalone for testing. This crashes, because the DB is still not ready. --- OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | 2 ++ .../ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | 4 ++-- .../ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 40a13f4..79796b1 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -48,6 +48,8 @@ + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 510e9cb..8aad7e0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -40,7 +40,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence { - public class LocalPresenceServiceConnector : ISharedRegionModule, IPresenceService + public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public string Name { - get { return "LocalPresenceServiceConnector"; } + get { return "LocalPresenceServicesConnector"; } } public void Initialise(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index d75ed51..6a674ce 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -41,7 +41,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence { - public class RemotePresenceServiceConnector : ISharedRegionModule, IPresenceService + public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 92a40129b5dfde0d8ef798941f5efb31ca3a73fd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 17:34:42 +0000 Subject: Database and presence changes. Untested --- .../ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | 6 +++--- .../ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 8aad7e0..a80a355 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence #region IPresenceService - public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) + public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); return false; @@ -175,9 +175,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_PresenceService.GetAgent(sessionID); } - public PresenceInfo[] GetAgents(string[] principalIDs) + public PresenceInfo[] GetAgents(string[] userIDs) { - return m_PresenceService.GetAgents(principalIDs); + return m_PresenceService.GetAgents(userIDs); } #endregion diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index 6a674ce..e652773 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence #region IPresenceService - public bool LoginAgent(UUID principalID, UUID sessionID, UUID secureSessionID) + public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) { m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); return false; @@ -148,9 +148,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return m_RemoteConnector.GetAgent(sessionID); } - public PresenceInfo[] GetAgents(string[] principalIDs) + public PresenceInfo[] GetAgents(string[] userIDs) { - return m_RemoteConnector.GetAgents(principalIDs); + return m_RemoteConnector.GetAgents(userIDs); } #endregion -- cgit v1.1 From 43691e827070f630a2acfbb70d88c1aa555f3f4d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 28 Dec 2009 11:46:34 -0800 Subject: Added some more log messages. This is beginning to work. --- .../CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 150728f..3ca5560 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -26,17 +26,21 @@ */ 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.Presence { public class PresenceDetector { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private IPresenceService m_PresenceService; public PresenceDetector(IPresenceService presenceservice) @@ -62,6 +66,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); } -- cgit v1.1 From e0fc854f05b137c353196356e5b26d11b6ee6867 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 28 Dec 2009 23:42:08 +0000 Subject: Adding new fields and home location methid to presence. Adding cleanup (deleting all but one presence record) on logout so that they don't pile up. --- .../ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | 5 +++++ .../ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index a80a355..644d755 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -180,6 +180,11 @@ 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/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index e652773..e8e140a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -153,6 +153,11 @@ 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 } -- cgit v1.1 From b4483df2701483aabd43fc7d03ebd74770d70170 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 15:58:40 -0800 Subject: * All modules and connectors for user account service are in place. Untested. * Cleaned up a few things on presence connectors --- .../Resources/CoreModulePlugin.addin.xml | 4 +- .../User/LocalUserAccountServiceConnector.cs | 131 +++++++++++++++ .../User/LocalUserServiceConnector.cs | 131 --------------- .../User/RemoteUserAccountServiceConnector.cs | 114 +++++++++++++ .../User/RemoteUserServiceConnector.cs | 114 ------------- .../LocalUserAccountServiceConnector.cs | 176 +++++++++++++++++++++ .../RemoteUserAccountServiceConnector.cs | 114 +++++++++++++ 7 files changed, 538 insertions(+), 246 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 79796b1..a7acc43 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -48,9 +48,11 @@ + - + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs new file mode 100644 index 0000000..cca5bb4 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs @@ -0,0 +1,131 @@ +/* + * 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.Reflection; +using log4net; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +{ + public class LocalUserServicesConnector : ISharedRegionModule + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IUserAccountService m_UserService; + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalUserServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("UserServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["UserService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); + return; + } + + string serviceDll = userConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService"); + return; + } + + Object[] args = new Object[] { source }; + m_UserService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_UserService == null) + { + m_log.Error("[USER CONNECTOR]: Can't load user service"); + return; + } + m_Enabled = true; + m_log.Info("[USER CONNECTOR]: Local user connector enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(m_UserService); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs deleted file mode 100644 index cca5bb4..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserServiceConnector.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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.Reflection; -using log4net; -using Nini.Config; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Server.Base; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User -{ - public class LocalUserServicesConnector : ISharedRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private IUserAccountService m_UserService; - - private bool m_Enabled = false; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "LocalUserServicesConnector"; } - } - - public void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("UserServices", ""); - if (name == Name) - { - IConfig userConfig = source.Configs["UserService"]; - if (userConfig == null) - { - m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); - return; - } - - string serviceDll = userConfig.GetString("LocalServiceModule", - String.Empty); - - if (serviceDll == String.Empty) - { - m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService"); - return; - } - - Object[] args = new Object[] { source }; - m_UserService = - ServerUtils.LoadPlugin(serviceDll, - args); - - if (m_UserService == null) - { - m_log.Error("[USER CONNECTOR]: Can't load user service"); - return; - } - m_Enabled = true; - m_log.Info("[USER CONNECTOR]: Local user connector enabled"); - } - } - } - - public void PostInitialise() - { - if (!m_Enabled) - return; - } - - public void Close() - { - if (!m_Enabled) - return; - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(m_UserService); - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - } - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs new file mode 100644 index 0000000..cef9129 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs @@ -0,0 +1,114 @@ +/* + * 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 log4net; +using System.Reflection; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +{ + public class RemoteUserServicesConnector : UserServicesConnector, + ISharedRegionModule, IUserAccountService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteUserServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("UserServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["UserService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[USER CONNECTOR]: Remote users enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs deleted file mode 100644 index cef9129..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserServiceConnector.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 log4net; -using System.Reflection; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User -{ - public class RemoteUserServicesConnector : UserServicesConnector, - ISharedRegionModule, IUserAccountService - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled = false; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "RemoteUserServicesConnector"; } - } - - public override void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("UserServices", ""); - if (name == Name) - { - IConfig userConfig = source.Configs["UserService"]; - if (userConfig == null) - { - m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); - return; - } - - m_Enabled = true; - - base.Initialise(source); - - m_log.Info("[USER CONNECTOR]: Remote users enabled"); - } - } - } - - public void PostInitialise() - { - if (!m_Enabled) - return; - } - - public void Close() - { - if (!m_Enabled) - return; - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(this); - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - } - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs new file mode 100644 index 0000000..e40d524 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs @@ -0,0 +1,176 @@ +/* + * 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 log4net; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +{ + public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IUserAccountService m_UserService; + + private bool m_Enabled = false; + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalUserAccountServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("UserAccountServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["UserAccountService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); + return; + } + + string serviceDll = userConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService"); + return; + } + + Object[] args = new Object[] { source }; + m_UserService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_UserService == null) + { + m_log.Error("[USER CONNECTOR]: Can't load user account service"); + return; + } + m_Enabled = true; + m_log.Info("[USER CONNECTOR]: Local user connector enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(m_UserService); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + + #endregion + + #region IUserAccountService + + public UserAccount GetUserAccount(UUID scopeID, UUID userID) + { + return m_UserService.GetUserAccount(scopeID, userID); + } + + public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) + { + return m_UserService.GetUserAccount(scopeID, FirstName, LastName); + } + + public UserAccount GetUserAccount(UUID scopeID, string Email) + { + return m_UserService.GetUserAccount(scopeID, Email); + } + + public List GetUserAccounts(UUID scopeID, string query) + { + return m_UserService.GetUserAccounts(scopeID, query); + } + + // Update all updatable fields + // + public bool SetUserAccount(UserAccount data) + { + return m_UserService.SetUserAccount(data); + } + + // Creates a user data record + public bool CreateUserAccount(UserAccount data) + { + return m_UserService.CreateUserAccount(data); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs new file mode 100644 index 0000000..0b72080 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs @@ -0,0 +1,114 @@ +/* + * 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 log4net; +using System.Reflection; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +{ + public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, + ISharedRegionModule, IUserAccountService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteUserAccountServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("UserServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["UserService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[USER CONNECTOR]: Remote users enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + } +} -- cgit v1.1 From 81bcedda835b2a5967980311daa82cf2615e0d59 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 16:06:21 -0800 Subject: Renamed user account modules to be consistent --- .../User/LocalUserAccountServiceConnector.cs | 131 --------------- .../User/RemoteUserAccountServiceConnector.cs | 114 ------------- .../LocalUserAccountServiceConnector.cs | 176 --------------------- .../RemoteUserAccountServiceConnector.cs | 114 ------------- .../LocalUserAccountServiceConnector.cs | 176 +++++++++++++++++++++ .../RemoteUserAccountServiceConnector.cs | 114 +++++++++++++ 6 files changed, 290 insertions(+), 535 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs deleted file mode 100644 index cca5bb4..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/LocalUserAccountServiceConnector.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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.Reflection; -using log4net; -using Nini.Config; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Server.Base; -using OpenSim.Services.Interfaces; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User -{ - public class LocalUserServicesConnector : ISharedRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private IUserAccountService m_UserService; - - private bool m_Enabled = false; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "LocalUserServicesConnector"; } - } - - public void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("UserServices", ""); - if (name == Name) - { - IConfig userConfig = source.Configs["UserService"]; - if (userConfig == null) - { - m_log.Error("[USER CONNECTOR]: UserService missing from OpenSim.ini"); - return; - } - - string serviceDll = userConfig.GetString("LocalServiceModule", - String.Empty); - - if (serviceDll == String.Empty) - { - m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService"); - return; - } - - Object[] args = new Object[] { source }; - m_UserService = - ServerUtils.LoadPlugin(serviceDll, - args); - - if (m_UserService == null) - { - m_log.Error("[USER CONNECTOR]: Can't load user service"); - return; - } - m_Enabled = true; - m_log.Info("[USER CONNECTOR]: Local user connector enabled"); - } - } - } - - public void PostInitialise() - { - if (!m_Enabled) - return; - } - - public void Close() - { - if (!m_Enabled) - return; - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(m_UserService); - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - } - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs deleted file mode 100644 index cef9129..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/User/RemoteUserAccountServiceConnector.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 log4net; -using System.Reflection; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User -{ - public class RemoteUserServicesConnector : UserServicesConnector, - ISharedRegionModule, IUserAccountService - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled = false; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "RemoteUserServicesConnector"; } - } - - public override void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("UserServices", ""); - if (name == Name) - { - IConfig userConfig = source.Configs["UserService"]; - if (userConfig == null) - { - m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); - return; - } - - m_Enabled = true; - - base.Initialise(source); - - m_log.Info("[USER CONNECTOR]: Remote users enabled"); - } - } - } - - public void PostInitialise() - { - if (!m_Enabled) - return; - } - - public void Close() - { - if (!m_Enabled) - return; - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(this); - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - } - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs deleted file mode 100644 index e40d524..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/LocalUserAccountServiceConnector.cs +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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 log4net; -using Nini.Config; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Server.Base; -using OpenSim.Services.Interfaces; - -using OpenMetaverse; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User -{ - public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private IUserAccountService m_UserService; - - private bool m_Enabled = false; - - #region ISharedRegionModule - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "LocalUserAccountServicesConnector"; } - } - - public void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("UserAccountServices", ""); - if (name == Name) - { - IConfig userConfig = source.Configs["UserAccountService"]; - if (userConfig == null) - { - m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); - return; - } - - string serviceDll = userConfig.GetString("LocalServiceModule", - String.Empty); - - if (serviceDll == String.Empty) - { - m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService"); - return; - } - - Object[] args = new Object[] { source }; - m_UserService = - ServerUtils.LoadPlugin(serviceDll, - args); - - if (m_UserService == null) - { - m_log.Error("[USER CONNECTOR]: Can't load user account service"); - return; - } - m_Enabled = true; - m_log.Info("[USER CONNECTOR]: Local user connector enabled"); - } - } - } - - public void PostInitialise() - { - if (!m_Enabled) - return; - } - - public void Close() - { - if (!m_Enabled) - return; - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(m_UserService); - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - } - - #endregion - - #region IUserAccountService - - public UserAccount GetUserAccount(UUID scopeID, UUID userID) - { - return m_UserService.GetUserAccount(scopeID, userID); - } - - public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) - { - return m_UserService.GetUserAccount(scopeID, FirstName, LastName); - } - - public UserAccount GetUserAccount(UUID scopeID, string Email) - { - return m_UserService.GetUserAccount(scopeID, Email); - } - - public List GetUserAccounts(UUID scopeID, string query) - { - return m_UserService.GetUserAccounts(scopeID, query); - } - - // Update all updatable fields - // - public bool SetUserAccount(UserAccount data) - { - return m_UserService.SetUserAccount(data); - } - - // Creates a user data record - public bool CreateUserAccount(UserAccount data) - { - return m_UserService.CreateUserAccount(data); - } - - #endregion - - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs deleted file mode 100644 index 0b72080..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccount/RemoteUserAccountServiceConnector.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 log4net; -using System.Reflection; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using OpenSim.Services.Connectors; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User -{ - public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, - ISharedRegionModule, IUserAccountService - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled = false; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "RemoteUserAccountServicesConnector"; } - } - - public override void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("UserServices", ""); - if (name == Name) - { - IConfig userConfig = source.Configs["UserService"]; - if (userConfig == null) - { - m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); - return; - } - - m_Enabled = true; - - base.Initialise(source); - - m_log.Info("[USER CONNECTOR]: Remote users enabled"); - } - } - } - - public void PostInitialise() - { - if (!m_Enabled) - return; - } - - public void Close() - { - if (!m_Enabled) - return; - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - scene.RegisterModuleInterface(this); - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - } - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs new file mode 100644 index 0000000..e40d524 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -0,0 +1,176 @@ +/* + * 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 log4net; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +{ + public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IUserAccountService m_UserService; + + private bool m_Enabled = false; + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalUserAccountServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("UserAccountServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["UserAccountService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini"); + return; + } + + string serviceDll = userConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section UserService"); + return; + } + + Object[] args = new Object[] { source }; + m_UserService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_UserService == null) + { + m_log.Error("[USER CONNECTOR]: Can't load user account service"); + return; + } + m_Enabled = true; + m_log.Info("[USER CONNECTOR]: Local user connector enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(m_UserService); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + + #endregion + + #region IUserAccountService + + public UserAccount GetUserAccount(UUID scopeID, UUID userID) + { + return m_UserService.GetUserAccount(scopeID, userID); + } + + public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) + { + return m_UserService.GetUserAccount(scopeID, FirstName, LastName); + } + + public UserAccount GetUserAccount(UUID scopeID, string Email) + { + return m_UserService.GetUserAccount(scopeID, Email); + } + + public List GetUserAccounts(UUID scopeID, string query) + { + return m_UserService.GetUserAccounts(scopeID, query); + } + + // Update all updatable fields + // + public bool SetUserAccount(UserAccount data) + { + return m_UserService.SetUserAccount(data); + } + + // Creates a user data record + public bool CreateUserAccount(UserAccount data) + { + return m_UserService.CreateUserAccount(data); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs new file mode 100644 index 0000000..0b72080 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -0,0 +1,114 @@ +/* + * 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 log4net; +using System.Reflection; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +{ + public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, + ISharedRegionModule, IUserAccountService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteUserAccountServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("UserServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["UserService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[USER CONNECTOR]: Remote users enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + } +} -- cgit v1.1 From 88d2df597e499600357c86ad0b1a755a13e9c6b1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 29 Dec 2009 16:34:02 -0800 Subject: * Fixed names. * Added configs for Standalone * Changed UserSericeBase to use useraccounts instead of user --- OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | 6 ++---- .../UserAccounts/LocalUserAccountServiceConnector.cs | 2 +- .../UserAccounts/RemoteUserAccountServiceConnector.cs | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index a7acc43..e4b0fd5 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -30,8 +30,6 @@ - - @@ -51,8 +49,8 @@ - - + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index e40d524..ce8c3a5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -37,7 +37,7 @@ using OpenSim.Services.Interfaces; using OpenMetaverse; -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 0b72080..d322aba 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -34,7 +34,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenSim.Services.Connectors; -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.User +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, ISharedRegionModule, IUserAccountService -- cgit v1.1 From 1d2a332b96794e2011b0527cf590c3ceedcd8af4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 30 Dec 2009 14:17:18 -0800 Subject: Unit tests for presence. They helped fix a couple of wrongnesses. --- .../Presence/LocalPresenceServiceConnector.cs | 13 ++- .../Presence/Tests/PresenceConnectorsTests.cs | 104 +++++++++++++++++++++ 2 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 644d755..2cb18c7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -44,13 +44,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - #region ISharedRegionModule - private bool m_Enabled = false; private PresenceDetector m_PresenceDetector; private IPresenceService m_PresenceService; + public LocalPresenceServicesConnector() + { + } + + public LocalPresenceServicesConnector(IConfigSource source) + { + Initialise(source); + } + + #region ISharedRegionModule + public Type ReplaceableInterface { get { return null; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs new file mode 100644 index 0000000..ebb2c3e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -0,0 +1,104 @@ +/* + * 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.IO; +using System.Reflection; +using System.Threading; +using log4net.Config; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenSim.Framework; +using Nini.Config; + +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; +using OpenSim.Region.Framework.Scenes; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Setup; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests +{ + [TestFixture] + public class PresenceConnectorsTests + { + LocalPresenceServicesConnector m_LocalConnector; + private void SetUp() + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("PresenceService"); + config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); + config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); + config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); + + m_LocalConnector = new LocalPresenceServicesConnector(config); + } + + /// + /// Test OpenSim Presence. + /// + [Test] + public void TestPresenceV0_1() + { + SetUp(); + + string user1 = UUID.Zero.ToString(); + UUID session1 = UUID.Zero; + + // this is not implemented by this connector + //m_LocalConnector.LoginAgent(user1, session1, UUID.Zero); + 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); + 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); + 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); + 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"); + + r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero); + Assert.IsFalse(r, "ReportAgent of non-logged in user returned true"); + } + } +} -- cgit v1.1 From 3507005d9decdbf579fb2b7b9928a7d97bd6cf5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:16:16 +0000 Subject: Remove CreateUserAccount. Rename SetUserAccount to StoreUserAccount. Implement the fetch operations fully. Rename one last UserService file to UserAccountService --- .../UserAccounts/LocalUserAccountServiceConnector.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index ce8c3a5..f55de5a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -159,15 +159,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts // Update all updatable fields // - public bool SetUserAccount(UserAccount data) + public bool StoreUserAccount(UserAccount data) { - return m_UserService.SetUserAccount(data); - } - - // Creates a user data record - public bool CreateUserAccount(UserAccount data) - { - return m_UserService.CreateUserAccount(data); + return m_UserService.StoreUserAccount(data); } #endregion -- cgit v1.1 From b29ae7246076126e8e39827564438db6e53eac8a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 30 Dec 2009 21:00:16 -0800 Subject: First pass at the new login service. Still incomplete, but doesn't disrupt the existing code. --- .../ServiceConnectorsOut/Interregion/RESTInterregionComms.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index 44458d1..fa3681a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -436,12 +436,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion } OSDMap resp = new OSDMap(2); - string reason = String.Empty; - uint teleportFlags = 0; - if (args.ContainsKey("teleport_flags")) - { - teleportFlags = args["teleport_flags"].AsUInteger(); - } + string reason = String.Empty; + uint teleportFlags = 0; + if (args.ContainsKey("teleport_flags")) + { + teleportFlags = args["teleport_flags"].AsUInteger(); + } // This is the meaning of POST agent m_regionClient.AdjustUserInformation(aCircuit); -- cgit v1.1 From 20318dba057a9a4c262cec1af43ba136ceba8e85 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 1 Jan 2010 02:05:19 +0000 Subject: Finally restire the EMPTY friends module (what a mess) --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 551 +-------------------- 1 file changed, 1 insertion(+), 550 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fceca8e..123e2dd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -58,530 +58,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { } - public string Name - { - get { return "FriendsModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - #region IInterregionFriendsComms - - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - List tpdAway = new List(); - - // destRegionHandle is a region on another server - uint x = 0, y = 0; - Utils.LongToUInts(destRegionHandle, out x, out y); - GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); - if (info != null) - { - string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; - - Hashtable reqParams = new Hashtable(); - reqParams["agentID"] = agentId.ToString(); - reqParams["agentOnline"] = online; - int count = 0; - foreach (UUID uuid in friends) - { - reqParams["friendID_" + count++] = uuid.ToString(); - } - reqParams["friendCount"] = count; - - IList parameters = new ArrayList(); - parameters.Add(reqParams); - try - { - XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters); - XmlRpcResponse response = request.Send(httpServer, 5000); - Hashtable respData = (Hashtable)response.Value; - - count = (int)respData["friendCount"]; - for (int i = 0; i < count; ++i) - { - UUID uuid; - if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid); - } - } - catch (WebException e) - { - // Ignore connect failures, simulators come and go - // - if (!e.Message.Contains("ConnectFailure")) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - } - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - } - } - else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle); - - return tpdAway; - } - - public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) - { - // destRegionHandle is a region on another server - uint x = 0, y = 0; - Utils.LongToUInts(destRegionHandle, out x, out y); - GridRegion info = m_gridServices.GetRegionByPosition(m_initialScene.RegionInfo.ScopeID, (int)x, (int)y); - if (info == null) - { - m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); - return false; // region not found??? - } - - string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; - - Hashtable reqParams = new Hashtable(); - reqParams["agentID"] = agentID.ToString(); - reqParams["friendID"] = exFriendID.ToString(); - - IList parameters = new ArrayList(); - parameters.Add(reqParams); - try - { - XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters); - XmlRpcResponse response = request.Send(httpServer, 5000); - Hashtable respData = (Hashtable)response.Value; - - return (bool)respData["success"]; - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - return false; - } - } - - #endregion - - #region Incoming XMLRPC messages - /// - /// Receive presence information changes about clients in other regions. - /// - /// - /// - public XmlRpcResponse processPresenceUpdateBulk(XmlRpcRequest req, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)req.Params[0]; - - List friendsNotHere = new List(); - - // this is called with the expectation that all the friends in the request are on this region-server. - // But as some time passed since we checked (on the other region-server, via the MessagingServer), - // some of the friends might have teleported away. - // Actually, even now, between this line and the sending below, some people could TP away. So, - // we'll have to lock the m_rootAgents list for the duration to prevent/delay that. - lock (m_rootAgents) - { - List friendsHere = new List(); - - try - { - UUID agentID = new UUID((string)requestData["agentID"]); - bool agentOnline = (bool)requestData["agentOnline"]; - int count = (int)requestData["friendCount"]; - for (int i = 0; i < count; ++i) - { - UUID uuid; - if (UUID.TryParse((string)requestData["friendID_" + i], out uuid)) - { - if (m_rootAgents.ContainsKey(uuid)) friendsHere.Add(GetRootPresenceFromAgentID(uuid)); - else friendsNotHere.Add(uuid); - } - } - - // now send, as long as they are still here... - UUID[] agentUUID = new UUID[] { agentID }; - if (agentOnline) - { - foreach (ScenePresence agent in friendsHere) - { - agent.ControllingClient.SendAgentOnline(agentUUID); - } - } - else - { - foreach (ScenePresence agent in friendsHere) - { - agent.ControllingClient.SendAgentOffline(agentUUID); - } - } - } - catch(Exception e) - { - m_log.Warn("[FRIENDS]: Got exception while parsing presence_update_bulk request:", e); - } - } - - // no need to lock anymore; if TPs happen now, worst case is that we have an additional agent in this region, - // which should be caught on the next iteration... - Hashtable result = new Hashtable(); - int idx = 0; - foreach (UUID uuid in friendsNotHere) - { - result["friendID_" + idx++] = uuid.ToString(); - } - result["friendCount"] = idx; - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - - return response; - } - - public XmlRpcResponse processTerminateFriend(XmlRpcRequest req, IPEndPoint remoteClient) - { - Hashtable requestData = (Hashtable)req.Params[0]; - - bool success = false; - - UUID agentID; - UUID friendID; - if (requestData.ContainsKey("agentID") && UUID.TryParse((string)requestData["agentID"], out agentID) && - requestData.ContainsKey("friendID") && UUID.TryParse((string)requestData["friendID"], out friendID)) - { - // try to find it and if it is there, prevent it to vanish before we sent the message - lock (m_rootAgents) - { - if (m_rootAgents.ContainsKey(agentID)) - { - m_log.DebugFormat("[FRIEND]: Sending terminate friend {0} to agent {1}", friendID, agentID); - GetRootPresenceFromAgentID(agentID).ControllingClient.SendTerminateFriend(friendID); - success = true; - } - } - } - - // return whether we were successful - Hashtable result = new Hashtable(); - result["success"] = success; - - XmlRpcResponse response = new XmlRpcResponse(); - response.Value = result; - return response; - } - - #endregion - - #region Scene events - - private void OnNewClient(IClientAPI client) - { - // All friends establishment protocol goes over instant message - // There's no way to send a message from the sim - // to a user to 'add a friend' without causing dialog box spam - - // Subscribe to instant messages - client.OnInstantMessage += OnInstantMessage; - - // Friend list management - client.OnApproveFriendRequest += OnApproveFriendRequest; - client.OnDenyFriendRequest += OnDenyFriendRequest; - client.OnTerminateFriendship += OnTerminateFriendship; - - // ... calling card handling... - client.OnOfferCallingCard += OnOfferCallingCard; - client.OnAcceptCallingCard += OnAcceptCallingCard; - client.OnDeclineCallingCard += OnDeclineCallingCard; - - // we need this one exactly once per agent session (see comments in the handler below) - client.OnEconomyDataRequest += OnEconomyDataRequest; - - // if it leaves, we want to know, too - client.OnLogout += OnLogout; - - client.OnGrantUserRights += GrantUserFriendRights; - client.OnTrackAgentEvent += FindAgent; - client.OnFindAgentEvent += FindAgent; - - } - - private void ClientClosed(UUID AgentId, Scene scene) - { - // agent's client was closed. As we handle logout in OnLogout, this here has only to handle - // TPing away (root agent is closed) or TPing/crossing in a region far enough away (client - // agent is closed). - // NOTE: In general, this doesn't mean that the agent logged out, just that it isn't around - // in one of the regions here anymore. - lock (m_rootAgents) - { - if (m_rootAgents.ContainsKey(AgentId)) - { - m_rootAgents.Remove(AgentId); - } - } - } - - private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) - { - lock (m_rootAgents) - { - m_rootAgents[avatar.UUID] = avatar.RegionHandle; - // Claim User! my user! Mine mine mine! - } - } - - private void MakeChildAgent(ScenePresence avatar) - { - lock (m_rootAgents) - { - if (m_rootAgents.ContainsKey(avatar.UUID)) - { - // only delete if the region matches. As this is a shared module, the avatar could be - // root agent in another region on this server. - if (m_rootAgents[avatar.UUID] == avatar.RegionHandle) - { - m_rootAgents.Remove(avatar.UUID); -// m_log.Debug("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); - } - } - } - } - #endregion - - private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) - { - ScenePresence returnAgent = null; - lock (m_scenes) - { - ScenePresence queryagent = null; - foreach (Scene scene in m_scenes.Values) - { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) - { - if (!queryagent.IsChildAgent) - { - returnAgent = queryagent; - break; - } - } - } - } - return returnAgent; - } - - private ScenePresence GetAnyPresenceFromAgentID(UUID AgentID) - { - ScenePresence returnAgent = null; - lock (m_scenes) - { - ScenePresence queryagent = null; - foreach (Scene scene in m_scenes.Values) - { - queryagent = scene.GetScenePresence(AgentID); - if (queryagent != null) - { - returnAgent = queryagent; - break; - } - } - } - return returnAgent; - } - - public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) - { - CachedUserInfo userInfo = m_initialScene.CommsManager.UserProfileCacheService.GetUserDetails(fromUserId); - - if (userInfo != null) - { - GridInstantMessage msg = new GridInstantMessage( - toUserClient.Scene, fromUserId, userInfo.UserProfile.Name, toUserClient.AgentId, - (byte)InstantMessageDialog.FriendshipOffered, offerMessage, false, Vector3.Zero); - - FriendshipOffered(msg); - } - else - { - m_log.ErrorFormat("[FRIENDS]: No user found for id {0} in OfferFriendship()", fromUserId); - } - } - - #region FriendRequestHandling - - private void OnInstantMessage(IClientAPI client, GridInstantMessage im) - { - // Friend Requests go by Instant Message.. using the dialog param - // https://wiki.secondlife.com/wiki/ImprovedInstantMessage - - if (im.dialog == (byte)InstantMessageDialog.FriendshipOffered) // 38 - { - // fromAgentName is the *destination* name (the friend we offer friendship to) - ScenePresence initiator = GetAnyPresenceFromAgentID(new UUID(im.fromAgentID)); - im.fromAgentName = initiator != null ? initiator.Name : "(hippo)"; - - FriendshipOffered(im); - } - else if (im.dialog == (byte)InstantMessageDialog.FriendshipAccepted) // 39 - { - FriendshipAccepted(client, im); - } - else if (im.dialog == (byte)InstantMessageDialog.FriendshipDeclined) // 40 - { - FriendshipDeclined(client, im); - } - } - - /// - /// Invoked when a user offers a friendship. - /// - /// - /// - /// - private void FriendshipOffered(GridInstantMessage im) - { - // this is triggered by the initiating agent: - // A local agent offers friendship to some possibly remote friend. - // A IM is triggered, processed here and sent to the friend (possibly in a remote region). - - m_log.DebugFormat("[FRIEND]: Offer(38) - From: {0}, FromName: {1} To: {2}, Session: {3}, Message: {4}, Offline {5}", - im.fromAgentID, im.fromAgentName, im.toAgentID, im.imSessionID, im.message, im.offline); - - // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text. - // For interoperability, we have to clear that - if (Util.isUUID(im.message)) im.message = ""; - - // be sneeky and use the initiator-UUID as transactionID. This means we can be stateless. - // we have to look up the agent name on friendship-approval, though. - im.imSessionID = im.fromAgentID; - - if (m_TransferModule != null) - { - // Send it to whoever is the destination. - // If new friend is local, it will send an IM to the viewer. - // If new friend is remote, it will cause a OnGridInstantMessage on the remote server - m_TransferModule.SendInstantMessage( - im, - delegate(bool success) - { - m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - } - - /// - /// Invoked when a user accepts a friendship offer. - /// - /// - /// - private void FriendshipAccepted(IClientAPI client, GridInstantMessage im) - { - m_log.DebugFormat("[FRIEND]: 39 - from client {0}, agent {2} {3}, imsession {4} to {5}: {6} (dialog {7})", - client.AgentId, im.fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); - } - - /// - /// Invoked when a user declines a friendship offer. - /// - /// May not currently be used - see OnDenyFriendRequest() instead - /// - /// - private void FriendshipDeclined(IClientAPI client, GridInstantMessage im) - { - UUID fromAgentID = new UUID(im.fromAgentID); - UUID toAgentID = new UUID(im.toAgentID); - - // declining the friendship offer causes a type 40 IM being sent to the (possibly remote) initiator - // toAgentID is initiator, fromAgentID declined friendship - m_log.DebugFormat("[FRIEND]: 40 - from client {0}, agent {1} {2}, imsession {3} to {4}: {5} (dialog {6})", - client != null ? client.AgentId.ToString() : "", - fromAgentID, im.fromAgentName, im.imSessionID, im.toAgentID, im.message, im.dialog); - - // Send the decline to whoever is the destination. - GridInstantMessage msg - = new GridInstantMessage( - client.Scene, fromAgentID, client.Name, toAgentID, - im.dialog, im.message, im.offline != 0, im.Position); - - // If new friend is local, it will send an IM to the viewer. - // If new friend is remote, it will cause a OnGridInstantMessage on the remote server - m_TransferModule.SendInstantMessage(msg, - delegate(bool success) { - m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - - private void OnGridInstantMessage(GridInstantMessage msg) - { - // This event won't be raised unless we have that agent, - // so we can depend on the above not trying to send - // via grid again - //m_log.DebugFormat("[FRIEND]: Got GridIM from {0}, to {1}, imSession {2}, message {3}, dialog {4}", - // msg.fromAgentID, msg.toAgentID, msg.imSessionID, msg.message, msg.dialog); - - if (msg.dialog == (byte)InstantMessageDialog.FriendshipOffered || - msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted || - msg.dialog == (byte)InstantMessageDialog.FriendshipDeclined) - { - // this should succeed as we *know* the root agent is here. - m_TransferModule.SendInstantMessage(msg, - delegate(bool success) { - //m_log.DebugFormat("[FRIEND]: sending IM success = {0}", success); - } - ); - } - - if (msg.dialog == (byte)InstantMessageDialog.FriendshipAccepted) - { - // for accept friendship, we have to do a bit more - ApproveFriendship(new UUID(msg.fromAgentID), new UUID(msg.toAgentID), msg.fromAgentName); - } - } - - private void ApproveFriendship(UUID fromAgentID, UUID toAgentID, string fromName) - { - m_log.DebugFormat("[FRIEND]: Approve friendship from {0} (ID: {1}) to {2}", - fromAgentID, fromName, toAgentID); - - // a new friend was added in the initiator's and friend's data, so the cache entries are wrong now. - lock (m_friendLists) - { - m_friendLists.Invalidate(fromAgentID.ToString()); - m_friendLists.Invalidate(toAgentID.ToString()); - } - - // now send presence update and add a calling card for the new friend - - ScenePresence initiator = GetAnyPresenceFromAgentID(toAgentID); - if (initiator == null) - { - // quite wrong. Shouldn't happen. - m_log.WarnFormat("[FRIEND]: Coudn't find initiator of friend request {0}", toAgentID); - return; - } - - m_log.DebugFormat("[FRIEND]: Tell {0} that {1} is online", - initiator.Name, fromName); - // tell initiator that friend is online - initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID }); - - // find the folder for the friend... - //InventoryFolderImpl folder = - // initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard); - IInventoryService invService = initiator.Scene.InventoryService; - InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard); - if (folder != null) - { - // ... and add the calling card - CreateCallingCard(initiator.ControllingClient, fromAgentID, folder.ID, fromName); - } ->>>>>>> master:OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs - } - public void AddRegion(Scene scene) { } @@ -594,10 +70,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { } - public void Close() - { - } - public string Name { get { return "FriendsModule"; } @@ -608,29 +80,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends get { return null; } } - public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, - string offerMessage) - { - } - public void FindAgent(IClientAPI remoteClient, UUID hunter, UUID target) + public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) { - List friendList = GetUserFriends(hunter); - foreach (FriendListItem item in friendList) - { - if(item.onlinestatus == true) - { - if(item.Friend == target && (item.FriendPerms & (uint)FriendRights.CanSeeOnMap) != 0) - { - ScenePresence SPTarget = ((Scene)remoteClient.Scene).GetScenePresence(target); - string regionname = SPTarget.Scene.RegionInfo.RegionName; - remoteClient.SendScriptTeleportRequest("FindAgent", regionname,new Vector3(SPTarget.AbsolutePosition),new Vector3(SPTarget.Lookat)); - } - } - else - { - remoteClient.SendAgentAlertMessage("The agent you are looking for is not online.", false); - } - } } public List GetUserFriends(UUID agentID) -- cgit v1.1 From 1387919c204eb66ab6a37eb0fdf0f3c38f0a6813 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 20:51:35 -0800 Subject: Yes! First test of new login service done still in 2009! Bombs in auth, because the data migration is missing. Will fix it next year... * HAPPY NEW YEAR! --- .../Resources/CoreModulePlugin.addin.xml | 2 + .../Login/LLLoginServiceInConnectorModule.cs | 125 +++++++++ .../Simulation/LocalSimulationConnector.cs | 298 +++++++++++++++++++++ 3 files changed, 425 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index e4b0fd5..d654d13 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -51,12 +51,14 @@ + \ \ + \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs new file mode 100644 index 0000000..ecb6c91 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs @@ -0,0 +1,125 @@ +/* + * 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.Reflection; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Server.Handlers.Login; +using OpenSim.Services.Interfaces; + + +namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login +{ + public class LLLoginServiceInConnectorModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Enabled = false; + private static bool m_Registered = false; + + private IConfigSource m_Config; + private List m_Scenes = new List(); + + #region IRegionModule interface + + public void Initialise(IConfigSource config) + { + m_Config = config; + + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + m_Enabled = moduleConfig.GetBoolean("LLLoginServiceInConnector", false); + if (m_Enabled) + { + m_log.Info("[LLLOGIN IN CONNECTOR]: LLLoginerviceInConnector enabled"); + } + + } + + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + + m_log.Info("[LLLOGIN IN CONNECTOR]: Starting..."); + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LLLoginServiceInConnectorModule"; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_Scenes.Add(scene); + + } + + public void RemoveRegion(Scene scene) + { + if (m_Enabled && m_Scenes.Contains(scene)) + m_Scenes.Remove(scene); + } + + public void RegionLoaded(Scene scene) + { + if (!m_Registered) + { + m_Registered = true; + new LLLoginServiceInConnector(m_Config, MainServer.Instance, scene); + //Object[] args = new Object[] { m_Config, MainServer.Instance, this, scene }; + //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:LLLoginServiceInConnector", args); + } + + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs new file mode 100644 index 0000000..430cc6e --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -0,0 +1,298 @@ +/* + * 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 log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation +{ + public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private List m_sceneList = new List(); + + + #region IRegionModule + + public void Initialise(IConfigSource config) + { + // This module is always on + m_log.Debug("[LOCAL SIMULATION]: Enabling LocalSimulation module"); + } + + public void PostInitialise() + { + } + + public void AddRegion(Scene scene) + { + } + + public void RemoveRegion(Scene scene) + { + RemoveScene(scene); + } + + public void RegionLoaded(Scene scene) + { + Init(scene); + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalSimulationConnectorModule"; } + } + + /// + /// Can be called from other modules. + /// + /// + public void RemoveScene(Scene scene) + { + lock (m_sceneList) + { + if (m_sceneList.Contains(scene)) + { + m_sceneList.Remove(scene); + } + } + } + + /// + /// Can be called from other modules. + /// + /// + public void Init(Scene scene) + { + if (!m_sceneList.Contains(scene)) + { + lock (m_sceneList) + { + m_sceneList.Add(scene); + scene.RegisterModuleInterface(this); + } + + } + } + + #endregion /* IRegionModule */ + + #region ISimulation + + /** + * Agent-related communications + */ + + public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) + { + + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { +// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); + return s.NewUserConnection(aCircuit, teleportFlags, out reason); + } + } + +// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + reason = "Did not find region " + x + "-" + y; + return false; + } + + public bool UpdateAgent(ulong regionHandle, AgentData cAgentData) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + //m_log.DebugFormat( + // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", + // s.RegionInfo.RegionName, regionHandle); + + s.IncomingChildAgentDataUpdate(cAgentData); + return true; + } + } + +// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); + return false; + } + + public bool UpdateAgent(ulong regionHandle, AgentPosition cAgentData) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); + s.IncomingChildAgentDataUpdate(cAgentData); + return true; + } + } + //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); + return false; + } + + public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) + { + agent = null; + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); + return s.IncomingRetrieveRootAgent(id, out agent); + } + } + //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); + return false; + } + + public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) + { + //uint x, y; + //Utils.LongToUInts(regionHandle, out x, out y); + //x = x / Constants.RegionSize; + //y = y / Constants.RegionSize; + //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); + return s.IncomingReleaseAgent(id); + } + } + //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); + return false; + } + + public bool CloseAgent(ulong regionHandle, UUID id) + { + //uint x, y; + //Utils.LongToUInts(regionHandle, out x, out y); + //x = x / Constants.RegionSize; + //y = y / Constants.RegionSize; + //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); + return s.IncomingCloseAgent(id); + } + } + //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); + return false; + } + + /** + * Object-related communications + */ + + public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); + if (isLocalCall) + { + // We need to make a local copy of the object + ISceneObject sogClone = sog.CloneForNewScene(); + sogClone.SetState(sog.GetStateSnapshot(), s); + return s.IncomingCreateObject(sogClone); + } + else + { + // Use the object as it came through the wire + return s.IncomingCreateObject(sog); + } + } + } + return false; + } + + public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionHandle) + { + return s.IncomingCreateObject(userID, itemID); + } + } + return false; + } + + + #endregion /* IInterregionComms */ + + #region Misc + + public IScene GetScene(ulong regionhandle) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionhandle) + return s; + } + // ? weird. should not happen + return m_sceneList[0]; + } + + public bool IsLocalRegion(ulong regionhandle) + { + foreach (Scene s in m_sceneList) + if (s.RegionInfo.RegionHandle == regionhandle) + return true; + return false; + } + + #endregion + } +} -- cgit v1.1 From 4240f2dec6f7348a99aea0d1b040fca6ea9d493b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 16:54:24 -0800 Subject: New LL login service is working! -- tested in standalone only. Things still missing from response, namely Library and Friends. Appearance service is also missing. --- OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index d654d13..5f5dc02 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -32,6 +32,8 @@ + + -- cgit v1.1 From ec53301e637b479edc00526d3d946814f63a02d1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 18:59:54 -0800 Subject: Forgotten modules in prior commit. --- .../LocalAuthenticationServiceConnector.cs | 159 +++++++++++++++++++++ .../RemoteAuthenticationServiceConnector.cs | 114 +++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs new file mode 100644 index 0000000..4c65722 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs @@ -0,0 +1,159 @@ +/* + * 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 log4net; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication +{ + public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IAuthenticationService m_AuthenticationService; + + private bool m_Enabled = false; + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalAuthenticationServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("AuthenticationServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["AuthenticationService"]; + if (userConfig == null) + { + m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); + return; + } + + string serviceDll = userConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[AUTH CONNECTOR]: No LocalServiceModule named in section AuthenticationService"); + return; + } + + Object[] args = new Object[] { source }; + m_AuthenticationService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_AuthenticationService == null) + { + m_log.Error("[AUTH CONNECTOR]: Can't load Authentication service"); + return; + } + m_Enabled = true; + m_log.Info("[AUTH CONNECTOR]: Local Authentication connector enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(m_AuthenticationService); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + + #endregion + + #region IAuthenticationService + + public string Authenticate(UUID principalID, string password, int lifetime) + { + // Not implemented at the regions + return string.Empty; + } + + public bool Verify(UUID principalID, string token, int lifetime) + { + return m_AuthenticationService.Verify(principalID, token, lifetime); + } + + public bool Release(UUID principalID, string token) + { + return m_AuthenticationService.Release(principalID, token); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs new file mode 100644 index 0000000..a053bc2 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs @@ -0,0 +1,114 @@ +/* + * 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 log4net; +using System.Reflection; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication +{ + public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector, + ISharedRegionModule, IAuthenticationService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteAuthenticationServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("AuthenticationServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["AuthenticationService"]; + if (userConfig == null) + { + m_log.Error("[AUTH CONNECTOR]: AuthenticationService missing from OpenSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[AUTH CONNECTOR]: Remote Authentication enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + } +} -- cgit v1.1 From 8a9677a5319793ff630d0761e204ae8961f375aa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 1 Jan 2010 21:12:46 -0800 Subject: The Library Service is now working. UserProfileCacheService.LibraryRoot is obsolete. Didn't delete it yet to avoid merge conflicts later -- want to stay out of core as much as possible. --- .../CoreModules/Framework/Library/LibraryModule.cs | 33 +++++++++++++++++----- .../Framework/Library/LocalInventoryService.cs | 4 +-- .../World/Permissions/PermissionsModule.cs | 29 +++++++++++++++---- 3 files changed, 51 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 6941e00..f1022fd 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -37,6 +37,7 @@ using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; using OpenMetaverse; using log4net; @@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library private string m_LibraryName = "OpenSim Library"; private Scene m_Scene; + private ILibraryService m_Library; + #region ISharedRegionModule public void Initialise(IConfigSource config) @@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); if (m_Enabled) { - IConfig libConfig = config.Configs["LibraryModule"]; + IConfig libConfig = config.Configs["LibraryService"]; if (libConfig != null) - m_LibraryName = libConfig.GetString("LibraryName", m_LibraryName); + { + string dllName = libConfig.GetString("LocalServiceModule", string.Empty); + m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName); + if (dllName != string.Empty) + { + Object[] args = new Object[] { config }; + m_Library = ServerUtils.LoadPlugin(dllName, args); + } + } + } + if (m_Library == null) + { + m_log.Warn("[LIBRARY MODULE]: No local library service. Module will be disabled."); + m_Enabled = false; } } @@ -91,10 +107,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library { m_Scene = scene; } + scene.RegisterModuleInterface(m_Library); } public void RemoveRegion(Scene scene) { + if (!m_Enabled) + return; + + scene.UnregisterModuleInterface(m_Library); } public void RegionLoaded(Scene scene) @@ -127,19 +148,17 @@ namespace OpenSim.Region.CoreModules.Framework.Library protected void LoadLibrariesFromArchives() { - InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; + InventoryFolderImpl lib = m_Library.LibraryRootFolder; if (lib == null) { m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); return; } - lib.Name = m_LibraryName; - RegionInfo regInfo = new RegionInfo(); Scene m_MockScene = new Scene(regInfo); m_MockScene.CommsManager = m_Scene.CommsManager; - LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib); + LocalInventoryService invService = new LocalInventoryService(lib); m_MockScene.RegisterModuleInterface(invService); m_MockScene.RegisterModuleInterface(m_Scene.AssetService); @@ -181,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library private void DumpLibrary() { - InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; + InventoryFolderImpl lib = m_Library.LibraryRootFolder; m_log.DebugFormat(" - folder {0}", lib.Name); DumpFolder(lib); diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs index 2c95b5a..685c031 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs @@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private LibraryRootFolder m_Library; + private InventoryFolderImpl m_Library; - public LocalInventoryService(LibraryRootFolder lib) + public LocalInventoryService(InventoryFolderImpl lib) { m_Library = lib; } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index c9b3071..91c0a53 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions protected Scene m_scene; + private InventoryFolderImpl m_libraryRootFolder; + protected InventoryFolderImpl LibraryRootFolder + { + get + { + if (m_libraryRootFolder != null) + return m_libraryRootFolder; + + ILibraryService lib = m_scene.RequestModuleInterface(); + if (lib != null) + { + m_libraryRootFolder = lib.LibraryRootFolder; + } + return m_libraryRootFolder; + } + } + #region Constants // These are here for testing. They will be taken out @@ -1005,9 +1022,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions IInventoryService invService = m_scene.InventoryService; InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); assetRequestItem = invService.GetItem(assetRequestItem); - if (assetRequestItem == null) // Library item + if (assetRequestItem == null && LibraryRootFolder != null) // Library item { - assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); + assetRequestItem = LibraryRootFolder.FindItem(notecard); if (assetRequestItem != null) // Implicitly readable return true; @@ -1425,9 +1442,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions IInventoryService invService = m_scene.InventoryService; InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); assetRequestItem = invService.GetItem(assetRequestItem); - if (assetRequestItem == null) // Library item + if (assetRequestItem == null && LibraryRootFolder != null) // Library item { - assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); + assetRequestItem = LibraryRootFolder.FindItem(script); if (assetRequestItem != null) // Implicitly readable return true; @@ -1520,9 +1537,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions IInventoryService invService = m_scene.InventoryService; InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); assetRequestItem = invService.GetItem(assetRequestItem); - if (assetRequestItem == null) // Library item + if (assetRequestItem == null && LibraryRootFolder != null) // Library item { - assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); + assetRequestItem = LibraryRootFolder.FindItem(notecard); if (assetRequestItem != null) // Implicitly readable return true; -- cgit v1.1 From 28702f585f632da43bcee2ca0d4c7a59fe036543 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 2 Jan 2010 15:07:38 -0800 Subject: * Avatar service connectors all in place, but untested. * Fixed a typo in RemoteUserAccountServiceConnector module. --- .../Resources/CoreModulePlugin.addin.xml | 2 + .../Avatar/LocalAvatarServiceConnector.cs | 168 +++++++++++++++++++++ .../Avatar/RemoteAvatarServiceConnector.cs | 114 ++++++++++++++ .../RemoteUserAccountServiceConnector.cs | 6 +- 4 files changed, 287 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 5f5dc02..8b831a5 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -32,6 +32,8 @@ + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs new file mode 100644 index 0000000..0c8ee61 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs @@ -0,0 +1,168 @@ +/* + * 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 log4net; +using Nini.Config; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Server.Base; +using OpenSim.Services.Interfaces; + +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar +{ + public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private IAvatarService m_AvatarService; + + private bool m_Enabled = false; + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "LocalAvatarServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("AvatarServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["AvatarService"]; + if (userConfig == null) + { + m_log.Error("[USER CONNECTOR]: AvatarService missing from OpenSim.ini"); + return; + } + + string serviceDll = userConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section AvatarService"); + return; + } + + Object[] args = new Object[] { source }; + m_AvatarService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_AvatarService == null) + { + m_log.Error("[USER CONNECTOR]: Can't load user account service"); + return; + } + m_Enabled = true; + m_log.Info("[USER CONNECTOR]: Local avatar connector enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(m_AvatarService); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + + #endregion + + #region IAvatarService + + public AvatarData GetAvatar(UUID userID) + { + return m_AvatarService.GetAvatar(userID); + } + + public bool SetAvatar(UUID userID, AvatarData avatar) + { + return m_AvatarService.SetAvatar(userID, avatar); + } + + public bool ResetAvatar(UUID userID) + { + return m_AvatarService.ResetAvatar(userID); + } + + public bool SetItems(UUID userID, string[] names, string[] values) + { + return m_AvatarService.SetItems(userID, names, values); + } + + public bool RemoveItems(UUID userID, string[] names) + { + return m_AvatarService.RemoveItems(userID, names); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs new file mode 100644 index 0000000..48759b5 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs @@ -0,0 +1,114 @@ +/* + * 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 log4net; +using System.Reflection; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar +{ + public class RemoteAvatarServicesConnector : AvatarServicesConnector, + ISharedRegionModule, IAvatarService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteAvatarServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("AvatarServices", ""); + if (name == Name) + { + IConfig userConfig = source.Configs["AvatarService"]; + if (userConfig == null) + { + m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpanSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[AVATAR CONNECTOR]: Remote avatars enabled"); + } + } + } + + public void PostInitialise() + { + if (!m_Enabled) + return; + } + + public void Close() + { + if (!m_Enabled) + return; + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + } + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index d322aba..7d61b20 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -60,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts IConfig moduleConfig = source.Configs["Modules"]; if (moduleConfig != null) { - string name = moduleConfig.GetString("UserServices", ""); + string name = moduleConfig.GetString("UserAccountServices", ""); if (name == Name) { - IConfig userConfig = source.Configs["UserService"]; + IConfig userConfig = source.Configs["UserAccountService"]; if (userConfig == null) { - m_log.Error("[USER CONNECTOR]: UserService missing from OpanSim.ini"); + m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpanSim.ini"); return; } -- cgit v1.1 From c268e342d19b6cc5969b1c1d94f20a3f4eb844ef Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 09:35:12 -0800 Subject: * Changed ISimulation interface to take a GridRegion as input arg instead of a regionHandle. * Added the RemoteSimulationConnectorModule, which is the replacement for RESTComms. Scenes is not using this yet, only (standalone) Login uses these region modules for now. * Completed SimulationServiceConnector and corresponding handlers. --- .../Resources/CoreModulePlugin.addin.xml | 2 + .../SimulationServiceInConnectorModule.cs | 9 +- .../Simulation/LocalSimulationConnector.cs | 129 +++++--- .../Simulation/RemoteSimulationConnector.cs | 356 +++++++++++++++++++++ 4 files changed, 447 insertions(+), 49 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 8b831a5..7b9fdee 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -56,6 +56,7 @@ + @@ -63,6 +64,7 @@ \ \ \ + \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index f28a318..03a5124 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs @@ -58,11 +58,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation IConfig moduleConfig = config.Configs["Modules"]; if (moduleConfig != null) { - string name = moduleConfig.GetString("SimulationService", ""); - if (name == Name) + m_Enabled = moduleConfig.GetBoolean("SimulationServiceInConnector", false); + if (m_Enabled) { - m_Enabled = true; - m_log.Info("[SIM SERVICE]: SimulationService enabled"); + m_log.Info("[SIM SERVICE]: SimulationService IN connector enabled"); } } @@ -84,7 +83,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation public string Name { - get { return "SimulationService"; } + get { return "SimulationServiceInConnectorModule"; } } public void AddRegion(Scene scene) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 430cc6e..074bfb5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -34,6 +34,7 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { @@ -42,13 +43,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private List m_sceneList = new List(); + private bool m_ModuleEnabled = false; #region IRegionModule public void Initialise(IConfigSource config) { - // This module is always on - m_log.Debug("[LOCAL SIMULATION]: Enabling LocalSimulation module"); + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("SimulationServices", ""); + if (name == Name) + { + //IConfig userConfig = config.Configs["SimulationService"]; + //if (userConfig == null) + //{ + // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); + // return; + //} + + m_ModuleEnabled = true; + + m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled"); + } + } } public void PostInitialise() @@ -57,16 +75,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation public void AddRegion(Scene scene) { + if (!m_ModuleEnabled) + return; + + Init(scene); + scene.RegisterModuleInterface(this); } public void RemoveRegion(Scene scene) { + if (!m_ModuleEnabled) + return; + RemoveScene(scene); + scene.UnregisterModuleInterface(this); } public void RegionLoaded(Scene scene) { - Init(scene); } public void Close() @@ -109,7 +135,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation lock (m_sceneList) { m_sceneList.Add(scene); - scene.RegisterModuleInterface(this); } } @@ -119,16 +144,33 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #region ISimulation + public IScene GetScene(ulong regionhandle) + { + foreach (Scene s in m_sceneList) + { + if (s.RegionInfo.RegionHandle == regionhandle) + return s; + } + // ? weird. should not happen + return m_sceneList[0]; + } + /** * Agent-related communications */ - public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) + public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) { + if (destination == null) + { + reason = "Given destination was null"; + m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination"); + return false; + } foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { // m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); return s.NewUserConnection(aCircuit, teleportFlags, out reason); @@ -136,17 +178,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation } // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - reason = "Did not find region " + x + "-" + y; + reason = "Did not find region " + destination.RegionName; return false; } - public bool UpdateAgent(ulong regionHandle, AgentData cAgentData) + public bool UpdateAgent(GridRegion destination, AgentData cAgentData) { + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.DebugFormat( // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", @@ -161,11 +204,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool UpdateAgent(ulong regionHandle, AgentPosition cAgentData) + public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) { + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); s.IncomingChildAgentDataUpdate(cAgentData); @@ -176,12 +222,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) + public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) { agent = null; + + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); return s.IncomingRetrieveRootAgent(id, out agent); @@ -191,16 +241,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) + public bool ReleaseAgent(GridRegion destination, UUID id, string uri) { - //uint x, y; - //Utils.LongToUInts(regionHandle, out x, out y); - //x = x / Constants.RegionSize; - //y = y / Constants.RegionSize; - //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); return s.IncomingReleaseAgent(id); @@ -210,16 +258,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool CloseAgent(ulong regionHandle, UUID id) + public bool CloseAgent(GridRegion destination, UUID id) { - //uint x, y; - //Utils.LongToUInts(regionHandle, out x, out y); - //x = x / Constants.RegionSize; - //y = y / Constants.RegionSize; - //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); return s.IncomingCloseAgent(id); @@ -233,11 +279,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation * Object-related communications */ - public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); if (isLocalCall) @@ -257,11 +306,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) + public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) { + if (destination == null) + return false; + foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == regionHandle) + if (s.RegionInfo.RegionHandle == destination.RegionHandle) { return s.IncomingCreateObject(userID, itemID); } @@ -274,17 +326,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #region Misc - public IScene GetScene(ulong regionhandle) - { - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionhandle) - return s; - } - // ? weird. should not happen - return m_sceneList[0]; - } - public bool IsLocalRegion(ulong regionhandle) { foreach (Scene s in m_sceneList) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs new file mode 100644 index 0000000..b7dc283 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -0,0 +1,356 @@ +/* + * 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; +using System.IO; +using System.Net; +using System.Reflection; +using System.Text; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Framework.Communications.Clients; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Hypergrid; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors.Simulation; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation +{ + public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService + { + private bool initialized = false; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected bool m_enabled = false; + protected Scene m_aScene; + // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module + protected LocalSimulationConnectorModule m_localBackend; + protected SimulationServiceConnector m_remoteConnector; + + protected CommunicationsManager m_commsManager; + + protected IHyperlinkService m_hyperlinkService; + + protected bool m_safemode; + protected IPAddress m_thisIP; + + #region IRegionModule + + public virtual void Initialise(IConfigSource config) + { + + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("SimulationServices", ""); + if (name == Name) + { + //IConfig userConfig = config.Configs["SimulationService"]; + //if (userConfig == null) + //{ + // m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpanSim.ini"); + // return; + //} + + m_remoteConnector = new SimulationServiceConnector(); + + m_enabled = true; + + m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled"); + } + } + } + + public virtual void PostInitialise() + { + } + + public virtual void Close() + { + } + + public void AddRegion(Scene scene) + { + } + + public void RemoveRegion(Scene scene) + { + if (m_enabled) + { + m_localBackend.RemoveScene(scene); + scene.UnregisterModuleInterface(this); + } + } + + public void RegionLoaded(Scene scene) + { + if (m_enabled) + { + if (!initialized) + { + InitOnce(scene); + initialized = true; + } + InitEach(scene); + } + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public virtual string Name + { + get { return "RemoteSimulationConnectorModule"; } + } + + protected virtual void InitEach(Scene scene) + { + m_localBackend.Init(scene); + scene.RegisterModuleInterface(this); + } + + protected virtual void InitOnce(Scene scene) + { + m_localBackend = new LocalSimulationConnectorModule(); + m_commsManager = scene.CommsManager; + m_aScene = scene; + m_hyperlinkService = m_aScene.RequestModuleInterface(); + //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); + m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); + } + + #endregion /* IRegionModule */ + + #region IInterregionComms + + public IScene GetScene(ulong handle) + { + return m_localBackend.GetScene(handle); + } + + /** + * Agent-related communications + */ + + public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) + { + if (destination == null) + { + reason = "Given destination was null"; + m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent was given a null destination"); + return false; + } + + // Try local first + if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, out reason)) + return true; + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + { + //m_regionClient.SendUserInformation(regInfo, aCircuit); + return m_remoteConnector.CreateAgent(destination, aCircuit, teleportFlags, out reason); + } + return false; + } + + public bool UpdateAgent(GridRegion destination, AgentData cAgentData) + { + if (destination == null) + return false; + + // Try local first + if (m_localBackend.UpdateAgent(destination, cAgentData)) + return true; + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_remoteConnector.UpdateAgent(destination, cAgentData); + + return false; + + } + + public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) + { + if (destination == null) + return false; + + // Try local first + if (m_localBackend.UpdateAgent(destination, cAgentData)) + return true; + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_remoteConnector.UpdateAgent(destination, cAgentData); + + return false; + + } + + public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) + { + agent = null; + + if (destination == null) + return false; + + // Try local first + if (m_localBackend.RetrieveAgent(destination, id, out agent)) + return true; + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_remoteConnector.RetrieveAgent(destination, id, out agent); + + return false; + + } + + public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + { + if (destination == null) + return false; + + // Try local first + if (m_localBackend.ReleaseAgent(destination, id, uri)) + return true; + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_remoteConnector.ReleaseAgent(destination, id, uri); + + return false; + } + + + public bool CloseAgent(GridRegion destination, UUID id) + { + if (destination == null) + return false; + + // Try local first + if (m_localBackend.CloseAgent(destination, id)) + return true; + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_remoteConnector.CloseAgent(destination, id); + + return false; + } + + /** + * Object-related communications + */ + + public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) + { + if (destination == null) + return false; + + // Try local first + if (m_localBackend.CreateObject(destination, sog, true)) + { + //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); + return true; + } + + // else do the remote thing + if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) + return m_remoteConnector.CreateObject(destination, sog, isLocalCall); + + return false; + } + + public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) + { + // Not Implemented + return false; + } + + #endregion /* IInterregionComms */ + + + protected class RegionToRegionClient : RegionClient + { + Scene m_aScene = null; + IHyperlinkService m_hyperlinkService; + + public RegionToRegionClient(Scene s, IHyperlinkService hyperService) + { + m_aScene = s; + m_hyperlinkService = hyperService; + } + + public override ulong GetRegionHandle(ulong handle) + { + if (m_aScene.SceneGridService is HGSceneCommunicationService) + { + if (m_hyperlinkService != null) + return m_hyperlinkService.FindRegionHandle(handle); + } + + return handle; + } + + public override bool IsHyperlink(ulong handle) + { + if (m_aScene.SceneGridService is HGSceneCommunicationService) + { + if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) + return true; + } + return false; + } + + public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) + { + if (m_hyperlinkService != null) + m_hyperlinkService.SendUserInformation(regInfo, aCircuit); + + } + + public override void AdjustUserInformation(AgentCircuitData aCircuit) + { + if (m_hyperlinkService != null) + m_hyperlinkService.AdjustUserInformation(aCircuit); + } + } + + } +} -- cgit v1.1 From 99efa99585639c94fdb484681663ac7b6f03538e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 3 Jan 2010 11:44:57 -0800 Subject: Successfully logged into a grid. --- .../Login/LLLoginServiceInConnectorModule.cs | 3 +++ .../SimulationServiceInConnectorModule.cs | 19 +++++++++-------- .../Simulation/RemoteSimulationConnector.cs | 24 +++++++++++++--------- 3 files changed, 28 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs index ecb6c91..2a9366c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs @@ -109,6 +109,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login public void RegionLoaded(Scene scene) { + if (!m_Enabled) + return; + if (!m_Registered) { m_Registered = true; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index 03a5124..5ee1c97 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs @@ -91,6 +91,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation if (!m_Enabled) return; + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + if (!m_Registered) { m_Registered = true; @@ -103,14 +114,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation } } - public void RemoveRegion(Scene scene) - { - } - - public void RegionLoaded(Scene scene) - { - } - #endregion } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index b7dc283..c9cc368 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -103,6 +103,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation public void AddRegion(Scene scene) { + if (!m_enabled) + return; + + if (!initialized) + { + InitOnce(scene); + initialized = true; + } + InitEach(scene); } public void RemoveRegion(Scene scene) @@ -116,15 +125,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation public void RegionLoaded(Scene scene) { - if (m_enabled) - { - if (!initialized) - { - InitOnce(scene); - initialized = true; - } - InitEach(scene); - } + if (!m_enabled) + return; + + m_hyperlinkService = m_aScene.RequestModuleInterface(); + } public Type ReplaceableInterface @@ -148,7 +153,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation m_localBackend = new LocalSimulationConnectorModule(); m_commsManager = scene.CommsManager; m_aScene = scene; - m_hyperlinkService = m_aScene.RequestModuleInterface(); //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); } -- cgit v1.1 From f11a97f12d328af8bb39b92fec5cb5780983b66a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 7 Jan 2010 15:53:55 -0800 Subject: * Finished SimulationServiceConnector * Started rerouting calls to UserService. * Compiles. May run. --- .../Avatar/InstantMessage/MessageTransferModule.cs | 60 ++++++++++++++-------- .../Inventory/Archiver/InventoryArchiverModule.cs | 2 +- .../Avatar/Profiles/AvatarProfilesModule.cs | 43 ++++++++-------- .../RemoteAuthorizationServiceConnector.cs | 6 +-- .../Presence/RemotePresenceServiceConnector.cs | 2 +- .../Simulation/LocalSimulationConnector.cs | 19 ++++--- .../Simulation/RemoteSimulationConnector.cs | 11 ++-- 7 files changed, 83 insertions(+), 60 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 2d4b421..c0d3f31 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -37,6 +37,8 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { @@ -46,10 +48,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private bool m_Enabled = false; protected List m_Scenes = new List(); - protected Dictionary m_UserRegionMap = new Dictionary(); + protected Dictionary m_UserRegionMap = new Dictionary(); public event UndeliveredMessage OnUndeliveredMessage; + private IPresenceService m_PresenceService; + protected IPresenceService PresenceService + { + get + { + if (m_PresenceService == null) + m_PresenceService = m_Scenes[0].RequestModuleInterface(); + return m_PresenceService; + } + } + public virtual void Initialise(IConfigSource config) { IConfig cnf = config.Configs["Messaging"]; @@ -416,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -430,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); } /// @@ -445,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// Pass in 0 the first time this method is called. It will be called recursively with the last /// regionhandle tried /// - protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle) + protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) { UUID toAgentID = new UUID(im.toAgentID); - UserAgentData upd = null; + PresenceInfo upd = null; bool lookupAgent = false; @@ -457,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_UserRegionMap.ContainsKey(toAgentID)) { - upd = new UserAgentData(); - upd.AgentOnline = true; - upd.Handle = m_UserRegionMap[toAgentID]; + upd = new PresenceInfo(); + upd.Online = true; + upd.RegionID = m_UserRegionMap[toAgentID]; // We need to compare the current regionhandle with the previous region handle // or the recursive loop will never end because it will never try to lookup the agent again - if (prevRegionHandle == upd.Handle) + if (prevRegionID == upd.RegionID) { lookupAgent = true; } @@ -479,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (lookupAgent) { // Non-cached user agent lookup. - upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID); + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + if (presences != null) + { + foreach (PresenceInfo p in presences) + if (p.Online) + { + upd = presences[0]; + break; + } + } if (upd != null) { // check if we've tried this before.. // This is one way to end the recursive loop // - if (upd.Handle == prevRegionHandle) + if (upd.RegionID == prevRegionID) { m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); HandleUndeliveredMessage(im, result); @@ -503,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (upd != null) { - if (upd.AgentOnline) + if (upd.Online) { - uint x = 0, y = 0; - Utils.LongToUInts(upd.Handle, out x, out y); - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID, - (int)x, (int)y); + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, + upd.RegionID); if (reginfo != null) { Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); @@ -524,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_UserRegionMap.ContainsKey(toAgentID)) { - m_UserRegionMap[toAgentID] = upd.Handle; + m_UserRegionMap[toAgentID] = upd.RegionID; } else { - m_UserRegionMap.Add(toAgentID, upd.Handle); + m_UserRegionMap.Add(toAgentID, upd.RegionID); } } result(true); @@ -543,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // This is recursive!!!!! SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.Handle); + upd.RegionID); } } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle); + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); HandleUndeliveredMessage(im, result); } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ecd60bd..6da43a8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { - if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) + if (m_aScene.AuthenticationService.Authenticate(userInfo.UserProfile.ID, pass, 1) != string.Empty) { return userInfo; } diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs index 8cf58c6..718ee2f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs @@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void RequestAvatarProperty(IClientAPI remoteClient, UUID avatarID) { // FIXME: finish adding fields such as url, masking, etc. - UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID); + UserProfileData profile = null; // m_scene.CommsManager.UserService.GetUserProfile(avatarID); if (null != profile) { Byte[] charterMember; @@ -143,26 +143,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile) { - UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); - - // if it's the profile of the user requesting the update, then we change only a few things. - if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) - { - Profile.Image = newProfile.Image; - Profile.FirstLifeImage = newProfile.FirstLifeImage; - Profile.AboutText = newProfile.AboutText; - Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; - Profile.ProfileUrl = newProfile.ProfileUrl; - } - else - { - return; - } - - if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) - { - RequestAvatarProperty(remoteClient, newProfile.ID); - } + return; + //UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); + + //// if it's the profile of the user requesting the update, then we change only a few things. + //if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) + //{ + // Profile.Image = newProfile.Image; + // Profile.FirstLifeImage = newProfile.FirstLifeImage; + // Profile.AboutText = newProfile.AboutText; + // Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; + // Profile.ProfileUrl = newProfile.ProfileUrl; + //} + //else + //{ + // return; + //} + + //if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) + //{ + // RequestAvatarProperty(remoteClient, newProfile.ID); + //} } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 68499f3..01a2615 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs @@ -139,9 +139,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization if (scene != null) { - UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID)); - isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName, - profile.Email, scene.RegionInfo.RegionName, regionID, out message); + UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID); + isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, + account.Email, scene.RegionInfo.RegionName, regionID, out message); } else { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index e8e140a..6c69570 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public string Name { - get { return "RemotePresenceServiceConnector"; } + get { return "RemotePresenceServicesConnector"; } } public void Initialise(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 074bfb5..c6c6af0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -172,12 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { -// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); + m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", destination.RegionName); return s.NewUserConnection(aCircuit, teleportFlags, out reason); } } -// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); + m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", destination.RegionName); reason = "Did not find region " + destination.RegionName; return false; } @@ -241,14 +241,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - if (destination == null) - return false; - foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == destination.RegionHandle) + if (s.RegionInfo.RegionID == origin) { //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); return s.IncomingReleaseAgent(id); @@ -334,6 +331,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } + public bool IsLocalRegion(UUID id) + { + foreach (Scene s in m_sceneList) + if (s.RegionInfo.RegionID == id) + return true; + return false; + } + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index c9cc368..f485cd1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -245,18 +245,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - if (destination == null) - return false; - // Try local first - if (m_localBackend.ReleaseAgent(destination, id, uri)) + if (m_localBackend.ReleaseAgent(origin, id, uri)) return true; // else do the remote thing - if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.ReleaseAgent(destination, id, uri); + if (!m_localBackend.IsLocalRegion(origin)) + return m_remoteConnector.ReleaseAgent(origin, id, uri); return false; } -- cgit v1.1 From b63405c1a796b44b58081857d01f726372467628 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 8 Jan 2010 10:43:34 -0800 Subject: Inching ahead... This compiles, but very likely does not run. --- .../InterGrid/OpenGridProtocolModule.cs | 38 ++++++++++++---------- .../Inventory/HGInventoryBroker.cs | 1 - .../Inventory/LocalInventoryServiceConnector.cs | 1 - .../Inventory/RemoteInventoryServiceConnector.cs | 1 - 4 files changed, 20 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index 10a3232..cf7bcef 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs @@ -534,26 +534,28 @@ namespace OpenSim.Region.CoreModules.InterGrid userProfile.WantDoMask = 0; userProfile.WebLoginKey = UUID.Random(); - // Do caps registration - // get seed capagentData.firstname = FirstName;agentData.lastname = LastName; - if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode) - { - homeScene.CommsManager.UserAdminService.AddUser( - agentData.firstname, agentData.lastname, CreateRandomStr(7), "", - homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID); + // !!! REFACTORING PROBLEM. This needs to be changed for 0.7 + // + //// Do caps registration + //// get seed capagentData.firstname = FirstName;agentData.lastname = LastName; + //if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode) + //{ + // homeScene.CommsManager.UserAdminService.AddUser( + // agentData.firstname, agentData.lastname, CreateRandomStr(7), "", + // homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID); - UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID); - if (userProfile2 != null) - { - userProfile = userProfile2; - userProfile.AboutText = "OGP USER"; - userProfile.FirstLifeAboutText = "OGP USER"; - homeScene.CommsManager.UserService.UpdateUserProfile(userProfile); - } - } + // UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID); + // if (userProfile2 != null) + // { + // userProfile = userProfile2; + // userProfile.AboutText = "OGP USER"; + // userProfile.FirstLifeAboutText = "OGP USER"; + // homeScene.CommsManager.UserService.UpdateUserProfile(userProfile); + // } + //} - // Stick our data in the cache so the region will know something about us - homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); + //// Stick our data in the cache so the region will know something about us + //homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); // Call 'new user' event handler string reason; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 1fdf1ef..7584dd8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -161,7 +161,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService; // ugh! m_UserProfileService.SetInventoryService(this); - scene.CommsManager.UserService.SetInventoryService(this); m_Initialized = true; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 66d11dd..f2e344f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -133,7 +133,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { // ugh! scene.CommsManager.UserProfileCacheService.SetInventoryService(this); - scene.CommsManager.UserService.SetInventoryService(this); m_Initialized = true; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 69504df..3580c27 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -116,7 +116,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { // ugh! scene.CommsManager.UserProfileCacheService.SetInventoryService(this); - scene.CommsManager.UserService.SetInventoryService(this); m_Initialized = true; } -- cgit v1.1 From 25fdbd6cbcfc857c444042745d7d4fa8e495a982 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 09:09:32 -0800 Subject: Less refs to UserProfileCacheService. Compiles but likely doesn't run. --- OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | 2 +- .../Inventory/Archiver/InventoryArchiveReadRequest.cs | 2 +- .../Inventory/Archiver/InventoryArchiveWriteRequest.cs | 2 +- .../CoreModules/World/Estate/EstateManagementModule.cs | 15 ++++----------- 4 files changed, 7 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 61b6d65..db94d2a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule } else { - string killer = DeadAvatar.Scene.CommsManager.UUIDNameRequestString(part.OwnerID); + string killer = DeadAvatar.Scene.GetUserName(part.OwnerID); DeadAvatar.ControllingClient.SendAgentAlertMessage("You impaled yourself on " + part.Name + " owned by " + killer +"!", true); } //DeadAvatar.Scene. part.ObjectOwner diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 160a9bd..3417c87 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Don't use the item ID that's in the file item.ID = UUID.Random(); - UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); + UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); if (UUID.Zero != ospResolvedId) { item.CreatorIdAsUuid = ospResolvedId; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 98b686e..8f75983 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); - saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.CommsManager); + saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService); string serialization = UserInventoryItemSerializer.Serialize(saveItem); m_archiveWriter.WriteFile(filename, serialization); diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index b1dcb14..5b82d4c 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -649,16 +649,9 @@ namespace OpenSim.Region.CoreModules.World.Estate lsri.TaskID = sog.UUID; lsri.TaskLocalID = sog.LocalId; lsri.TaskName = sog.GetPartName(obj); - if (m_scene.CommsManager.UUIDNameCachedTest(sog.OwnerID)) - { - lsri.OwnerName = m_scene.CommsManager.UUIDNameRequestString(sog.OwnerID); - } - else - { - lsri.OwnerName = "waiting"; - lock (uuidNameLookupList) - uuidNameLookupList.Add(sog.OwnerID); - } + lsri.OwnerName = "waiting"; + lock (uuidNameLookupList) + uuidNameLookupList.Add(sog.OwnerID); if (filter.Length != 0) { @@ -709,7 +702,7 @@ namespace OpenSim.Region.CoreModules.World.Estate for (int i = 0; i < uuidarr.Length; i++) { // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); - m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); + m_scene.GetUserName(uuidarr[i]); // we drop it. It gets cached though... so we're ready for the next request. } } -- cgit v1.1 From 28d6705358c2e383fb46c57f064de4dcff144e33 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 9 Jan 2010 20:46:32 +0000 Subject: Preliminary work on the new default region setting mechanism --- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 14 ++++++++++++++ .../Grid/LocalGridServiceConnector.cs | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 93cb60c..501f730 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -808,6 +808,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion + public List GetDefaultRegions(UUID scopeID) + { + return null; + } + + public List GetFallbackRegions(UUID scopeID, int x, int y) + { + return null; + } + + public int GetRegionFlags(UUID scopeID, UUID regionID) + { + return 0; + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 1c72488..f0081fc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -250,5 +250,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_log.InfoFormat(" {0} @ {1}={2}", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize); } } + + public List GetDefaultRegions(UUID scopeID) + { + return null; + } + + public List GetFallbackRegions(UUID scopeID, int x, int y) + { + return null; + } + + public int GetRegionFlags(UUID scopeID, UUID regionID) + { + return 0; + } + } } -- cgit v1.1 From 96ecdcf9c5ba35e589a599ad37cc6ce1a83f46f1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 9 Jan 2010 18:04:50 -0800 Subject: * Added SetPassword to IAuthenticationService. * Added create user command to UserAccountService. Works. * Deleted create user command from OpenSim. --- .../Authentication/LocalAuthenticationServiceConnector.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs index 4c65722..acc362b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs @@ -153,6 +153,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication return m_AuthenticationService.Release(principalID, token); } + public bool SetPassword(UUID principalID, string passwd) + { + return m_AuthenticationService.SetPassword(principalID, passwd); + } + #endregion } -- cgit v1.1 From 1e1b2ab221851efc414678b7ea52ef2ca788ce9f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 10:40:07 -0800 Subject: * OMG! All but one references to UserProfileCacheService have been rerouted! * HG is seriously broken here * Compiles. Untested. --- .../Agent/TextureDownload/TextureDownloadModule.cs | 4 +- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 15 +- .../CoreModules/Avatar/Dialog/DialogModule.cs | 9 +- .../Archiver/InventoryArchiveReadRequest.cs | 14 +- .../Archiver/InventoryArchiveWriteRequest.cs | 16 +- .../Inventory/Archiver/InventoryArchiverModule.cs | 57 +- .../Archiver/Tests/InventoryArchiverTests.cs | 956 +++++++++++---------- .../CoreModules/Framework/Library/LibraryModule.cs | 9 +- .../Hypergrid/HGStandaloneLoginModule.cs | 326 ------- .../ServiceConnectorsOut/Asset/HGAssetBroker.cs | 18 +- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 195 +++-- .../Inventory/HGInventoryBroker.cs | 81 +- .../Inventory/LocalInventoryServiceConnector.cs | 2 - .../Inventory/RemoteInventoryServiceConnector.cs | 23 +- .../World/Archiver/ArchiveReadRequest.cs | 5 +- .../World/Permissions/PermissionsModule.cs | 6 +- 16 files changed, 707 insertions(+), 1029 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs index 71ff28c..5809bae 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs @@ -214,8 +214,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload { Scene scene = (Scene)client.Scene; - CachedUserInfo profile = scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); - if (profile == null) // Deny unknown user + ScenePresence sp = scene.GetScenePresence(client.AgentId); + if (sp == null) // Deny unknown user return; IInventoryService invService = scene.InventoryService; diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 35c59aa..884e6a6 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -46,21 +46,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) { - CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId); + AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId); //if ((profile != null) && (profile.RootFolder != null)) - if (profile != null) + if (avatar != null) { - appearance = m_scene.CommsManager.AvatarService.GetUserAppearance(avatarId); - if (appearance != null) - { - //SetAppearanceAssets(profile, ref appearance); - //m_log.DebugFormat("[APPEARANCE]: Found : {0}", appearance.ToString()); - return true; - } + appearance = avatar.ToAvatarAppearance(); + return true; } - appearance = CreateDefault(avatarId); m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId); + appearance = CreateDefault(avatarId); return false; } diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 72ec869..c59992e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -34,6 +34,7 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Dialog { @@ -116,12 +117,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog UUID avatarID, string objectName, UUID objectID, UUID ownerID, string message, UUID textureID, int ch, string[] buttonlabels) { - CachedUserInfo info = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(ownerID); + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); string ownerFirstName, ownerLastName; - if (info != null) + if (account != null) { - ownerFirstName = info.UserProfile.FirstName; - ownerLastName = info.UserProfile.SurName; + ownerFirstName = account.FirstName; + ownerLastName = account.LastName; } else { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 3417c87..706d891 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected TarArchiveReader archive; - private CachedUserInfo m_userInfo; + private UserAccount m_userInfo; private string m_invPath; /// @@ -67,7 +67,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private Stream m_loadStream; public InventoryArchiveReadRequest( - Scene scene, CachedUserInfo userInfo, string invPath, string loadPath) + Scene scene, UserAccount userInfo, string invPath, string loadPath) : this( scene, userInfo, @@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } public InventoryArchiveReadRequest( - Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream) + Scene scene, UserAccount userInfo, string invPath, Stream loadStream) { m_scene = scene; m_userInfo = userInfo; @@ -103,7 +103,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); InventoryFolderBase rootDestinationFolder = InventoryArchiveUtils.FindFolderByPath( - m_scene.InventoryService, m_userInfo.UserProfile.ID, m_invPath); + m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath); if (null == rootDestinationFolder) { @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // even though there is a AssetType.RootCategory destFolder = new InventoryFolderBase( - newFolderId, newFolderName, m_userInfo.UserProfile.ID, + newFolderId, newFolderName, m_userInfo.PrincipalID, (short)AssetType.Unknown, destFolder.ID, 1); m_scene.InventoryService.AddFolder(destFolder); @@ -368,10 +368,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } else { - item.CreatorIdAsUuid = m_userInfo.UserProfile.ID; + item.CreatorIdAsUuid = m_userInfo.PrincipalID; } - item.Owner = m_userInfo.UserProfile.ID; + item.Owner = m_userInfo.PrincipalID; // Reset folder ID to the one in which we want to load it item.Folder = loadFolder.ID; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 8f75983..ab5dafd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -41,6 +41,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Osp; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { @@ -54,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private const string STAR_WILDCARD = "*"; private InventoryArchiverModule m_module; - private CachedUserInfo m_userInfo; + private UserAccount m_userInfo; private string m_invPath; protected TarArchiveWriter m_archiveWriter; protected UuidGatherer m_assetGatherer; @@ -89,7 +90,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public InventoryArchiveWriteRequest( Guid id, InventoryArchiverModule module, Scene scene, - CachedUserInfo userInfo, string invPath, string savePath) + UserAccount userInfo, string invPath, string savePath) : this( id, module, @@ -105,7 +106,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// public InventoryArchiveWriteRequest( Guid id, InventoryArchiverModule module, Scene scene, - CachedUserInfo userInfo, string invPath, Stream saveStream) + UserAccount userInfo, string invPath, Stream saveStream) { m_id = id; m_module = module; @@ -215,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { InventoryFolderBase inventoryFolder = null; InventoryItemBase inventoryItem = null; - InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); + InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); bool foundStar = false; @@ -318,14 +319,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver foreach (UUID creatorId in m_userUuids.Keys) { // Record the creator of this item - CachedUserInfo creator - = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); + UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, creatorId); if (creator != null) { m_archiveWriter.WriteFile( - ArchiveConstants.USERS_PATH + creator.UserProfile.Name + ".xml", - UserProfileSerializer.Serialize(creator.UserProfile)); + ArchiveConstants.USERS_PATH + creator.FirstName + " " + creator.LastName + ".xml", + UserProfileSerializer.Serialize(creator)); } else { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 6da43a8..ea6da8c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Trigger the inventory archive saved event. /// protected internal void TriggerInventoryArchiveSaved( - Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, + Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException) { InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; @@ -125,11 +125,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (m_scenes.Count > 0) { - CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); + UserAccount userInfo = GetUserInfo(firstName, lastName, pass); if (userInfo != null) { - if (CheckPresence(userInfo.UserProfile.ID)) + if (CheckPresence(userInfo.PrincipalID)) { new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); return true; @@ -137,8 +137,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", - userInfo.UserProfile.Name, userInfo.UserProfile.ID); + "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator", + userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); } } } @@ -150,11 +150,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (m_scenes.Count > 0) { - CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); + UserAccount userInfo = GetUserInfo(firstName, lastName, pass); if (userInfo != null) { - if (CheckPresence(userInfo.UserProfile.ID)) + if (CheckPresence(userInfo.PrincipalID)) { new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); return true; @@ -162,8 +162,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", - userInfo.UserProfile.Name, userInfo.UserProfile.ID); + "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator", + userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); } } } @@ -175,11 +175,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (m_scenes.Count > 0) { - CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); + UserAccount userInfo = GetUserInfo(firstName, lastName, pass); if (userInfo != null) { - if (CheckPresence(userInfo.UserProfile.ID)) + if (CheckPresence(userInfo.PrincipalID)) { InventoryArchiveReadRequest request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); @@ -190,8 +190,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", - userInfo.UserProfile.Name, userInfo.UserProfile.ID); + "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator", + userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); } } } @@ -203,11 +203,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (m_scenes.Count > 0) { - CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); + UserAccount userInfo = GetUserInfo(firstName, lastName, pass); if (userInfo != null) { - if (CheckPresence(userInfo.UserProfile.ID)) + if (CheckPresence(userInfo.PrincipalID)) { InventoryArchiveReadRequest request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); @@ -218,8 +218,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", - userInfo.UserProfile.Name, userInfo.UserProfile.ID); + "[INVENTORY ARCHIVER]: User {0} {1} {2} not logged in to this region simulator", + userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); } } } @@ -291,7 +291,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } private void SaveInvConsoleCommandCompleted( - Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, + Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException) { lock (m_pendingConsoleSaves) @@ -304,13 +304,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (succeeded) { - m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0}", userInfo.UserProfile.Name); + m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); } else { m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Archive save for {0} failed - {1}", - userInfo.UserProfile.Name, reportedException.Message); + "[INVENTORY ARCHIVER]: Archive save for {0} {1} failed - {2}", + userInfo.FirstName, userInfo.LastName, reportedException.Message); } } @@ -321,11 +321,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// User password /// - protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass) + protected UserAccount GetUserInfo(string firstName, string lastName, string pass) { - CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); - //m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName); - if (null == userInfo) + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); + if (null == account) { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Failed to find user info for {0} {1}", @@ -335,9 +334,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { - if (m_aScene.AuthenticationService.Authenticate(userInfo.UserProfile.ID, pass, 1) != string.Empty) + if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, pass, 1) != string.Empty) { - return userInfo; + return account; } else { @@ -358,14 +357,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// Notify the client of loaded nodes if they are logged in /// /// Can be empty. In which case, nothing happens - private void UpdateClientWithLoadedNodes(CachedUserInfo userInfo, List loadedNodes) + private void UpdateClientWithLoadedNodes(UserAccount userInfo, List loadedNodes) { if (loadedNodes.Count == 0) return; foreach (Scene scene in m_scenes.Values) { - ScenePresence user = scene.GetScenePresence(userInfo.UserProfile.ID); + ScenePresence user = scene.GetScenePresence(userInfo.PrincipalID); if (user != null && !user.IsChildAgent) { diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index e4dad18..89486fb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests } private void SaveCompleted( - Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, + Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException) { mre.Set(); @@ -76,124 +76,126 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// // Commenting for now! The mock inventory service needs more beef, at least for // GetFolderForType - [Test] - public void TestSaveIarV0_1() - { - TestHelper.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); - - InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); - - Scene scene = SceneSetupHelpers.SetupScene("Inventory"); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); - CommunicationsManager cm = scene.CommsManager; - - // Create user - string userFirstName = "Jock"; - string userLastName = "Stirrup"; - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - - lock (this) - { - UserProfileTestUtils.CreateUserWithInventory( - cm, userFirstName, userLastName, userId, InventoryReceived); - Monitor.Wait(this, 60000); - } - - // Create asset - SceneObjectGroup object1; - SceneObjectPart part1; - { - string partName = "My Little Dog Object"; - UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); - Vector3 groupPosition = new Vector3(10, 20, 30); - Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); - Vector3 offsetPosition = new Vector3(5, 10, 15); - - part1 - = new SceneObjectPart( - ownerId, shape, groupPosition, rotationOffset, offsetPosition); - part1.Name = partName; - - object1 = new SceneObjectGroup(part1); - scene.AddNewSceneObject(object1, false); - } - - UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); - scene.AssetService.Store(asset1); - - // Create item - UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = "My Little Dog"; - item1.AssetID = asset1.FullID; - item1.ID = item1Id; - InventoryFolderBase objsFolder - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); - item1.Folder = objsFolder.ID; - scene.AddInventoryItem(userId, item1); - - MemoryStream archiveWriteStream = new MemoryStream(); - archiverModule.OnInventoryArchiveSaved += SaveCompleted; - - mre.Reset(); - archiverModule.ArchiveInventory( - Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); - mre.WaitOne(60000, false); - - byte[] archive = archiveWriteStream.ToArray(); - MemoryStream archiveReadStream = new MemoryStream(archive); - TarArchiveReader tar = new TarArchiveReader(archiveReadStream); - - //bool gotControlFile = false; - bool gotObject1File = false; - //bool gotObject2File = false; - string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); - string expectedObject1FilePath = string.Format( - "{0}{1}{2}", - ArchiveConstants.INVENTORY_PATH, - InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), - expectedObject1FileName); - - string filePath; - TarArchiveReader.TarEntryType tarEntryType; - - Console.WriteLine("Reading archive"); - - while (tar.ReadEntry(out filePath, out tarEntryType) != null) - { - Console.WriteLine("Got {0}", filePath); - -// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) + // REFACTORING PROBLEM. This needs to be rewritten. + +// [Test] +// public void TestSaveIarV0_1() +// { +// TestHelper.InMethod(); +// //log4net.Config.XmlConfigurator.Configure(); + +// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + +// Scene scene = SceneSetupHelpers.SetupScene("Inventory"); +// SceneSetupHelpers.SetupSceneModules(scene, archiverModule); +// CommunicationsManager cm = scene.CommsManager; + +// // Create user +// string userFirstName = "Jock"; +// string userLastName = "Stirrup"; +// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + +// lock (this) +// { +// UserProfileTestUtils.CreateUserWithInventory( +// cm, userFirstName, userLastName, userId, InventoryReceived); +// Monitor.Wait(this, 60000); +// } + +// // Create asset +// SceneObjectGroup object1; +// SceneObjectPart part1; +// { +// string partName = "My Little Dog Object"; +// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); +// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); +// Vector3 groupPosition = new Vector3(10, 20, 30); +// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); +// Vector3 offsetPosition = new Vector3(5, 10, 15); + +// part1 +// = new SceneObjectPart( +// ownerId, shape, groupPosition, rotationOffset, offsetPosition); +// part1.Name = partName; + +// object1 = new SceneObjectGroup(part1); +// scene.AddNewSceneObject(object1, false); +// } + +// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); +// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); +// scene.AssetService.Store(asset1); + +// // Create item +// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); +// InventoryItemBase item1 = new InventoryItemBase(); +// item1.Name = "My Little Dog"; +// item1.AssetID = asset1.FullID; +// item1.ID = item1Id; +// InventoryFolderBase objsFolder +// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); +// item1.Folder = objsFolder.ID; +// scene.AddInventoryItem(userId, item1); + +// MemoryStream archiveWriteStream = new MemoryStream(); +// archiverModule.OnInventoryArchiveSaved += SaveCompleted; + +// mre.Reset(); +// archiverModule.ArchiveInventory( +// Guid.NewGuid(), userFirstName, userLastName, "Objects", "troll", archiveWriteStream); +// mre.WaitOne(60000, false); + +// byte[] archive = archiveWriteStream.ToArray(); +// MemoryStream archiveReadStream = new MemoryStream(archive); +// TarArchiveReader tar = new TarArchiveReader(archiveReadStream); + +// //bool gotControlFile = false; +// bool gotObject1File = false; +// //bool gotObject2File = false; +// string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); +// string expectedObject1FilePath = string.Format( +// "{0}{1}{2}", +// ArchiveConstants.INVENTORY_PATH, +// InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), +// expectedObject1FileName); + +// string filePath; +// TarArchiveReader.TarEntryType tarEntryType; + +// Console.WriteLine("Reading archive"); + +// while (tar.ReadEntry(out filePath, out tarEntryType) != null) +// { +// Console.WriteLine("Got {0}", filePath); + +//// if (ArchiveConstants.CONTROL_FILE_PATH == filePath) +//// { +//// gotControlFile = true; +//// } + +// if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) // { -// gotControlFile = true; +//// string fileName = filePath.Remove(0, "Objects/".Length); +//// +//// if (fileName.StartsWith(part1.Name)) +//// { +// Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); +// gotObject1File = true; +//// } +//// else if (fileName.StartsWith(part2.Name)) +//// { +//// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); +//// gotObject2File = true; +//// } // } - - if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) - { -// string fileName = filePath.Remove(0, "Objects/".Length); -// -// if (fileName.StartsWith(part1.Name)) -// { - Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); - gotObject1File = true; -// } -// else if (fileName.StartsWith(part2.Name)) -// { -// Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); -// gotObject2File = true; -// } - } - } +// } -// Assert.That(gotControlFile, Is.True, "No control file in archive"); - Assert.That(gotObject1File, Is.True, "No item1 file in archive"); -// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); +//// Assert.That(gotControlFile, Is.True, "No control file in archive"); +// Assert.That(gotObject1File, Is.True, "No item1 file in archive"); +//// Assert.That(gotObject2File, Is.True, "No object2 file in archive"); - // TODO: Test presence of more files and contents of files. - } +// // TODO: Test presence of more files and contents of files. +// } /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where @@ -201,187 +203,189 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// /// This test also does some deeper probing of loading into nested inventory structures - [Test] - public void TestLoadIarV0_1ExistingUsers() - { - TestHelper.InMethod(); - - //log4net.Config.XmlConfigurator.Configure(); - - string userFirstName = "Mr"; - string userLastName = "Tiddles"; - UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555"); - string userItemCreatorFirstName = "Lord"; - string userItemCreatorLastName = "Lucan"; - UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); - - string item1Name = "b.lsl"; - string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random()); - - MemoryStream archiveWriteStream = new MemoryStream(); - TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = item1Name; - item1.AssetID = UUID.Random(); - item1.GroupID = UUID.Random(); - item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); - //item1.CreatorId = userUuid.ToString(); - //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; - item1.Owner = UUID.Zero; - - string item1FileName - = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); - tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); - tar.Close(); - - MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - SerialiserModule serialiserModule = new SerialiserModule(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); - - // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - IUserAdminService userAdminService = scene.CommsManager.UserAdminService; - - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - userAdminService.AddUser( - userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); - userAdminService.AddUser( - userItemCreatorFirstName, userItemCreatorLastName, "hampshire", - String.Empty, 1000, 1000, userItemCreatorUuid); - - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); - - CachedUserInfo userInfo - = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - - InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); - - Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); - -// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the -// UUID, not the OSPA itself. + /// REFACTORING PROBLEM. This needs to be rewritten. +// [Test] +// public void TestLoadIarV0_1ExistingUsers() +// { +// TestHelper.InMethod(); + +// //log4net.Config.XmlConfigurator.Configure(); + +// string userFirstName = "Mr"; +// string userLastName = "Tiddles"; +// UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000555"); +// string userItemCreatorFirstName = "Lord"; +// string userItemCreatorLastName = "Lucan"; +// UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); + +// string item1Name = "b.lsl"; +// string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1Name, UUID.Random()); + +// MemoryStream archiveWriteStream = new MemoryStream(); +// TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); + +// InventoryItemBase item1 = new InventoryItemBase(); +// item1.Name = item1Name; +// item1.AssetID = UUID.Random(); +// item1.GroupID = UUID.Random(); +// item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); +// //item1.CreatorId = userUuid.ToString(); +// //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; +// item1.Owner = UUID.Zero; + +// string item1FileName +// = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); +// tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); +// tar.Close(); + +// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); +// SerialiserModule serialiserModule = new SerialiserModule(); +// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + +// // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene +// Scene scene = SceneSetupHelpers.SetupScene("inventory"); +// IUserAdminService userAdminService = scene.CommsManager.UserAdminService; + +// SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); +// userAdminService.AddUser( +// userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); +// userAdminService.AddUser( +// userItemCreatorFirstName, userItemCreatorLastName, "hampshire", +// String.Empty, 1000, 1000, userItemCreatorUuid); + +// archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); + +// CachedUserInfo userInfo +// = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); + +// InventoryItemBase foundItem1 +// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name); + +// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); + +//// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the +//// UUID, not the OSPA itself. +//// Assert.That( +//// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), +//// "Loaded item non-uuid creator doesn't match original"); // Assert.That( -// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), +// foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), // "Loaded item non-uuid creator doesn't match original"); - Assert.That( - foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()), - "Loaded item non-uuid creator doesn't match original"); - - Assert.That( - foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), - "Loaded item uuid creator doesn't match original"); - Assert.That(foundItem1.Owner, Is.EqualTo(userUuid), - "Loaded item owner doesn't match inventory reciever"); - - // Now try loading to a root child folder - UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA"); - archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); - archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); - - InventoryItemBase foundItem2 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name); - Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); - - // Now try loading to a more deeply nested folder - UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC"); - archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); - archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); - - InventoryItemBase foundItem3 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name); - Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); - } - - [Test] - public void TestIarV0_1WithEscapedChars() - { - TestHelper.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); - - string itemName = "You & you are a mean/man/"; - string humanEscapedItemName = @"You & you are a mean\/man\/"; - string userPassword = "meowfood"; - - InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); - - Scene scene = SceneSetupHelpers.SetupScene("Inventory"); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule); - CommunicationsManager cm = scene.CommsManager; - - // Create user - string userFirstName = "Jock"; - string userLastName = "Stirrup"; - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); - - lock (this) - { - UserProfileTestUtils.CreateUserWithInventory( - cm, userFirstName, userLastName, userPassword, userId, InventoryReceived); - Monitor.Wait(this, 60000); - } - // Create asset - SceneObjectGroup object1; - SceneObjectPart part1; - { - string partName = "part name"; - UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); - PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); - Vector3 groupPosition = new Vector3(10, 20, 30); - Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); - Vector3 offsetPosition = new Vector3(5, 10, 15); - - part1 - = new SceneObjectPart( - ownerId, shape, groupPosition, rotationOffset, offsetPosition); - part1.Name = partName; - - object1 = new SceneObjectGroup(part1); - scene.AddNewSceneObject(object1, false); - } - - UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); - AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); - scene.AssetService.Store(asset1); - - // Create item - UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = itemName; - item1.AssetID = asset1.FullID; - item1.ID = item1Id; - InventoryFolderBase objsFolder - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); - item1.Folder = objsFolder.ID; - scene.AddInventoryItem(userId, item1); - - MemoryStream archiveWriteStream = new MemoryStream(); - archiverModule.OnInventoryArchiveSaved += SaveCompleted; - - mre.Reset(); - archiverModule.ArchiveInventory( - Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); - mre.WaitOne(60000, false); - - // LOAD ITEM - MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - - archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); - - InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath( - scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); - - Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); // Assert.That( -// foundItem1.CreatorId, Is.EqualTo(userUuid), -// "Loaded item non-uuid creator doesn't match that of the loading user"); - Assert.That( - foundItem1.Name, Is.EqualTo(itemName), - "Loaded item name doesn't match saved name"); - } +// foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid), +// "Loaded item uuid creator doesn't match original"); +// Assert.That(foundItem1.Owner, Is.EqualTo(userUuid), +// "Loaded item owner doesn't match inventory reciever"); + +// // Now try loading to a root child folder +// UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA"); +// archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); +// archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); + +// InventoryItemBase foundItem2 +// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xA/" + item1Name); +// Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); + +// // Now try loading to a more deeply nested folder +// UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC"); +// archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); +// archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); + +// InventoryItemBase foundItem3 +// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + item1Name); +// Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); + //} + + // REFACTORING PROBLEM. Needs rewrite. +// [Test] +// public void TestIarV0_1WithEscapedChars() +// { +// TestHelper.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); + +// string itemName = "You & you are a mean/man/"; +// string humanEscapedItemName = @"You & you are a mean\/man\/"; +// string userPassword = "meowfood"; + +// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + +// Scene scene = SceneSetupHelpers.SetupScene("Inventory"); +// SceneSetupHelpers.SetupSceneModules(scene, archiverModule); +// CommunicationsManager cm = scene.CommsManager; + +// // Create user +// string userFirstName = "Jock"; +// string userLastName = "Stirrup"; +// UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); + +// lock (this) +// { +// UserProfileTestUtils.CreateUserWithInventory( +// cm, userFirstName, userLastName, userPassword, userId, InventoryReceived); +// Monitor.Wait(this, 60000); +// } + +// // Create asset +// SceneObjectGroup object1; +// SceneObjectPart part1; +// { +// string partName = "part name"; +// UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); +// PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); +// Vector3 groupPosition = new Vector3(10, 20, 30); +// Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); +// Vector3 offsetPosition = new Vector3(5, 10, 15); + +// part1 +// = new SceneObjectPart( +// ownerId, shape, groupPosition, rotationOffset, offsetPosition); +// part1.Name = partName; + +// object1 = new SceneObjectGroup(part1); +// scene.AddNewSceneObject(object1, false); +// } + +// UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); +// AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); +// scene.AssetService.Store(asset1); + +// // Create item +// UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); +// InventoryItemBase item1 = new InventoryItemBase(); +// item1.Name = itemName; +// item1.AssetID = asset1.FullID; +// item1.ID = item1Id; +// InventoryFolderBase objsFolder +// = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); +// item1.Folder = objsFolder.ID; +// scene.AddInventoryItem(userId, item1); + +// MemoryStream archiveWriteStream = new MemoryStream(); +// archiverModule.OnInventoryArchiveSaved += SaveCompleted; + +// mre.Reset(); +// archiverModule.ArchiveInventory( +// Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); +// mre.WaitOne(60000, false); + +// // LOAD ITEM +// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + +// archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); + +// InventoryItemBase foundItem1 +// = InventoryArchiveUtils.FindItemByPath( +// scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); + +// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); +//// Assert.That( +//// foundItem1.CreatorId, Is.EqualTo(userUuid), +//// "Loaded item non-uuid creator doesn't match that of the loading user"); +// Assert.That( +// foundItem1.Name, Is.EqualTo(itemName), +// "Loaded item name doesn't match saved name"); +// } /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where @@ -390,199 +394,203 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests /// /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature /// (as tested in the a later commented out test) - [Test] - public void TestLoadIarV0_1AbsentUsers() - { - TestHelper.InMethod(); - - //log4net.Config.XmlConfigurator.Configure(); - - string userFirstName = "Charlie"; - string userLastName = "Chan"; - UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); - string userItemCreatorFirstName = "Bat"; - string userItemCreatorLastName = "Man"; - //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); - - string itemName = "b.lsl"; - string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); - - MemoryStream archiveWriteStream = new MemoryStream(); - TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = itemName; - item1.AssetID = UUID.Random(); - item1.GroupID = UUID.Random(); - item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); - //item1.CreatorId = userUuid.ToString(); - //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; - item1.Owner = UUID.Zero; - - string item1FileName - = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); - tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); - tar.Close(); - - MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - SerialiserModule serialiserModule = new SerialiserModule(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); - - // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - IUserAdminService userAdminService = scene.CommsManager.UserAdminService; - - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - userAdminService.AddUser( - userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); - - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); - - CachedUserInfo userInfo - = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - - InventoryItemBase foundItem1 - = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); - - Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); + /// REFACTORING PROBLEM. Needs rewrite. +// [Test] +// public void TestLoadIarV0_1AbsentUsers() +// { +// TestHelper.InMethod(); + +// //log4net.Config.XmlConfigurator.Configure(); + +// string userFirstName = "Charlie"; +// string userLastName = "Chan"; +// UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); +// string userItemCreatorFirstName = "Bat"; +// string userItemCreatorLastName = "Man"; +// //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); + +// string itemName = "b.lsl"; +// string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); + +// MemoryStream archiveWriteStream = new MemoryStream(); +// TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); + +// InventoryItemBase item1 = new InventoryItemBase(); +// item1.Name = itemName; +// item1.AssetID = UUID.Random(); +// item1.GroupID = UUID.Random(); +// item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); +// //item1.CreatorId = userUuid.ToString(); +// //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; +// item1.Owner = UUID.Zero; + +// string item1FileName +// = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); +// tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); +// tar.Close(); + +// MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); +// SerialiserModule serialiserModule = new SerialiserModule(); +// InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + +// // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene +// Scene scene = SceneSetupHelpers.SetupScene("inventory"); +// IUserAdminService userAdminService = scene.CommsManager.UserAdminService; + +// SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); +// userAdminService.AddUser( +// userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); + +// archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); + +// CachedUserInfo userInfo +// = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); + +// InventoryItemBase foundItem1 +// = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); + +// Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); +//// Assert.That( +//// foundItem1.CreatorId, Is.EqualTo(userUuid), +//// "Loaded item non-uuid creator doesn't match that of the loading user"); // Assert.That( -// foundItem1.CreatorId, Is.EqualTo(userUuid), -// "Loaded item non-uuid creator doesn't match that of the loading user"); - Assert.That( - foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), - "Loaded item uuid creator doesn't match that of the loading user"); - } +// foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), +// "Loaded item uuid creator doesn't match that of the loading user"); +// } /// /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where /// no account exists with the creator name /// /// Disabled since temporary profiles have not yet been implemented. + /// REFACTORING PROBLEM. Needs rewrite. + /// //[Test] - public void TestLoadIarV0_1TempProfiles() - { - TestHelper.InMethod(); - - //log4net.Config.XmlConfigurator.Configure(); - - string userFirstName = "Dennis"; - string userLastName = "Menace"; - UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); - string user2FirstName = "Walter"; - string user2LastName = "Mitty"; - - string itemName = "b.lsl"; - string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); - - MemoryStream archiveWriteStream = new MemoryStream(); - TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - - InventoryItemBase item1 = new InventoryItemBase(); - item1.Name = itemName; - item1.AssetID = UUID.Random(); - item1.GroupID = UUID.Random(); - item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); - item1.Owner = UUID.Zero; - - string item1FileName - = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); - tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); - tar.Close(); - - MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); - SerialiserModule serialiserModule = new SerialiserModule(); - InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); - - // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene - Scene scene = SceneSetupHelpers.SetupScene(); - IUserAdminService userAdminService = scene.CommsManager.UserAdminService; - - SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); - userAdminService.AddUser( - userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); - - archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); - - // Check that a suitable temporary user profile has been created. - UserProfileData user2Profile - = scene.CommsManager.UserService.GetUserProfile( - OspResolver.HashName(user2FirstName + " " + user2LastName)); - Assert.That(user2Profile, Is.Not.Null); - Assert.That(user2Profile.FirstName == user2FirstName); - Assert.That(user2Profile.SurName == user2LastName); - - CachedUserInfo userInfo - = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); - userInfo.OnInventoryReceived += InventoryReceived; - - lock (this) - { - userInfo.FetchInventory(); - Monitor.Wait(this, 60000); - } - - InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); - - Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); - Assert.That( - foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); - Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); - - Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); - } + //public void TestLoadIarV0_1TempProfiles() + //{ + // TestHelper.InMethod(); + + // //log4net.Config.XmlConfigurator.Configure(); + + // string userFirstName = "Dennis"; + // string userLastName = "Menace"; + // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); + // string user2FirstName = "Walter"; + // string user2LastName = "Mitty"; + + // string itemName = "b.lsl"; + // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); + + // MemoryStream archiveWriteStream = new MemoryStream(); + // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); + + // InventoryItemBase item1 = new InventoryItemBase(); + // item1.Name = itemName; + // item1.AssetID = UUID.Random(); + // item1.GroupID = UUID.Random(); + // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); + // item1.Owner = UUID.Zero; + + // string item1FileName + // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); + // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); + // tar.Close(); + + // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); + // SerialiserModule serialiserModule = new SerialiserModule(); + // InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); + + // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene + // Scene scene = SceneSetupHelpers.SetupScene(); + // IUserAdminService userAdminService = scene.CommsManager.UserAdminService; + + // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); + // userAdminService.AddUser( + // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); + + // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); + + // // Check that a suitable temporary user profile has been created. + // UserProfileData user2Profile + // = scene.CommsManager.UserService.GetUserProfile( + // OspResolver.HashName(user2FirstName + " " + user2LastName)); + // Assert.That(user2Profile, Is.Not.Null); + // Assert.That(user2Profile.FirstName == user2FirstName); + // Assert.That(user2Profile.SurName == user2LastName); + + // CachedUserInfo userInfo + // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); + // userInfo.OnInventoryReceived += InventoryReceived; + + // lock (this) + // { + // userInfo.FetchInventory(); + // Monitor.Wait(this, 60000); + // } + + // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); + + // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); + // Assert.That( + // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); + // Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); + + // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); + //} /// /// Test replication of an archive path to the user's inventory. /// - [Test] - public void TestReplicateArchivePathToUserInventory() - { - TestHelper.InMethod(); - - //log4net.Config.XmlConfigurator.Configure(); - - Scene scene = SceneSetupHelpers.SetupScene("inventory"); - CommunicationsManager commsManager = scene.CommsManager; - CachedUserInfo userInfo; - - lock (this) - { - userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); - Monitor.Wait(this, 60000); - } - - //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); - - Dictionary foldersCreated = new Dictionary(); - List nodesLoaded = new List(); - - string folder1Name = "a"; - string folder2Name = "b"; - string itemName = "c.lsl"; - - string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); - string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); - string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); - - string itemArchivePath - = string.Format( - "{0}{1}{2}{3}", - ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); - - //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); - - new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) - .ReplicateArchivePathToUserInventory( - itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), - foldersCreated, nodesLoaded); - - //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); - //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); - InventoryFolderBase folder1 - = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); - Assert.That(folder1, Is.Not.Null, "Could not find folder a"); - InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); - Assert.That(folder2, Is.Not.Null, "Could not find folder b"); - } + //[Test] + //public void TestReplicateArchivePathToUserInventory() + //{ + // TestHelper.InMethod(); + + // //log4net.Config.XmlConfigurator.Configure(); + + // Scene scene = SceneSetupHelpers.SetupScene("inventory"); + // CommunicationsManager commsManager = scene.CommsManager; + // CachedUserInfo userInfo; + + // lock (this) + // { + // // !!! REFACTORING PROBLEM. This needs to be rewritten + // userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); + // Monitor.Wait(this, 60000); + // } + + // //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); + + // Dictionary foldersCreated = new Dictionary(); + // List nodesLoaded = new List(); + + // string folder1Name = "a"; + // string folder2Name = "b"; + // string itemName = "c.lsl"; + + // string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); + // string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); + // string itemArchiveName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); + + // string itemArchivePath + // = string.Format( + // "{0}{1}{2}{3}", + // ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); + + // //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); + + // new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) + // .ReplicateArchivePathToUserInventory( + // itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), + // foldersCreated, nodesLoaded); + + // //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); + // //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); + // InventoryFolderBase folder1 + // = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); + // Assert.That(folder1, Is.Not.Null, "Could not find folder a"); + // InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); + // Assert.That(folder2, Is.Not.Null, "Could not find folder b"); + //} } } diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index f1022fd..cc5b0e4 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -162,11 +162,10 @@ namespace OpenSim.Region.CoreModules.Framework.Library m_MockScene.RegisterModuleInterface(invService); m_MockScene.RegisterModuleInterface(m_Scene.AssetService); - UserProfileData profile = new UserProfileData(); - profile.FirstName = "OpenSim"; - profile.ID = lib.Owner; - profile.SurName = "Library"; - CachedUserInfo uinfo = new CachedUserInfo(invService, profile); + UserAccount uinfo = new UserAccount(lib.Owner); + uinfo.FirstName = "OpenSim"; + uinfo.LastName = "Library"; + uinfo.ServiceURLs = new Dictionary(); foreach (string iarFileName in Directory.GetFiles(pathToLibraries, "*.iar")) { diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs deleted file mode 100644 index 46ee3c0..0000000 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs +++ /dev/null @@ -1,326 +0,0 @@ -/* - * 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; -using System.Collections.Generic; -using System.Net; -using System.Reflection; -using System.Text.RegularExpressions; -using log4net; -using Nini.Config; -using OpenMetaverse; -using Nwc.XmlRpc; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Services; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Capabilities; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; - -namespace OpenSim.Region.CoreModules.Hypergrid -{ - public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected List m_scenes = new List(); - protected Scene m_firstScene; - - protected bool m_enabled = false; // Module is only enabled if running in standalone mode - - public bool RegionLoginsEnabled - { - get - { - if (m_firstScene != null) - { - return m_firstScene.SceneGridService.RegionLoginsEnabled; - } - else - { - return false; - } - } - } - - protected HGLoginAuthService m_loginService; - - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource source) - { - if (m_firstScene == null) - { - m_firstScene = scene; - - IConfig startupConfig = source.Configs["Startup"]; - if (startupConfig != null) - { - m_enabled = !startupConfig.GetBoolean("gridmode", false); - } - - if (m_enabled) - { - m_log.Debug("[HGLogin]: HGlogin module enabled"); - bool authenticate = true; - string welcomeMessage = "Welcome to OpenSim"; - IConfig standaloneConfig = source.Configs["StandAlone"]; - if (standaloneConfig != null) - { - authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true); - welcomeMessage = standaloneConfig.GetString("welcome_message"); - } - - //TODO: fix casting. - LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder; - - IHttpServer httpServer = MainServer.Instance; - - //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference - m_loginService - = new HGLoginAuthService( - (UserManagerBase)m_firstScene.CommsManager.UserAdminService, - welcomeMessage, - m_firstScene.CommsManager.InterServiceInventoryService, - m_firstScene.CommsManager.NetworkServersInfo, - authenticate, - rootFolder, - this); - - httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod); - httpServer.AddXmlRPCHandler("check_auth_session", m_loginService.XmlRPCCheckAuthSession, false); - httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance); - httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance); - - } - } - - if (m_enabled) - { - AddScene(scene); - } - } - - public void PostInitialise() - { - - } - - public void Close() - { - - } - - public string Name - { - get { return "HGStandaloneLoginModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - protected void AddScene(Scene scene) - { - lock (m_scenes) - { - if (!m_scenes.Contains(scene)) - { - m_scenes.Add(scene); - } - } - } - - public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason) - { - reason = String.Empty; - return true; - } - - public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message) - { - Scene scene; - if (TryGetRegion(regionHandle, out scene)) - { - scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message); - } - } - - public RegionInfo RequestNeighbourInfo(ulong regionhandle) - { - Scene scene; - if (TryGetRegion(regionhandle, out scene)) - { - return scene.RegionInfo; - } - return null; - } - - public RegionInfo RequestClosestRegion(string region) - { - Scene scene; - if (TryGetRegion(region, out scene)) - { - return scene.RegionInfo; - } - else if (m_scenes.Count > 0) - { - return m_scenes[0].RegionInfo; - } - return null; - } - - public RegionInfo RequestNeighbourInfo(UUID regionID) - { - Scene scene; - if (TryGetRegion(regionID, out scene)) - { - return scene.RegionInfo; - } - return null; - } - - protected bool TryGetRegion(ulong regionHandle, out Scene scene) - { - lock (m_scenes) - { - foreach (Scene nextScene in m_scenes) - { - if (nextScene.RegionInfo.RegionHandle == regionHandle) - { - scene = nextScene; - return true; - } - } - } - - scene = null; - return false; - } - - protected bool TryGetRegion(UUID regionID, out Scene scene) - { - lock (m_scenes) - { - foreach (Scene nextScene in m_scenes) - { - if (nextScene.RegionInfo.RegionID == regionID) - { - scene = nextScene; - return true; - } - } - } - - scene = null; - return false; - } - - protected bool TryGetRegion(string regionName, out Scene scene) - { - lock (m_scenes) - { - foreach (Scene nextScene in m_scenes) - { - if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase)) - { - scene = nextScene; - return true; - } - } - } - - scene = null; - return false; - } - - public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - AvatarAppearance appearance; - Hashtable responseData; - if (requestData.Contains("owner")) - { - appearance = m_firstScene.CommsManager.AvatarService.GetUserAppearance(new UUID((string)requestData["owner"])); - if (appearance == null) - { - responseData = new Hashtable(); - responseData["error_type"] = "no appearance"; - responseData["error_desc"] = "There was no appearance found for this avatar"; - } - else - { - responseData = appearance.ToHashTable(); - } - } - else - { - responseData = new Hashtable(); - responseData["error_type"] = "unknown_avatar"; - responseData["error_desc"] = "The avatar appearance requested is not in the database"; - } - - response.Value = responseData; - return response; - } - - public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient) - { - XmlRpcResponse response = new XmlRpcResponse(); - Hashtable requestData = (Hashtable)request.Params[0]; - Hashtable responseData; - if (requestData.Contains("owner")) - { - AvatarAppearance appearance = new AvatarAppearance(requestData); - - // TODO: Sometime in the future we may have a database layer that is capable of updating appearance when - // the TextureEntry is null. When that happens, this check can be removed - if (appearance.Texture != null) - m_firstScene.CommsManager.AvatarService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance); - - responseData = new Hashtable(); - responseData["returnString"] = "TRUE"; - } - else - { - responseData = new Hashtable(); - responseData["error_type"] = "unknown_avatar"; - responseData["error_desc"] = "The avatar appearance requested is not in the database"; - } - response.Value = responseData; - return response; - } - } - -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 0aa753d..044764b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -366,18 +366,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset public string GetUserAssetServer(UUID userID) { - CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); - if ((uinfo != null) && (uinfo.UserProfile != null)) - { - if ((uinfo.UserProfile.UserAssetURI == string.Empty) || (uinfo.UserProfile.UserAssetURI == "")) - return m_LocalAssetServiceURI; - return uinfo.UserProfile.UserAssetURI.Trim('/'); - } - else - { - // we don't know anyting about this user - return string.Empty; - } + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); + + if (account != null && account.ServiceURLs.ContainsKey("AssetServerURI") && account.ServiceURLs["AssetServerURI"] != null) + return account.ServiceURLs["AssetServerURI"].ToString(); + + return string.Empty; } public string GetSimAssetServer() diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 501f730..3c1f7b6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -38,6 +38,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; using OpenSim.Server.Base; using OpenSim.Services.Connectors.Grid; using OpenSim.Framework.Console; @@ -603,93 +604,105 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) { - CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); + // REFACTORING PROBLEM. This needs to change. Some of this info should go with the agent circuit data. - if (uinfo == null) - return false; - - if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || - (!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo))) - { - m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); - - // Set the position of the region on the remote grid -// ulong realHandle = FindRegionHandle(regInfo.RegionHandle); - uint x = 0, y = 0; - Utils.LongToUInts(regInfo.RegionHandle, out x, out y); - GridRegion clonedRegion = new GridRegion(regInfo); - clonedRegion.RegionLocX = (int)x; - clonedRegion.RegionLocY = (int)y; - - // Get the user's home region information and adapt the region handle - GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, uinfo.UserProfile.HomeRegionID); - if (m_HyperlinkHandles.ContainsKey(uinfo.UserProfile.HomeRegionID)) - { - ulong realHandle = m_HyperlinkHandles[uinfo.UserProfile.HomeRegionID]; - Utils.LongToUInts(realHandle, out x, out y); - m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y); - home.RegionLocX = (int)x; - home.RegionLocY = (int)y; - } + //UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, agentData.AgentID); + //if (account == null) + // return false; - // Get the user's service URLs - string serverURI = ""; - if (uinfo.UserProfile is ForeignUserProfileData) - serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); - string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI; - - string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI); - if ((assetServer == null) || (assetServer == "")) - assetServer = LocalAssetServerURI; - - string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); - if ((inventoryServer == null) || (inventoryServer == "")) - inventoryServer = LocalInventoryServerURI; - - if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer)) - { - m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); - return false; - } - } - //if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) + //if ((IsLocalUser(account) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || + // (!IsLocalUser(account) && !IsGoingHome(uinfo, regInfo))) //{ - // m_log.Info("[HGrid]: User seems to be going to foreign region."); - // if (!InformRegionOfUser(regInfo, agentData)) + // m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); + + // PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(agentData.SessionID); + // if (pinfo != null) + // { + // // Set the position of the region on the remote grid + // // ulong realHandle = FindRegionHandle(regInfo.RegionHandle); + // uint x = 0, y = 0; + // Utils.LongToUInts(regInfo.RegionHandle, out x, out y); + // GridRegion clonedRegion = new GridRegion(regInfo); + // clonedRegion.RegionLocX = (int)x; + // clonedRegion.RegionLocY = (int)y; + + // // Get the user's home region information and adapt the region handle + // GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, pinfo.HomeRegionID); + // if (m_HyperlinkHandles.ContainsKey(pinfo.HomeRegionID)) + // { + // ulong realHandle = m_HyperlinkHandles[pinfo.HomeRegionID]; + // Utils.LongToUInts(realHandle, out x, out y); + // m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y); + // home.RegionLocX = (int)x; + // home.RegionLocY = (int)y; + // } + + // // Get the user's service URLs + // string serverURI = ""; + // if (uinfo.UserProfile is ForeignUserProfileData) + // serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); + // string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI; + + // string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI); + // if ((assetServer == null) || (assetServer == "")) + // assetServer = LocalAssetServerURI; + + // string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); + // if ((inventoryServer == null) || (inventoryServer == "")) + // inventoryServer = LocalInventoryServerURI; + + // if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer)) + // { + // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); + // return false; + // } + // } + // else // { - // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); + // m_log.Warn("[HGrid]: Unable to find local presence of transferring user."); // return false; // } //} - //else - // m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); - - // May need to change agent's name - if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) - { - agentData.firstname = agentData.firstname + "." + agentData.lastname; - agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; - } + ////if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) + ////{ + //// m_log.Info("[HGrid]: User seems to be going to foreign region."); + //// if (!InformRegionOfUser(regInfo, agentData)) + //// { + //// m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); + //// return false; + //// } + ////} + ////else + //// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); + + //// May need to change agent's name + //if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) + //{ + // agentData.firstname = agentData.firstname + "." + agentData.lastname; + // agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; + //} return true; } public void AdjustUserInformation(AgentCircuitData agentData) { - CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); - if ((uinfo != null) && (uinfo.UserProfile != null) && - (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) - { - //m_log.Debug("---------------> Local User!"); - string[] parts = agentData.firstname.Split(new char[] { '.' }); - if (parts.Length == 2) - { - agentData.firstname = parts[0]; - agentData.lastname = parts[1]; - } - } - //else - // m_log.Debug("---------------> Foreign User!"); + // REFACTORING PROBLEM!!! This needs to change + + //CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); + //if ((uinfo != null) && (uinfo.UserProfile != null) && + // (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) + //{ + // //m_log.Debug("---------------> Local User!"); + // string[] parts = agentData.firstname.Split(new char[] { '.' }); + // if (parts.Length == 2) + // { + // agentData.firstname = parts[0]; + // agentData.lastname = parts[1]; + // } + //} + ////else + //// m_log.Debug("---------------> Foreign User!"); } // Check if a local user exists with the same UUID as the incoming foreign user @@ -699,16 +712,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (!m_aScene.SceneGridService.RegionLoginsEnabled) return false; - CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); - if (uinfo != null) + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); + if (account != null) { - // uh-oh we have a potential intruder - if (uinfo.SessionID != sessionID) - // can't have a foreigner with a local UUID - return false; - else + if (m_aScene.AuthenticationService.Verify(userID, sessionID.ToString(), 30)) + { // oh, so it's you! welcome back comingHome = true; + } + else + // can't have a foreigner with a local UUID + return false; } // OK, user can come in @@ -717,7 +731,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void AcceptUser(ForeignUserProfileData user, GridRegion home) { - m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); + // REFACTORING PROBLEM. uh-oh, commenting this breaks HG completely + // Needs to be rewritten + //m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); + ulong realHandle = home.RegionHandle; // Change the local coordinates // X=0 on the map @@ -733,8 +750,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public bool IsLocalUser(UUID userID) { - CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(userID); - return IsLocalUser(uinfo); + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); + return IsLocalUser(account); } #endregion @@ -767,13 +784,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); } - protected bool IsLocalUser(CachedUserInfo uinfo) + protected bool IsLocalUser(UserAccount account) { - if (uinfo == null) - return false; + if (account != null && + account.ServiceURLs.ContainsKey("HomeURI") && + account.ServiceURLs["HomeURI"] != null) - return !(uinfo.UserProfile is ForeignUserProfileData); + return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI); + return false; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 7584dd8..5ed2b7a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private bool m_Enabled = false; private bool m_Initialized = false; private Scene m_Scene; - private UserProfileCacheService m_UserProfileService; // This should change to IUserProfileService + private IUserAccountService m_UserAccountService; // This should change to IUserProfileService private IInventoryService m_GridService; private ISessionAuthInventoryService m_HGService; @@ -157,10 +157,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!m_Initialized) { m_Scene = scene; - // HACK for now. Ugh! - m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService; - // ugh! - m_UserProfileService.SetInventoryService(this); + m_UserAccountService = m_Scene.UserAccountService; m_Initialized = true; } @@ -514,58 +511,66 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private UUID GetSessionID(UUID userID) { - CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); - if (uinfo != null) - return uinfo.SessionID; + ScenePresence sp = null; + if (m_Scene.TryGetAvatar(userID, out sp)) + { + return sp.ControllingClient.SessionId; + } - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user profile for {0} not found", userID); + m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scene presence for {0} not found", userID); return UUID.Zero; } private bool IsLocalGridUser(UUID userID) { - if (m_UserProfileService == null) - { - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no profile service. Returning false."); - return false; - } + return true; - CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); - if (uinfo == null) - { - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no profile for user {0}. Returning true.", userID); - return true; - } + // REFACTORING PROBLEM. This needs to be rewritten - if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == "")) - // this happens in standalone profiles, apparently - return true; + //if (m_UserAccountService == null) + //{ + // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no user account service. Returning false."); + // return false; + //} + + //UserAccount uinfo = m_UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + //if (uinfo == null) + //{ + // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no account for user {0}. Returning false.", userID); + // return false; + //} + + //if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == "")) + // // this happens in standalone profiles, apparently + // return true; - string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); + //string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); - string uri = LocalGridInventory.TrimEnd('/'); + //string uri = LocalGridInventory.TrimEnd('/'); - if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) - { - return true; - } - m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user {0} is foreign({1} - {2})", userID, userInventoryServerURI, uri); - return false; + //if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) + //{ + // return true; + //} + //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user {0} is foreign({1} - {2})", userID, userInventoryServerURI, uri); + //return false; } private string GetUserInventoryURI(UUID userID) { string invURI = LocalGridInventory; + // REFACTORING PROBLEM!!! This needs to be rewritten + + //CachedUserInfo uinfo = m_UserAccountService.GetUserDetails(userID); + //if ((uinfo == null) || (uinfo.UserProfile == null)) + // return invURI; - CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); - if ((uinfo == null) || (uinfo.UserProfile == null)) - return invURI; + //string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); - string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); + //if ((userInventoryServerURI != null) && + // (userInventoryServerURI != "")) + // invURI = userInventoryServerURI; - if ((userInventoryServerURI != null) && - (userInventoryServerURI != "")) - invURI = userInventoryServerURI; return invURI; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index f2e344f..9d6da4f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -131,8 +131,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!m_Initialized) { - // ugh! - scene.CommsManager.UserProfileCacheService.SetInventoryService(this); m_Initialized = true; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 3580c27..575a190 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -49,7 +49,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private bool m_Enabled = false; private bool m_Initialized = false; private Scene m_Scene; - private UserProfileCacheService m_UserProfileService; private InventoryServicesConnector m_RemoteConnector; public Type ReplaceableInterface @@ -114,8 +113,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!m_Initialized) { - // ugh! - scene.CommsManager.UserProfileCacheService.SetInventoryService(this); m_Initialized = true; } @@ -133,10 +130,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public void RegionLoaded(Scene scene) { - m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService; - if (m_UserProfileService != null) - m_log.Debug("[XXXX] Set m_UserProfileService in " + m_Scene.RegionInfo.RegionName); - if (!m_Enabled) return; @@ -344,21 +337,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private UUID GetSessionID(UUID userID) { - //if (m_Scene == null) - //{ - // m_log.Debug("[INVENTORY CONNECTOR]: OOPS! scene is null"); - //} - - if (m_UserProfileService == null) + ScenePresence sp = null; + if (m_Scene.TryGetAvatar(userID, out sp)) { - //m_log.Debug("[INVENTORY CONNECTOR]: OOPS! UserProfileCacheService is null"); - return UUID.Zero; + return sp.ControllingClient.SessionId; } - CachedUserInfo uinfo = m_UserProfileService.GetUserDetails(userID); - if (uinfo != null) - return uinfo.SessionID; - m_log.DebugFormat("[INVENTORY CONNECTOR]: user profile for {0} not found", userID); + m_log.DebugFormat("[INVENTORY CONNECTOR]: scene presence for {0} not found", userID); return UUID.Zero; } diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 52add23..4c43389 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -42,6 +42,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.World.Archiver { @@ -292,8 +293,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver { if (!m_validUserUuids.ContainsKey(uuid)) { - CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(uuid); - if (profile != null && profile.UserProfile != null) + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); + if (account != null) m_validUserUuids.Add(uuid, true); else m_validUserUuids.Add(uuid, false); diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index ae3dc2e..aaebd00 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -491,10 +491,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (m_allowGridGods) { - CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(user); - if (profile != null && profile.UserProfile != null) + UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, user); + if (account != null) { - if (profile.UserProfile.GodLevel >= 200) + if (account.UserLevel >= 200) return true; } } -- cgit v1.1 From 3c90d834eac382af5edf091e83aea1ffcce91792 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 22:41:42 +0000 Subject: Remove all references to master avatar, replacing with estate owner where appropriate. This changes the behavior of the REST plugins and RemoteAdmin's region creation process. --- .../CoreModules/World/Archiver/ArchiveReadRequest.cs | 16 ++++++---------- .../CoreModules/World/Estate/EstateManagementModule.cs | 18 ++---------------- .../CoreModules/World/Land/LandManagementModule.cs | 15 +++------------ .../CoreModules/World/Permissions/PermissionsModule.cs | 6 ------ 4 files changed, 11 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 4c43389..cc5dfa1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -182,10 +182,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Try to retain the original creator/owner/lastowner if their uuid is present on this grid // otherwise, use the master avatar uuid instead - UUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; - - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) - masterAvatarId = m_scene.RegionInfo.EstateSettings.EstateOwner; // Reload serialized parcels m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); @@ -194,7 +190,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver { LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); if (!ResolveUserUuid(parcel.OwnerID)) - parcel.OwnerID = masterAvatarId; + parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; landData.Add(parcel); } m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); @@ -233,13 +229,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver foreach (SceneObjectPart part in sceneObject.Children.Values) { if (!ResolveUserUuid(part.CreatorID)) - part.CreatorID = masterAvatarId; + part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; if (!ResolveUserUuid(part.OwnerID)) - part.OwnerID = masterAvatarId; + part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; if (!ResolveUserUuid(part.LastOwnerID)) - part.LastOwnerID = masterAvatarId; + part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; // And zap any troublesome sit target information part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); @@ -255,11 +251,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver { if (!ResolveUserUuid(kvp.Value.OwnerID)) { - kvp.Value.OwnerID = masterAvatarId; + kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; } if (!ResolveUserUuid(kvp.Value.CreatorID)) { - kvp.Value.CreatorID = masterAvatarId; + kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; } } } diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 5b82d4c..2109336 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -57,10 +57,7 @@ namespace OpenSim.Region.CoreModules.World.Estate if (!m_scene.RegionInfo.EstateSettings.UseGlobalTime) sun=(uint)(m_scene.RegionInfo.EstateSettings.SunPosition*1024.0) + 0x1800; UUID estateOwner; - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) - estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; - else - estateOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID; + estateOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; if (m_scene.Permissions.IsGod(remote_client.AgentId)) estateOwner = remote_client.AgentId; @@ -230,8 +227,6 @@ namespace OpenSim.Region.CoreModules.World.Estate if (user == m_scene.RegionInfo.EstateSettings.EstateOwner) return; // never process EO - if (user == m_scene.RegionInfo.MasterAvatarAssignedUUID) - return; // never process owner switch (estateAccessType) { @@ -741,14 +736,7 @@ namespace OpenSim.Region.CoreModules.World.Estate args.waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight; args.regionFlags = GetRegionFlags(); args.regionName = m_scene.RegionInfo.RegionName; - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) - args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; - else - args.SimOwner = m_scene.RegionInfo.MasterAvatarAssignedUUID; - - // Fudge estate owner - //if (m_scene.Permissions.IsGod(remoteClient.AgentId)) - // args.SimOwner = remoteClient.AgentId; + args.SimOwner = m_scene.RegionInfo.EstateSettings.EstateOwner; args.terrainBase0 = UUID.Zero; args.terrainBase1 = UUID.Zero; @@ -1127,8 +1115,6 @@ namespace OpenSim.Region.CoreModules.World.Estate public bool IsManager(UUID avatarID) { - if (avatarID == m_scene.RegionInfo.MasterAvatarAssignedUUID) - return true; if (avatarID == m_scene.RegionInfo.EstateSettings.EstateOwner) return true; diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 9b39b09..f0c87f4 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -227,10 +227,7 @@ namespace OpenSim.Region.CoreModules.World.Land ILandObject fullSimParcel = new LandObject(UUID.Zero, false, m_scene); fullSimParcel.SetLandBitmap(fullSimParcel.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) - fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; - else - fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + fullSimParcel.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; fullSimParcel.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); AddLandObject(fullSimParcel); } @@ -1090,10 +1087,7 @@ namespace OpenSim.Region.CoreModules.World.Land { if (m_scene.Permissions.CanAbandonParcel(remote_client.AgentId, land)) { - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) - land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; - else - land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; land.LandData.GroupID = UUID.Zero; land.LandData.IsGroupOwned = false; m_scene.ForEachClient(SendParcelOverlay); @@ -1114,10 +1108,7 @@ namespace OpenSim.Region.CoreModules.World.Land { if (m_scene.Permissions.CanReclaimParcel(remote_client.AgentId, land)) { - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) - land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; - else - land.LandData.OwnerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; + land.LandData.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; land.LandData.ClaimDate = Util.UnixTimeSinceEpoch(); land.LandData.GroupID = UUID.Zero; land.LandData.IsGroupOwned = false; diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index aaebd00..ee76440 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -477,12 +477,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions { if (user == UUID.Zero) return false; - if (m_scene.RegionInfo.MasterAvatarAssignedUUID != UUID.Zero) - { - if (m_RegionOwnerIsGod && (m_scene.RegionInfo.MasterAvatarAssignedUUID == user)) - return true; - } - if (m_scene.RegionInfo.EstateSettings.EstateOwner != UUID.Zero) { if (m_scene.RegionInfo.EstateSettings.EstateOwner == user) -- cgit v1.1 From 4dd523b45d1e635c66eb4e556764fabe29dbfc58 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 15:34:56 -0800 Subject: * Changed IPresenceService Logout, so that it takes a position and a lookat * CommsManager.AvatarService rerouted --- .../CoreModules/Resources/CoreModulePlugin.addin.xml | 2 -- .../Interregion/RESTInterregionComms.cs | 15 ++++++++------- .../Presence/LocalPresenceServiceConnector.cs | 4 ++-- .../ServiceConnectorsOut/Presence/PresenceDetector.cs | 18 +++++++++++++++++- .../Presence/RemotePresenceServiceConnector.cs | 4 ++-- .../Presence/Tests/PresenceConnectorsTests.cs | 2 +- 6 files changed, 30 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 7b9fdee..a43b728 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -46,8 +46,6 @@ - - diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs index fa3681a..10ab76f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs @@ -781,13 +781,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion ipaddr = Util.GetHostFromDNS(parts[0]); if (parts.Length == 2) UInt32.TryParse(parts[1], out port); - - // local authority (standalone), local call - if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port)) - return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key); - // remote call - else - return AuthClient.VerifyKey("http://" + authority, userID, key); + return true; + + //// local authority (standalone), local call + //if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port)) + // return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key); + //// remote call + //else + // return AuthClient.VerifyKey("http://" + authority, userID, key); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 2cb18c7..d78daf9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs @@ -163,9 +163,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence return false; } - public bool LogoutAgent(UUID sessionID) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { - return m_PresenceService.LogoutAgent(sessionID); + return m_PresenceService.LogoutAgent(sessionID, position, lookat); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 3ca5560..891fc14 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -42,6 +42,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IPresenceService m_PresenceService; + private Scene m_aScene; public PresenceDetector(IPresenceService presenceservice) { @@ -54,6 +55,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence scene.EventManager.OnNewClient += OnNewClient; m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); + + if (m_aScene == null) + m_aScene = scene; } public void RemoveRegion(Scene scene) @@ -62,6 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence scene.EventManager.OnNewClient -= OnNewClient; m_PresenceService.LogoutRegionAgents(scene.RegionInfo.RegionID); + } public void OnMakeRootAgent(ScenePresence sp) @@ -78,7 +83,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public void OnLogout(IClientAPI client) { client.OnLogout -= OnLogout; - m_PresenceService.LogoutAgent(client.SessionId); + + ScenePresence sp = null; + Vector3 position = new Vector3(128, 128, 0); + Vector3 lookat = new Vector3(0, 1, 0); + + if (m_aScene.TryGetAvatar(client.AgentId, out sp)) + { + position = sp.AbsolutePosition; + lookat = sp.Lookat; + } + m_PresenceService.LogoutAgent(client.SessionId, position, lookat); + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index 6c69570..865f99e 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) + public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) { - return m_RemoteConnector.LogoutAgent(sessionID); + return m_RemoteConnector.LogoutAgent(sessionID, position, lookat); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index ebb2c3e..9ba1bdc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests 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); + r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY); Assert.IsTrue(r, "LogoutAgent returned false"); result = m_LocalConnector.GetAgent(session1); Assert.IsNotNull(result, "Agent session disappeared from storage after logout"); -- cgit v1.1 From 53e83e5dbb3590cb9c858aa301665357d1511b30 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 16:20:59 -0800 Subject: * Starting to clean the house... * Fixed circular dependency --- .../Archiver/InventoryArchiveWriteRequest.cs | 2 +- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 41 +++++++++++----------- 2 files changed, 22 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index ab5dafd..0d9d758 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -325,7 +325,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { m_archiveWriter.WriteFile( ArchiveConstants.USERS_PATH + creator.FirstName + " " + creator.LastName + ".xml", - UserProfileSerializer.Serialize(creator)); + UserProfileSerializer.Serialize(creator.PrincipalID, creator.FirstName, creator.LastName)); } else { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 3c1f7b6..f3ccbda 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -763,26 +763,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return (userData.UserServerURI == LocalUserServerURI); } - // Is the user going back to the home region or the home grid? - protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) - { - if (uinfo == null) - return false; - - if (uinfo.UserProfile == null) - return false; - - if (!(uinfo.UserProfile is ForeignUserProfileData)) - // it's a home user, can't be outside to return home - return false; - - // OK, it's a foreign user with a ForeignUserProfileData - // and is going back to exactly the home region. - // We can't check if it's going back to a non-home region - // of the home grid. That will be dealt with in the - // receiving end - return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); - } + // REFACTORING PROBLEM + //// Is the user going back to the home region or the home grid? + //protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) + //{ + // if (uinfo == null) + // return false; + + // if (uinfo.UserProfile == null) + // return false; + + // if (!(uinfo.UserProfile is ForeignUserProfileData)) + // // it's a home user, can't be outside to return home + // return false; + + // // OK, it's a foreign user with a ForeignUserProfileData + // // and is going back to exactly the home region. + // // We can't check if it's going back to a non-home region + // // of the home grid. That will be dealt with in the + // // receiving end + // return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); + //} protected bool IsLocalUser(UserAccount account) { -- cgit v1.1 From 49618dc102c42b7125303511d826f76f0ebaab4c Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 19:19:34 -0800 Subject: Moved GridInfo service from where it was to Handlers/Grid --- .../Resources/CoreModulePlugin.addin.xml | 1 + .../Grid/GridInfoServiceInConnectorModule.cs | 123 +++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index a43b728..1cc8ca9 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -63,6 +63,7 @@ \ \ \ + \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs new file mode 100644 index 0000000..7c9b752 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs @@ -0,0 +1,123 @@ +/* + * 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.Reflection; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Server.Handlers.Grid; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid +{ + public class GridInfoServiceInConnectorModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Enabled = false; + + private IConfigSource m_Config; + bool m_Registered = false; + + #region IRegionModule interface + + public void Initialise(IConfigSource config) + { + //// This module is only on for standalones in hypergrid mode + //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && + // config.Configs["Startup"].GetBoolean("hypergrid", true); + //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); + m_Config = config; + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + m_Enabled = moduleConfig.GetBoolean("GridInfoServiceInConnector", false); + if (m_Enabled) + { + m_log.Info("[GRIDINFO IN CONNECTOR]: GridInfo Service In Connector enabled"); + } + + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "GridInfoService"; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + if (!m_Registered) + { + m_Registered = true; + + m_log.Info("[GridInfo]: Starting..."); + + new GridInfoServerInConnector(m_Config, MainServer.Instance, "GridInfoService"); + } + + } + + #endregion + + } +} -- cgit v1.1 From 0c2946031bccf75c28968b6adcde5cce5bc45c13 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 19:42:36 -0800 Subject: CommunicationsManager is practically empty. Only NetworkServersInfo is there. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 884e6a6..2b3d56d 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -154,9 +154,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { IClientAPI clientView = (IClientAPI)sender; - ScenePresence avatar = m_scene.GetScenePresence(clientView.AgentId); + ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId); - if (avatar == null) + if (sp == null) { m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); return; @@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) { m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); - avatAppearance = avatar.Appearance; + avatAppearance = sp.Appearance; } //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); @@ -179,10 +179,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory } } - SetAppearanceAssets(avatar.UUID, ref avatAppearance); + SetAppearanceAssets(sp.UUID, ref avatAppearance); + AvatarData adata = new AvatarData(avatAppearance); + m_scene.AvatarService.SetAvatar(clientView.AgentId, adata); - m_scene.CommsManager.AvatarService.UpdateUserAppearance(clientView.AgentId, avatAppearance); - avatar.Appearance = avatAppearance; + sp.Appearance = avatAppearance; } public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) @@ -193,7 +194,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void UpdateDatabase(UUID user, AvatarAppearance appearance) { - m_scene.CommsManager.AvatarService.UpdateUserAppearance(user, appearance); + AvatarData adata = new AvatarData(appearance); + m_scene.AvatarService.SetAvatar(user, adata); + } private static byte[] GetDefaultVisualParams() -- cgit v1.1 From dc4bbf6065ad4cb914c9d44f2e6496a2e3d99814 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 20:29:09 -0800 Subject: All Framework.Communications.Clients and Framework.Communications.Services deleted, including old LoginService. --- .../Interregion/LocalInterregionComms.cs | 319 -------- .../Interregion/RESTInterregionComms.cs | 844 --------------------- .../Simulation/RemoteSimulationConnector.cs | 48 -- 3 files changed, 1211 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs deleted file mode 100644 index d68c683..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs +++ /dev/null @@ -1,319 +0,0 @@ -/* - * 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 log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion -{ - public class LocalInterregionComms : ISharedRegionModule, IInterregionCommsOut, IInterregionCommsIn - { - private bool m_enabled = false; - - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private List m_sceneList = new List(); - - #region Events - public event ChildAgentUpdateReceived OnChildAgentUpdate; - - #endregion /* Events */ - - #region IRegionModule - - public void Initialise(IConfigSource config) - { - if (m_sceneList.Count == 0) - { - IConfig startupConfig = config.Configs["Communications"]; - - if ((startupConfig != null) && (startupConfig.GetString("InterregionComms", "RESTComms") == "LocalComms")) - { - m_log.Debug("[LOCAL COMMS]: Enabling InterregionComms LocalComms module"); - m_enabled = true; - } - } - } - - public void PostInitialise() - { - } - - public void AddRegion(Scene scene) - { - } - - public void RemoveRegion(Scene scene) - { - if (m_enabled) - { - RemoveScene(scene); - } - } - - public void RegionLoaded(Scene scene) - { - if (m_enabled) - { - Init(scene); - } - } - - public void Close() - { - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "LocalInterregionCommsModule"; } - } - - /// - /// Can be called from other modules. - /// - /// - public void RemoveScene(Scene scene) - { - lock (m_sceneList) - { - if (m_sceneList.Contains(scene)) - { - m_sceneList.Remove(scene); - } - } - } - - /// - /// Can be called from other modules. - /// - /// - public void Init(Scene scene) - { - if (!m_sceneList.Contains(scene)) - { - lock (m_sceneList) - { - m_sceneList.Add(scene); - if (m_enabled) - scene.RegisterModuleInterface(this); - scene.RegisterModuleInterface(this); - } - - } - } - - #endregion /* IRegionModule */ - - #region IInterregionComms - - /** - * Agent-related communications - */ - - public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) - { - - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { -// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); - return s.NewUserConnection(aCircuit, teleportFlags, out reason); - } - } - -// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - reason = "Did not find region " + x + "-" + y; - return false; - } - - public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) - { - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - //m_log.DebugFormat( - // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", - // s.RegionInfo.RegionName, regionHandle); - - s.IncomingChildAgentDataUpdate(cAgentData); - return true; - } - } - -// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); - return false; - } - - public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) - { - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); - s.IncomingChildAgentDataUpdate(cAgentData); - return true; - } - } - //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); - return false; - } - - public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) - { - agent = null; - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); - return s.IncomingRetrieveRootAgent(id, out agent); - } - } - //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate"); - return false; - } - - public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) - { - //uint x, y; - //Utils.LongToUInts(regionHandle, out x, out y); - //x = x / Constants.RegionSize; - //y = y / Constants.RegionSize; - //m_log.Debug("\n >>> Local SendReleaseAgent " + x + "-" + y); - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); - return s.IncomingReleaseAgent(id); - } - } - //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); - return false; - } - - public bool SendCloseAgent(ulong regionHandle, UUID id) - { - //uint x, y; - //Utils.LongToUInts(regionHandle, out x, out y); - //x = x / Constants.RegionSize; - //y = y / Constants.RegionSize; - //m_log.Debug("\n >>> Local SendCloseAgent " + x + "-" + y); - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); - return s.IncomingCloseAgent(id); - } - } - //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); - return false; - } - - /** - * Object-related communications - */ - - public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) - { - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); - if (isLocalCall) - { - // We need to make a local copy of the object - ISceneObject sogClone = sog.CloneForNewScene(); - sogClone.SetState(sog.GetStateSnapshot(), s); - return s.IncomingCreateObject(sogClone); - } - else - { - // Use the object as it came through the wire - return s.IncomingCreateObject(sog); - } - } - } - return false; - } - - public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) - { - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionHandle) - { - return s.IncomingCreateObject(userID, itemID); - } - } - return false; - } - - - #endregion /* IInterregionComms */ - - #region Misc - - public Scene GetScene(ulong regionhandle) - { - foreach (Scene s in m_sceneList) - { - if (s.RegionInfo.RegionHandle == regionhandle) - return s; - } - // ? weird. should not happen - return m_sceneList[0]; - } - - public bool IsLocalRegion(ulong regionhandle) - { - foreach (Scene s in m_sceneList) - if (s.RegionInfo.RegionHandle == regionhandle) - return true; - return false; - } - - #endregion - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs deleted file mode 100644 index 10ab76f..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/RESTInterregionComms.cs +++ /dev/null @@ -1,844 +0,0 @@ -/* - * 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; -using System.IO; -using System.Net; -using System.Reflection; -using System.Text; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Clients; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; -using OpenSim.Region.Framework.Scenes.Serialization; -using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion -{ - public class RESTInterregionComms : ISharedRegionModule, IInterregionCommsOut - { - private bool initialized = false; - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected bool m_enabled = false; - protected Scene m_aScene; - // RESTInterregionComms does not care about local regions; it delegates that to the Local module - protected LocalInterregionComms m_localBackend; - - protected CommunicationsManager m_commsManager; - - protected RegionToRegionClient m_regionClient; - - protected IHyperlinkService m_hyperlinkService; - - protected bool m_safemode; - protected IPAddress m_thisIP; - - #region IRegionModule - - public virtual void Initialise(IConfigSource config) - { - IConfig startupConfig = config.Configs["Communications"]; - - if ((startupConfig == null) || ((startupConfig != null) - && (startupConfig.GetString("InterregionComms", "RESTComms") == "RESTComms"))) - { - m_log.Info("[REST COMMS]: Enabling InterregionComms RESTComms module"); - m_enabled = true; - if (config.Configs["Hypergrid"] != null) - m_safemode = config.Configs["Hypergrid"].GetBoolean("safemode", false); - } - } - - public virtual void PostInitialise() - { - } - - public virtual void Close() - { - } - - public void AddRegion(Scene scene) - { - } - - public void RemoveRegion(Scene scene) - { - if (m_enabled) - { - m_localBackend.RemoveScene(scene); - scene.UnregisterModuleInterface(this); - } - } - - public void RegionLoaded(Scene scene) - { - if (m_enabled) - { - if (!initialized) - { - InitOnce(scene); - initialized = true; - AddHTTPHandlers(); - } - InitEach(scene); - } - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public virtual string Name - { - get { return "RESTInterregionCommsModule"; } - } - - protected virtual void InitEach(Scene scene) - { - m_localBackend.Init(scene); - scene.RegisterModuleInterface(this); - } - - protected virtual void InitOnce(Scene scene) - { - m_localBackend = new LocalInterregionComms(); - m_commsManager = scene.CommsManager; - m_aScene = scene; - m_hyperlinkService = m_aScene.RequestModuleInterface(); - m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); - m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); - } - - protected virtual void AddHTTPHandlers() - { - MainServer.Instance.AddHTTPHandler("/agent/", AgentHandler); - MainServer.Instance.AddHTTPHandler("/object/", ObjectHandler); - } - - #endregion /* IRegionModule */ - - #region IInterregionComms - - /** - * Agent-related communications - */ - - public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason) - { - // Try local first - if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit, teleportFlags, out reason)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(regionHandle)) - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (regInfo != null) - { - m_regionClient.SendUserInformation(regInfo, aCircuit); - - return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None", teleportFlags, out reason); - } - //else - // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - } - return false; - } - - public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData) - { - // Try local first - if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(regionHandle)) - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (regInfo != null) - { - return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); - } - //else - // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - } - return false; - - } - - public bool SendChildAgentUpdate(ulong regionHandle, AgentPosition cAgentData) - { - // Try local first - if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(regionHandle)) - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (regInfo != null) - { - return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData); - } - //else - // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - } - return false; - - } - - public bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent) - { - // Try local first - if (m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(regionHandle)) - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (regInfo != null) - { - return m_regionClient.DoRetrieveRootAgentCall(regInfo, id, out agent); - } - //else - // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - } - return false; - - } - - public bool SendReleaseAgent(ulong regionHandle, UUID id, string uri) - { - // Try local first - if (m_localBackend.SendReleaseAgent(regionHandle, id, uri)) - return true; - - // else do the remote thing - return m_regionClient.DoReleaseAgentCall(regionHandle, id, uri); - } - - - public bool SendCloseAgent(ulong regionHandle, UUID id) - { - // Try local first - if (m_localBackend.SendCloseAgent(regionHandle, id)) - return true; - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(regionHandle)) - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (regInfo != null) - { - return m_regionClient.DoCloseAgentCall(regInfo, id); - } - //else - // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - } - return false; - } - - /** - * Object-related communications - */ - - public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall) - { - // Try local first - if (m_localBackend.SendCreateObject(regionHandle, sog, true)) - { - //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); - return true; - } - - // else do the remote thing - if (!m_localBackend.IsLocalRegion(regionHandle)) - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion regInfo = m_aScene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); - if (regInfo != null) - { - return m_regionClient.DoCreateObjectCall( - regInfo, sog, SceneObjectSerializer.ToXml2Format(sog), m_aScene.m_allowScriptCrossings); - } - //else - // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); - } - return false; - } - - public bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID) - { - // Not Implemented - return false; - } - - #endregion /* IInterregionComms */ - - #region Incoming calls from remote instances - - /** - * Agent-related incoming calls - */ - - public Hashtable AgentHandler(Hashtable request) - { - //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); - - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); - - Hashtable responsedata = new Hashtable(); - responsedata["content_type"] = "text/html"; - responsedata["keepalive"] = false; - - - UUID agentID; - string action; - ulong regionHandle; - if (!GetParams((string)request["uri"], out agentID, out regionHandle, out action)) - { - m_log.InfoFormat("[REST COMMS]: Invalid parameters for agent message {0}", request["uri"]); - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "false"; - - return responsedata; - } - - // Next, let's parse the verb - string method = (string)request["http-method"]; - if (method.Equals("PUT")) - { - DoAgentPut(request, responsedata); - return responsedata; - } - else if (method.Equals("POST")) - { - DoAgentPost(request, responsedata, agentID); - return responsedata; - } - else if (method.Equals("GET")) - { - DoAgentGet(request, responsedata, agentID, regionHandle); - return responsedata; - } - else if (method.Equals("DELETE")) - { - DoAgentDelete(request, responsedata, agentID, action, regionHandle); - return responsedata; - } - else - { - m_log.InfoFormat("[REST COMMS]: method {0} not supported in agent message", method); - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "false"; - - return responsedata; - } - - } - - protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id) - { - if (m_safemode) - { - // Authentication - string authority = string.Empty; - string authToken = string.Empty; - if (!GetAuthentication(request, out authority, out authToken)) - { - m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]); - responsedata["int_response_code"] = 403; - responsedata["str_response_string"] = "Forbidden"; - return ; - } - if (!VerifyKey(id, authority, authToken)) - { - m_log.InfoFormat("[REST COMMS]: Authentication failed for agent message {0}", request["uri"]); - responsedata["int_response_code"] = 403; - responsedata["str_response_string"] = "Forbidden"; - return ; - } - m_log.DebugFormat("[REST COMMS]: Authentication succeeded for {0}", id); - } - - OSDMap args = RegionClient.GetOSDMap((string)request["body"]); - if (args == null) - { - responsedata["int_response_code"] = 400; - responsedata["str_response_string"] = "false"; - return; - } - - // retrieve the regionhandle - ulong regionhandle = 0; - if (args["destination_handle"] != null) - UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); - - AgentCircuitData aCircuit = new AgentCircuitData(); - try - { - aCircuit.UnpackAgentCircuitData(args); - } - catch (Exception ex) - { - m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildCreate message {0}", ex.Message); - return; - } - - OSDMap resp = new OSDMap(2); - string reason = String.Empty; - uint teleportFlags = 0; - if (args.ContainsKey("teleport_flags")) - { - teleportFlags = args["teleport_flags"].AsUInteger(); - } - - // This is the meaning of POST agent - m_regionClient.AdjustUserInformation(aCircuit); - bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, teleportFlags, out reason); - - resp["reason"] = OSD.FromString(reason); - resp["success"] = OSD.FromBoolean(result); - - // TODO: add reason if not String.Empty? - responsedata["int_response_code"] = 200; - responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); - } - - protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata) - { - OSDMap args = RegionClient.GetOSDMap((string)request["body"]); - if (args == null) - { - responsedata["int_response_code"] = 400; - responsedata["str_response_string"] = "false"; - return; - } - - // retrieve the regionhandle - ulong regionhandle = 0; - if (args["destination_handle"] != null) - UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle); - - string messageType; - if (args["message_type"] != null) - messageType = args["message_type"].AsString(); - else - { - m_log.Warn("[REST COMMS]: Agent Put Message Type not found. "); - messageType = "AgentData"; - } - - bool result = true; - if ("AgentData".Equals(messageType)) - { - AgentData agent = new AgentData(); - try - { - agent.Unpack(args); - } - catch (Exception ex) - { - m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); - return; - } - - //agent.Dump(); - // This is one of the meanings of PUT agent - result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); - - } - else if ("AgentPosition".Equals(messageType)) - { - AgentPosition agent = new AgentPosition(); - try - { - agent.Unpack(args); - } - catch (Exception ex) - { - m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message); - return; - } - //agent.Dump(); - // This is one of the meanings of PUT agent - result = m_localBackend.SendChildAgentUpdate(regionhandle, agent); - - } - - responsedata["int_response_code"] = 200; - responsedata["str_response_string"] = result.ToString(); - } - - protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle) - { - IAgentData agent = null; - bool result = m_localBackend.SendRetrieveRootAgent(regionHandle, id, out agent); - OSDMap map = null; - if (result) - { - if (agent != null) // just to make sure - { - map = agent.Pack(); - string strBuffer = ""; - try - { - strBuffer = OSDParser.SerializeJsonString(map); - } - catch (Exception e) - { - m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); - // ignore. buffer will be empty, caller should check. - } - - responsedata["content_type"] = "application/json"; - responsedata["int_response_code"] = 200; - responsedata["str_response_string"] = strBuffer; - } - else - { - responsedata["int_response_code"] = 500; - responsedata["str_response_string"] = "Internal error"; - } - } - else - { - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "Not Found"; - } - } - - protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) - { - //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); - - if (action.Equals("release")) - m_localBackend.SendReleaseAgent(regionHandle, id, ""); - else - m_localBackend.SendCloseAgent(regionHandle, id); - - responsedata["int_response_code"] = 200; - responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); - - m_log.Debug("[REST COMMS]: Agent Deleted."); - } - - /** - * Object-related incoming calls - */ - - public Hashtable ObjectHandler(Hashtable request) - { - m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called"); - - m_log.Debug("---------------------------"); - m_log.Debug(" >> uri=" + request["uri"]); - m_log.Debug(" >> content-type=" + request["content-type"]); - m_log.Debug(" >> http-method=" + request["http-method"]); - m_log.Debug("---------------------------\n"); - - Hashtable responsedata = new Hashtable(); - responsedata["content_type"] = "text/html"; - - UUID objectID; - string action; - ulong regionHandle; - if (!GetParams((string)request["uri"], out objectID, out regionHandle, out action)) - { - m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]); - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "false"; - - return responsedata; - } - - // Next, let's parse the verb - string method = (string)request["http-method"]; - if (method.Equals("POST")) - { - DoObjectPost(request, responsedata, regionHandle); - return responsedata; - } - else if (method.Equals("PUT")) - { - DoObjectPut(request, responsedata, regionHandle); - return responsedata; - } - //else if (method.Equals("DELETE")) - //{ - // DoObjectDelete(request, responsedata, agentID, action, regionHandle); - // return responsedata; - //} - else - { - m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method); - responsedata["int_response_code"] = 404; - responsedata["str_response_string"] = "false"; - - return responsedata; - } - - } - - protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle) - { - OSDMap args = RegionClient.GetOSDMap((string)request["body"]); - if (args == null) - { - responsedata["int_response_code"] = 400; - responsedata["str_response_string"] = "false"; - return; - } - - string sogXmlStr = "", extraStr = "", stateXmlStr = ""; - if (args["sog"] != null) - sogXmlStr = args["sog"].AsString(); - if (args["extra"] != null) - extraStr = args["extra"].AsString(); - - IScene s = m_localBackend.GetScene(regionhandle); - SceneObjectGroup sog = null; - try - { - sog = SceneObjectSerializer.FromXml2Format(sogXmlStr); - sog.ExtraFromXmlString(extraStr); - } - catch (Exception ex) - { - m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message); - responsedata["int_response_code"] = 400; - responsedata["str_response_string"] = "false"; - return; - } - - if ((args["state"] != null) && m_aScene.m_allowScriptCrossings) - { - stateXmlStr = args["state"].AsString(); - if (stateXmlStr != "") - { - try - { - sog.SetState(stateXmlStr, s); - } - catch (Exception ex) - { - m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message); - - } - } - } - // This is the meaning of POST object - bool result = m_localBackend.SendCreateObject(regionhandle, sog, false); - - responsedata["int_response_code"] = 200; - responsedata["str_response_string"] = result.ToString(); - } - - protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle) - { - OSDMap args = RegionClient.GetOSDMap((string)request["body"]); - if (args == null) - { - responsedata["int_response_code"] = 400; - responsedata["str_response_string"] = "false"; - return; - } - - UUID userID = UUID.Zero, itemID = UUID.Zero; - if (args["userid"] != null) - userID = args["userid"].AsUUID(); - if (args["itemid"] != null) - itemID = args["itemid"].AsUUID(); - - // This is the meaning of PUT object - bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID); - - responsedata["int_response_code"] = 200; - responsedata["str_response_string"] = result.ToString(); - } - - #endregion - - #region Misc - - - /// - /// Extract the param from an uri. - /// - /// Something like this: /agent/uuid/ or /agent/uuid/handle/release - /// uuid on uuid field - /// optional action - public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action) - { - uuid = UUID.Zero; - action = ""; - regionHandle = 0; - - uri = uri.Trim(new char[] { '/' }); - string[] parts = uri.Split('/'); - if (parts.Length <= 1) - { - return false; - } - else - { - if (!UUID.TryParse(parts[1], out uuid)) - return false; - - if (parts.Length >= 3) - UInt64.TryParse(parts[2], out regionHandle); - if (parts.Length >= 4) - action = parts[3]; - - return true; - } - } - - public static bool GetAuthentication(Hashtable request, out string authority, out string authKey) - { - authority = string.Empty; - authKey = string.Empty; - - Uri authUri; - Hashtable headers = (Hashtable)request["headers"]; - - // Authorization keys look like this: - // http://orgrid.org:8002/ - if (headers.ContainsKey("authorization") && (string)headers["authorization"] != "None") - { - if (Uri.TryCreate((string)headers["authorization"], UriKind.Absolute, out authUri)) - { - authority = authUri.Authority; - authKey = authUri.PathAndQuery.Trim('/'); - m_log.DebugFormat("[REST COMMS]: Got authority {0} and key {1}", authority, authKey); - return true; - } - else - m_log.Debug("[REST COMMS]: Wrong format for Authorization header: " + (string)headers["authorization"]); - } - else - m_log.Debug("[REST COMMS]: Authorization header not found"); - - return false; - } - - bool VerifyKey(UUID userID, string authority, string key) - { - string[] parts = authority.Split(':'); - IPAddress ipaddr = IPAddress.None; - uint port = 0; - if (parts.Length <= 2) - ipaddr = Util.GetHostFromDNS(parts[0]); - if (parts.Length == 2) - UInt32.TryParse(parts[1], out port); - return true; - - //// local authority (standalone), local call - //if (m_thisIP.Equals(ipaddr) && (m_aScene.RegionInfo.HttpPort == port)) - // return ((IAuthentication)m_aScene.CommsManager.UserAdminService).VerifyKey(userID, key); - //// remote call - //else - // return AuthClient.VerifyKey("http://" + authority, userID, key); - } - - - #endregion Misc - - protected class RegionToRegionClient : RegionClient - { - Scene m_aScene = null; - IHyperlinkService m_hyperlinkService; - - public RegionToRegionClient(Scene s, IHyperlinkService hyperService) - { - m_aScene = s; - m_hyperlinkService = hyperService; - } - - public override ulong GetRegionHandle(ulong handle) - { - if (m_aScene.SceneGridService is HGSceneCommunicationService) - { - if (m_hyperlinkService != null) - return m_hyperlinkService.FindRegionHandle(handle); - } - - return handle; - } - - public override bool IsHyperlink(ulong handle) - { - if (m_aScene.SceneGridService is HGSceneCommunicationService) - { - if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) - return true; - } - return false; - } - - public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) - { - if (m_hyperlinkService != null) - m_hyperlinkService.SendUserInformation(regInfo, aCircuit); - - } - - public override void AdjustUserInformation(AgentCircuitData aCircuit) - { - if (m_hyperlinkService != null) - m_hyperlinkService.AdjustUserInformation(aCircuit); - } - } - - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index f485cd1..81496d6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -37,7 +37,6 @@ using OpenMetaverse; using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Clients; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; @@ -306,52 +305,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #endregion /* IInterregionComms */ - - protected class RegionToRegionClient : RegionClient - { - Scene m_aScene = null; - IHyperlinkService m_hyperlinkService; - - public RegionToRegionClient(Scene s, IHyperlinkService hyperService) - { - m_aScene = s; - m_hyperlinkService = hyperService; - } - - public override ulong GetRegionHandle(ulong handle) - { - if (m_aScene.SceneGridService is HGSceneCommunicationService) - { - if (m_hyperlinkService != null) - return m_hyperlinkService.FindRegionHandle(handle); - } - - return handle; - } - - public override bool IsHyperlink(ulong handle) - { - if (m_aScene.SceneGridService is HGSceneCommunicationService) - { - if ((m_hyperlinkService != null) && (m_hyperlinkService.GetHyperlinkRegion(handle) != null)) - return true; - } - return false; - } - - public override void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) - { - if (m_hyperlinkService != null) - m_hyperlinkService.SendUserInformation(regInfo, aCircuit); - - } - - public override void AdjustUserInformation(AgentCircuitData aCircuit) - { - if (m_hyperlinkService != null) - m_hyperlinkService.AdjustUserInformation(aCircuit); - } - } - } } -- cgit v1.1 From 751e70af788bf27fa0401c25d899f73186c8eafa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 10 Jan 2010 21:37:36 -0800 Subject: NetworkServersInfo removed from CommsManager. --- OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | 17 ++++++++-------- .../InterGrid/OpenGridProtocolModule.cs | 4 ++-- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 23 +++++++++++----------- .../Inventory/HGInventoryBroker.cs | 8 +++++--- 4 files changed, 27 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs index 0f2ba32..f9bc935 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs @@ -119,14 +119,15 @@ namespace OpenSim.Region.CoreModules.InterGrid Hashtable requestData = (Hashtable)req.Params[0]; - if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey)) - { - responseData["accepted"] = false; - responseData["success"] = false; - responseData["error"] = "Invalid Key"; - response.Value = responseData; - return response; - } + // REFACTORING PROBLEM. This authorization needs to be replaced with some other + //if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey)) + //{ + // responseData["accepted"] = false; + // responseData["success"] = false; + // responseData["error"] = "Invalid Key"; + // response.Value = responseData; + // return response; + //} string message = (string)requestData["message"]; string user = (string)requestData["user"]; diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index cf7bcef..8cf4619 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs @@ -528,9 +528,9 @@ namespace OpenSim.Region.CoreModules.InterGrid userProfile.PasswordHash = "$1$"; userProfile.PasswordSalt = ""; userProfile.SurName = agentData.lastname; - userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL; + //userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL; userProfile.UserFlags = 0; - userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL; + //userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL; userProfile.WantDoMask = 0; userProfile.WebLoginKey = UUID.Random(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index f3ccbda..782eddf 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -155,12 +155,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); - // Yikes!! Remove this as soon as user services get refactored - LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.AssetURL; - LocalInventoryServerURI = scene.CommsManager.NetworkServersInfo.InventoryURL; - LocalUserServerURI = scene.CommsManager.NetworkServersInfo.UserURL; - HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI); - } public void RemoveRegion(Scene scene) @@ -760,7 +754,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid protected bool IsComingHome(ForeignUserProfileData userData) { - return (userData.UserServerURI == LocalUserServerURI); + return false; + // REFACTORING PROBLEM + //return (userData.UserServerURI == LocalUserServerURI); } // REFACTORING PROBLEM @@ -787,13 +783,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid protected bool IsLocalUser(UserAccount account) { - if (account != null && - account.ServiceURLs.ContainsKey("HomeURI") && - account.ServiceURLs["HomeURI"] != null) + return true; - return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI); + // REFACTORING PROBLEM + //if (account != null && + // account.ServiceURLs.ContainsKey("HomeURI") && + // account.ServiceURLs["HomeURI"] != null) - return false; + // return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI); + + //return false; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 5ed2b7a..8fed4da 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -61,9 +61,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { get { - if (m_LocalGridInventoryURI == null || m_LocalGridInventoryURI == "") - m_LocalGridInventoryURI = m_Scene.CommsManager.NetworkServersInfo.InventoryURL; - return m_LocalGridInventoryURI; + return string.Empty; + // REFACTORING PROBLEM + //if (m_LocalGridInventoryURI == null || m_LocalGridInventoryURI == "") + // m_LocalGridInventoryURI = m_Scene.CommsManager.NetworkServersInfo.InventoryURL; + //return m_LocalGridInventoryURI; } } -- cgit v1.1 From 001d3695683d9511446d194feeb763c437170028 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 07:45:47 -0800 Subject: CommunicationsManager deleted. --- OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | 1 - OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs | 2 -- .../ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | 3 --- 3 files changed, 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index cc5b0e4..cf06e01 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -157,7 +157,6 @@ namespace OpenSim.Region.CoreModules.Framework.Library RegionInfo regInfo = new RegionInfo(); Scene m_MockScene = new Scene(regInfo); - m_MockScene.CommsManager = m_Scene.CommsManager; LocalInventoryService invService = new LocalInventoryService(lib); m_MockScene.RegisterModuleInterface(invService); m_MockScene.RegisterModuleInterface(m_Scene.AssetService); diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs index f9bc935..b7d3904 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs @@ -46,7 +46,6 @@ namespace OpenSim.Region.CoreModules.InterGrid { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly List m_scenes = new List(); - private CommunicationsManager m_com; private IConfigSource m_settings; #region Implementation of IRegionModuleBase @@ -88,7 +87,6 @@ namespace OpenSim.Region.CoreModules.InterGrid { if (m_settings.Configs["Startup"].GetBoolean("gridmode", false)) { - m_com = m_scenes[0].CommsManager; MainServer.Instance.AddXmlRPCHandler("grid_message", GridWideMessage); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 81496d6..bd2d8cb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -58,8 +58,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation protected LocalSimulationConnectorModule m_localBackend; protected SimulationServiceConnector m_remoteConnector; - protected CommunicationsManager m_commsManager; - protected IHyperlinkService m_hyperlinkService; protected bool m_safemode; @@ -150,7 +148,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation protected virtual void InitOnce(Scene scene) { m_localBackend = new LocalSimulationConnectorModule(); - m_commsManager = scene.CommsManager; m_aScene = scene; //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService); m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); -- cgit v1.1 From c5ea783526611a968400a1936e4c6764ee1c7013 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 07:51:33 -0800 Subject: OpenSim/Framework/Communications/Cache deleted. LibraryRootFolder deleted. --- .../CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs | 2 +- OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | 2 +- .../Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs | 2 +- OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 2 +- OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | 2 +- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 2 +- OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs | 2 +- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 2 +- .../Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 2 +- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 2 +- .../Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 2 +- .../CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 2 +- OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | 2 +- OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs | 2 +- OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | 2 +- OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 2 +- .../CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | 2 +- .../ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs | 2 +- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 +- OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 2 +- OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index c9ee54f..012d581 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -30,7 +30,7 @@ using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index f698ea1..fbd0ed1 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -31,7 +31,7 @@ using System.Reflection; using log4net; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Agent.AssetTransaction diff --git a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs index 5809bae..c7bf6c8 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs @@ -33,7 +33,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using BlockingQueue = OpenSim.Framework.BlockingQueue; diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 2b3d56d..87d0b0d 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -31,7 +31,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index c59992e..fac052a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs @@ -31,7 +31,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 123e2dd..64854b2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -36,7 +36,7 @@ using Nwc.XmlRpc; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs index 8ce5092..7303fe7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs @@ -30,7 +30,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 706d891..65ad703 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -37,7 +37,7 @@ using log4net; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework.Communications.Osp; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 0d9d758..ef10104 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -37,7 +37,7 @@ using OpenSim.Framework; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework.Communications.Osp; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ea6da8c..b055f8b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -34,7 +34,7 @@ using Nini.Config; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 89486fb..9c95e78 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -38,7 +38,7 @@ using OpenSim.Framework; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework.Communications.Osp; using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; using OpenSim.Region.CoreModules.World.Serialiser; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 55d4f14..4f03b0e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -32,7 +32,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index cf06e01..e53290c 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -31,7 +31,7 @@ using System.Reflection; using OpenSim.Framework; using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Interfaces; diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs index 685c031..49589fd 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs @@ -29,7 +29,7 @@ using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Services.Interfaces; using OpenMetaverse; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 044764b..af2f3d6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -31,7 +31,7 @@ using System; using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 782eddf..592991b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -31,7 +31,7 @@ using System.Net; using System.Reflection; using System.Xml; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 8fed4da..0c5097a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -31,7 +31,7 @@ using System; using System.Collections.Generic; using System.Reflection; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index 575a190..f20a2a9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -32,7 +32,7 @@ using System.Reflection; using Nini.Config; using OpenSim.Framework; using OpenSim.Framework.Statistics; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Services.Connectors; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index cc5dfa1..bb9c6fe 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -38,7 +38,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index edac4a4..8c1e1c2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -34,7 +34,7 @@ using NUnit.Framework; using NUnit.Framework.SyntaxHelpers; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Framework.Serialization; using OpenSim.Region.CoreModules.World.Serialiser; using OpenSim.Region.CoreModules.World.Terrain; diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index ee76440..3d7516d 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -32,7 +32,7 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Framework.Communications.Cache; + using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -- cgit v1.1 From 77e43f480154b0a950d9d5f54df5c225fc64e77a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 11 Jan 2010 17:30:05 -0800 Subject: Fixed a couple of bugs with Appearance. Appearance is all good now. --- .../Avatar/AvatarFactory/AvatarFactoryModule.cs | 17 ++++++++++------- .../Avatar/LocalAvatarServiceConnector.cs | 10 +++++----- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 87d0b0d..c01d66a 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory //if ((profile != null) && (profile.RootFolder != null)) if (avatar != null) { - appearance = avatar.ToAvatarAppearance(); + appearance = avatar.ToAvatarAppearance(avatarId); return true; } @@ -153,6 +153,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory /// public void AvatarIsWearing(Object sender, AvatarWearingArgs e) { + m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing"); + IClientAPI clientView = (IClientAPI)sender; ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId); @@ -162,12 +164,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory return; } - AvatarAppearance avatAppearance = null; - if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) - { - m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); - avatAppearance = sp.Appearance; - } + AvatarAppearance avatAppearance = sp.Appearance; + //if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) + //{ + // m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); + // avatAppearance = sp.Appearance; + //} //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); @@ -194,6 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void UpdateDatabase(UUID user, AvatarAppearance appearance) { + m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); AvatarData adata = new AvatarData(appearance); m_scene.AvatarService.SetAvatar(user, adata); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs index 0c8ee61..47f19a3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar IConfig userConfig = source.Configs["AvatarService"]; if (userConfig == null) { - m_log.Error("[USER CONNECTOR]: AvatarService missing from OpenSim.ini"); + m_log.Error("[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini"); return; } @@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar if (serviceDll == String.Empty) { - m_log.Error("[USER CONNECTOR]: No LocalServiceModule named in section AvatarService"); + m_log.Error("[AVATAR CONNECTOR]: No LocalServiceModule named in section AvatarService"); return; } @@ -92,11 +92,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar if (m_AvatarService == null) { - m_log.Error("[USER CONNECTOR]: Can't load user account service"); + m_log.Error("[AVATAR CONNECTOR]: Can't load user account service"); return; } m_Enabled = true; - m_log.Info("[USER CONNECTOR]: Local avatar connector enabled"); + m_log.Info("[AVATAR CONNECTOR]: Local avatar connector enabled"); } } } @@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar if (!m_Enabled) return; - scene.RegisterModuleInterface(m_AvatarService); + scene.RegisterModuleInterface(this); } public void RemoveRegion(Scene scene) -- cgit v1.1 From 66920a9047b54db947d02f252e17409b7fc32ef0 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 12 Jan 2010 09:22:58 -0800 Subject: Fixed more appearance woes that showed up using remote connectors. Appearance is now being passed with AgentCircuitData, as it should be. --- .../Inventory/RemoteInventoryServiceConnector.cs | 8 -------- .../Simulation/LocalSimulationConnector.cs | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index f20a2a9..aa3b30d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -337,15 +337,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private UUID GetSessionID(UUID userID) { - ScenePresence sp = null; - if (m_Scene.TryGetAvatar(userID, out sp)) - { - return sp.ControllingClient.SessionId; - } - - m_log.DebugFormat("[INVENTORY CONNECTOR]: scene presence for {0} not found", userID); return UUID.Zero; - } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index c6c6af0..723973c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -172,12 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { - m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", destination.RegionName); + m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName); return s.NewUserConnection(aCircuit, teleportFlags, out reason); } } - m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", destination.RegionName); + m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Did not find region {0} for SendCreateChildAgent", destination.RegionName); reason = "Did not find region " + destination.RegionName; return false; } @@ -191,9 +191,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { - //m_log.DebugFormat( - // "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate", - // s.RegionInfo.RegionName, regionHandle); + m_log.DebugFormat( + "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", + s.RegionInfo.RegionName, destination.RegionHandle); s.IncomingChildAgentDataUpdate(cAgentData); return true; -- cgit v1.1 From 7356860b487febd12c2e0de2f009a6df9ea0aeec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 09:17:30 -0800 Subject: Several more buglets removed. --- OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 3 +-- .../ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index c01d66a..a0ff151 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -196,10 +196,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public void UpdateDatabase(UUID user, AvatarAppearance appearance) { - m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); + //m_log.DebugFormat("[APPEARANCE]: UpdateDatabase"); AvatarData adata = new AvatarData(appearance); m_scene.AvatarService.SetAvatar(user, adata); - } private static byte[] GetDefaultVisualParams() diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index bd2d8cb..227c37f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; // Try local first - if (m_localBackend.CreateObject(destination, sog, true)) + if (m_localBackend.CreateObject(destination, sog, isLocalCall)) { //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); return true; -- cgit v1.1 From e90a5895ada61aab7fc27ab6f67b13a20676e07b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 21:32:48 -0800 Subject: Bug fix in releasing agent. In Scene, always use SimulatonService, and not m_SimulationService, because it may be null... --- .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 723973c..a341f2f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -251,7 +251,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return s.IncomingReleaseAgent(id); } } - //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent"); + //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin); return false; } @@ -262,7 +262,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == destination.RegionHandle) + if (s.RegionInfo.RegionID == destination.RegionID) { //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); return s.IncomingCloseAgent(id); -- cgit v1.1 From e9d376972ffb6237a55045448271a92026f41198 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 14 Jan 2010 08:05:08 -0800 Subject: Added a UserAccountCache to the UserAccountServiceConnectors. Uses a CenomeCache. --- .../LocalUserAccountServiceConnector.cs | 25 ++++++- .../RemoteUserAccountServiceConnector.cs | 34 +++++++++ .../UserAccounts/UserAccountCache.cs | 87 ++++++++++++++++++++++ 3 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index f55de5a..07fee79 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -46,6 +46,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts MethodBase.GetCurrentMethod().DeclaringType); private IUserAccountService m_UserService; + private UserAccountCache m_Cache; private bool m_Enabled = false; @@ -96,6 +97,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return; } m_Enabled = true; + m_Cache = new UserAccountCache(); + m_log.Info("[USER CONNECTOR]: Local user connector enabled"); } } @@ -139,12 +142,28 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public UserAccount GetUserAccount(UUID scopeID, UUID userID) { - return m_UserService.GetUserAccount(scopeID, userID); + UserAccount account = m_Cache.Get(userID); + if (account != null) + return account; + + account = m_UserService.GetUserAccount(scopeID, userID); + if (account != null) + m_Cache.Cache(account); + + return account; } - public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName) + public UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) { - return m_UserService.GetUserAccount(scopeID, FirstName, LastName); + UserAccount account = m_Cache.Get(firstName + " " + lastName); + if (account != null) + return account; + + account = m_UserService.GetUserAccount(scopeID, firstName, lastName); + if (account != null) + m_Cache.Cache(account); + + return account; } public UserAccount GetUserAccount(UUID scopeID, string Email) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 7d61b20..13acdf2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -34,6 +34,8 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenSim.Services.Connectors; +using OpenMetaverse; + namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, @@ -44,6 +46,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; + private UserAccountCache m_Cache; public Type ReplaceableInterface { @@ -73,6 +76,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts m_Enabled = true; base.Initialise(source); + m_Cache = new UserAccountCache(); m_log.Info("[USER CONNECTOR]: Remote users enabled"); } @@ -110,5 +114,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if (!m_Enabled) return; } + + #region Overwritten methods from IUserAccountService + + public override UserAccount GetUserAccount(UUID scopeID, UUID userID) + { + UserAccount account = m_Cache.Get(userID); + if (account != null) + return account; + + account = base.GetUserAccount(scopeID, userID); + if (account != null) + m_Cache.Cache(account); + + return account; + } + + public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) + { + UserAccount account = m_Cache.Get(firstName + " " + lastName); + if (account != null) + return account; + + account = base.GetUserAccount(scopeID, firstName, lastName); + if (account != null) + m_Cache.Cache(account); + + return account; + } + + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs new file mode 100644 index 0000000..e430fc7 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -0,0 +1,87 @@ +/* + * 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.Reflection; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; +using OpenMetaverse; +using log4net; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts +{ + public class UserAccountCache + { + //private static readonly ILog m_log = + // LogManager.GetLogger( + // MethodBase.GetCurrentMethod().DeclaringType); + + private ICnmCache m_UUIDCache; + private Dictionary m_NameCache; + + public UserAccountCache() + { + // Warning: the size values are a bit fuzzy. What matters + // most for this cache is the count value (128 entries). + m_UUIDCache = CnmSynchronizedCache.Synchronized(new CnmMemoryCache( + 128, 128*512, TimeSpan.FromMinutes(30.0))); + m_NameCache = new Dictionary(); // this one is unbound + } + + public void Cache(UserAccount account) + { + m_UUIDCache.Set(account.PrincipalID, account, 512); + m_NameCache[account.Name] = account.PrincipalID; + + //m_log.DebugFormat("[USER CACHE]: cached user {0} {1}", account.FirstName, account.LastName); + } + + public UserAccount Get(UUID userID) + { + UserAccount account = null; + if (m_UUIDCache.TryGetValue(userID, out account)) + { + //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); + return account; + } + + return null; + } + + public UserAccount Get(string name) + { + if (!m_NameCache.ContainsKey(name)) + return null; + + UserAccount account = null; + if (m_UUIDCache.TryGetValue(m_NameCache[name], out account)) + return account; + + return null; + } + } +} -- cgit v1.1 From f1c30784ac767bf5f62e81748984b76d85d71f6a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 15 Jan 2010 15:11:58 -0800 Subject: * General cleanup of Teleports, Crossings and Child agents. They are now in the new AgentTransferModule, in line with what MW started implementing back in May -- ITeleportModule. This has been renamed IAgentTransferModule, to be more generic. * HGSceneCommunicationService has been deleted * SceneCommunicationService will likely be deleted soon too --- .../Agent/AgentTransfer/AgentTransferModule.cs | 1188 ++++++++++++++++++++ .../Resources/CoreModulePlugin.addin.xml | 1 + .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 4 +- .../Simulation/LocalSimulationConnector.cs | 17 +- .../CoreModules/World/WorldMap/MapSearchModule.cs | 7 +- 5 files changed, 1208 insertions(+), 9 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs b/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs new file mode 100644 index 0000000..8e3d041 --- /dev/null +++ b/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs @@ -0,0 +1,1188 @@ +/* + * 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.Net; +using System.Reflection; +using System.Threading; + +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Agent.AgentTransfer +{ + public class AgentTransferModule : ISharedRegionModule, IAgentTransferModule + { + #region ISharedRegionModule + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + protected Scene m_aScene; + protected List m_agentsInTransit; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "AgentTransferModule"; } + } + + public virtual void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("AgentTransferModule", ""); + if (name == Name) + { + m_agentsInTransit = new List(); + m_Enabled = true; + m_log.Info("[AGENT TRANSFER MODULE]: Enabled."); + } + } + } + + public virtual void PostInitialise() + { + } + + public virtual void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + if (m_aScene == null) + m_aScene = scene; + + scene.RegisterModuleInterface(this); + } + + public virtual void Close() + { + if (!m_Enabled) + return; + } + + + public virtual void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + if (scene == m_aScene) + m_aScene = null; + } + + public virtual void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + + #endregion + + #region Teleports + + public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) + { + if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) + return; + + bool destRegionUp = true; + + IEventQueue eq = sp.Scene.RequestModuleInterface(); + + // Reset animations; the viewer does that in teleports. + sp.Animator.ResetAnimations(); + + if (regionHandle == sp.Scene.RegionInfo.RegionHandle) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", + position, sp.Scene.RegionInfo.RegionName); + + // Teleport within the same region + if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) + { + Vector3 emergencyPos = new Vector3(128, 128, 128); + + m_log.WarnFormat( + "[AGENT TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + position, sp.Name, sp.UUID, emergencyPos); + position = emergencyPos; + } + + // TODO: Get proper AVG Height + float localAVHeight = 1.56f; + float posZLimit = 22; + + // TODO: Check other Scene HeightField + if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) + { + posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; + } + + float newPosZ = posZLimit + localAVHeight; + if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + position.Z = newPosZ; + } + + // Only send this if the event queue is null + if (eq == null) + sp.ControllingClient.SendTeleportLocationStart(); + + sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); + sp.Teleport(position); + } + else + { + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); + + if (reg != null) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", + position, reg.RegionName); + + uint newRegionX = (uint)(reg.RegionHandle >> 40); + uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); + uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); + + ulong destinationHandle = GetRegionHandle(reg); + + if (eq == null) + sp.ControllingClient.SendTeleportLocationStart(); + + // Let's do DNS resolution only once in this process, please! + // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, + // it's actually doing a lot of work. + IPEndPoint endPoint = reg.ExternalEndPoint; + if (endPoint.Address == null) + { + // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. + destRegionUp = false; + } + + if (destRegionUp) + { + // Fixing a bug where teleporting while sitting results in the avatar ending up removed from + // both regions + if (sp.ParentID != (uint)0) + sp.StandUp(); + + if (!sp.ValidateAttachments()) + { + sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); + return; + } + + // the avatar.Close below will clear the child region list. We need this below for (possibly) + // closing the child agents, so save it here (we need a copy as it is Clear()-ed). + //List childRegions = new List(avatar.GetKnownRegionList()); + // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport + // failure at this point (unlike a border crossing failure). So perhaps this can never fail + // once we reach here... + //avatar.Scene.RemoveCapsHandler(avatar.UUID); + + string capsPath = String.Empty; + AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); + agentCircuit.BaseFolder = UUID.Zero; + agentCircuit.InventoryFolder = UUID.Zero; + agentCircuit.startpos = position; + agentCircuit.child = true; + agentCircuit.Appearance = sp.Appearance; + + if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) + { + // brand new agent, let's create a new caps seed + agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + } + + string reason = String.Empty; + + // Let's create an agent there if one doesn't exist yet. + //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) + if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) + { + sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", + reason)); + return; + } + + // OK, it got this agent. Let's close some child agents + sp.CloseChildAgents(newRegionX, newRegionY); + + if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) + { + #region IP Translation for NAT + IClientIPEndpoint ipepClient; + if (sp.ClientView.TryGet(out ipepClient)) + { + capsPath + = "http://" + + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName) + + ":" + + reg.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + else + { + capsPath + = "http://" + + reg.ExternalHostName + + ":" + + reg.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + #endregion + + if (eq != null) + { + #region IP Translation for NAT + // Uses ipepClient above + if (sp.ClientView.TryGet(out ipepClient)) + { + endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + } + #endregion + + eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); + + // ES makes the client send a UseCircuitCode message to the destination, + // which triggers a bunch of things there. + // So let's wait + Thread.Sleep(2000); + + eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + + } + else + { + sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); + } + } + else + { + agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); + capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + + "/CAPS/" + agentCircuit.CapsPath + "0000/"; + } + + // Expect avatar crossing is a heavy-duty function at the destination. + // That is where MakeRoot is called, which fetches appearance and inventory. + // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. + //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, + // position, false); + + //{ + // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); + // // We should close that agent we just created over at destination... + // List lst = new List(); + // lst.Add(reg.RegionHandle); + // SendCloseChildAgentAsync(avatar.UUID, lst); + // return; + //} + + SetInTransit(sp.UUID); + + // Let's send a full update of the agent. This is a synchronous call. + AgentData agent = new AgentData(); + sp.CopyTo(agent); + agent.Position = position; + agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + + "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; + + m_aScene.SimulationService.UpdateAgent(reg, agent); + + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); + + + if (eq != null) + { + eq.TeleportFinishEvent(destinationHandle, 13, endPoint, + 0, teleportFlags, capsPath, sp.UUID); + } + else + { + sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, + teleportFlags, capsPath); + } + + // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which + // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation + // that the client contacted the destination before we send the attachments and close things here. + if (!WaitForCallback(sp.UUID)) + { + // Client never contacted destination. Let's restore everything back + sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); + + ResetFromTransit(sp.UUID); + + // Yikes! We should just have a ref to scene here. + //sp.Scene.InformClientOfNeighbours(sp); + EnableChildAgents(sp); + + // Finally, kill the agent we just created at the destination. + m_aScene.SimulationService.CloseAgent(reg, sp.UUID); + + return; + } + + KillEntity(sp.Scene, sp.LocalId); + + sp.MakeChildAgent(); + + // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it + sp.CrossAttachmentsIntoNewRegion(reg, true); + + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone + + if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) + { + Thread.Sleep(5000); + sp.Close(); + sp.Scene.IncomingCloseAgent(sp.UUID); + } + else + // now we have a child agent in this region. + sp.Reset(); + + + // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! + if (sp.Scene.NeedSceneCacheClear(sp.UUID)) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: User {0} is going to another region, profile cache removed", + sp.UUID); + } + } + else + { + sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); + } + } + else + { + // TP to a place that doesn't exist (anymore) + // Inform the viewer about that + sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); + + // and set the map-tile to '(Offline)' + uint regX, regY; + Utils.LongToUInts(regionHandle, out regX, out regY); + + MapBlockData block = new MapBlockData(); + block.X = (ushort)(regX / Constants.RegionSize); + block.Y = (ushort)(regY / Constants.RegionSize); + block.Access = 254; // == not there + + List blocks = new List(); + blocks.Add(block); + sp.ControllingClient.SendMapBlock(blocks, 0); + } + } + } + + #endregion + + #region Enable Child Agent + /// + /// This informs a single neighboring region about agent "avatar". + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + public void EnableChildAgent(ScenePresence sp, GridRegion region) + { + AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = new Vector3(128, 128, 70); + agent.child = true; + agent.Appearance = sp.Appearance; + + InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, + InformClientOfNeighbourCompleted, + d); + } + #endregion + + #region Crossings + + public void Cross(ScenePresence agent, bool isFlying) + { + Scene scene = agent.Scene; + Vector3 pos = agent.AbsolutePosition; + Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); + uint neighbourx = scene.RegionInfo.RegionLocX; + uint neighboury = scene.RegionInfo.RegionLocY; + const float boundaryDistance = 1.7f; + Vector3 northCross = new Vector3(0, boundaryDistance, 0); + Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); + Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); + Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0); + + // distance to edge that will trigger crossing + + + // distance into new region to place avatar + const float enterDistance = 0.5f; + + if (scene.TestBorderCross(pos + westCross, Cardinals.W)) + { + if (scene.TestBorderCross(pos + northCross, Cardinals.N)) + { + Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); + neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); + } + else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) + { + Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = b.TriggerRegionY; + neighbourx = b.TriggerRegionX; + + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } + } + + Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); + if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) + { + neighbourx--; + newpos.X = Constants.RegionSize - enterDistance; + } + else + { + neighboury = ba.TriggerRegionY; + neighbourx = ba.TriggerRegionX; + + + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + + + return; + } + + } + else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) + { + Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E); + neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); + newpos.X = enterDistance; + + if (scene.TestBorderCross(pos + southCross, Cardinals.S)) + { + Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = ba.TriggerRegionY; + neighbourx = ba.TriggerRegionX; + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } + } + else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) + { + Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N); + neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); + newpos.Y = enterDistance; + } + + + } + else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) + { + Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = b.TriggerRegionY; + neighbourx = b.TriggerRegionX; + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } + } + else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) + { + + Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); + neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); + newpos.Y = enterDistance; + } + + /* + + if (pos.X < boundaryDistance) //West + { + neighbourx--; + newpos.X = Constants.RegionSize - enterDistance; + } + else if (pos.X > Constants.RegionSize - boundaryDistance) // East + { + neighbourx++; + newpos.X = enterDistance; + } + + if (pos.Y < boundaryDistance) // South + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else if (pos.Y > Constants.RegionSize - boundaryDistance) // North + { + neighboury++; + newpos.Y = enterDistance; + } + */ + + CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; + d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); + + } + + + public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY, + Vector3 position, + Scene initiatingScene); + + private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) + { + + // This assumes that we know what our neighbors are. + + InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; + d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, + InformClientToInitiateTeleportToLocationCompleted, + d); + } + + public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position, + Scene initiatingScene) + { + Thread.Sleep(10000); + IMessageTransferModule im = initiatingScene.RequestModuleInterface(); + if (im != null) + { + UUID gotoLocation = Util.BuildFakeParcelID( + Util.UIntsToLong( + (regionX * + (uint)Constants.RegionSize), + (regionY * + (uint)Constants.RegionSize)), + (uint)(int)position.X, + (uint)(int)position.Y, + (uint)(int)position.Z); + GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero, + "Region", agent.UUID, + (byte)InstantMessageDialog.GodLikeRequestTeleport, false, + "", gotoLocation, false, new Vector3(127, 0, 0), + new Byte[0]); + im.SendInstantMessage(m, delegate(bool success) + { + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); + }); + + } + } + + private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) + { + InformClientToInitateTeleportToLocationDelegate icon = + (InformClientToInitateTeleportToLocationDelegate)iar.AsyncState; + icon.EndInvoke(iar); + } + + public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); + + /// + /// This Closes child agents on neighboring regions + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) + { + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); + + Scene m_scene = agent.Scene; + ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); + + int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); + + if (neighbourRegion != null && agent.ValidateAttachments()) + { + pos = pos + (agent.Velocity); + + SetInTransit(agent.UUID); + AgentData cAgent = new AgentData(); + agent.CopyTo(cAgent); + cAgent.Position = pos; + if (isFlying) + cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; + cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + + "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; + + m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent); + + // Next, let's close the child agent connections that are too far away. + agent.CloseChildAgents(neighbourx, neighboury); + + //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); + agent.ControllingClient.RequestClientInfo(); + + //m_log.Debug("BEFORE CROSS"); + //Scene.DumpChildrenSeeds(UUID); + //DumpKnownRegions(); + string agentcaps; + if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) + { + m_log.ErrorFormat("[AGENT TRANSFER MODULE]: No AGENT TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", + neighbourRegion.RegionHandle); + return agent; + } + // TODO Should construct this behind a method + string capsPath = + "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; + + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); + + IEventQueue eq = agent.Scene.RequestModuleInterface(); + if (eq != null) + { + eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, + capsPath, agent.UUID, agent.ControllingClient.SessionId); + } + else + { + agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, + capsPath); + } + + if (!WaitForCallback(agent.UUID)) + { + m_log.Debug("[AGENT TRANSFER MODULE]: Callback never came in crossing agent"); + ResetFromTransit(agent.UUID); + + // Yikes! We should just have a ref to scene here. + //agent.Scene.InformClientOfNeighbours(agent); + EnableChildAgents(agent); + + return agent; + } + + agent.MakeChildAgent(); + // now we have a child agent in this region. Request all interesting data about other (root) agents + agent.SendInitialFullUpdateToAllClients(); + + agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true); + + // m_scene.SendKillObject(m_localId); + + agent.Scene.NotifyMyCoarseLocationChange(); + // the user may change their profile information in other region, + // so the userinfo in UserProfileCache is not reliable any more, delete it + // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! + if (agent.Scene.NeedSceneCacheClear(agent.UUID)) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: User {0} is going to another region", agent.UUID); + } + } + + //m_log.Debug("AFTER CROSS"); + //Scene.DumpChildrenSeeds(UUID); + //DumpKnownRegions(); + return agent; + } + + private void CrossAgentToNewRegionCompleted(IAsyncResult iar) + { + CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; + ScenePresence agent = icon.EndInvoke(iar); + + // If the cross was successful, this agent is a child agent + if (agent.IsChildAgent) + agent.Reset(); + else // Not successful + agent.RestoreInCurrentScene(); + + // In any case + agent.NotInTransit(); + + //m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); + } + + #endregion + + + #region Enable Child Agents + + private delegate void InformClientOfNeighbourDelegate( + ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); + + /// + /// This informs all neighboring regions about agent "avatar". + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + public void EnableChildAgents(ScenePresence sp) + { + List neighbours = new List(); + RegionInfo m_regionInfo = sp.Scene.RegionInfo; + + if (m_regionInfo != null) + { + neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + } + else + { + m_log.Debug("[AGENT TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); + } + + /// We need to find the difference between the new regions where there are no child agents + /// and the regions where there are already child agents. We only send notification to the former. + List neighbourHandles = NeighbourHandles(neighbours); // on this region + neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too + List previousRegionNeighbourHandles; + + if (sp.Scene.CapsModule != null) + { + previousRegionNeighbourHandles = + new List(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys); + } + else + { + previousRegionNeighbourHandles = new List(); + } + + List newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); + List oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); + + //Dump("Current Neighbors", neighbourHandles); + //Dump("Previous Neighbours", previousRegionNeighbourHandles); + //Dump("New Neighbours", newRegions); + //Dump("Old Neighbours", oldRegions); + + /// Update the scene presence's known regions here on this region + sp.DropOldNeighbours(oldRegions); + + /// Collect as many seeds as possible + Dictionary seeds; + if (sp.Scene.CapsModule != null) + seeds + = new Dictionary(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); + else + seeds = new Dictionary(); + + //m_log.Debug(" !!! No. of seeds: " + seeds.Count); + if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) + seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); + + /// Create the necessary child agents + List cagents = new List(); + foreach (GridRegion neighbour in neighbours) + { + if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) + { + + AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = new Vector3(128, 128, 70); + agent.child = true; + agent.Appearance = sp.Appearance; + + if (newRegions.Contains(neighbour.RegionHandle)) + { + agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath); + seeds.Add(neighbour.RegionHandle, agent.CapsPath); + } + else + agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); + + cagents.Add(agent); + } + } + + /// Update all child agent with everyone's seeds + foreach (AgentCircuitData a in cagents) + { + a.ChildrenCapSeeds = new Dictionary(seeds); + } + + if (sp.Scene.CapsModule != null) + { + sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); + } + sp.KnownRegions = seeds; + //avatar.Scene.DumpChildrenSeeds(avatar.UUID); + //avatar.DumpKnownRegions(); + + bool newAgent = false; + int count = 0; + foreach (GridRegion neighbour in neighbours) + { + //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); + // Don't do it if there's already an agent in that region + if (newRegions.Contains(neighbour.RegionHandle)) + newAgent = true; + else + newAgent = false; + + if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) + { + InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + try + { + d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, + InformClientOfNeighbourCompleted, + d); + } + + catch (ArgumentOutOfRangeException) + { + m_log.ErrorFormat( + "[AGENT TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", + neighbour.ExternalHostName, + neighbour.RegionHandle, + neighbour.RegionLocX, + neighbour.RegionLocY); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[AGENT TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", + neighbour.ExternalHostName, + neighbour.RegionHandle, + neighbour.RegionLocX, + neighbour.RegionLocY, + e); + + // FIXME: Okay, even though we've failed, we're still going to throw the exception on, + // since I don't know what will happen if we just let the client continue + + // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. + // throw e; + + } + } + count++; + } + } + + private void InformClientOfNeighbourCompleted(IAsyncResult iar) + { + InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; + icon.EndInvoke(iar); + //m_log.WarnFormat(" --> InformClientOfNeighbourCompleted"); + } + + /// + /// Async component for informing client of which neighbours exist + /// + /// + /// This needs to run asynchronously, as a network timeout may block the thread for a long while + /// + /// + /// + /// + /// + private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, + IPEndPoint endPoint, bool newAgent) + { + // Let's wait just a little to give time to originating regions to catch up with closing child agents + // after a cross here + Thread.Sleep(500); + + Scene m_scene = sp.Scene; + + uint x, y; + Utils.LongToUInts(reg.RegionHandle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + m_log.Info("[AGENT TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); + + string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + + "/CAPS/" + a.CapsPath + "0000/"; + + string reason = String.Empty; + + + bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, 0, out reason); // m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason); + + if (regionAccepted && newAgent) + { + IEventQueue eq = sp.Scene.RequestModuleInterface(); + if (eq != null) + { + #region IP Translation for NAT + IClientIPEndpoint ipepClient; + if (sp.ClientView.TryGet(out ipepClient)) + { + endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + } + #endregion + + eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); + eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1} in region {2}", + capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); + } + else + { + sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); + // TODO: make Event Queue disablable! + } + + m_log.Info("[AGENT TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); + + } + + } + + protected List RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) + { + RegionInfo m_regionInfo = pScene.RegionInfo; + + Border[] northBorders = pScene.NorthBorders.ToArray(); + Border[] southBorders = pScene.SouthBorders.ToArray(); + Border[] eastBorders = pScene.EastBorders.ToArray(); + Border[] westBorders = pScene.WestBorders.ToArray(); + + // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. + if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) + { + return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); + } + else + { + Vector2 extent = Vector2.Zero; + for (int i = 0; i < eastBorders.Length; i++) + { + extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; + } + for (int i = 0; i < northBorders.Length; i++) + { + extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; + } + + // Loss of fraction on purpose + extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; + extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; + + int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize; + int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize; + + int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; + int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; + + List neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); + neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); + + return neighbours; + } + } + + private List NewNeighbours(List currentNeighbours, List previousNeighbours) + { + return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); + } + + // private List CommonNeighbours(List currentNeighbours, List previousNeighbours) + // { + // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); + // } + + private List OldNeighbours(List currentNeighbours, List previousNeighbours) + { + return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); + } + + private List NeighbourHandles(List neighbours) + { + List handles = new List(); + foreach (GridRegion reg in neighbours) + { + handles.Add(reg.RegionHandle); + } + return handles; + } + + private void Dump(string msg, List handles) + { + m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg); + foreach (ulong handle in handles) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + m_log.InfoFormat("({0}, {1})", x, y); + } + } + + #endregion + + + #region Agent Arrived + public void AgentArrivedAtDestination(UUID id) + { + //m_log.Debug(" >>> ReleaseAgent called <<< "); + ResetFromTransit(id); + } + + #endregion + + + #region Misc + protected bool IsOutsideRegion(Scene s, Vector3 pos) + { + + if (s.TestBorderCross(pos, Cardinals.N)) + return true; + if (s.TestBorderCross(pos, Cardinals.S)) + return true; + if (s.TestBorderCross(pos, Cardinals.E)) + return true; + if (s.TestBorderCross(pos, Cardinals.W)) + return true; + + return false; + } + + protected bool WaitForCallback(UUID id) + { + int count = 200; + while (m_agentsInTransit.Contains(id) && count-- > 0) + { + //m_log.Debug(" >>> Waiting... " + count); + Thread.Sleep(100); + } + + if (count > 0) + return true; + else + return false; + } + + protected void SetInTransit(UUID id) + { + lock (m_agentsInTransit) + { + if (!m_agentsInTransit.Contains(id)) + m_agentsInTransit.Add(id); + } + } + + protected bool ResetFromTransit(UUID id) + { + lock (m_agentsInTransit) + { + if (m_agentsInTransit.Contains(id)) + { + m_agentsInTransit.Remove(id); + return true; + } + } + return false; + } + + protected void KillEntity(Scene scene, uint localID) + { + scene.SendKillObject(localID); + } + + protected virtual ulong GetRegionHandle(GridRegion region) + { + return region.RegionHandle; + } + + protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) + { + return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 1cc8ca9..f980c24 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -8,6 +8,7 @@ + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 592991b..fa705be 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -385,7 +385,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private static Random random = new Random(); - + // From the command line link-region public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) { string host = "127.0.0.1"; @@ -441,6 +441,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); } + // From the command line and the 2 above public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) { @@ -572,6 +573,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); } + // From the map and secondlife://blah public GridRegion GetHyperlinkRegion(ulong handle) { foreach (GridRegion r in m_HyperlinkRegions.Values) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index a341f2f..f4383f1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -43,6 +43,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private List m_sceneList = new List(); + private IAgentTransferModule m_AgentTransferModule; + protected IAgentTransferModule AgentTransferModule + { + get + { + if (m_AgentTransferModule == null) + m_AgentTransferModule = m_sceneList[0].RequestModuleInterface(); + return m_AgentTransferModule; + } + } + private bool m_ModuleEnabled = false; #region IRegionModule @@ -247,8 +258,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (s.RegionInfo.RegionID == origin) { - //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); - return s.IncomingReleaseAgent(id); + m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); + AgentTransferModule.AgentArrivedAtDestination(id); + return true; +// return s.IncomingReleaseAgent(id); } } //m_log.Debug("[LOCAL COMMS]: region not found in SendReleaseAgent " + origin); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index be46fa5..42b4632 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (info != null) regionInfos.Add(info); } - if ((regionInfos.Count == 0) && IsHypergridOn()) + if ((regionInfos.Count == 0)) { // OK, we tried but there are no regions matching that name. // Let's check quickly if this is a domain name, and if so link to it @@ -158,11 +158,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap remoteClient.SendMapBlock(blocks, 0); } - private bool IsHypergridOn() - { - return (m_scene.SceneGridService is HGSceneCommunicationService); - } - private Scene GetClientScene(IClientAPI client) { foreach (Scene s in m_scenes) -- cgit v1.1 From 4ac3c0e81b8760ef31f741cd55e703eee86b93b7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 15 Jan 2010 17:14:48 -0800 Subject: Renamed IAgentTransferModule to IEntityTransferModule -- accounts for objects too. --- .../Agent/AgentTransfer/AgentTransferModule.cs | 1188 ------------------- .../EntityTransfer/EntityTransferModule.cs | 1201 ++++++++++++++++++++ .../Simulation/LocalSimulationConnector.cs | 6 +- 3 files changed, 1204 insertions(+), 1191 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs create mode 100644 OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs b/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs deleted file mode 100644 index 8e3d041..0000000 --- a/OpenSim/Region/CoreModules/Agent/AgentTransfer/AgentTransferModule.cs +++ /dev/null @@ -1,1188 +0,0 @@ -/* - * 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.Net; -using System.Reflection; -using System.Threading; - -using OpenSim.Framework; -using OpenSim.Framework.Capabilities; -using OpenSim.Framework.Client; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; - -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -using OpenMetaverse; -using log4net; -using Nini.Config; - -namespace OpenSim.Region.CoreModules.Agent.AgentTransfer -{ - public class AgentTransferModule : ISharedRegionModule, IAgentTransferModule - { - #region ISharedRegionModule - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled = false; - protected Scene m_aScene; - protected List m_agentsInTransit; - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "AgentTransferModule"; } - } - - public virtual void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("AgentTransferModule", ""); - if (name == Name) - { - m_agentsInTransit = new List(); - m_Enabled = true; - m_log.Info("[AGENT TRANSFER MODULE]: Enabled."); - } - } - } - - public virtual void PostInitialise() - { - } - - public virtual void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - if (m_aScene == null) - m_aScene = scene; - - scene.RegisterModuleInterface(this); - } - - public virtual void Close() - { - if (!m_Enabled) - return; - } - - - public virtual void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - if (scene == m_aScene) - m_aScene = null; - } - - public virtual void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - } - - - #endregion - - #region Teleports - - public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) - { - if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) - return; - - bool destRegionUp = true; - - IEventQueue eq = sp.Scene.RequestModuleInterface(); - - // Reset animations; the viewer does that in teleports. - sp.Animator.ResetAnimations(); - - if (regionHandle == sp.Scene.RegionInfo.RegionHandle) - { - m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", - position, sp.Scene.RegionInfo.RegionName); - - // Teleport within the same region - if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) - { - Vector3 emergencyPos = new Vector3(128, 128, 128); - - m_log.WarnFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", - position, sp.Name, sp.UUID, emergencyPos); - position = emergencyPos; - } - - // TODO: Get proper AVG Height - float localAVHeight = 1.56f; - float posZLimit = 22; - - // TODO: Check other Scene HeightField - if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) - { - posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; - } - - float newPosZ = posZLimit + localAVHeight; - if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - position.Z = newPosZ; - } - - // Only send this if the event queue is null - if (eq == null) - sp.ControllingClient.SendTeleportLocationStart(); - - sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); - sp.Teleport(position); - } - else - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); - - if (reg != null) - { - m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", - position, reg.RegionName); - - uint newRegionX = (uint)(reg.RegionHandle >> 40); - uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); - uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); - - ulong destinationHandle = GetRegionHandle(reg); - - if (eq == null) - sp.ControllingClient.SendTeleportLocationStart(); - - // Let's do DNS resolution only once in this process, please! - // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, - // it's actually doing a lot of work. - IPEndPoint endPoint = reg.ExternalEndPoint; - if (endPoint.Address == null) - { - // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. - destRegionUp = false; - } - - if (destRegionUp) - { - // Fixing a bug where teleporting while sitting results in the avatar ending up removed from - // both regions - if (sp.ParentID != (uint)0) - sp.StandUp(); - - if (!sp.ValidateAttachments()) - { - sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); - return; - } - - // the avatar.Close below will clear the child region list. We need this below for (possibly) - // closing the child agents, so save it here (we need a copy as it is Clear()-ed). - //List childRegions = new List(avatar.GetKnownRegionList()); - // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport - // failure at this point (unlike a border crossing failure). So perhaps this can never fail - // once we reach here... - //avatar.Scene.RemoveCapsHandler(avatar.UUID); - - string capsPath = String.Empty; - AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); - agentCircuit.BaseFolder = UUID.Zero; - agentCircuit.InventoryFolder = UUID.Zero; - agentCircuit.startpos = position; - agentCircuit.child = true; - agentCircuit.Appearance = sp.Appearance; - - if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) - { - // brand new agent, let's create a new caps seed - agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); - } - - string reason = String.Empty; - - // Let's create an agent there if one doesn't exist yet. - //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) - if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) - { - sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", - reason)); - return; - } - - // OK, it got this agent. Let's close some child agents - sp.CloseChildAgents(newRegionX, newRegionY); - - if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) - { - #region IP Translation for NAT - IClientIPEndpoint ipepClient; - if (sp.ClientView.TryGet(out ipepClient)) - { - capsPath - = "http://" - + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName) - + ":" - + reg.HttpPort - + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); - } - else - { - capsPath - = "http://" - + reg.ExternalHostName - + ":" - + reg.HttpPort - + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); - } - #endregion - - if (eq != null) - { - #region IP Translation for NAT - // Uses ipepClient above - if (sp.ClientView.TryGet(out ipepClient)) - { - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); - } - #endregion - - eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); - - // ES makes the client send a UseCircuitCode message to the destination, - // which triggers a bunch of things there. - // So let's wait - Thread.Sleep(2000); - - eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - - } - else - { - sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); - } - } - else - { - agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); - capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort - + "/CAPS/" + agentCircuit.CapsPath + "0000/"; - } - - // Expect avatar crossing is a heavy-duty function at the destination. - // That is where MakeRoot is called, which fetches appearance and inventory. - // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. - //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, - // position, false); - - //{ - // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); - // // We should close that agent we just created over at destination... - // List lst = new List(); - // lst.Add(reg.RegionHandle); - // SendCloseChildAgentAsync(avatar.UUID, lst); - // return; - //} - - SetInTransit(sp.UUID); - - // Let's send a full update of the agent. This is a synchronous call. - AgentData agent = new AgentData(); - sp.CopyTo(agent); - agent.Position = position; - agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + - "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; - - m_aScene.SimulationService.UpdateAgent(reg, agent); - - m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); - - - if (eq != null) - { - eq.TeleportFinishEvent(destinationHandle, 13, endPoint, - 0, teleportFlags, capsPath, sp.UUID); - } - else - { - sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, - teleportFlags, capsPath); - } - - // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which - // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation - // that the client contacted the destination before we send the attachments and close things here. - if (!WaitForCallback(sp.UUID)) - { - // Client never contacted destination. Let's restore everything back - sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); - - ResetFromTransit(sp.UUID); - - // Yikes! We should just have a ref to scene here. - //sp.Scene.InformClientOfNeighbours(sp); - EnableChildAgents(sp); - - // Finally, kill the agent we just created at the destination. - m_aScene.SimulationService.CloseAgent(reg, sp.UUID); - - return; - } - - KillEntity(sp.Scene, sp.LocalId); - - sp.MakeChildAgent(); - - // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - sp.CrossAttachmentsIntoNewRegion(reg, true); - - // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone - - if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) - { - Thread.Sleep(5000); - sp.Close(); - sp.Scene.IncomingCloseAgent(sp.UUID); - } - else - // now we have a child agent in this region. - sp.Reset(); - - - // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! - if (sp.Scene.NeedSceneCacheClear(sp.UUID)) - { - m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: User {0} is going to another region, profile cache removed", - sp.UUID); - } - } - else - { - sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); - } - } - else - { - // TP to a place that doesn't exist (anymore) - // Inform the viewer about that - sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); - - // and set the map-tile to '(Offline)' - uint regX, regY; - Utils.LongToUInts(regionHandle, out regX, out regY); - - MapBlockData block = new MapBlockData(); - block.X = (ushort)(regX / Constants.RegionSize); - block.Y = (ushort)(regY / Constants.RegionSize); - block.Access = 254; // == not there - - List blocks = new List(); - blocks.Add(block); - sp.ControllingClient.SendMapBlock(blocks, 0); - } - } - } - - #endregion - - #region Enable Child Agent - /// - /// This informs a single neighboring region about agent "avatar". - /// Calls an asynchronous method to do so.. so it doesn't lag the sim. - /// - public void EnableChildAgent(ScenePresence sp, GridRegion region) - { - AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); - agent.BaseFolder = UUID.Zero; - agent.InventoryFolder = UUID.Zero; - agent.startpos = new Vector3(128, 128, 70); - agent.child = true; - agent.Appearance = sp.Appearance; - - InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; - d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, - InformClientOfNeighbourCompleted, - d); - } - #endregion - - #region Crossings - - public void Cross(ScenePresence agent, bool isFlying) - { - Scene scene = agent.Scene; - Vector3 pos = agent.AbsolutePosition; - Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); - uint neighbourx = scene.RegionInfo.RegionLocX; - uint neighboury = scene.RegionInfo.RegionLocY; - const float boundaryDistance = 1.7f; - Vector3 northCross = new Vector3(0, boundaryDistance, 0); - Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); - Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); - Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0); - - // distance to edge that will trigger crossing - - - // distance into new region to place avatar - const float enterDistance = 0.5f; - - if (scene.TestBorderCross(pos + westCross, Cardinals.W)) - { - if (scene.TestBorderCross(pos + northCross, Cardinals.N)) - { - Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); - neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); - } - else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) - { - Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); - if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) - { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; - } - else - { - neighboury = b.TriggerRegionY; - neighbourx = b.TriggerRegionX; - - Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; - agent.ControllingClient.SendAgentAlertMessage( - String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); - InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); - return; - } - } - - Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); - if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) - { - neighbourx--; - newpos.X = Constants.RegionSize - enterDistance; - } - else - { - neighboury = ba.TriggerRegionY; - neighbourx = ba.TriggerRegionX; - - - Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; - agent.ControllingClient.SendAgentAlertMessage( - String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); - InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); - - - return; - } - - } - else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) - { - Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E); - neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); - newpos.X = enterDistance; - - if (scene.TestBorderCross(pos + southCross, Cardinals.S)) - { - Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); - if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) - { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; - } - else - { - neighboury = ba.TriggerRegionY; - neighbourx = ba.TriggerRegionX; - Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; - agent.ControllingClient.SendAgentAlertMessage( - String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); - InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); - return; - } - } - else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) - { - Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N); - neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); - newpos.Y = enterDistance; - } - - - } - else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) - { - Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); - if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) - { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; - } - else - { - neighboury = b.TriggerRegionY; - neighbourx = b.TriggerRegionX; - Vector3 newposition = pos; - newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; - newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; - agent.ControllingClient.SendAgentAlertMessage( - String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); - InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); - return; - } - } - else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) - { - - Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); - neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); - newpos.Y = enterDistance; - } - - /* - - if (pos.X < boundaryDistance) //West - { - neighbourx--; - newpos.X = Constants.RegionSize - enterDistance; - } - else if (pos.X > Constants.RegionSize - boundaryDistance) // East - { - neighbourx++; - newpos.X = enterDistance; - } - - if (pos.Y < boundaryDistance) // South - { - neighboury--; - newpos.Y = Constants.RegionSize - enterDistance; - } - else if (pos.Y > Constants.RegionSize - boundaryDistance) // North - { - neighboury++; - newpos.Y = enterDistance; - } - */ - - CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; - d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); - - } - - - public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY, - Vector3 position, - Scene initiatingScene); - - private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) - { - - // This assumes that we know what our neighbors are. - - InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; - d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, - InformClientToInitiateTeleportToLocationCompleted, - d); - } - - public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position, - Scene initiatingScene) - { - Thread.Sleep(10000); - IMessageTransferModule im = initiatingScene.RequestModuleInterface(); - if (im != null) - { - UUID gotoLocation = Util.BuildFakeParcelID( - Util.UIntsToLong( - (regionX * - (uint)Constants.RegionSize), - (regionY * - (uint)Constants.RegionSize)), - (uint)(int)position.X, - (uint)(int)position.Y, - (uint)(int)position.Z); - GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero, - "Region", agent.UUID, - (byte)InstantMessageDialog.GodLikeRequestTeleport, false, - "", gotoLocation, false, new Vector3(127, 0, 0), - new Byte[0]); - im.SendInstantMessage(m, delegate(bool success) - { - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); - }); - - } - } - - private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) - { - InformClientToInitateTeleportToLocationDelegate icon = - (InformClientToInitateTeleportToLocationDelegate)iar.AsyncState; - icon.EndInvoke(iar); - } - - public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); - - /// - /// This Closes child agents on neighboring regions - /// Calls an asynchronous method to do so.. so it doesn't lag the sim. - /// - protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) - { - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); - - Scene m_scene = agent.Scene; - ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); - - int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); - GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); - - if (neighbourRegion != null && agent.ValidateAttachments()) - { - pos = pos + (agent.Velocity); - - SetInTransit(agent.UUID); - AgentData cAgent = new AgentData(); - agent.CopyTo(cAgent); - cAgent.Position = pos; - if (isFlying) - cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; - cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + - "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; - - m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent); - - // Next, let's close the child agent connections that are too far away. - agent.CloseChildAgents(neighbourx, neighboury); - - //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); - agent.ControllingClient.RequestClientInfo(); - - //m_log.Debug("BEFORE CROSS"); - //Scene.DumpChildrenSeeds(UUID); - //DumpKnownRegions(); - string agentcaps; - if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) - { - m_log.ErrorFormat("[AGENT TRANSFER MODULE]: No AGENT TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", - neighbourRegion.RegionHandle); - return agent; - } - // TODO Should construct this behind a method - string capsPath = - "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort - + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; - - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); - - IEventQueue eq = agent.Scene.RequestModuleInterface(); - if (eq != null) - { - eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, - capsPath, agent.UUID, agent.ControllingClient.SessionId); - } - else - { - agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, - capsPath); - } - - if (!WaitForCallback(agent.UUID)) - { - m_log.Debug("[AGENT TRANSFER MODULE]: Callback never came in crossing agent"); - ResetFromTransit(agent.UUID); - - // Yikes! We should just have a ref to scene here. - //agent.Scene.InformClientOfNeighbours(agent); - EnableChildAgents(agent); - - return agent; - } - - agent.MakeChildAgent(); - // now we have a child agent in this region. Request all interesting data about other (root) agents - agent.SendInitialFullUpdateToAllClients(); - - agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true); - - // m_scene.SendKillObject(m_localId); - - agent.Scene.NotifyMyCoarseLocationChange(); - // the user may change their profile information in other region, - // so the userinfo in UserProfileCache is not reliable any more, delete it - // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! - if (agent.Scene.NeedSceneCacheClear(agent.UUID)) - { - m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: User {0} is going to another region", agent.UUID); - } - } - - //m_log.Debug("AFTER CROSS"); - //Scene.DumpChildrenSeeds(UUID); - //DumpKnownRegions(); - return agent; - } - - private void CrossAgentToNewRegionCompleted(IAsyncResult iar) - { - CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; - ScenePresence agent = icon.EndInvoke(iar); - - // If the cross was successful, this agent is a child agent - if (agent.IsChildAgent) - agent.Reset(); - else // Not successful - agent.RestoreInCurrentScene(); - - // In any case - agent.NotInTransit(); - - //m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); - } - - #endregion - - - #region Enable Child Agents - - private delegate void InformClientOfNeighbourDelegate( - ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); - - /// - /// This informs all neighboring regions about agent "avatar". - /// Calls an asynchronous method to do so.. so it doesn't lag the sim. - /// - public void EnableChildAgents(ScenePresence sp) - { - List neighbours = new List(); - RegionInfo m_regionInfo = sp.Scene.RegionInfo; - - if (m_regionInfo != null) - { - neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); - } - else - { - m_log.Debug("[AGENT TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); - } - - /// We need to find the difference between the new regions where there are no child agents - /// and the regions where there are already child agents. We only send notification to the former. - List neighbourHandles = NeighbourHandles(neighbours); // on this region - neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too - List previousRegionNeighbourHandles; - - if (sp.Scene.CapsModule != null) - { - previousRegionNeighbourHandles = - new List(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys); - } - else - { - previousRegionNeighbourHandles = new List(); - } - - List newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); - List oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); - - //Dump("Current Neighbors", neighbourHandles); - //Dump("Previous Neighbours", previousRegionNeighbourHandles); - //Dump("New Neighbours", newRegions); - //Dump("Old Neighbours", oldRegions); - - /// Update the scene presence's known regions here on this region - sp.DropOldNeighbours(oldRegions); - - /// Collect as many seeds as possible - Dictionary seeds; - if (sp.Scene.CapsModule != null) - seeds - = new Dictionary(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); - else - seeds = new Dictionary(); - - //m_log.Debug(" !!! No. of seeds: " + seeds.Count); - if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) - seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); - - /// Create the necessary child agents - List cagents = new List(); - foreach (GridRegion neighbour in neighbours) - { - if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) - { - - AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); - agent.BaseFolder = UUID.Zero; - agent.InventoryFolder = UUID.Zero; - agent.startpos = new Vector3(128, 128, 70); - agent.child = true; - agent.Appearance = sp.Appearance; - - if (newRegions.Contains(neighbour.RegionHandle)) - { - agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); - sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath); - seeds.Add(neighbour.RegionHandle, agent.CapsPath); - } - else - agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); - - cagents.Add(agent); - } - } - - /// Update all child agent with everyone's seeds - foreach (AgentCircuitData a in cagents) - { - a.ChildrenCapSeeds = new Dictionary(seeds); - } - - if (sp.Scene.CapsModule != null) - { - sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); - } - sp.KnownRegions = seeds; - //avatar.Scene.DumpChildrenSeeds(avatar.UUID); - //avatar.DumpKnownRegions(); - - bool newAgent = false; - int count = 0; - foreach (GridRegion neighbour in neighbours) - { - //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); - // Don't do it if there's already an agent in that region - if (newRegions.Contains(neighbour.RegionHandle)) - newAgent = true; - else - newAgent = false; - - if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) - { - InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; - try - { - d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, - InformClientOfNeighbourCompleted, - d); - } - - catch (ArgumentOutOfRangeException) - { - m_log.ErrorFormat( - "[AGENT TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", - neighbour.ExternalHostName, - neighbour.RegionHandle, - neighbour.RegionLocX, - neighbour.RegionLocY); - } - catch (Exception e) - { - m_log.ErrorFormat( - "[AGENT TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", - neighbour.ExternalHostName, - neighbour.RegionHandle, - neighbour.RegionLocX, - neighbour.RegionLocY, - e); - - // FIXME: Okay, even though we've failed, we're still going to throw the exception on, - // since I don't know what will happen if we just let the client continue - - // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. - // throw e; - - } - } - count++; - } - } - - private void InformClientOfNeighbourCompleted(IAsyncResult iar) - { - InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; - icon.EndInvoke(iar); - //m_log.WarnFormat(" --> InformClientOfNeighbourCompleted"); - } - - /// - /// Async component for informing client of which neighbours exist - /// - /// - /// This needs to run asynchronously, as a network timeout may block the thread for a long while - /// - /// - /// - /// - /// - private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, - IPEndPoint endPoint, bool newAgent) - { - // Let's wait just a little to give time to originating regions to catch up with closing child agents - // after a cross here - Thread.Sleep(500); - - Scene m_scene = sp.Scene; - - uint x, y; - Utils.LongToUInts(reg.RegionHandle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - m_log.Info("[AGENT TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); - - string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort - + "/CAPS/" + a.CapsPath + "0000/"; - - string reason = String.Empty; - - - bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, 0, out reason); // m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason); - - if (regionAccepted && newAgent) - { - IEventQueue eq = sp.Scene.RequestModuleInterface(); - if (eq != null) - { - #region IP Translation for NAT - IClientIPEndpoint ipepClient; - if (sp.ClientView.TryGet(out ipepClient)) - { - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); - } - #endregion - - eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); - eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1} in region {2}", - capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); - } - else - { - sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); - // TODO: make Event Queue disablable! - } - - m_log.Info("[AGENT TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); - - } - - } - - protected List RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) - { - RegionInfo m_regionInfo = pScene.RegionInfo; - - Border[] northBorders = pScene.NorthBorders.ToArray(); - Border[] southBorders = pScene.SouthBorders.ToArray(); - Border[] eastBorders = pScene.EastBorders.ToArray(); - Border[] westBorders = pScene.WestBorders.ToArray(); - - // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. - if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) - { - return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); - } - else - { - Vector2 extent = Vector2.Zero; - for (int i = 0; i < eastBorders.Length; i++) - { - extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; - } - for (int i = 0; i < northBorders.Length; i++) - { - extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; - } - - // Loss of fraction on purpose - extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; - extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; - - int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize; - int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize; - - int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; - int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; - - List neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); - neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); - - return neighbours; - } - } - - private List NewNeighbours(List currentNeighbours, List previousNeighbours) - { - return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); - } - - // private List CommonNeighbours(List currentNeighbours, List previousNeighbours) - // { - // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); - // } - - private List OldNeighbours(List currentNeighbours, List previousNeighbours) - { - return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); - } - - private List NeighbourHandles(List neighbours) - { - List handles = new List(); - foreach (GridRegion reg in neighbours) - { - handles.Add(reg.RegionHandle); - } - return handles; - } - - private void Dump(string msg, List handles) - { - m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg); - foreach (ulong handle in handles) - { - uint x, y; - Utils.LongToUInts(handle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - m_log.InfoFormat("({0}, {1})", x, y); - } - } - - #endregion - - - #region Agent Arrived - public void AgentArrivedAtDestination(UUID id) - { - //m_log.Debug(" >>> ReleaseAgent called <<< "); - ResetFromTransit(id); - } - - #endregion - - - #region Misc - protected bool IsOutsideRegion(Scene s, Vector3 pos) - { - - if (s.TestBorderCross(pos, Cardinals.N)) - return true; - if (s.TestBorderCross(pos, Cardinals.S)) - return true; - if (s.TestBorderCross(pos, Cardinals.E)) - return true; - if (s.TestBorderCross(pos, Cardinals.W)) - return true; - - return false; - } - - protected bool WaitForCallback(UUID id) - { - int count = 200; - while (m_agentsInTransit.Contains(id) && count-- > 0) - { - //m_log.Debug(" >>> Waiting... " + count); - Thread.Sleep(100); - } - - if (count > 0) - return true; - else - return false; - } - - protected void SetInTransit(UUID id) - { - lock (m_agentsInTransit) - { - if (!m_agentsInTransit.Contains(id)) - m_agentsInTransit.Add(id); - } - } - - protected bool ResetFromTransit(UUID id) - { - lock (m_agentsInTransit) - { - if (m_agentsInTransit.Contains(id)) - { - m_agentsInTransit.Remove(id); - return true; - } - } - return false; - } - - protected void KillEntity(Scene scene, uint localID) - { - scene.SendKillObject(localID); - } - - protected virtual ulong GetRegionHandle(GridRegion region) - { - return region.RegionHandle; - } - - protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) - { - return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); - } - - #endregion - - } -} diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs new file mode 100644 index 0000000..af004b0 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -0,0 +1,1201 @@ +/* + * 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.Net; +using System.Reflection; +using System.Threading; + +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.EntityTransfer +{ + public class AgentTransferModule : ISharedRegionModule, IEntityTransferModule + { + #region ISharedRegionModule + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + protected Scene m_aScene; + protected List m_agentsInTransit; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "AgentTransferModule"; } + } + + public virtual void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("AgentTransferModule", ""); + if (name == Name) + { + m_agentsInTransit = new List(); + m_Enabled = true; + m_log.Info("[AGENT TRANSFER MODULE]: Enabled."); + } + } + } + + public virtual void PostInitialise() + { + } + + public virtual void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + if (m_aScene == null) + m_aScene = scene; + + scene.RegisterModuleInterface(this); + } + + public virtual void Close() + { + if (!m_Enabled) + return; + } + + + public virtual void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + if (scene == m_aScene) + m_aScene = null; + } + + public virtual void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + + #endregion + + #region Teleports + + public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) + { + if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) + return; + + bool destRegionUp = true; + + IEventQueue eq = sp.Scene.RequestModuleInterface(); + + // Reset animations; the viewer does that in teleports. + sp.Animator.ResetAnimations(); + + if (regionHandle == sp.Scene.RegionInfo.RegionHandle) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", + position, sp.Scene.RegionInfo.RegionName); + + // Teleport within the same region + if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) + { + Vector3 emergencyPos = new Vector3(128, 128, 128); + + m_log.WarnFormat( + "[AGENT TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + position, sp.Name, sp.UUID, emergencyPos); + position = emergencyPos; + } + + // TODO: Get proper AVG Height + float localAVHeight = 1.56f; + float posZLimit = 22; + + // TODO: Check other Scene HeightField + if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) + { + posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; + } + + float newPosZ = posZLimit + localAVHeight; + if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + position.Z = newPosZ; + } + + // Only send this if the event queue is null + if (eq == null) + sp.ControllingClient.SendTeleportLocationStart(); + + sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); + sp.Teleport(position); + } + else + { + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); + + if (reg != null) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", + position, reg.RegionName); + + uint newRegionX = (uint)(reg.RegionHandle >> 40); + uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); + uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); + + ulong destinationHandle = GetRegionHandle(reg); + GridRegion finalDestination = GetFinalDestination(reg); + + if (eq == null) + sp.ControllingClient.SendTeleportLocationStart(); + + // Let's do DNS resolution only once in this process, please! + // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, + // it's actually doing a lot of work. + IPEndPoint endPoint = reg.ExternalEndPoint; + if (endPoint.Address == null) + { + // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. + destRegionUp = false; + } + + if (destRegionUp) + { + // Fixing a bug where teleporting while sitting results in the avatar ending up removed from + // both regions + if (sp.ParentID != (uint)0) + sp.StandUp(); + + if (!sp.ValidateAttachments()) + { + sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); + return; + } + + // the avatar.Close below will clear the child region list. We need this below for (possibly) + // closing the child agents, so save it here (we need a copy as it is Clear()-ed). + //List childRegions = new List(avatar.GetKnownRegionList()); + // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport + // failure at this point (unlike a border crossing failure). So perhaps this can never fail + // once we reach here... + //avatar.Scene.RemoveCapsHandler(avatar.UUID); + + string capsPath = String.Empty; + AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); + agentCircuit.BaseFolder = UUID.Zero; + agentCircuit.InventoryFolder = UUID.Zero; + agentCircuit.startpos = position; + agentCircuit.child = true; + agentCircuit.Appearance = sp.Appearance; + + if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) + { + // brand new agent, let's create a new caps seed + agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + } + + string reason = String.Empty; + + // Let's create an agent there if one doesn't exist yet. + if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) + { + sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", + reason)); + return; + } + + // OK, it got this agent. Let's close some child agents + sp.CloseChildAgents(newRegionX, newRegionY); + + if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) + { + #region IP Translation for NAT + IClientIPEndpoint ipepClient; + if (sp.ClientView.TryGet(out ipepClient)) + { + capsPath + = "http://" + + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName) + + ":" + + reg.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + else + { + capsPath + = "http://" + + reg.ExternalHostName + + ":" + + reg.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + #endregion + + if (eq != null) + { + #region IP Translation for NAT + // Uses ipepClient above + if (sp.ClientView.TryGet(out ipepClient)) + { + endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + } + #endregion + + eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); + + // ES makes the client send a UseCircuitCode message to the destination, + // which triggers a bunch of things there. + // So let's wait + Thread.Sleep(2000); + + eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + + } + else + { + sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); + } + } + else + { + agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); + capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + + "/CAPS/" + agentCircuit.CapsPath + "0000/"; + } + + // Expect avatar crossing is a heavy-duty function at the destination. + // That is where MakeRoot is called, which fetches appearance and inventory. + // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. + //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, + // position, false); + + //{ + // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); + // // We should close that agent we just created over at destination... + // List lst = new List(); + // lst.Add(reg.RegionHandle); + // SendCloseChildAgentAsync(avatar.UUID, lst); + // return; + //} + + SetInTransit(sp.UUID); + + // Let's send a full update of the agent. This is a synchronous call. + AgentData agent = new AgentData(); + sp.CopyTo(agent); + agent.Position = position; + agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + + "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; + + m_aScene.SimulationService.UpdateAgent(reg, agent); + + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); + + + if (eq != null) + { + eq.TeleportFinishEvent(destinationHandle, 13, endPoint, + 0, teleportFlags, capsPath, sp.UUID); + } + else + { + sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, + teleportFlags, capsPath); + } + + // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which + // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation + // that the client contacted the destination before we send the attachments and close things here. + if (!WaitForCallback(sp.UUID)) + { + // Client never contacted destination. Let's restore everything back + sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); + + ResetFromTransit(sp.UUID); + + // Yikes! We should just have a ref to scene here. + //sp.Scene.InformClientOfNeighbours(sp); + EnableChildAgents(sp); + + // Finally, kill the agent we just created at the destination. + m_aScene.SimulationService.CloseAgent(reg, sp.UUID); + + return; + } + + KillEntity(sp.Scene, sp.LocalId); + + sp.MakeChildAgent(); + + // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it + sp.CrossAttachmentsIntoNewRegion(reg, true); + + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone + + if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) + { + Thread.Sleep(5000); + sp.Close(); + sp.Scene.IncomingCloseAgent(sp.UUID); + } + else + // now we have a child agent in this region. + sp.Reset(); + + + // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! + if (sp.Scene.NeedSceneCacheClear(sp.UUID)) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: User {0} is going to another region, profile cache removed", + sp.UUID); + } + } + else + { + sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); + } + } + else + { + // TP to a place that doesn't exist (anymore) + // Inform the viewer about that + sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); + + // and set the map-tile to '(Offline)' + uint regX, regY; + Utils.LongToUInts(regionHandle, out regX, out regY); + + MapBlockData block = new MapBlockData(); + block.X = (ushort)(regX / Constants.RegionSize); + block.Y = (ushort)(regY / Constants.RegionSize); + block.Access = 254; // == not there + + List blocks = new List(); + blocks.Add(block); + sp.ControllingClient.SendMapBlock(blocks, 0); + } + } + } + + protected void KillEntity(Scene scene, uint localID) + { + scene.SendKillObject(localID); + } + + protected virtual ulong GetRegionHandle(GridRegion region) + { + return region.RegionHandle; + } + + protected virtual GridRegion GetFinalDestination(GridRegion region) + { + return region; + } + + protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) + { + return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); + } + + protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) + { + return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); + } + + protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) + { + + if (s.TestBorderCross(pos, Cardinals.N)) + return true; + if (s.TestBorderCross(pos, Cardinals.S)) + return true; + if (s.TestBorderCross(pos, Cardinals.E)) + return true; + if (s.TestBorderCross(pos, Cardinals.W)) + return true; + + return false; + } + + + #endregion + + #region Enable Child Agent + /// + /// This informs a single neighboring region about agent "avatar". + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + public void EnableChildAgent(ScenePresence sp, GridRegion region) + { + AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = new Vector3(128, 128, 70); + agent.child = true; + agent.Appearance = sp.Appearance; + + InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, + InformClientOfNeighbourCompleted, + d); + } + #endregion + + #region Crossings + + public void Cross(ScenePresence agent, bool isFlying) + { + Scene scene = agent.Scene; + Vector3 pos = agent.AbsolutePosition; + Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); + uint neighbourx = scene.RegionInfo.RegionLocX; + uint neighboury = scene.RegionInfo.RegionLocY; + const float boundaryDistance = 1.7f; + Vector3 northCross = new Vector3(0, boundaryDistance, 0); + Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); + Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); + Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0); + + // distance to edge that will trigger crossing + + + // distance into new region to place avatar + const float enterDistance = 0.5f; + + if (scene.TestBorderCross(pos + westCross, Cardinals.W)) + { + if (scene.TestBorderCross(pos + northCross, Cardinals.N)) + { + Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); + neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); + } + else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) + { + Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = b.TriggerRegionY; + neighbourx = b.TriggerRegionX; + + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } + } + + Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); + if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) + { + neighbourx--; + newpos.X = Constants.RegionSize - enterDistance; + } + else + { + neighboury = ba.TriggerRegionY; + neighbourx = ba.TriggerRegionX; + + + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + + + return; + } + + } + else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) + { + Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E); + neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); + newpos.X = enterDistance; + + if (scene.TestBorderCross(pos + southCross, Cardinals.S)) + { + Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = ba.TriggerRegionY; + neighbourx = ba.TriggerRegionX; + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } + } + else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) + { + Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N); + neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); + newpos.Y = enterDistance; + } + + + } + else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) + { + Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); + if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else + { + neighboury = b.TriggerRegionY; + neighbourx = b.TriggerRegionX; + Vector3 newposition = pos; + newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; + newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; + agent.ControllingClient.SendAgentAlertMessage( + String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); + InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); + return; + } + } + else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) + { + + Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); + neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); + newpos.Y = enterDistance; + } + + /* + + if (pos.X < boundaryDistance) //West + { + neighbourx--; + newpos.X = Constants.RegionSize - enterDistance; + } + else if (pos.X > Constants.RegionSize - boundaryDistance) // East + { + neighbourx++; + newpos.X = enterDistance; + } + + if (pos.Y < boundaryDistance) // South + { + neighboury--; + newpos.Y = Constants.RegionSize - enterDistance; + } + else if (pos.Y > Constants.RegionSize - boundaryDistance) // North + { + neighboury++; + newpos.Y = enterDistance; + } + */ + + CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; + d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); + + } + + + public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY, + Vector3 position, + Scene initiatingScene); + + private void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, Scene initiatingScene) + { + + // This assumes that we know what our neighbors are. + + InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; + d.BeginInvoke(agent, regionX, regionY, position, initiatingScene, + InformClientToInitiateTeleportToLocationCompleted, + d); + } + + public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position, + Scene initiatingScene) + { + Thread.Sleep(10000); + IMessageTransferModule im = initiatingScene.RequestModuleInterface(); + if (im != null) + { + UUID gotoLocation = Util.BuildFakeParcelID( + Util.UIntsToLong( + (regionX * + (uint)Constants.RegionSize), + (regionY * + (uint)Constants.RegionSize)), + (uint)(int)position.X, + (uint)(int)position.Y, + (uint)(int)position.Z); + GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero, + "Region", agent.UUID, + (byte)InstantMessageDialog.GodLikeRequestTeleport, false, + "", gotoLocation, false, new Vector3(127, 0, 0), + new Byte[0]); + im.SendInstantMessage(m, delegate(bool success) + { + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); + }); + + } + } + + private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) + { + InformClientToInitateTeleportToLocationDelegate icon = + (InformClientToInitateTeleportToLocationDelegate)iar.AsyncState; + icon.EndInvoke(iar); + } + + public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); + + /// + /// This Closes child agents on neighboring regions + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) + { + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); + + Scene m_scene = agent.Scene; + ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); + + int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); + GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); + + if (neighbourRegion != null && agent.ValidateAttachments()) + { + pos = pos + (agent.Velocity); + + SetInTransit(agent.UUID); + AgentData cAgent = new AgentData(); + agent.CopyTo(cAgent); + cAgent.Position = pos; + if (isFlying) + cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; + cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort + + "/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; + + m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent); + + // Next, let's close the child agent connections that are too far away. + agent.CloseChildAgents(neighbourx, neighboury); + + //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); + agent.ControllingClient.RequestClientInfo(); + + //m_log.Debug("BEFORE CROSS"); + //Scene.DumpChildrenSeeds(UUID); + //DumpKnownRegions(); + string agentcaps; + if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) + { + m_log.ErrorFormat("[AGENT TRANSFER MODULE]: No AGENT TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", + neighbourRegion.RegionHandle); + return agent; + } + // TODO Should construct this behind a method + string capsPath = + "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; + + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); + + IEventQueue eq = agent.Scene.RequestModuleInterface(); + if (eq != null) + { + eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, + capsPath, agent.UUID, agent.ControllingClient.SessionId); + } + else + { + agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, + capsPath); + } + + if (!WaitForCallback(agent.UUID)) + { + m_log.Debug("[AGENT TRANSFER MODULE]: Callback never came in crossing agent"); + ResetFromTransit(agent.UUID); + + // Yikes! We should just have a ref to scene here. + //agent.Scene.InformClientOfNeighbours(agent); + EnableChildAgents(agent); + + return agent; + } + + agent.MakeChildAgent(); + // now we have a child agent in this region. Request all interesting data about other (root) agents + agent.SendInitialFullUpdateToAllClients(); + + agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true); + + // m_scene.SendKillObject(m_localId); + + agent.Scene.NotifyMyCoarseLocationChange(); + // the user may change their profile information in other region, + // so the userinfo in UserProfileCache is not reliable any more, delete it + // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! + if (agent.Scene.NeedSceneCacheClear(agent.UUID)) + { + m_log.DebugFormat( + "[AGENT TRANSFER MODULE]: User {0} is going to another region", agent.UUID); + } + } + + //m_log.Debug("AFTER CROSS"); + //Scene.DumpChildrenSeeds(UUID); + //DumpKnownRegions(); + return agent; + } + + private void CrossAgentToNewRegionCompleted(IAsyncResult iar) + { + CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; + ScenePresence agent = icon.EndInvoke(iar); + + // If the cross was successful, this agent is a child agent + if (agent.IsChildAgent) + agent.Reset(); + else // Not successful + agent.RestoreInCurrentScene(); + + // In any case + agent.NotInTransit(); + + //m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); + } + + #endregion + + + #region Enable Child Agents + + private delegate void InformClientOfNeighbourDelegate( + ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); + + /// + /// This informs all neighboring regions about agent "avatar". + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + public void EnableChildAgents(ScenePresence sp) + { + List neighbours = new List(); + RegionInfo m_regionInfo = sp.Scene.RegionInfo; + + if (m_regionInfo != null) + { + neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); + } + else + { + m_log.Debug("[AGENT TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); + } + + /// We need to find the difference between the new regions where there are no child agents + /// and the regions where there are already child agents. We only send notification to the former. + List neighbourHandles = NeighbourHandles(neighbours); // on this region + neighbourHandles.Add(sp.Scene.RegionInfo.RegionHandle); // add this region too + List previousRegionNeighbourHandles; + + if (sp.Scene.CapsModule != null) + { + previousRegionNeighbourHandles = + new List(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID).Keys); + } + else + { + previousRegionNeighbourHandles = new List(); + } + + List newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); + List oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); + + //Dump("Current Neighbors", neighbourHandles); + //Dump("Previous Neighbours", previousRegionNeighbourHandles); + //Dump("New Neighbours", newRegions); + //Dump("Old Neighbours", oldRegions); + + /// Update the scene presence's known regions here on this region + sp.DropOldNeighbours(oldRegions); + + /// Collect as many seeds as possible + Dictionary seeds; + if (sp.Scene.CapsModule != null) + seeds + = new Dictionary(sp.Scene.CapsModule.GetChildrenSeeds(sp.UUID)); + else + seeds = new Dictionary(); + + //m_log.Debug(" !!! No. of seeds: " + seeds.Count); + if (!seeds.ContainsKey(sp.Scene.RegionInfo.RegionHandle)) + seeds.Add(sp.Scene.RegionInfo.RegionHandle, sp.ControllingClient.RequestClientInfo().CapsPath); + + /// Create the necessary child agents + List cagents = new List(); + foreach (GridRegion neighbour in neighbours) + { + if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) + { + + AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = new Vector3(128, 128, 70); + agent.child = true; + agent.Appearance = sp.Appearance; + + if (newRegions.Contains(neighbour.RegionHandle)) + { + agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + sp.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath); + seeds.Add(neighbour.RegionHandle, agent.CapsPath); + } + else + agent.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, neighbour.RegionHandle); + + cagents.Add(agent); + } + } + + /// Update all child agent with everyone's seeds + foreach (AgentCircuitData a in cagents) + { + a.ChildrenCapSeeds = new Dictionary(seeds); + } + + if (sp.Scene.CapsModule != null) + { + sp.Scene.CapsModule.SetChildrenSeed(sp.UUID, seeds); + } + sp.KnownRegions = seeds; + //avatar.Scene.DumpChildrenSeeds(avatar.UUID); + //avatar.DumpKnownRegions(); + + bool newAgent = false; + int count = 0; + foreach (GridRegion neighbour in neighbours) + { + //m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); + // Don't do it if there's already an agent in that region + if (newRegions.Contains(neighbour.RegionHandle)) + newAgent = true; + else + newAgent = false; + + if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) + { + InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + try + { + d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, + InformClientOfNeighbourCompleted, + d); + } + + catch (ArgumentOutOfRangeException) + { + m_log.ErrorFormat( + "[AGENT TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", + neighbour.ExternalHostName, + neighbour.RegionHandle, + neighbour.RegionLocX, + neighbour.RegionLocY); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[AGENT TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", + neighbour.ExternalHostName, + neighbour.RegionHandle, + neighbour.RegionLocX, + neighbour.RegionLocY, + e); + + // FIXME: Okay, even though we've failed, we're still going to throw the exception on, + // since I don't know what will happen if we just let the client continue + + // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. + // throw e; + + } + } + count++; + } + } + + private void InformClientOfNeighbourCompleted(IAsyncResult iar) + { + InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; + icon.EndInvoke(iar); + //m_log.WarnFormat(" --> InformClientOfNeighbourCompleted"); + } + + /// + /// Async component for informing client of which neighbours exist + /// + /// + /// This needs to run asynchronously, as a network timeout may block the thread for a long while + /// + /// + /// + /// + /// + private void InformClientOfNeighbourAsync(ScenePresence sp, AgentCircuitData a, GridRegion reg, + IPEndPoint endPoint, bool newAgent) + { + // Let's wait just a little to give time to originating regions to catch up with closing child agents + // after a cross here + Thread.Sleep(500); + + Scene m_scene = sp.Scene; + + uint x, y; + Utils.LongToUInts(reg.RegionHandle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + m_log.Info("[AGENT TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); + + string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + + "/CAPS/" + a.CapsPath + "0000/"; + + string reason = String.Empty; + + + bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, 0, out reason); // m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason); + + if (regionAccepted && newAgent) + { + IEventQueue eq = sp.Scene.RequestModuleInterface(); + if (eq != null) + { + #region IP Translation for NAT + IClientIPEndpoint ipepClient; + if (sp.ClientView.TryGet(out ipepClient)) + { + endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + } + #endregion + + eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); + eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1} in region {2}", + capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); + } + else + { + sp.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); + // TODO: make Event Queue disablable! + } + + m_log.Info("[AGENT TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); + + } + + } + + protected List RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) + { + RegionInfo m_regionInfo = pScene.RegionInfo; + + Border[] northBorders = pScene.NorthBorders.ToArray(); + Border[] southBorders = pScene.SouthBorders.ToArray(); + Border[] eastBorders = pScene.EastBorders.ToArray(); + Border[] westBorders = pScene.WestBorders.ToArray(); + + // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. + if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) + { + return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); + } + else + { + Vector2 extent = Vector2.Zero; + for (int i = 0; i < eastBorders.Length; i++) + { + extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; + } + for (int i = 0; i < northBorders.Length; i++) + { + extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; + } + + // Loss of fraction on purpose + extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; + extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; + + int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize; + int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize; + + int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; + int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; + + List neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); + neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); + + return neighbours; + } + } + + private List NewNeighbours(List currentNeighbours, List previousNeighbours) + { + return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); + } + + // private List CommonNeighbours(List currentNeighbours, List previousNeighbours) + // { + // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); + // } + + private List OldNeighbours(List currentNeighbours, List previousNeighbours) + { + return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); + } + + private List NeighbourHandles(List neighbours) + { + List handles = new List(); + foreach (GridRegion reg in neighbours) + { + handles.Add(reg.RegionHandle); + } + return handles; + } + + private void Dump(string msg, List handles) + { + m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg); + foreach (ulong handle in handles) + { + uint x, y; + Utils.LongToUInts(handle, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + m_log.InfoFormat("({0}, {1})", x, y); + } + } + + #endregion + + + #region Agent Arrived + public void AgentArrivedAtDestination(UUID id) + { + //m_log.Debug(" >>> ReleaseAgent called <<< "); + ResetFromTransit(id); + } + + #endregion + + + #region Misc + + protected bool WaitForCallback(UUID id) + { + int count = 200; + while (m_agentsInTransit.Contains(id) && count-- > 0) + { + //m_log.Debug(" >>> Waiting... " + count); + Thread.Sleep(100); + } + + if (count > 0) + return true; + else + return false; + } + + protected void SetInTransit(UUID id) + { + lock (m_agentsInTransit) + { + if (!m_agentsInTransit.Contains(id)) + m_agentsInTransit.Add(id); + } + } + + protected bool ResetFromTransit(UUID id) + { + lock (m_agentsInTransit) + { + if (m_agentsInTransit.Contains(id)) + { + m_agentsInTransit.Remove(id); + return true; + } + } + return false; + } + + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index f4383f1..e913891 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -43,13 +43,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private List m_sceneList = new List(); - private IAgentTransferModule m_AgentTransferModule; - protected IAgentTransferModule AgentTransferModule + private IEntityTransferModule m_AgentTransferModule; + protected IEntityTransferModule AgentTransferModule { get { if (m_AgentTransferModule == null) - m_AgentTransferModule = m_sceneList[0].RequestModuleInterface(); + m_AgentTransferModule = m_sceneList[0].RequestModuleInterface(); return m_AgentTransferModule; } } -- cgit v1.1 From f5cba18600dd3b479e87ea45cad2b133fc4cd284 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 15 Jan 2010 17:17:24 -0800 Subject: Comment --- OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index fa705be..8ec20eb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -568,6 +568,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return true; } + // From the map search public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor) { return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); -- cgit v1.1 From bd6d1a24448dafea5be7ddbcd591b352040e4412 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 16 Jan 2010 07:46:07 -0800 Subject: Moved prim crossing to EntityTransferModule. Not complete yet. --- .../EntityTransfer/EntityTransferModule.cs | 421 ++++++++++++++++++--- .../Resources/CoreModulePlugin.addin.xml | 2 +- 2 files changed, 373 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index af004b0..44d3858 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -46,15 +46,16 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { - public class AgentTransferModule : ISharedRegionModule, IEntityTransferModule + public class EntityTransferModule : ISharedRegionModule, IEntityTransferModule { - #region ISharedRegionModule - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; protected Scene m_aScene; protected List m_agentsInTransit; + #region ISharedRegionModule + public Type ReplaceableInterface { get { return null; } @@ -62,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public string Name { - get { return "AgentTransferModule"; } + get { return "BasicEntityTransferModule"; } } public virtual void Initialise(IConfigSource source) @@ -70,12 +71,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer IConfig moduleConfig = source.Configs["Modules"]; if (moduleConfig != null) { - string name = moduleConfig.GetString("AgentTransferModule", ""); + string name = moduleConfig.GetString("EntityTransferModule", ""); if (name == Name) { m_agentsInTransit = new List(); m_Enabled = true; - m_log.Info("[AGENT TRANSFER MODULE]: Enabled."); + m_log.InfoFormat("[ENTITY TRANSFER MODULE]: {0} nabled.", Name); } } } @@ -120,7 +121,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion - #region Teleports + #region Agent Teleports public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { @@ -137,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (regionHandle == sp.Scene.RegionInfo.RegionHandle) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", position, sp.Scene.RegionInfo.RegionName); // Teleport within the same region @@ -146,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 emergencyPos = new Vector3(128, 128, 128); m_log.WarnFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", position, sp.Name, sp.UUID, emergencyPos); position = emergencyPos; } @@ -183,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (reg != null) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", position, reg.RegionName); uint newRegionX = (uint)(reg.RegionHandle >> 40); @@ -338,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_aScene.SimulationService.UpdateAgent(reg, agent); m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); + "[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); if (eq != null) @@ -377,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.MakeChildAgent(); // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - sp.CrossAttachmentsIntoNewRegion(reg, true); + CrossAttachmentsIntoNewRegion(reg, sp, true); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone @@ -396,7 +397,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (sp.Scene.NeedSceneCacheClear(sp.UUID)) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: User {0} is going to another region, profile cache removed", + "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", sp.UUID); } } @@ -470,28 +471,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion - #region Enable Child Agent - /// - /// This informs a single neighboring region about agent "avatar". - /// Calls an asynchronous method to do so.. so it doesn't lag the sim. - /// - public void EnableChildAgent(ScenePresence sp, GridRegion region) - { - AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); - agent.BaseFolder = UUID.Zero; - agent.InventoryFolder = UUID.Zero; - agent.startpos = new Vector3(128, 128, 70); - agent.child = true; - agent.Appearance = sp.Appearance; - - InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; - d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, - InformClientOfNeighbourCompleted, - d); - } - #endregion - - #region Crossings + #region Agent Crossings public void Cross(ScenePresence agent, bool isFlying) { @@ -700,7 +680,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer new Byte[0]); im.SendInstantMessage(m, delegate(bool success) { - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Client Initiating Teleport sending IM success = {0}", success); }); } @@ -721,7 +701,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) { - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); Scene m_scene = agent.Scene; ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); @@ -756,7 +736,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string agentcaps; if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) { - m_log.ErrorFormat("[AGENT TRANSFER MODULE]: No AGENT TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", + m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.", neighbourRegion.RegionHandle); return agent; } @@ -765,7 +745,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); IEventQueue eq = agent.Scene.RequestModuleInterface(); if (eq != null) @@ -781,7 +761,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!WaitForCallback(agent.UUID)) { - m_log.Debug("[AGENT TRANSFER MODULE]: Callback never came in crossing agent"); + m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent"); ResetFromTransit(agent.UUID); // Yikes! We should just have a ref to scene here. @@ -795,7 +775,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); - agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true); + CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); // m_scene.SendKillObject(m_localId); @@ -806,7 +786,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (agent.Scene.NeedSceneCacheClear(agent.UUID)) { m_log.DebugFormat( - "[AGENT TRANSFER MODULE]: User {0} is going to another region", agent.UUID); + "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); } } @@ -830,11 +810,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // In any case agent.NotInTransit(); - //m_log.DebugFormat("[AGENT TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); + //m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); } #endregion + #region Enable Child Agent + /// + /// This informs a single neighboring region about agent "avatar". + /// Calls an asynchronous method to do so.. so it doesn't lag the sim. + /// + public void EnableChildAgent(ScenePresence sp, GridRegion region) + { + AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); + agent.BaseFolder = UUID.Zero; + agent.InventoryFolder = UUID.Zero; + agent.startpos = new Vector3(128, 128, 70); + agent.child = true; + agent.Appearance = sp.Appearance; + + InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; + d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, + InformClientOfNeighbourCompleted, + d); + } + #endregion #region Enable Child Agents @@ -856,7 +856,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } else { - m_log.Debug("[AGENT TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); + m_log.Debug("[ENTITY TRANSFER MODULE]: m_regionInfo was null in EnableChildAgents, is this a NPC?"); } /// We need to find the difference between the new regions where there are no child agents @@ -963,7 +963,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer catch (ArgumentOutOfRangeException) { m_log.ErrorFormat( - "[AGENT TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", + "[ENTITY TRANSFER MODULE]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", neighbour.ExternalHostName, neighbour.RegionHandle, neighbour.RegionLocX, @@ -972,7 +972,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer catch (Exception e) { m_log.ErrorFormat( - "[AGENT TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", + "[ENTITY TRANSFER MODULE]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", neighbour.ExternalHostName, neighbour.RegionHandle, neighbour.RegionLocX, @@ -1021,7 +1021,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Utils.LongToUInts(reg.RegionHandle, out x, out y); x = x / Constants.RegionSize; y = y / Constants.RegionSize; - m_log.Info("[AGENT TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); + m_log.Info("[ENTITY TRANSFER MODULE]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + a.CapsPath + "0000/"; @@ -1046,7 +1046,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - m_log.DebugFormat("[AGENT TRANSFER MODULE]: Sending new AGENT TRANSFER MODULE seed url {0} to client {1} in region {2}", + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1} in region {2}", capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); } else @@ -1055,7 +1055,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // TODO: make Event Queue disablable! } - m_log.Info("[AGENT TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); + m_log.Info("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); } @@ -1154,6 +1154,329 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion + #region Object Crossings + /// + /// Move the given scene object into a new region depending on which region its absolute position has moved + /// into. + /// + /// This method locates the new region handle and offsets the prim position for the new region + /// + /// the attempted out of region position of the scene object + /// the scene object that we're crossing + public void Cross(SceneObjectGroup grp, Vector3 attemptedPosition, bool silent) + { + if (grp == null) + return; + if (grp.IsDeleted) + return; + + Scene scene = grp.Scene; + if (scene == null) + return; + + if (grp.RootPart.DIE_AT_EDGE) + { + // We remove the object here + try + { + scene.DeleteSceneObject(grp, false); + } + catch (Exception) + { + m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); + } + return; + } + + int thisx = (int)scene.RegionInfo.RegionLocX; + int thisy = (int)scene.RegionInfo.RegionLocY; + Vector3 EastCross = new Vector3(0.1f, 0, 0); + Vector3 WestCross = new Vector3(-0.1f, 0, 0); + Vector3 NorthCross = new Vector3(0, 0.1f, 0); + Vector3 SouthCross = new Vector3(0, -0.1f, 0); + + + // use this if no borders were crossed! + ulong newRegionHandle + = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), + (uint)((thisy) * Constants.RegionSize)); + + Vector3 pos = attemptedPosition; + + int changeX = 1; + int changeY = 1; + + if (scene.TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) + { + if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + { + + Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + + + newRegionHandle + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)((thisy - changeY) * Constants.RegionSize)); + // x - 1 + // y - 1 + } + else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + { + Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + newRegionHandle + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)((thisy + changeY) * Constants.RegionSize)); + // x - 1 + // y + 1 + } + else + { + Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); + + if (crossedBorderx.BorderLine.Z > 0) + { + pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); + changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.X = ((pos.X + Constants.RegionSize)); + + newRegionHandle + = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), + (uint)(thisy * Constants.RegionSize)); + // x - 1 + } + } + else if (scene.TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) + { + if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + { + + pos.X = ((pos.X - Constants.RegionSize)); + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + + newRegionHandle + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)((thisy - changeY) * Constants.RegionSize)); + // x + 1 + // y - 1 + } + else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + { + pos.X = ((pos.X - Constants.RegionSize)); + pos.Y = ((pos.Y - Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)((thisy + changeY) * Constants.RegionSize)); + // x + 1 + // y + 1 + } + else + { + pos.X = ((pos.X - Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), + (uint)(thisy * Constants.RegionSize)); + // x + 1 + } + } + else if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) + { + Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); + //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) + + if (crossedBordery.BorderLine.Z > 0) + { + pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); + changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); + } + else + pos.Y = ((pos.Y + Constants.RegionSize)); + + newRegionHandle + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); + // y - 1 + } + else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) + { + + pos.Y = ((pos.Y - Constants.RegionSize)); + newRegionHandle + = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); + // y + 1 + } + + // Offset the positions for the new region across the border + Vector3 oldGroupPosition = grp.RootPart.GroupPosition; + grp.OffsetForNewRegion(pos); + + // If we fail to cross the border, then reset the position of the scene object on that border. + uint x = 0, y = 0; + Utils.LongToUInts(newRegionHandle, out x, out y); + GridRegion destination = scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, silent)) + { + grp.OffsetForNewRegion(oldGroupPosition); + grp.ScheduleGroupForFullUpdate(); + } + } + + + /// + /// Move the given scene object into a new region + /// + /// + /// Scene Object Group that we're crossing + /// + /// true if the crossing itself was successful, false on failure + /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region + /// + protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent) + { + //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); + + bool successYN = false; + grp.RootPart.UpdateFlag = 0; + //int primcrossingXMLmethod = 0; + + if (destination != null) + { + //string objectState = grp.GetStateSnapshot(); + + //successYN + // = m_sceneGridService.PrimCrossToNeighboringRegion( + // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); + //if (successYN && (objectState != "") && m_allowScriptCrossings) + //{ + // successYN = m_sceneGridService.PrimCrossToNeighboringRegion( + // newRegionHandle, grp.UUID, objectState, 100); + //} + + //// And the new channel... + //if (m_interregionCommsOut != null) + // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); + if (m_aScene.SimulationService != null) + successYN = m_aScene.SimulationService.CreateObject(destination, grp, true); + + if (successYN) + { + // We remove the object here + try + { + grp.Scene.DeleteSceneObject(grp, silent); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[ENTITY TRANSFER MODULE]: Exception deleting the old object left behind on a border crossing for {0}, {1}", + grp, e); + } + } + else + { + if (!grp.IsDeleted) + { + if (grp.RootPart.PhysActor != null) + { + grp.RootPart.PhysActor.CrossingFailure(); + } + } + + m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); + } + } + else + { + m_log.Error("[ENTITY TRANSFER MODULE]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()"); + } + + return successYN; + } + + protected bool CrossAttachmentsIntoNewRegion(GridRegion destination, ScenePresence sp, bool silent) + { + List m_attachments = sp.Attachments; + lock (m_attachments) + { + // Validate + foreach (SceneObjectGroup gobj in m_attachments) + { + if (gobj == null || gobj.IsDeleted) + return false; + } + + foreach (SceneObjectGroup gobj in m_attachments) + { + // If the prim group is null then something must have happened to it! + if (gobj != null && gobj.RootPart != null) + { + // Set the parent localID to 0 so it transfers over properly. + gobj.RootPart.SetParentLocalId(0); + gobj.AbsolutePosition = gobj.RootPart.AttachedPos; + gobj.RootPart.IsAttachment = false; + //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); + CrossPrimGroupIntoNewRegion(destination, gobj, silent); + } + } + m_attachments.Clear(); + + return true; + } + } + + #endregion #region Misc diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 106e87c..68cf060 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -8,7 +8,7 @@ - + -- cgit v1.1 From ee1fb81376041f6eef27bbb3e84b56ae6e2357b3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 16 Jan 2010 08:42:20 -0800 Subject: Finished moving object crossings into EntityTransferModule --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 44d3858..25415af 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -339,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_aScene.SimulationService.UpdateAgent(reg, agent); m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1}", capsPath, sp.UUID); + "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); if (eq != null) @@ -745,7 +745,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1}", capsPath, agent.UUID); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); IEventQueue eq = agent.Scene.RequestModuleInterface(); if (eq != null) @@ -1046,7 +1046,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new ENTITY TRANSFER MODULE seed url {0} to client {1} in region {2}", + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1} in region {2}", capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); } else -- cgit v1.1 From 04e29c1bacbc1e2df980ae15896a847ce7535da2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 16 Jan 2010 21:42:44 -0800 Subject: Beginning of rewriting HG. Compiles, and runs, but HG functions not restored yet. --- .../EntityTransfer/EntityTransferModule.cs | 2 +- .../Grid/HypergridServiceInConnectorModule.cs | 14 +- .../ServiceConnectorsOut/Grid/HGCommands.cs | 303 ---------- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 650 ++------------------- 4 files changed, 48 insertions(+), 921 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 25415af..827dafe 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1154,7 +1154,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion - #region Object Crossings + #region Object Transfers /// /// Move the given scene object into a new region depending on which region its absolute position has moved /// into. diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index b12d778..6ec0fcf 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -36,7 +36,7 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Interfaces; using OpenSim.Server.Base; using OpenSim.Server.Handlers.Base; -using OpenSim.Server.Handlers.Grid; +using OpenSim.Server.Handlers.Hypergrid; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid private IConfigSource m_Config; bool m_Registered = false; - HypergridServiceInConnector m_HypergridHandler; + GatekeeperServiceInConnector m_HypergridHandler; #region IRegionModule interface @@ -102,9 +102,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid { if (!m_Enabled) return; - - GridRegion rinfo = new GridRegion(scene.RegionInfo); - m_HypergridHandler.RemoveRegion(rinfo); } public void RegionLoaded(Scene scene) @@ -119,13 +116,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid m_log.Info("[HypergridService]: Starting..."); // Object[] args = new Object[] { m_Config, MainServer.Instance }; - - m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance, scene.RequestModuleInterface()); + ISimulationService simService = scene.RequestModuleInterface(); + m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); } - - GridRegion rinfo = new GridRegion(scene.RegionInfo); - m_HypergridHandler.AddRegion(rinfo); } #endregion diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs deleted file mode 100644 index 0974372..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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 System.Xml; -using log4net; -using Nini.Config; -using OpenSim.Framework; -//using OpenSim.Framework.Communications; -using OpenSim.Framework.Console; -using OpenSim.Region.Framework; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid -{ - public class HGCommands - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private HGGridConnector m_HGGridConnector; - private Scene m_scene; - - private static uint m_autoMappingX = 0; - private static uint m_autoMappingY = 0; - private static bool m_enableAutoMapping = false; - - public HGCommands(HGGridConnector hgConnector, Scene scene) - { - m_HGGridConnector = hgConnector; - m_scene = scene; - } - - //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, - // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) - //{ - // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); - - // return - // new HGScene( - // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, - // m_moduleLoader, false, m_configSettings.PhysicalPrim, - // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); - //} - - public void RunCommand(string module, string[] cmdparams) - { - List args = new List(cmdparams); - if (args.Count < 1) - return; - - string command = args[0]; - args.RemoveAt(0); - - cmdparams = args.ToArray(); - - RunHGCommand(command, cmdparams); - - } - - private void RunHGCommand(string command, string[] cmdparams) - { - if (command.Equals("link-mapping")) - { - if (cmdparams.Length == 2) - { - try - { - m_autoMappingX = Convert.ToUInt32(cmdparams[0]); - m_autoMappingY = Convert.ToUInt32(cmdparams[1]); - m_enableAutoMapping = true; - } - catch (Exception) - { - m_autoMappingX = 0; - m_autoMappingY = 0; - m_enableAutoMapping = false; - } - } - } - else if (command.Equals("link-region")) - { - if (cmdparams.Length < 3) - { - if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) - { - LoadXmlLinkFile(cmdparams); - } - else - { - LinkRegionCmdUsage(); - } - return; - } - - if (cmdparams[2].Contains(":")) - { - // New format - int xloc, yloc; - string mapName; - try - { - xloc = Convert.ToInt32(cmdparams[0]); - yloc = Convert.ToInt32(cmdparams[1]); - mapName = cmdparams[2]; - if (cmdparams.Length > 3) - for (int i = 3; i < cmdparams.Length; i++) - mapName += " " + cmdparams[i]; - - m_log.Info(">> MapName: " + mapName); - //internalPort = Convert.ToUInt32(cmdparams[4]); - //remotingPort = Convert.ToUInt32(cmdparams[5]); - } - catch (Exception e) - { - m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); - LinkRegionCmdUsage(); - return; - } - - // Convert cell coordinates given by the user to meters - xloc = xloc * (int)Constants.RegionSize; - yloc = yloc * (int)Constants.RegionSize; - m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); - } - else - { - // old format - GridRegion regInfo; - int xloc, yloc; - uint externalPort; - string externalHostName; - try - { - xloc = Convert.ToInt32(cmdparams[0]); - yloc = Convert.ToInt32(cmdparams[1]); - externalPort = Convert.ToUInt32(cmdparams[3]); - externalHostName = cmdparams[2]; - //internalPort = Convert.ToUInt32(cmdparams[4]); - //remotingPort = Convert.ToUInt32(cmdparams[5]); - } - catch (Exception e) - { - m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); - LinkRegionCmdUsage(); - return; - } - - // Convert cell coordinates given by the user to meters - xloc = xloc * (int)Constants.RegionSize; - yloc = yloc * (int)Constants.RegionSize; - if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) - { - if (cmdparams.Length >= 5) - { - regInfo.RegionName = ""; - for (int i = 4; i < cmdparams.Length; i++) - regInfo.RegionName += cmdparams[i] + " "; - } - } - } - return; - } - else if (command.Equals("unlink-region")) - { - if (cmdparams.Length < 1) - { - UnlinkRegionCmdUsage(); - return; - } - if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0])) - m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]); - else - m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]); - } - } - - private void LoadXmlLinkFile(string[] cmdparams) - { - //use http://www.hgurl.com/hypergrid.xml for test - try - { - XmlReader r = XmlReader.Create(cmdparams[0]); - XmlConfigSource cs = new XmlConfigSource(r); - string[] excludeSections = null; - - if (cmdparams.Length == 2) - { - if (cmdparams[1].ToLower().StartsWith("excludelist:")) - { - string excludeString = cmdparams[1].ToLower(); - excludeString = excludeString.Remove(0, 12); - char[] splitter = { ';' }; - - excludeSections = excludeString.Split(splitter); - } - } - - for (int i = 0; i < cs.Configs.Count; i++) - { - bool skip = false; - if ((excludeSections != null) && (excludeSections.Length > 0)) - { - for (int n = 0; n < excludeSections.Length; n++) - { - if (excludeSections[n] == cs.Configs[i].Name.ToLower()) - { - skip = true; - break; - } - } - } - if (!skip) - { - ReadLinkFromConfig(cs.Configs[i]); - } - } - } - catch (Exception e) - { - m_log.Error(e.ToString()); - } - } - - - private void ReadLinkFromConfig(IConfig config) - { - GridRegion regInfo; - int xloc, yloc; - uint externalPort; - string externalHostName; - uint realXLoc, realYLoc; - - xloc = Convert.ToInt32(config.GetString("xloc", "0")); - yloc = Convert.ToInt32(config.GetString("yloc", "0")); - externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); - externalHostName = config.GetString("externalHostName", ""); - realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); - realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); - - if (m_enableAutoMapping) - { - xloc = (int)((xloc % 100) + m_autoMappingX); - yloc = (int)((yloc % 100) + m_autoMappingY); - } - - if (((realXLoc == 0) && (realYLoc == 0)) || - (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && - ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) - { - xloc = xloc * (int)Constants.RegionSize; - yloc = yloc * (int)Constants.RegionSize; - if ( - m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, - externalHostName, out regInfo)) - { - regInfo.RegionName = config.GetString("localName", ""); - } - } - } - - - private void LinkRegionCmdUsage() - { - m_log.Info("Usage: link-region :[:]"); - m_log.Info("Usage: link-region []"); - m_log.Info("Usage: link-region []"); - } - - private void UnlinkRegionCmdUsage() - { - m_log.Info("Usage: unlink-region :"); - m_log.Info("Usage: unlink-region "); - } - - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index de71b56..75eb889 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -49,12 +49,11 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { - public class HGGridConnector : ISharedRegionModule, IGridService, IHyperlinkService + public class HGGridConnector : ISharedRegionModule, IGridService { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private static string LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI; private bool m_Enabled = false; private bool m_Initialized = false; @@ -63,18 +62,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private Dictionary m_LocalScenes = new Dictionary(); private IGridService m_GridServiceConnector; - private HypergridServiceConnector m_HypergridServiceConnector; + private IHypergridService m_HypergridService; - // Hyperlink regions are hyperlinks on the map - protected Dictionary m_HyperlinkRegions = new Dictionary(); - - // Known regions are home regions of visiting foreign users. - // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when - // the visitor goes away. They are mapped to X=0 on the map. - // This is key-ed on agent ID - protected Dictionary m_knownRegions = new Dictionary(); - - protected Dictionary m_HyperlinkHandles = new Dictionary(); #region ISharedRegionModule @@ -125,13 +114,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (module == String.Empty) { m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); - //return; throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); } Object[] args = new Object[] { source }; m_GridServiceConnector = ServerUtils.LoadPlugin(module, args); + string hypergrid = gridConfig.GetString("HypergridService", string.Empty); + if (hypergrid == String.Empty) + { + m_log.Error("[HGGRID CONNECTOR]: No HypergridService named in section GridService"); + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + m_HypergridService = ServerUtils.LoadPlugin(hypergrid, args); + + if (m_GridServiceConnector == null || m_HypergridService == null) + throw new Exception("Unable to proceed. HGGrid services could not be loaded."); } public void PostInitialise() @@ -151,7 +149,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; scene.RegisterModuleInterface(this); - scene.RegisterModuleInterface(this); ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); @@ -175,18 +172,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { m_aScene = scene; - m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); - - HGCommands hgCommands = new HGCommands(this, scene); - MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-region", - "link-region :[:] ", - "Link a hypergrid region", hgCommands.RunCommand); - MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlink-region", - "unlink-region or : ", - "Unlink a hypergrid region", hgCommands.RunCommand); - MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "link-mapping", "link-mapping [ ] ", - "Set local coordinate to map HG regions to", hgCommands.RunCommand); - m_Initialized = true; } } @@ -197,50 +182,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public string RegisterRegion(UUID scopeID, GridRegion regionInfo) { - // Region doesn't exist here. Trying to link remote region - if (regionInfo.RegionID.Equals(UUID.Zero)) - { - m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); - ulong regionHandle = 0; - regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle); - if (!regionInfo.RegionID.Equals(UUID.Zero)) - { - AddHyperlinkRegion(regionInfo, regionHandle); - m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); - - // Try get the map image - m_HypergridServiceConnector.GetMapImage(regionInfo); - return String.Empty; - } - else - { - m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); - return "No such region"; - } - // Note that these remote regions aren't registered in localBackend, so return null, no local listeners - } - else // normal grid - return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); + return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); } public bool DeregisterRegion(UUID regionID) { - // Try the hyperlink collection - if (m_HyperlinkRegions.ContainsKey(regionID)) - { - RemoveHyperlinkRegion(regionID); - return true; - } - // Try the foreign users home collection - - foreach (GridRegion r in m_knownRegions.Values) - if (r.RegionID == regionID) - { - RemoveHyperlinkHomeRegion(regionID); - return true; - } - - // Finally, try the normal route return m_GridServiceConnector.DeregisterRegion(regionID); } @@ -253,41 +199,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { - // Try the hyperlink collection - if (m_HyperlinkRegions.ContainsKey(regionID)) - return m_HyperlinkRegions[regionID]; - - // Try the foreign users home collection - foreach (GridRegion r in m_knownRegions.Values) - if (r.RegionID == regionID) - return r; - - // Finally, try the normal route - return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); + GridRegion region = m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); + if (region != null) + return region; + + region = m_HypergridService.GetRegionByUUID(regionID); + + return region; } public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; - // Try the hyperlink collection - foreach (GridRegion r in m_HyperlinkRegions.Values) - { - if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) - return r; - } - // Try the foreign users home collection - foreach (GridRegion r in m_knownRegions.Values) - { - if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) - { - return r; - } - } + GridRegion region = m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); + if (region != null) + return region; + + region = m_HypergridService.GetRegionByPosition(snapX, snapY); - // Finally, try the normal route - return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); + return region; } public GridRegion GetRegionByName(UUID scopeID, string regionName) @@ -297,551 +229,55 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (region != null) return region; - // Try the hyperlink collection - foreach (GridRegion r in m_HyperlinkRegions.Values) - { - if (r.RegionName == regionName) - return r; - } + region = m_HypergridService.GetRegionByName(regionName); - // Try the foreign users home collection - foreach (GridRegion r in m_knownRegions.Values) - { - if (r.RegionName == regionName) - return r; - } - return null; + return region; } public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { - List rinfos = new List(); - if (name == string.Empty) - return rinfos; - - foreach (GridRegion r in m_HyperlinkRegions.Values) - if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower())) - rinfos.Add(r); + return new List(); + + List rinfos = m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber); + + rinfos.AddRange(m_HypergridService.GetRegionsByName(name)); + if (rinfos.Count > maxNumber) + rinfos.RemoveRange(maxNumber - 1, rinfos.Count - maxNumber); - rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); return rinfos; } public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; -// int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; - List rinfos = new List(); - foreach (GridRegion r in m_HyperlinkRegions.Values) - if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && - (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) - rinfos.Add(r); + List rinfos = m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); - rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax)); + rinfos.AddRange(m_HypergridService.GetRegionRange(snapXmin, snapXmax, snapYmin, snapYmax)); return rinfos; } - #endregion - - #region Auxiliary - - private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) - { - m_HyperlinkRegions[regionInfo.RegionID] = regionInfo; - m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; - } - - private void RemoveHyperlinkRegion(UUID regionID) - { - m_HyperlinkRegions.Remove(regionID); - m_HyperlinkHandles.Remove(regionID); - } - - private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) - { - m_knownRegions[userID] = regionInfo; - m_HyperlinkHandles[regionInfo.RegionID] = regionHandle; - } - - private void RemoveHyperlinkHomeRegion(UUID regionID) - { - foreach (KeyValuePair kvp in m_knownRegions) - { - if (kvp.Value.RegionID == regionID) - { - m_knownRegions.Remove(kvp.Key); - } - } - m_HyperlinkHandles.Remove(regionID); - } - #endregion - - #region IHyperlinkService - - private static Random random = new Random(); - - // From the command line link-region - public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) - { - string host = "127.0.0.1"; - string portstr; - string regionName = ""; - uint port = 9000; - string[] parts = mapName.Split(new char[] { ':' }); - if (parts.Length >= 1) - { - host = parts[0]; - } - if (parts.Length >= 2) - { - portstr = parts[1]; - //m_log.Debug("-- port = " + portstr); - if (!UInt32.TryParse(portstr, out port)) - regionName = parts[1]; - } - // always take the last one - if (parts.Length >= 3) - { - regionName = parts[2]; - } - - // Sanity check. Don't ever link to this sim. - IPAddress ipaddr = null; - try - { - ipaddr = Util.GetHostFromDNS(host); - } - catch { } - - if ((ipaddr != null) && - !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) - { - GridRegion regInfo; - bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); - if (success) - { - regInfo.RegionName = mapName; - return regInfo; - } - } - - return null; - } - - - // From the map search and secondlife://blah - public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) - { - int xloc = random.Next(0, Int16.MaxValue) * (int) Constants.RegionSize; - return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); - } - - // From the command line and the 2 above - public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, - string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) - { - m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); - - regInfo = new GridRegion(); - regInfo.RegionName = externalRegionName; - regInfo.HttpPort = externalPort; - regInfo.ExternalHostName = externalHostName; - regInfo.RegionLocX = xloc; - regInfo.RegionLocY = yloc; - - try - { - regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); - } - catch (Exception e) - { - m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); - return false; - } - - // Finally, link it - if (RegisterRegion(UUID.Zero, regInfo) != String.Empty) - { - m_log.Warn("[HGrid]: Unable to link region"); - return false; - } - - int x, y; - if (!Check4096(m_scene, regInfo, out x, out y)) - { - DeregisterRegion(regInfo.RegionID); - if (client != null) - client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); - m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); - return false; - } - - if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) - { - DeregisterRegion(regInfo.RegionID); - if (client != null) - client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); - m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); - return false; - } - - m_log.Debug("[HGrid]: link region succeeded"); - return true; - } - - public bool TryUnlinkRegion(Scene m_scene, string mapName) - { - GridRegion regInfo = null; - if (mapName.Contains(":")) - { - string host = "127.0.0.1"; - //string portstr; - //string regionName = ""; - uint port = 9000; - string[] parts = mapName.Split(new char[] { ':' }); - if (parts.Length >= 1) - { - host = parts[0]; - } - // if (parts.Length >= 2) - // { - // portstr = parts[1]; - // if (!UInt32.TryParse(portstr, out port)) - // regionName = parts[1]; - // } - // always take the last one - // if (parts.Length >= 3) - // { - // regionName = parts[2]; - // } - foreach (GridRegion r in m_HyperlinkRegions.Values) - if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) - regInfo = r; - } - else - { - foreach (GridRegion r in m_HyperlinkRegions.Values) - if (r.RegionName.Equals(mapName)) - regInfo = r; - } - if (regInfo != null) - { - return DeregisterRegion(regInfo.RegionID); - } - else - { - m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); - return false; - } - } - - /// - /// Cope with this viewer limitation. - /// - /// - /// - public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y) - { - ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; - uint ux = 0, uy = 0; - Utils.LongToUInts(realHandle, out ux, out uy); - x = (int)(ux / Constants.RegionSize); - y = (int)(uy / Constants.RegionSize); - - if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - x) >= 4096) || - (Math.Abs((int)m_scene.RegionInfo.RegionLocY - y) >= 4096)) - { - return false; - } - return true; - } - - public bool CheckCoords(uint thisx, uint thisy, int x, int y) - { - if ((thisx == x) && (thisy == y)) - return false; - return true; - } - - // From the map search - public GridRegion TryLinkRegion(IClientAPI client, string regionDescriptor) - { - return TryLinkRegion((Scene)client.Scene, client, regionDescriptor); - } - - // From the map and secondlife://blah - public GridRegion GetHyperlinkRegion(ulong handle) - { - foreach (GridRegion r in m_HyperlinkRegions.Values) - if (r.RegionHandle == handle) - return r; - foreach (GridRegion r in m_knownRegions.Values) - if (r.RegionHandle == handle) - return r; - return null; - } - - public ulong FindRegionHandle(ulong handle) - { - foreach (GridRegion r in m_HyperlinkRegions.Values) - if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) - return m_HyperlinkHandles[r.RegionID]; - - foreach (GridRegion r in m_knownRegions.Values) - if ((r.RegionHandle == handle) && (m_HyperlinkHandles.ContainsKey(r.RegionID))) - return m_HyperlinkHandles[r.RegionID]; - - return handle; - } - - public bool SendUserInformation(GridRegion regInfo, AgentCircuitData agentData) - { - // REFACTORING PROBLEM. This needs to change. Some of this info should go with the agent circuit data. - - //UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, agentData.AgentID); - //if (account == null) - // return false; - - //if ((IsLocalUser(account) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) || - // (!IsLocalUser(account) && !IsGoingHome(uinfo, regInfo))) - //{ - // m_log.Info("[HGrid]: Local user is going to foreign region or foreign user is going elsewhere"); - - // PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(agentData.SessionID); - // if (pinfo != null) - // { - // // Set the position of the region on the remote grid - // // ulong realHandle = FindRegionHandle(regInfo.RegionHandle); - // uint x = 0, y = 0; - // Utils.LongToUInts(regInfo.RegionHandle, out x, out y); - // GridRegion clonedRegion = new GridRegion(regInfo); - // clonedRegion.RegionLocX = (int)x; - // clonedRegion.RegionLocY = (int)y; - - // // Get the user's home region information and adapt the region handle - // GridRegion home = GetRegionByUUID(m_aScene.RegionInfo.ScopeID, pinfo.HomeRegionID); - // if (m_HyperlinkHandles.ContainsKey(pinfo.HomeRegionID)) - // { - // ulong realHandle = m_HyperlinkHandles[pinfo.HomeRegionID]; - // Utils.LongToUInts(realHandle, out x, out y); - // m_log.DebugFormat("[HGrid]: Foreign user is going elsewhere. Adjusting home handle from {0}-{1} to {2}-{3}", home.RegionLocX, home.RegionLocY, x, y); - // home.RegionLocX = (int)x; - // home.RegionLocY = (int)y; - // } - - // // Get the user's service URLs - // string serverURI = ""; - // if (uinfo.UserProfile is ForeignUserProfileData) - // serverURI = Util.ServerURI(((ForeignUserProfileData)uinfo.UserProfile).UserServerURI); - // string userServer = (serverURI == "") || (serverURI == null) ? LocalUserServerURI : serverURI; - - // string assetServer = Util.ServerURI(uinfo.UserProfile.UserAssetURI); - // if ((assetServer == null) || (assetServer == "")) - // assetServer = LocalAssetServerURI; - - // string inventoryServer = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); - // if ((inventoryServer == null) || (inventoryServer == "")) - // inventoryServer = LocalInventoryServerURI; - - // if (!m_HypergridServiceConnector.InformRegionOfUser(clonedRegion, agentData, home, userServer, assetServer, inventoryServer)) - // { - // m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); - // return false; - // } - // } - // else - // { - // m_log.Warn("[HGrid]: Unable to find local presence of transferring user."); - // return false; - // } - //} - ////if ((uinfo == null) || !IsGoingHome(uinfo, regInfo)) - ////{ - //// m_log.Info("[HGrid]: User seems to be going to foreign region."); - //// if (!InformRegionOfUser(regInfo, agentData)) - //// { - //// m_log.Warn("[HGrid]: Could not inform remote region of transferring user."); - //// return false; - //// } - ////} - ////else - //// m_log.Info("[HGrid]: User seems to be going home " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName); - - //// May need to change agent's name - //if (IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) - //{ - // agentData.firstname = agentData.firstname + "." + agentData.lastname; - // agentData.lastname = "@" + LocalUserServerURI.Replace("http://", ""); ; //HGNetworkServersInfo.Singleton.LocalUserServerURI; - //} - - return true; - } - - public void AdjustUserInformation(AgentCircuitData agentData) - { - // REFACTORING PROBLEM!!! This needs to change - - //CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID); - //if ((uinfo != null) && (uinfo.UserProfile != null) && - // (IsLocalUser(uinfo) || !(uinfo.UserProfile is ForeignUserProfileData))) - //{ - // //m_log.Debug("---------------> Local User!"); - // string[] parts = agentData.firstname.Split(new char[] { '.' }); - // if (parts.Length == 2) - // { - // agentData.firstname = parts[0]; - // agentData.lastname = parts[1]; - // } - //} - ////else - //// m_log.Debug("---------------> Foreign User!"); - } - - // Check if a local user exists with the same UUID as the incoming foreign user - public bool CheckUserAtEntry(UUID userID, UUID sessionID, out bool comingHome) - { - comingHome = false; - - UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); - if (account != null) - { - if (m_aScene.AuthenticationService.Verify(userID, sessionID.ToString(), 30)) - { - // oh, so it's you! welcome back - comingHome = true; - } - else - // can't have a foreigner with a local UUID - return false; - } - - // OK, user can come in - return true; - } - - public void AcceptUser(ForeignUserProfileData user, GridRegion home) - { - // REFACTORING PROBLEM. uh-oh, commenting this breaks HG completely - // Needs to be rewritten - //m_aScene.CommsManager.UserProfileCacheService.PreloadUserCache(user); - - ulong realHandle = home.RegionHandle; - // Change the local coordinates - // X=0 on the map - home.RegionLocX = 0; - home.RegionLocY = random.Next(0, 10000) * (int)Constants.RegionSize; - - AddHyperlinkHomeRegion(user.ID, home, realHandle); - - DumpUserData(user); - DumpRegionData(home); - - } - - public bool IsLocalUser(UUID userID) - { - UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, userID); - return IsLocalUser(account); - } - - #endregion - - #region IHyperlink Misc - - protected bool IsComingHome(ForeignUserProfileData userData) - { - return false; - // REFACTORING PROBLEM - //return (userData.UserServerURI == LocalUserServerURI); - } - - // REFACTORING PROBLEM - //// Is the user going back to the home region or the home grid? - //protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo) - //{ - // if (uinfo == null) - // return false; - - // if (uinfo.UserProfile == null) - // return false; - - // if (!(uinfo.UserProfile is ForeignUserProfileData)) - // // it's a home user, can't be outside to return home - // return false; - - // // OK, it's a foreign user with a ForeignUserProfileData - // // and is going back to exactly the home region. - // // We can't check if it's going back to a non-home region - // // of the home grid. That will be dealt with in the - // // receiving end - // return (uinfo.UserProfile.HomeRegionID == rinfo.RegionID); - //} - - protected bool IsLocalUser(UserAccount account) - { - return true; - - // REFACTORING PROBLEM - //if (account != null && - // account.ServiceURLs.ContainsKey("HomeURI") && - // account.ServiceURLs["HomeURI"] != null) - - // return (account.ServiceURLs["HomeURI"].ToString() == LocalUserServerURI); - - //return false; - } - - - protected bool IsLocalRegion(ulong handle) - { - return m_LocalScenes.ContainsKey(handle); - } - - private void DumpUserData(ForeignUserProfileData userData) - { - m_log.Info(" ------------ User Data Dump ----------"); - m_log.Info(" >> Name: " + userData.FirstName + " " + userData.SurName); - m_log.Info(" >> HomeID: " + userData.HomeRegionID); - m_log.Info(" >> UserServer: " + userData.UserServerURI); - m_log.Info(" >> InvServer: " + userData.UserInventoryURI); - m_log.Info(" >> AssetServer: " + userData.UserAssetURI); - m_log.Info(" ------------ -------------- ----------"); - } - - private void DumpRegionData(GridRegion rinfo) - { - m_log.Info(" ------------ Region Data Dump ----------"); - m_log.Info(" >> handle: " + rinfo.RegionHandle); - m_log.Info(" >> coords: " + rinfo.RegionLocX + ", " + rinfo.RegionLocY); - m_log.Info(" >> external host name: " + rinfo.ExternalHostName); - m_log.Info(" >> http port: " + rinfo.HttpPort); - m_log.Info(" >> external EP address: " + rinfo.ExternalEndPoint.Address); - m_log.Info(" >> external EP port: " + rinfo.ExternalEndPoint.Port); - m_log.Info(" ------------ -------------- ----------"); - } - - - #endregion - public List GetDefaultRegions(UUID scopeID) { - return null; + return m_GridServiceConnector.GetDefaultRegions(scopeID); } public List GetFallbackRegions(UUID scopeID, int x, int y) { - return null; + return m_GridServiceConnector.GetFallbackRegions(scopeID, x, y); } public int GetRegionFlags(UUID scopeID, UUID regionID) { - return 0; + return m_GridServiceConnector.GetRegionFlags(scopeID, regionID); } + + #endregion } } -- cgit v1.1 From bd4d94a4f5490708773db7e211c0c96999bb84c2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 07:54:03 -0800 Subject: Hyperlinking minimally tested and working. --- OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 75eb889..773286c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -40,7 +40,6 @@ using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; using OpenSim.Server.Base; -using OpenSim.Services.Connectors.Grid; using OpenSim.Framework.Console; using OpenMetaverse; -- cgit v1.1 From f276ba57bf5bd732fbc6a255213c9bb7f5f5f148 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 11:33:47 -0800 Subject: HG agent transfers are starting to work. Gatekeeper handlers are missing. --- .../EntityTransfer/EntityTransferModule.cs | 469 +++++++++++---------- .../Resources/CoreModulePlugin.addin.xml | 1 + .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 27 +- 3 files changed, 267 insertions(+), 230 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 827dafe..d0171fe 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer get { return null; } } - public string Name + public virtual string Name { get { return "BasicEntityTransferModule"; } } @@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_agentsInTransit = new List(); m_Enabled = true; - m_log.InfoFormat("[ENTITY TRANSFER MODULE]: {0} nabled.", Name); + m_log.InfoFormat("[ENTITY TRANSFER MODULE]: {0} enabled.", Name); } } } @@ -135,296 +135,312 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Reset animations; the viewer does that in teleports. sp.Animator.ResetAnimations(); - if (regionHandle == sp.Scene.RegionInfo.RegionHandle) + try { - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", - position, sp.Scene.RegionInfo.RegionName); - - // Teleport within the same region - if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) - { - Vector3 emergencyPos = new Vector3(128, 128, 128); - - m_log.WarnFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", - position, sp.Name, sp.UUID, emergencyPos); - position = emergencyPos; - } - - // TODO: Get proper AVG Height - float localAVHeight = 1.56f; - float posZLimit = 22; - - // TODO: Check other Scene HeightField - if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) + if (regionHandle == sp.Scene.RegionInfo.RegionHandle) { - posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; - } - - float newPosZ = posZLimit + localAVHeight; - if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) - { - position.Z = newPosZ; - } + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}", + position, sp.Scene.RegionInfo.RegionName); - // Only send this if the event queue is null - if (eq == null) - sp.ControllingClient.SendTeleportLocationStart(); + // Teleport within the same region + if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) + { + Vector3 emergencyPos = new Vector3(128, 128, 128); - sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); - sp.Teleport(position); - } - else - { - uint x = 0, y = 0; - Utils.LongToUInts(regionHandle, out x, out y); - GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); + m_log.WarnFormat( + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", + position, sp.Name, sp.UUID, emergencyPos); + position = emergencyPos; + } - if (reg != null) - { - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", - position, reg.RegionName); + // TODO: Get proper AVG Height + float localAVHeight = 1.56f; + float posZLimit = 22; - uint newRegionX = (uint)(reg.RegionHandle >> 40); - uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); - uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); + // TODO: Check other Scene HeightField + if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) + { + posZLimit = (float)sp.Scene.Heightmap[(int)position.X, (int)position.Y]; + } - ulong destinationHandle = GetRegionHandle(reg); - GridRegion finalDestination = GetFinalDestination(reg); + float newPosZ = posZLimit + localAVHeight; + if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) + { + position.Z = newPosZ; + } + // Only send this if the event queue is null if (eq == null) sp.ControllingClient.SendTeleportLocationStart(); - // Let's do DNS resolution only once in this process, please! - // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, - // it's actually doing a lot of work. - IPEndPoint endPoint = reg.ExternalEndPoint; - if (endPoint.Address == null) - { - // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. - destRegionUp = false; - } + sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); + sp.Teleport(position); + } + else + { + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion reg = m_aScene.GridService.GetRegionByPosition(sp.Scene.RegionInfo.ScopeID, (int)x, (int)y); - if (destRegionUp) + if (reg != null) { - // Fixing a bug where teleporting while sitting results in the avatar ending up removed from - // both regions - if (sp.ParentID != (uint)0) - sp.StandUp(); + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", + position, reg.RegionName); + + uint newRegionX = (uint)(reg.RegionHandle >> 40); + uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); + uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); - if (!sp.ValidateAttachments()) + GridRegion finalDestination = GetFinalDestination(reg); + if (finalDestination == null) { - sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is having problems. Unable to teleport agent."); + sp.ControllingClient.SendTeleportFailed("Problem at destination"); return; } + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", finalDestination.RegionLocX, finalDestination.RegionLocY, finalDestination.RegionID); + ulong destinationHandle = finalDestination.RegionHandle; - // the avatar.Close below will clear the child region list. We need this below for (possibly) - // closing the child agents, so save it here (we need a copy as it is Clear()-ed). - //List childRegions = new List(avatar.GetKnownRegionList()); - // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport - // failure at this point (unlike a border crossing failure). So perhaps this can never fail - // once we reach here... - //avatar.Scene.RemoveCapsHandler(avatar.UUID); - - string capsPath = String.Empty; - AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); - agentCircuit.BaseFolder = UUID.Zero; - agentCircuit.InventoryFolder = UUID.Zero; - agentCircuit.startpos = position; - agentCircuit.child = true; - agentCircuit.Appearance = sp.Appearance; - - if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) + if (eq == null) + sp.ControllingClient.SendTeleportLocationStart(); + + // Let's do DNS resolution only once in this process, please! + // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, + // it's actually doing a lot of work. + IPEndPoint endPoint = finalDestination.ExternalEndPoint; + if (endPoint.Address == null) { - // brand new agent, let's create a new caps seed - agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. + destRegionUp = false; } - string reason = String.Empty; - - // Let's create an agent there if one doesn't exist yet. - if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) + if (destRegionUp) { - sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", - reason)); - return; - } + // Fixing a bug where teleporting while sitting results in the avatar ending up removed from + // both regions + if (sp.ParentID != (uint)0) + sp.StandUp(); - // OK, it got this agent. Let's close some child agents - sp.CloseChildAgents(newRegionX, newRegionY); + if (!sp.ValidateAttachments()) + { + sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); + return; + } - if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) - { - #region IP Translation for NAT - IClientIPEndpoint ipepClient; - if (sp.ClientView.TryGet(out ipepClient)) + // the avatar.Close below will clear the child region list. We need this below for (possibly) + // closing the child agents, so save it here (we need a copy as it is Clear()-ed). + //List childRegions = new List(avatar.GetKnownRegionList()); + // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport + // failure at this point (unlike a border crossing failure). So perhaps this can never fail + // once we reach here... + //avatar.Scene.RemoveCapsHandler(avatar.UUID); + + string capsPath = String.Empty; + AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); + agentCircuit.BaseFolder = UUID.Zero; + agentCircuit.InventoryFolder = UUID.Zero; + agentCircuit.startpos = position; + agentCircuit.child = true; + agentCircuit.Appearance = sp.Appearance; + + if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) { - capsPath - = "http://" - + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName) - + ":" - + reg.HttpPort - + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + // brand new agent, let's create a new caps seed + agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); } - else + + string reason = String.Empty; + + // Let's create an agent there if one doesn't exist yet. + if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) { - capsPath - = "http://" - + reg.ExternalHostName - + ":" - + reg.HttpPort - + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", + reason)); + return; } - #endregion - if (eq != null) + // OK, it got this agent. Let's close some child agents + sp.CloseChildAgents(newRegionX, newRegionY); + + if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) { #region IP Translation for NAT - // Uses ipepClient above + IClientIPEndpoint ipepClient; if (sp.ClientView.TryGet(out ipepClient)) { - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + capsPath + = "http://" + + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName) + + ":" + + finalDestination.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + else + { + capsPath + = "http://" + + finalDestination.ExternalHostName + + ":" + + finalDestination.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); } #endregion - eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); + if (eq != null) + { + #region IP Translation for NAT + // Uses ipepClient above + if (sp.ClientView.TryGet(out ipepClient)) + { + endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + } + #endregion + + eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); - // ES makes the client send a UseCircuitCode message to the destination, - // which triggers a bunch of things there. - // So let's wait - Thread.Sleep(2000); + // ES makes the client send a UseCircuitCode message to the destination, + // which triggers a bunch of things there. + // So let's wait + Thread.Sleep(2000); - eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + } + else + { + sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); + } } else { - sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); + agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); + capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort + + "/CAPS/" + agentCircuit.CapsPath + "0000/"; } - } - else - { - agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); - capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort - + "/CAPS/" + agentCircuit.CapsPath + "0000/"; - } - - // Expect avatar crossing is a heavy-duty function at the destination. - // That is where MakeRoot is called, which fetches appearance and inventory. - // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. - //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, - // position, false); - - //{ - // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); - // // We should close that agent we just created over at destination... - // List lst = new List(); - // lst.Add(reg.RegionHandle); - // SendCloseChildAgentAsync(avatar.UUID, lst); - // return; - //} - SetInTransit(sp.UUID); + // Expect avatar crossing is a heavy-duty function at the destination. + // That is where MakeRoot is called, which fetches appearance and inventory. + // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. + //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, + // position, false); + + //{ + // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); + // // We should close that agent we just created over at destination... + // List lst = new List(); + // lst.Add(reg.RegionHandle); + // SendCloseChildAgentAsync(avatar.UUID, lst); + // return; + //} + + SetInTransit(sp.UUID); + + // Let's send a full update of the agent. This is a synchronous call. + AgentData agent = new AgentData(); + sp.CopyTo(agent); + agent.Position = position; + agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + + "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; + + // Straight to the region. Safe. + m_aScene.SimulationService.UpdateAgent(reg, agent); - // Let's send a full update of the agent. This is a synchronous call. - AgentData agent = new AgentData(); - sp.CopyTo(agent); - agent.Position = position; - agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + - "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); - m_aScene.SimulationService.UpdateAgent(reg, agent); - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); + if (eq != null) + { + eq.TeleportFinishEvent(destinationHandle, 13, endPoint, + 0, teleportFlags, capsPath, sp.UUID); + } + else + { + sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, + teleportFlags, capsPath); + } + // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which + // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation + // that the client contacted the destination before we send the attachments and close things here. + if (!WaitForCallback(sp.UUID)) + { + // Client never contacted destination. Let's restore everything back + sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); - if (eq != null) - { - eq.TeleportFinishEvent(destinationHandle, 13, endPoint, - 0, teleportFlags, capsPath, sp.UUID); - } - else - { - sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, - teleportFlags, capsPath); - } + ResetFromTransit(sp.UUID); - // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which - // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation - // that the client contacted the destination before we send the attachments and close things here. - if (!WaitForCallback(sp.UUID)) - { - // Client never contacted destination. Let's restore everything back - sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); + // Yikes! We should just have a ref to scene here. + //sp.Scene.InformClientOfNeighbours(sp); + EnableChildAgents(sp); - ResetFromTransit(sp.UUID); + // Finally, kill the agent we just created at the destination. + m_aScene.SimulationService.CloseAgent(reg, sp.UUID); - // Yikes! We should just have a ref to scene here. - //sp.Scene.InformClientOfNeighbours(sp); - EnableChildAgents(sp); + return; + } - // Finally, kill the agent we just created at the destination. - m_aScene.SimulationService.CloseAgent(reg, sp.UUID); + KillEntity(sp.Scene, sp.LocalId); - return; - } + sp.MakeChildAgent(); - KillEntity(sp.Scene, sp.LocalId); + // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it + CrossAttachmentsIntoNewRegion(reg, sp, true); - sp.MakeChildAgent(); + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone - // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - CrossAttachmentsIntoNewRegion(reg, sp, true); + if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) + { + Thread.Sleep(5000); + sp.Close(); + sp.Scene.IncomingCloseAgent(sp.UUID); + } + else + // now we have a child agent in this region. + sp.Reset(); - // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone - if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) - { - Thread.Sleep(5000); - sp.Close(); - sp.Scene.IncomingCloseAgent(sp.UUID); + // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! + if (sp.Scene.NeedSceneCacheClear(sp.UUID)) + { + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", + sp.UUID); + } } else - // now we have a child agent in this region. - sp.Reset(); - - - // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! - if (sp.Scene.NeedSceneCacheClear(sp.UUID)) { - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", - sp.UUID); + sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); } } else { - sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); + // TP to a place that doesn't exist (anymore) + // Inform the viewer about that + sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); + + // and set the map-tile to '(Offline)' + uint regX, regY; + Utils.LongToUInts(regionHandle, out regX, out regY); + + MapBlockData block = new MapBlockData(); + block.X = (ushort)(regX / Constants.RegionSize); + block.Y = (ushort)(regY / Constants.RegionSize); + block.Access = 254; // == not there + + List blocks = new List(); + blocks.Add(block); + sp.ControllingClient.SendMapBlock(blocks, 0); } } - else - { - // TP to a place that doesn't exist (anymore) - // Inform the viewer about that - sp.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); - - // and set the map-tile to '(Offline)' - uint regX, regY; - Utils.LongToUInts(regionHandle, out regX, out regY); - - MapBlockData block = new MapBlockData(); - block.X = (ushort)(regX / Constants.RegionSize); - block.Y = (ushort)(regY / Constants.RegionSize); - block.Access = 254; // == not there - - List blocks = new List(); - blocks.Add(block); - sp.ControllingClient.SendMapBlock(blocks, 0); - } + } + catch (Exception e) + { + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace); + sp.ControllingClient.SendTeleportFailed("Internal error"); } } @@ -433,11 +449,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer scene.SendKillObject(localID); } - protected virtual ulong GetRegionHandle(GridRegion region) - { - return region.RegionHandle; - } - protected virtual GridRegion GetFinalDestination(GridRegion region) { return region; diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 68cf060..08a90a2 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -9,6 +9,7 @@ + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 773286c..07f3cdc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -48,7 +48,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { - public class HGGridConnector : ISharedRegionModule, IGridService + public class HGGridConnector : ISharedRegionModule, IGridService, IHypergridService { private static readonly ILog m_log = LogManager.GetLogger( @@ -148,6 +148,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; scene.RegisterModuleInterface(this); + scene.RegisterModuleInterface(this); ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); @@ -158,6 +159,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_Enabled) { m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); + scene.UnregisterModuleInterface(this); + scene.UnregisterModuleInterface(this); ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); } } @@ -278,5 +281,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion + #region IHypergridService + + public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) + { + return m_HypergridService.LinkRegion(regionDescriptor, out regionID, out regionHandle, out imageURL, out reason); + } + + public GridRegion GetHyperlinkRegion(GridRegion gateway, UUID regionID) + { + if (m_LocalScenes.ContainsKey(gateway.RegionHandle)) + return gateway; + + return m_HypergridService.GetHyperlinkRegion(gateway, regionID); + } + + public GridRegion GetRegionByUUID(UUID regionID) { return null; } + public GridRegion GetRegionByPosition(int x, int y) { return null; } + public GridRegion GetRegionByName(string name) { return null; } + public List GetRegionsByName(string name) { return null; } + public List GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; } + + #endregion } } -- cgit v1.1 From 5e034f5933fd23d6023167cdb24a141eac1f2e85 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 11:35:27 -0800 Subject: Oops, forgot this one. --- .../EntityTransfer/HGEntityTransferModule.cs | 137 +++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs new file mode 100644 index 0000000..5d88311 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -0,0 +1,137 @@ +/* + * 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.Services.Connectors.Hypergrid; +using OpenSim.Services.Interfaces; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.EntityTransfer +{ + public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + private IHypergridService m_HypergridService; + private IHypergridService HyperGridService + { + get + { + if (m_HypergridService == null) + m_HypergridService = m_aScene.RequestModuleInterface(); + return m_HypergridService; + } + } + + #region ISharedRegionModule + + public override string Name + { + get { return "HGEntityTransferModule"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("EntityTransferModule", ""); + if (name == Name) + { + m_agentsInTransit = new List(); + m_Enabled = true; + m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); + } + } + } + + public override void PostInitialise() + { + } + + public override void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + if (m_aScene == null) + m_aScene = scene; + + scene.RegisterModuleInterface(this); + } + + public override void Close() + { + if (!m_Enabled) + return; + } + + + public override void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + if (scene == m_aScene) + m_aScene = null; + } + + public override void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region HG overrides + + protected override GridRegion GetFinalDestination(GridRegion region) + { + return HyperGridService.GetHyperlinkRegion(region, region.RegionID); + } + + protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) + { + return true; + } + + + #endregion + } +} -- cgit v1.1 From b2e6ec9e12ad07eb08496ebe8ca0476b793017d5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 18:04:55 -0800 Subject: Agent gets there through the Gatekeeper, but still a few quirks to fix. --- .../EntityTransfer/EntityTransferModule.cs | 23 ++-- .../EntityTransfer/HGEntityTransferModule.cs | 27 +++++ .../Resources/CoreModulePlugin.addin.xml | 1 + .../AuthenticationServiceInConnectorModule.cs | 119 +++++++++++++++++++++ 4 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index d0171fe..8268bfa 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -239,12 +239,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer //avatar.Scene.RemoveCapsHandler(avatar.UUID); string capsPath = String.Empty; + + AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); - agentCircuit.BaseFolder = UUID.Zero; - agentCircuit.InventoryFolder = UUID.Zero; agentCircuit.startpos = position; agentCircuit.child = true; agentCircuit.Appearance = sp.Appearance; + if (currentAgentCircuit != null) + agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) { @@ -255,9 +257,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason = String.Empty; // Let's create an agent there if one doesn't exist yet. - if (!m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) + if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) { - sp.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", + sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", reason)); return; } @@ -345,8 +347,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; - // Straight to the region. Safe. - m_aScene.SimulationService.UpdateAgent(reg, agent); + UpdateAgent(reg, finalDestination, agent); m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); @@ -444,6 +445,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } + protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + { + return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); + } + + protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) + { + return m_aScene.SimulationService.UpdateAgent(reg, agent); + } + protected void KillEntity(Scene scene, uint localID) { scene.SendKillObject(localID); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 5d88311..e5a862d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Connectors.Hypergrid; @@ -58,6 +59,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } + private GatekeeperServiceConnector m_GatekeeperConnector; + #region ISharedRegionModule public override string Name @@ -74,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (name == Name) { m_agentsInTransit = new List(); + m_GatekeeperConnector = new GatekeeperServiceConnector(); m_Enabled = true; m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); } @@ -131,6 +135,29 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return true; } + protected override bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + { + reason = string.Empty; + if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) + { + // this user is going to another grid + reg.RegionName = finalDestination.RegionName; + return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason); + } + + return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); + } + + protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) + { + if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) + { + // this user is going to another grid + return m_GatekeeperConnector.UpdateAgent(reg, agent); + } + + return m_aScene.SimulationService.UpdateAgent(reg, agent); + } #endregion } diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 08a90a2..c61198d 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -66,6 +66,7 @@ \ \ \ + \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs new file mode 100644 index 0000000..02acddc --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs @@ -0,0 +1,119 @@ +/* + * 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.Reflection; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Server.Handlers.Authentication; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication +{ + public class AuthenticationServiceInConnectorModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Enabled = false; + + private IConfigSource m_Config; + bool m_Registered = false; + + #region IRegionModule interface + + public void Initialise(IConfigSource config) + { + m_Config = config; + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + m_Enabled = moduleConfig.GetBoolean("AuthenticationServiceInConnector", false); + if (m_Enabled) + { + m_log.Info("[AUTHENTICATION IN CONNECTOR]: Authentication Service In Connector enabled"); + } + + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "AuthenticationServiceInConnectorModule"; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + if (!m_Registered) + { + m_Registered = true; + + m_log.Info("[AUTHENTICATION IN CONNECTOR]: Starting..."); + + new AuthenticationServiceConnector(m_Config, MainServer.Instance, "AuthenticationService"); + } + + } + + #endregion + + } +} -- cgit v1.1 From b5fcb5e872ec138ff7138906bffae193b6dae1a6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 17 Jan 2010 20:10:42 -0800 Subject: HG teleports through gatekeeper are working. --- .../Framework/EntityTransfer/EntityTransferModule.cs | 18 ++++++++++++------ .../Framework/EntityTransfer/HGEntityTransferModule.cs | 11 ----------- 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8268bfa..622d057 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -344,8 +344,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer AgentData agent = new AgentData(); sp.CopyTo(agent); agent.Position = position; - agent.CallbackURI = "http://" + sp.Scene.RegionInfo.ExternalHostName + ":" + sp.Scene.RegionInfo.HttpPort + - "/agent/" + sp.UUID.ToString() + "/" + sp.Scene.RegionInfo.RegionID.ToString() + "/release/"; + SetCallbackURL(agent, sp.Scene.RegionInfo); UpdateAgent(reg, finalDestination, agent); @@ -379,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer EnableChildAgents(sp); // Finally, kill the agent we just created at the destination. - m_aScene.SimulationService.CloseAgent(reg, sp.UUID); + m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); return; } @@ -389,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.MakeChildAgent(); // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - CrossAttachmentsIntoNewRegion(reg, sp, true); + CrossAttachmentsIntoNewRegion(finalDestination, sp, true); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone @@ -447,12 +446,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { - return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); + return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); } protected virtual bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) { - return m_aScene.SimulationService.UpdateAgent(reg, agent); + return m_aScene.SimulationService.UpdateAgent(finalDestination, agent); + } + + protected virtual void SetCallbackURL(AgentData agent, RegionInfo region) + { + agent.CallbackURI = "http://" + region.ExternalHostName + ":" + region.HttpPort + + "/agent/" + agent.AgentID.ToString() + "/" + region.RegionID.ToString() + "/release/"; + } protected void KillEntity(Scene scene, uint localID) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index e5a862d..6645293 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -148,17 +148,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); } - protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agent) - { - if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) - { - // this user is going to another grid - return m_GatekeeperConnector.UpdateAgent(reg, agent); - } - - return m_aScene.SimulationService.UpdateAgent(reg, agent); - } - #endregion } } -- cgit v1.1 From bbbe9e73cca2a0ed5d35db1b054b8ed4cd23bfea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 09:14:19 -0800 Subject: * Fixed misspelling of field in GridService * Moved TeleportClientHome to EntityTransferModule --- .../EntityTransfer/EntityTransferModule.cs | 35 +++++++++++++++++++- .../EntityTransfer/HGEntityTransferModule.cs | 37 ---------------------- 2 files changed, 34 insertions(+), 38 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 622d057..fcc7a85 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private bool m_Enabled = false; + protected bool m_Enabled = false; protected Scene m_aScene; protected List m_agentsInTransit; @@ -94,6 +94,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_aScene = scene; scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += OnNewClient; + } + + protected void OnNewClient(IClientAPI client) + { + client.OnTeleportHomeRequest += TeleportHome; } public virtual void Close() @@ -499,6 +505,33 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer #endregion + #region Teleport Home + + public virtual void TeleportHome(UUID id, IClientAPI client) + { + 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); + + if (pinfo != null) + { + GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID); + if (regionInfo == null) + { + // can't find the Home region: Tell viewer and abort + client.SendTeleportFailed("Your home region could not be found."); + return; + } + // 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, + (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); + } + } + + #endregion + + #region Agent Crossings public void Cross(ScenePresence agent, bool isFlying) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 6645293..101aea0 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -47,7 +47,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private bool m_Enabled = false; private IHypergridService m_HypergridService; private IHypergridService HyperGridService { @@ -84,42 +83,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } - public override void PostInitialise() - { - } - - public override void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - if (m_aScene == null) - m_aScene = scene; - - scene.RegisterModuleInterface(this); - } - - public override void Close() - { - if (!m_Enabled) - return; - } - - - public override void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - if (scene == m_aScene) - m_aScene = null; - } - - public override void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - } #endregion -- cgit v1.1 From fd64823466ee667d0d827f95d3001ec8675512b2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 10:37:11 -0800 Subject: * Added missing GatekeeperServiceConnector * Added basic machinery for teleporting users home. Untested. --- .../EntityTransfer/EntityTransferModule.cs | 456 +++++++++++---------- .../EntityTransfer/HGEntityTransferModule.cs | 49 +++ 2 files changed, 281 insertions(+), 224 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index fcc7a85..e85f270 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -183,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); sp.Teleport(position); } - else + else // Another region possibly in another simulator { uint x = 0, y = 0; Utils.LongToUInts(regionHandle, out x, out y); @@ -191,15 +191,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (reg != null) { - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", - position, reg.RegionName); - - uint newRegionX = (uint)(reg.RegionHandle >> 40); - uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); - uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); - GridRegion finalDestination = GetFinalDestination(reg); if (finalDestination == null) { @@ -207,220 +198,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.ControllingClient.SendTeleportFailed("Problem at destination"); return; } - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", finalDestination.RegionLocX, finalDestination.RegionLocY, finalDestination.RegionID); - ulong destinationHandle = finalDestination.RegionHandle; - - if (eq == null) - sp.ControllingClient.SendTeleportLocationStart(); - - // Let's do DNS resolution only once in this process, please! - // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, - // it's actually doing a lot of work. - IPEndPoint endPoint = finalDestination.ExternalEndPoint; - if (endPoint.Address == null) - { - // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. - destRegionUp = false; - } - - if (destRegionUp) - { - // Fixing a bug where teleporting while sitting results in the avatar ending up removed from - // both regions - if (sp.ParentID != (uint)0) - sp.StandUp(); - - if (!sp.ValidateAttachments()) - { - sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); - return; - } - - // the avatar.Close below will clear the child region list. We need this below for (possibly) - // closing the child agents, so save it here (we need a copy as it is Clear()-ed). - //List childRegions = new List(avatar.GetKnownRegionList()); - // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport - // failure at this point (unlike a border crossing failure). So perhaps this can never fail - // once we reach here... - //avatar.Scene.RemoveCapsHandler(avatar.UUID); - - string capsPath = String.Empty; - - AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); - AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); - agentCircuit.startpos = position; - agentCircuit.child = true; - agentCircuit.Appearance = sp.Appearance; - if (currentAgentCircuit != null) - agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; - - if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) - { - // brand new agent, let's create a new caps seed - agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); - } - - string reason = String.Empty; - - // Let's create an agent there if one doesn't exist yet. - if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) - { - sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", - reason)); - return; - } - - // OK, it got this agent. Let's close some child agents - sp.CloseChildAgents(newRegionX, newRegionY); - - if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) - { - #region IP Translation for NAT - IClientIPEndpoint ipepClient; - if (sp.ClientView.TryGet(out ipepClient)) - { - capsPath - = "http://" - + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName) - + ":" - + finalDestination.HttpPort - + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); - } - else - { - capsPath - = "http://" - + finalDestination.ExternalHostName - + ":" - + finalDestination.HttpPort - + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); - } - #endregion - - if (eq != null) - { - #region IP Translation for NAT - // Uses ipepClient above - if (sp.ClientView.TryGet(out ipepClient)) - { - endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); - } - #endregion - - eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); - - // ES makes the client send a UseCircuitCode message to the destination, - // which triggers a bunch of things there. - // So let's wait - Thread.Sleep(2000); - - eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - - } - else - { - sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); - } - } - else - { - agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); - capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort - + "/CAPS/" + agentCircuit.CapsPath + "0000/"; - } - - // Expect avatar crossing is a heavy-duty function at the destination. - // That is where MakeRoot is called, which fetches appearance and inventory. - // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. - //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, - // position, false); - - //{ - // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); - // // We should close that agent we just created over at destination... - // List lst = new List(); - // lst.Add(reg.RegionHandle); - // SendCloseChildAgentAsync(avatar.UUID, lst); - // return; - //} - - SetInTransit(sp.UUID); - - // Let's send a full update of the agent. This is a synchronous call. - AgentData agent = new AgentData(); - sp.CopyTo(agent); - agent.Position = position; - SetCallbackURL(agent, sp.Scene.RegionInfo); - - UpdateAgent(reg, finalDestination, agent); - - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); - - - if (eq != null) - { - eq.TeleportFinishEvent(destinationHandle, 13, endPoint, - 0, teleportFlags, capsPath, sp.UUID); - } - else - { - sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, - teleportFlags, capsPath); - } - - // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which - // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation - // that the client contacted the destination before we send the attachments and close things here. - if (!WaitForCallback(sp.UUID)) - { - // Client never contacted destination. Let's restore everything back - sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); - - ResetFromTransit(sp.UUID); - - // Yikes! We should just have a ref to scene here. - //sp.Scene.InformClientOfNeighbours(sp); - EnableChildAgents(sp); - - // Finally, kill the agent we just created at the destination. - m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); - - return; - } - - KillEntity(sp.Scene, sp.LocalId); - - sp.MakeChildAgent(); - - // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - CrossAttachmentsIntoNewRegion(finalDestination, sp, true); - - // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone - - if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) - { - Thread.Sleep(5000); - sp.Close(); - sp.Scene.IncomingCloseAgent(sp.UUID); - } - else - // now we have a child agent in this region. - sp.Reset(); - - - // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! - if (sp.Scene.NeedSceneCacheClear(sp.UUID)) - { - m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", - sp.UUID); - } - } - else - { - sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); - } + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}", + finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID); + + // + // This is it + // + DoTeleport(sp, reg, finalDestination, position, lookAt, teleportFlags, eq); + // + // + // } else { @@ -450,6 +237,227 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } + protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) + { + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", + position, reg.RegionName); + + uint newRegionX = (uint)(reg.RegionHandle >> 40); + uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); + uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); + uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); + + ulong destinationHandle = finalDestination.RegionHandle; + + if (eq == null) + sp.ControllingClient.SendTeleportLocationStart(); + + // Let's do DNS resolution only once in this process, please! + // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, + // it's actually doing a lot of work. + IPEndPoint endPoint = finalDestination.ExternalEndPoint; + if (endPoint.Address != null) + { + // Fixing a bug where teleporting while sitting results in the avatar ending up removed from + // both regions + if (sp.ParentID != (uint)0) + sp.StandUp(); + + if (!sp.ValidateAttachments()) + { + sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); + return; + } + + // the avatar.Close below will clear the child region list. We need this below for (possibly) + // closing the child agents, so save it here (we need a copy as it is Clear()-ed). + //List childRegions = new List(avatar.GetKnownRegionList()); + // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport + // failure at this point (unlike a border crossing failure). So perhaps this can never fail + // once we reach here... + //avatar.Scene.RemoveCapsHandler(avatar.UUID); + + string capsPath = String.Empty; + + AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo(); + agentCircuit.startpos = position; + agentCircuit.child = true; + agentCircuit.Appearance = sp.Appearance; + if (currentAgentCircuit != null) + agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs; + + if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) + { + // brand new agent, let's create a new caps seed + agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); + } + + string reason = String.Empty; + + // Let's create an agent there if one doesn't exist yet. + if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) + { + sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", + reason)); + return; + } + + // OK, it got this agent. Let's close some child agents + sp.CloseChildAgents(newRegionX, newRegionY); + + if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) + { + #region IP Translation for NAT + IClientIPEndpoint ipepClient; + if (sp.ClientView.TryGet(out ipepClient)) + { + capsPath + = "http://" + + NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName) + + ":" + + finalDestination.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + else + { + capsPath + = "http://" + + finalDestination.ExternalHostName + + ":" + + finalDestination.HttpPort + + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); + } + #endregion + + if (eq != null) + { + #region IP Translation for NAT + // Uses ipepClient above + if (sp.ClientView.TryGet(out ipepClient)) + { + endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); + } + #endregion + + eq.EnableSimulator(destinationHandle, endPoint, sp.UUID); + + // ES makes the client send a UseCircuitCode message to the destination, + // which triggers a bunch of things there. + // So let's wait + Thread.Sleep(2000); + + eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); + + } + else + { + sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint); + } + } + else + { + agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle); + capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort + + "/CAPS/" + agentCircuit.CapsPath + "0000/"; + } + + // Expect avatar crossing is a heavy-duty function at the destination. + // That is where MakeRoot is called, which fetches appearance and inventory. + // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. + //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, + // position, false); + + //{ + // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); + // // We should close that agent we just created over at destination... + // List lst = new List(); + // lst.Add(reg.RegionHandle); + // SendCloseChildAgentAsync(avatar.UUID, lst); + // return; + //} + + SetInTransit(sp.UUID); + + // Let's send a full update of the agent. This is a synchronous call. + AgentData agent = new AgentData(); + sp.CopyTo(agent); + agent.Position = position; + SetCallbackURL(agent, sp.Scene.RegionInfo); + + UpdateAgent(reg, finalDestination, agent); + + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID); + + + if (eq != null) + { + eq.TeleportFinishEvent(destinationHandle, 13, endPoint, + 0, teleportFlags, capsPath, sp.UUID); + } + else + { + sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4, + teleportFlags, capsPath); + } + + // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which + // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation + // that the client contacted the destination before we send the attachments and close things here. + if (!WaitForCallback(sp.UUID)) + { + // Client never contacted destination. Let's restore everything back + sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); + + ResetFromTransit(sp.UUID); + + // Yikes! We should just have a ref to scene here. + //sp.Scene.InformClientOfNeighbours(sp); + EnableChildAgents(sp); + + // Finally, kill the agent we just created at the destination. + m_aScene.SimulationService.CloseAgent(finalDestination, sp.UUID); + + return; + } + + KillEntity(sp.Scene, sp.LocalId); + + sp.MakeChildAgent(); + + // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it + CrossAttachmentsIntoNewRegion(finalDestination, sp, true); + + // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone + + if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) + { + Thread.Sleep(5000); + sp.Close(); + sp.Scene.IncomingCloseAgent(sp.UUID); + } + else + // now we have a child agent in this region. + sp.Reset(); + + + // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! + if (sp.Scene.NeedSceneCacheClear(sp.UUID)) + { + m_log.DebugFormat( + "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", + sp.UUID); + } + } + else + { + sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); + } + } + + protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 101aea0..0e6323b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -111,6 +111,55 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); } + public override void TeleportHome(UUID id, IClientAPI client) + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); + + // Let's find out if this is a foreign user or a local user + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id); + if (account != null) + { + // local grid user + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); + base.TeleportHome(id, client); + return; + } + + // Foreign user wants to go home + // + AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); + if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) + { + client.SendTeleportFailed("Your information has been lost"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); + return; + } + + GridRegion homeGatekeeper = MakeRegion(aCircuit); + if (homeGatekeeper == null) + { + client.SendTeleportFailed("Your information has been lost"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed"); + return; + } + + Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; + GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); + } #endregion + + private GridRegion MakeRegion(AgentCircuitData aCircuit) + { + GridRegion region = new GridRegion(); + + Uri uri = null; + if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) + return null; + + region.ExternalHostName = uri.Host; + region.HttpPort = (uint)uri.Port; + region.RegionName = string.Empty; + return region; + } } } -- cgit v1.1 From 3d536944153d4931cf891d6a788a47484f3e6f4d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 16:34:23 -0800 Subject: Go Home works. With security!! --- .../EntityTransfer/EntityTransferModule.cs | 10 +- .../EntityTransfer/HGEntityTransferModule.cs | 69 ++++++++++- .../Resources/CoreModulePlugin.addin.xml | 2 +- .../Grid/HypergridServiceInConnectorModule.cs | 128 -------------------- .../Hypergrid/HypergridServiceInConnectorModule.cs | 129 +++++++++++++++++++++ 5 files changed, 201 insertions(+), 137 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index e85f270..ed8c0fd 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -134,8 +134,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (!sp.Scene.Permissions.CanTeleport(sp.UUID)) return; - bool destRegionUp = true; - IEventQueue eq = sp.Scene.RequestModuleInterface(); // Reset animations; the viewer does that in teleports. @@ -240,8 +238,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) { m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation to {0} in {1}", - position, reg.RegionName); + "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", + reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); @@ -297,7 +295,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string reason = String.Empty; // Let's create an agent there if one doesn't exist yet. - if (!CreateAgent(reg, finalDestination, agentCircuit, teleportFlags, out reason)) + if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason)) { sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}", reason)); @@ -458,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } - protected virtual bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + protected virtual bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { return m_aScene.SimulationService.CreateAgent(finalDestination, agentCircuit, teleportFlags, out reason); } diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 0e6323b..d39537d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -34,6 +34,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Connectors.Hypergrid; using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; using GridRegion = OpenSim.Services.Interfaces.GridRegion; @@ -59,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } private GatekeeperServiceConnector m_GatekeeperConnector; + private IHomeUsersSecurityService m_Security; #region ISharedRegionModule @@ -77,12 +79,42 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { m_agentsInTransit = new List(); m_GatekeeperConnector = new GatekeeperServiceConnector(); + + IConfig config = source.Configs["HGEntityTransferModule"]; + if (config != null) + { + string dll = config.GetString("HomeUsersSecurityService", string.Empty); + if (dll != string.Empty) + { + Object[] args = new Object[] { source }; + m_Security = ServerUtils.LoadPlugin(dll, args); + if (m_Security == null) + m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service"); + else + m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded"); + } + } + m_Enabled = true; m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); } } } + public override void AddRegion(Scene scene) + { + base.AddRegion(scene); + if (m_Enabled) + scene.RegisterModuleInterface(m_Security); + } + + public override void RemoveRegion(Scene scene) + { + base.AddRegion(scene); + if (m_Enabled) + scene.UnregisterModuleInterface(m_Security); + } + #endregion @@ -98,13 +130,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return true; } - protected override bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) + protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { reason = string.Empty; - if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) + if (reg.RegionLocX != finalDestination.RegionLocX || reg.RegionLocY != finalDestination.RegionLocY) { // this user is going to another grid reg.RegionName = finalDestination.RegionName; + reg.RegionID = finalDestination.RegionID; + reg.RegionLocX = finalDestination.RegionLocX; + reg.RegionLocY = finalDestination.RegionLocY; + + // Log their session and remote endpoint in the home users security service + IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface(); + if (security != null) + security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint); + + // Log them out of this grid + sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); + return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason); } @@ -145,6 +189,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); + if (finalDestination == null) + { + client.SendTeleportFailed("Your home region could not be found"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); + return; + } + + ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); + if (sp == null) + { + client.SendTeleportFailed("Internal error"); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); + return; + } + + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", + aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); + + IEventQueue eq = sp.Scene.RequestModuleInterface(); + DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); } #endregion @@ -159,6 +223,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer region.ExternalHostName = uri.Host; region.HttpPort = (uint)uri.Port; region.RegionName = string.Empty; + region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0); return region; } } diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index c61198d..0e3739a 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -62,7 +62,7 @@ \ - \ + \ \ \ \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs deleted file mode 100644 index 6ec0fcf..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.Reflection; -using System.Collections.Generic; -using log4net; -using Nini.Config; -using OpenSim.Framework; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Server.Base; -using OpenSim.Server.Handlers.Base; -using OpenSim.Server.Handlers.Hypergrid; -using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid -{ - public class HypergridServiceInConnectorModule : ISharedRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool m_Enabled = false; - - private IConfigSource m_Config; - bool m_Registered = false; - GatekeeperServiceInConnector m_HypergridHandler; - - #region IRegionModule interface - - public void Initialise(IConfigSource config) - { - //// This module is only on for standalones in hypergrid mode - //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && - // config.Configs["Startup"].GetBoolean("hypergrid", true); - //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); - m_Config = config; - IConfig moduleConfig = config.Configs["Modules"]; - if (moduleConfig != null) - { - m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false); - if (m_Enabled) - { - m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled"); - } - - } - - } - - public void PostInitialise() - { - } - - public void Close() - { - } - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "HypergridService"; } - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - } - - public void RemoveRegion(Scene scene) - { - if (!m_Enabled) - return; - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - if (!m_Registered) - { - m_Registered = true; - - m_log.Info("[HypergridService]: Starting..."); - -// Object[] args = new Object[] { m_Config, MainServer.Instance }; - ISimulationService simService = scene.RequestModuleInterface(); - m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); - //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); - } - } - - #endregion - - } -} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs new file mode 100644 index 0000000..6e6946c --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs @@ -0,0 +1,129 @@ +/* + * 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.Reflection; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Server.Handlers.Hypergrid; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid +{ + public class HypergridServiceInConnectorModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Enabled = false; + + private IConfigSource m_Config; + bool m_Registered = false; + GatekeeperServiceInConnector m_HypergridHandler; + + #region IRegionModule interface + + public void Initialise(IConfigSource config) + { + //// This module is only on for standalones in hypergrid mode + //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && + // config.Configs["Startup"].GetBoolean("hypergrid", true); + //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); + m_Config = config; + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false); + if (m_Enabled) + { + m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled"); + } + + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "HypergridService"; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + } + + public void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + if (!m_Registered) + { + m_Registered = true; + + m_log.Info("[HypergridService]: Starting..."); + +// Object[] args = new Object[] { m_Config, MainServer.Instance }; + ISimulationService simService = scene.RequestModuleInterface(); + m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); + //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); + scene.RegisterModuleInterface(m_HypergridHandler.GateKeeper); + } + } + + #endregion + + } +} -- cgit v1.1 From 5908b8ed7c273d239642a9d31e1844f9a2392e3d Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 19 Jan 2010 11:33:42 +0000 Subject: Change a member of the friendslist module to better reflect the client side data storage paradigm of the friends list and avoid repeated, unneccessary fetches of the entire friends list. --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 4 ++-- .../Region/CoreModules/World/Permissions/PermissionsModule.cs | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 64854b2..a07b6e2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -84,9 +84,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { } - public List GetUserFriends(UUID agentID) + public uint GetFriendPerms(UUID principalID, UUID friendID) { - return null; + return 1; } } } diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 8fa0c65..72dd373 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -504,13 +504,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (m_friendsModule == null) return false; - List profile = m_friendsModule.GetUserFriends(user); + uint friendPerms = m_friendsModule.GetFriendPerms(user, objectOwner); + if ((friendPerms & (uint)FriendRights.CanModifyObjects) != 0) + return true; - foreach (FriendListItem item in profile) - { - if (item.Friend == objectOwner && (item.FriendPerms & (uint)FriendRights.CanModifyObjects) != 0) - return true; - } return false; } -- cgit v1.1 From 48b03c2c61a422c3ac9843892a2ae93b29a9f7b8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 14:30:48 -0800 Subject: Integrated the hyperlinking with the GridService. --- .../EntityTransfer/HGEntityTransferModule.cs | 45 +++++++------ .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 74 ++++------------------ 2 files changed, 39 insertions(+), 80 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index d39537d..e237ca2 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -48,16 +48,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private IHypergridService m_HypergridService; - private IHypergridService HyperGridService - { - get - { - if (m_HypergridService == null) - m_HypergridService = m_aScene.RequestModuleInterface(); - return m_HypergridService; - } - } + private bool m_Initialized = false; private GatekeeperServiceConnector m_GatekeeperConnector; private IHomeUsersSecurityService m_Security; @@ -78,7 +69,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (name == Name) { m_agentsInTransit = new List(); - m_GatekeeperConnector = new GatekeeperServiceConnector(); IConfig config = source.Configs["HGEntityTransferModule"]; if (config != null) @@ -108,6 +98,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer scene.RegisterModuleInterface(m_Security); } + public override void RegionLoaded(Scene scene) + { + base.RegionLoaded(scene); + if (m_Enabled) + if (!m_Initialized) + { + m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); + m_Initialized = true; + } + + } public override void RemoveRegion(Scene scene) { base.AddRegion(scene); @@ -122,7 +123,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override GridRegion GetFinalDestination(GridRegion region) { - return HyperGridService.GetHyperlinkRegion(region, region.RegionID); + int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); + if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) + { + return m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); + } + return region; } protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) @@ -133,13 +139,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) { reason = string.Empty; - if (reg.RegionLocX != finalDestination.RegionLocX || reg.RegionLocY != finalDestination.RegionLocY) + int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); + if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid - reg.RegionName = finalDestination.RegionName; - reg.RegionID = finalDestination.RegionID; - reg.RegionLocX = finalDestination.RegionLocX; - reg.RegionLocY = finalDestination.RegionLocY; + // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination + GridRegion region = new GridRegion(reg); + region.RegionName = finalDestination.RegionName; + region.RegionID = finalDestination.RegionID; + region.RegionLocX = finalDestination.RegionLocX; + region.RegionLocY = finalDestination.RegionLocY; // Log their session and remote endpoint in the home users security service IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface(); @@ -149,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Log them out of this grid sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); - return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason); + return m_GatekeeperConnector.CreateAgent(region, agentCircuit, teleportFlags, out reason); } return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 07f3cdc..67eae87 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -48,7 +48,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { - public class HGGridConnector : ISharedRegionModule, IGridService, IHypergridService + public class HGGridConnector : ISharedRegionModule, IGridService { private static readonly ILog m_log = LogManager.GetLogger( @@ -61,8 +61,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private Dictionary m_LocalScenes = new Dictionary(); private IGridService m_GridServiceConnector; - private IHypergridService m_HypergridService; - #region ISharedRegionModule @@ -119,16 +117,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid Object[] args = new Object[] { source }; m_GridServiceConnector = ServerUtils.LoadPlugin(module, args); - string hypergrid = gridConfig.GetString("HypergridService", string.Empty); - if (hypergrid == String.Empty) - { - m_log.Error("[HGGRID CONNECTOR]: No HypergridService named in section GridService"); - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } - m_HypergridService = ServerUtils.LoadPlugin(hypergrid, args); - - if (m_GridServiceConnector == null || m_HypergridService == null) - throw new Exception("Unable to proceed. HGGrid services could not be loaded."); } public void PostInitialise() @@ -148,7 +136,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; scene.RegisterModuleInterface(this); - scene.RegisterModuleInterface(this); ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); @@ -160,7 +147,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); scene.UnregisterModuleInterface(this); - scene.UnregisterModuleInterface(this); ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); } } @@ -201,13 +187,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { - GridRegion region = m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); - if (region != null) - return region; + return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); + //if (region != null) + // return region; - region = m_HypergridService.GetRegionByUUID(regionID); + //region = m_HypergridService.GetRegionByUUID(regionID); - return region; + //return region; } public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) @@ -216,10 +202,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; GridRegion region = m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); - if (region != null) - return region; + //if (region != null) + // return region; - region = m_HypergridService.GetRegionByPosition(snapX, snapY); + //region = m_HypergridService.GetRegionByPosition(snapX, snapY); return region; } @@ -231,7 +217,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (region != null) return region; - region = m_HypergridService.GetRegionByName(regionName); + //region = m_HypergridService.GetRegionByName(regionName); return region; } @@ -241,27 +227,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (name == string.Empty) return new List(); - List rinfos = m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber); - - rinfos.AddRange(m_HypergridService.GetRegionsByName(name)); - if (rinfos.Count > maxNumber) - rinfos.RemoveRange(maxNumber - 1, rinfos.Count - maxNumber); - - return rinfos; + return m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber); } public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { - int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; - int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; - int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; - int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; - - List rinfos = m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); - - rinfos.AddRange(m_HypergridService.GetRegionRange(snapXmin, snapXmax, snapYmin, snapYmax)); - - return rinfos; + return m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); } public List GetDefaultRegions(UUID scopeID) @@ -281,27 +252,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion - #region IHypergridService - - public bool LinkRegion(string regionDescriptor, out UUID regionID, out ulong regionHandle, out string imageURL, out string reason) - { - return m_HypergridService.LinkRegion(regionDescriptor, out regionID, out regionHandle, out imageURL, out reason); - } - - public GridRegion GetHyperlinkRegion(GridRegion gateway, UUID regionID) - { - if (m_LocalScenes.ContainsKey(gateway.RegionHandle)) - return gateway; - - return m_HypergridService.GetHyperlinkRegion(gateway, regionID); - } - - public GridRegion GetRegionByUUID(UUID regionID) { return null; } - public GridRegion GetRegionByPosition(int x, int y) { return null; } - public GridRegion GetRegionByName(string name) { return null; } - public List GetRegionsByName(string name) { return null; } - public List GetRegionRange(int xmin, int xmax, int ymin, int ymax) { return null; } - #endregion } } -- cgit v1.1 From ea3d287f70d48eb2d3abf6eb1506bf64674874c5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 15:04:41 -0800 Subject: Some method implementations were missing from LocalGridServiceConnector. --- .../EntityTransfer/HGEntityTransferModule.cs | 2 ++ .../Grid/LocalGridServiceConnector.cs | 30 +++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index e237ca2..a1de57a 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -124,8 +124,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override GridRegion GetFinalDestination(GridRegion region) { int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); + //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); return m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); } return region; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 86a8c13..1b00c8a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -238,6 +238,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); } + public List GetDefaultRegions(UUID scopeID) + { + return m_GridService.GetDefaultRegions(scopeID); + } + + public List GetFallbackRegions(UUID scopeID, int x, int y) + { + return m_GridService.GetFallbackRegions(scopeID, x, y); + } + + public int GetRegionFlags(UUID scopeID, UUID regionID) + { + return m_GridService.GetRegionFlags(scopeID, regionID); + } + #endregion public void NeighboursCommand(string module, string[] cmdparams) @@ -251,20 +266,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } } - public List GetDefaultRegions(UUID scopeID) - { - return null; - } - - public List GetFallbackRegions(UUID scopeID, int x, int y) - { - return null; - } - - public int GetRegionFlags(UUID scopeID, UUID regionID) - { - return 0; - } - } } -- cgit v1.1 From 70465f4c9073033b87c781c35172656985fedccc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 16:23:18 -0800 Subject: Removed obsolete interface IHyperlink. --- .../Simulation/RemoteSimulationConnector.cs | 5 ----- .../CoreModules/World/WorldMap/MapSearchModule.cs | 19 ------------------- 2 files changed, 24 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 227c37f..24b5d6c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -58,8 +58,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation protected LocalSimulationConnectorModule m_localBackend; protected SimulationServiceConnector m_remoteConnector; - protected IHyperlinkService m_hyperlinkService; - protected bool m_safemode; protected IPAddress m_thisIP; @@ -124,9 +122,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (!m_enabled) return; - - m_hyperlinkService = m_aScene.RequestModuleInterface(); - } public Type ReplaceableInterface diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 42b4632..56200ec 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -104,25 +104,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap if (info != null) regionInfos.Add(info); } - if ((regionInfos.Count == 0)) - { - // OK, we tried but there are no regions matching that name. - // Let's check quickly if this is a domain name, and if so link to it - if (mapName.Contains(".")) - { - // It probably is a domain name. Try to link to it. - GridRegion regInfo; - Scene cScene = GetClientScene(remoteClient); - IHyperlinkService hyperService = cScene.RequestModuleInterface(); - if (hyperService != null) - { - regInfo = hyperService.TryLinkRegion(remoteClient, mapName); - if (regInfo != null) - regionInfos.Add(regInfo); - } - } - } - List blocks = new List(); MapBlockData data; -- cgit v1.1 From 7c00469cd210cfdda3dd835867469159d4c8b9d9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 27 Jan 2010 08:00:29 -0800 Subject: Added ExternalName config on Gatekeeper. --- .../CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index a1de57a..4d5844c 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -157,6 +157,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (security != null) security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint); + //string token = sp.Scene.AuthenticationService.MakeToken(sp.UUID, reg.ExternalHostName + ":" + reg.HttpPort, 30); // Log them out of this grid sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); -- cgit v1.1 From 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 28 Jan 2010 19:19:42 -0800 Subject: HG 1.5 is in place. Tested in standalone only. --- .../EntityTransfer/EntityTransferModule.cs | 10 +- .../EntityTransfer/HGEntityTransferModule.cs | 112 +++++++++++---------- .../Hypergrid/HypergridServiceInConnectorModule.cs | 4 +- 3 files changed, 71 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ed8c0fd..44f1191 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -237,9 +237,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq) { + if (reg == null || finalDestination == null) + { + sp.ControllingClient.SendTeleportFailed("Unable to locate destination"); + return; + } + m_log.DebugFormat( - "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3} final destination {4}", - reg.ExternalHostName, reg.HttpPort, reg.RegionName, position, finalDestination.RegionName); + "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}", + reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position); uint newRegionX = (uint)(reg.RegionHandle >> 40); uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 4d5844c..85c2742 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -44,14 +44,13 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { - public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule + public class HGEntityTransferModule : EntityTransferModule, ISharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Initialized = false; private GatekeeperServiceConnector m_GatekeeperConnector; - private IHomeUsersSecurityService m_Security; #region ISharedRegionModule @@ -69,21 +68,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (name == Name) { m_agentsInTransit = new List(); - - IConfig config = source.Configs["HGEntityTransferModule"]; - if (config != null) - { - string dll = config.GetString("HomeUsersSecurityService", string.Empty); - if (dll != string.Empty) - { - Object[] args = new Object[] { source }; - m_Security = ServerUtils.LoadPlugin(dll, args); - if (m_Security == null) - m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service"); - else - m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded"); - } - } m_Enabled = true; m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); @@ -95,7 +79,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { base.AddRegion(scene); if (m_Enabled) - scene.RegisterModuleInterface(m_Security); + { + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(OnNewClient); + } + } + + void OnNewClient(IClientAPI client) + { + client.OnLogout += new Action(OnLogout); } public override void RegionLoaded(Scene scene) @@ -113,13 +105,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { base.AddRegion(scene); if (m_Enabled) - scene.UnregisterModuleInterface(m_Security); + { + scene.UnregisterModuleInterface(this); + } } #endregion - #region HG overrides + #region HG overrides of IEntiryTransferModule protected override GridRegion GetFinalDestination(GridRegion region) { @@ -142,26 +136,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer { reason = string.Empty; int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); - if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) + if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid - // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination - GridRegion region = new GridRegion(reg); - region.RegionName = finalDestination.RegionName; - region.RegionID = finalDestination.RegionID; - region.RegionLocX = finalDestination.RegionLocX; - region.RegionLocY = finalDestination.RegionLocY; - - // Log their session and remote endpoint in the home users security service - IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface(); - if (security != null) - security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint); - - //string token = sp.Scene.AuthenticationService.MakeToken(sp.UUID, reg.ExternalHostName + ":" + reg.HttpPort, 30); - // Log them out of this grid - sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat); - - return m_GatekeeperConnector.CreateAgent(region, agentCircuit, teleportFlags, out reason); + string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver); + 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); + + return success; } return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); @@ -184,23 +169,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Foreign user wants to go home // AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); - if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI"))) + if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("HomeURI"))) { client.SendTeleportFailed("Your information has been lost"); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); return; } - GridRegion homeGatekeeper = MakeRegion(aCircuit); - if (homeGatekeeper == null) - { - client.SendTeleportFailed("Your information has been lost"); - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed"); - return; - } - + IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY; - GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt); + GridRegion finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt); if (finalDestination == null) { client.SendTeleportFailed("Your home region could not be found"); @@ -216,20 +194,52 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", + IEventQueue eq = sp.Scene.RequestModuleInterface(); + GridRegion homeGatekeeper = MakeRegion(aCircuit); + + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}", aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName); - IEventQueue eq = sp.Scene.RequestModuleInterface(); DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); } #endregion + #region IUserAgentVerificationModule + + public bool VerifyClient(AgentCircuitData aCircuit, string token) + { + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string url = aCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService security = new UserAgentServiceConnector(url); + return security.VerifyClient(aCircuit.SessionID, token); + } + + return false; + } + + void OnLogout(IClientAPI obj) + { + AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); + + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string url = aCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService security = new UserAgentServiceConnector(url); + security.LogoutAgent(obj.AgentId, obj.SessionId); + } + + } + + #endregion + private GridRegion MakeRegion(AgentCircuitData aCircuit) { GridRegion region = new GridRegion(); Uri uri = null; - if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri)) + if (!aCircuit.ServiceURLs.ContainsKey("HomeURI") || + (aCircuit.ServiceURLs.ContainsKey("HomeURI") && !Uri.TryCreate(aCircuit.ServiceURLs["HomeURI"].ToString(), UriKind.Absolute, out uri))) return null; region.ExternalHostName = uri.Host; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs index 6e6946c..c737f8b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs @@ -115,11 +115,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid m_log.Info("[HypergridService]: Starting..."); -// Object[] args = new Object[] { m_Config, MainServer.Instance }; ISimulationService simService = scene.RequestModuleInterface(); m_HypergridHandler = new GatekeeperServiceInConnector(m_Config, MainServer.Instance, simService); - //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); scene.RegisterModuleInterface(m_HypergridHandler.GateKeeper); + + new UserAgentServerConnector(m_Config, MainServer.Instance); } } -- cgit v1.1 From 0c81966c0a8f69474fb542d7b4df1780ef756519 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Jan 2010 09:12:22 -0800 Subject: Works for grid login. --- .../EntityTransfer/EntityTransferModule.cs | 6 +++- .../EntityTransfer/HGEntityTransferModule.cs | 39 ++++++++++++++++------ 2 files changed, 33 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 44f1191..ee6cb04 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -97,7 +97,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer scene.EventManager.OnNewClient += OnNewClient; } - protected void OnNewClient(IClientAPI client) + protected virtual void OnNewClient(IClientAPI client) { client.OnTeleportHomeRequest += TeleportHome; } @@ -268,6 +268,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (sp.ParentID != (uint)0) sp.StandUp(); + m_log.Debug("XXX HERE 1"); if (!sp.ValidateAttachments()) { sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); @@ -978,12 +979,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (neighbour.RegionHandle != sp.Scene.RegionInfo.RegionHandle) { + AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); AgentCircuitData agent = sp.ControllingClient.RequestClientInfo(); agent.BaseFolder = UUID.Zero; agent.InventoryFolder = UUID.Zero; agent.startpos = new Vector3(128, 128, 70); agent.child = true; agent.Appearance = sp.Appearance; + if (currentAgentCircuit != null) + agent.ServiceURLs = currentAgentCircuit.ServiceURLs; if (newRegions.Contains(neighbour.RegionHandle)) { diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 85c2742..fbf8be9 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -85,8 +85,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } } - void OnNewClient(IClientAPI client) + protected override void OnNewClient(IClientAPI client) { + base.OnNewClient(client); client.OnLogout += new Action(OnLogout); } @@ -118,7 +119,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override GridRegion GetFinalDestination(GridRegion region) { int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, region.RegionID); - //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); @@ -129,7 +130,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) { - return true; + if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) + return true; + + int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); + if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) + return true; + + return false; } protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) @@ -139,14 +147,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) { // this user is going to another grid - string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); - IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver); - 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); - - return success; + if (agentCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string userAgentDriver = agentCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService connector = new UserAgentServiceConnector(userAgentDriver); + 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); + + return success; + } + else + { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent does not have a HomeURI address"); + return false; + } } return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); @@ -220,6 +236,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer void OnLogout(IClientAPI obj) { + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: client {0} logged out in {1}", obj.AgentId, obj.Scene.RegionInfo.RegionName); AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) -- cgit v1.1 From 5001f61c08fea2ebfcb2590be69073d04d129d70 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Jan 2010 18:59:41 -0800 Subject: * HGGridConnector is no longer necessary. * Handle logout properly. This needed an addition to IClientAPI, because of how the logout packet is currently being handled -- the agent is being removed from the scene before the different event handlers are executed, which is broken. --- .../EntityTransfer/EntityTransferModule.cs | 9 +- .../EntityTransfer/HGEntityTransferModule.cs | 28 ++- .../Resources/CoreModulePlugin.addin.xml | 1 - .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 257 --------------------- 4 files changed, 20 insertions(+), 275 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index ee6cb04..53de269 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -268,7 +268,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (sp.ParentID != (uint)0) sp.StandUp(); - m_log.Debug("XXX HERE 1"); if (!sp.ValidateAttachments()) { sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); @@ -351,7 +350,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // ES makes the client send a UseCircuitCode message to the destination, // which triggers a bunch of things there. // So let's wait - Thread.Sleep(2000); + Thread.Sleep(200); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); @@ -428,13 +427,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - KillEntity(sp.Scene, sp.LocalId); - - sp.MakeChildAgent(); // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it CrossAttachmentsIntoNewRegion(finalDestination, sp, true); + KillEntity(sp.Scene, sp.LocalId); + + sp.MakeChildAgent(); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index fbf8be9..28593fc 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -81,16 +81,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer if (m_Enabled) { scene.RegisterModuleInterface(this); - scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(OnNewClient); } } protected override void OnNewClient(IClientAPI client) { - base.OnNewClient(client); - client.OnLogout += new Action(OnLogout); + client.OnTeleportHomeRequest += TeleportHome; + client.OnConnectionClosed += new Action(OnConnectionClosed); } + public override void RegionLoaded(Scene scene) { base.RegionLoaded(scene); @@ -234,18 +234,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return false; } - void OnLogout(IClientAPI obj) + void OnConnectionClosed(IClientAPI obj) { - m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: client {0} logged out in {1}", obj.AgentId, obj.Scene.RegionInfo.RegionName); - AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); - - if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + if (obj.IsLoggingOut) { - string url = aCircuit.ServiceURLs["HomeURI"].ToString(); - IUserAgentService security = new UserAgentServiceConnector(url); - security.LogoutAgent(obj.AgentId, obj.SessionId); - } + AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + { + string url = aCircuit.ServiceURLs["HomeURI"].ToString(); + IUserAgentService security = new UserAgentServiceConnector(url); + security.LogoutAgent(obj.AgentId, obj.SessionId); + //m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Sent logout call to UserAgentService @ {0}", url); + } + else + m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: HomeURI not found for agent {0} logout", obj.AgentId); + } } #endregion diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 0e3739a..e10fa60 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -50,7 +50,6 @@ - diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs deleted file mode 100644 index 67eae87..0000000 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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.Net; -using System.Reflection; -using System.Xml; - - -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; -using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; -using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; -using OpenSim.Server.Base; -using OpenSim.Framework.Console; - -using OpenMetaverse; -using log4net; -using Nini.Config; - -namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid -{ - public class HGGridConnector : ISharedRegionModule, IGridService - { - private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); - - private bool m_Enabled = false; - private bool m_Initialized = false; - - private Scene m_aScene; - private Dictionary m_LocalScenes = new Dictionary(); - - private IGridService m_GridServiceConnector; - - #region ISharedRegionModule - - public Type ReplaceableInterface - { - get { return null; } - } - - public string Name - { - get { return "HGGridServicesConnector"; } - } - - public void Initialise(IConfigSource source) - { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) - { - string name = moduleConfig.GetString("GridServices", ""); - if (name == Name) - { - IConfig gridConfig = source.Configs["GridService"]; - if (gridConfig == null) - { - m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); - return; - } - - - InitialiseConnectorModule(source); - - m_Enabled = true; - m_log.Info("[HGGRID CONNECTOR]: HG grid enabled"); - } - } - } - - private void InitialiseConnectorModule(IConfigSource source) - { - IConfig gridConfig = source.Configs["GridService"]; - if (gridConfig == null) - { - m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); - throw new Exception("Grid connector init error"); - } - - string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty); - if (module == String.Empty) - { - m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } - - Object[] args = new Object[] { source }; - m_GridServiceConnector = ServerUtils.LoadPlugin(module, args); - - } - - public void PostInitialise() - { - if (m_Enabled) - ((ISharedRegionModule)m_GridServiceConnector).PostInitialise(); - } - - public void Close() - { - } - - public void AddRegion(Scene scene) - { - if (!m_Enabled) - return; - - m_LocalScenes[scene.RegionInfo.RegionHandle] = scene; - scene.RegisterModuleInterface(this); - - ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); - - } - - public void RemoveRegion(Scene scene) - { - if (m_Enabled) - { - m_LocalScenes.Remove(scene.RegionInfo.RegionHandle); - scene.UnregisterModuleInterface(this); - ((ISharedRegionModule)m_GridServiceConnector).RemoveRegion(scene); - } - } - - public void RegionLoaded(Scene scene) - { - if (!m_Enabled) - return; - - if (!m_Initialized) - { - m_aScene = scene; - - m_Initialized = true; - } - } - - #endregion - - #region IGridService - - public string RegisterRegion(UUID scopeID, GridRegion regionInfo) - { - return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); - } - - public bool DeregisterRegion(UUID regionID) - { - return m_GridServiceConnector.DeregisterRegion(regionID); - } - - public List GetNeighbours(UUID scopeID, UUID regionID) - { - // No serving neighbours on hyperliked regions. - // Just the regular regions. - return m_GridServiceConnector.GetNeighbours(scopeID, regionID); - } - - public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) - { - return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); - //if (region != null) - // return region; - - //region = m_HypergridService.GetRegionByUUID(regionID); - - //return region; - } - - public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) - { - int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; - int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; - - GridRegion region = m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); - //if (region != null) - // return region; - - //region = m_HypergridService.GetRegionByPosition(snapX, snapY); - - return region; - } - - public GridRegion GetRegionByName(UUID scopeID, string regionName) - { - // Try normal grid first - GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); - if (region != null) - return region; - - //region = m_HypergridService.GetRegionByName(regionName); - - return region; - } - - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) - { - if (name == string.Empty) - return new List(); - - return m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber); - } - - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) - { - return m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); - } - - public List GetDefaultRegions(UUID scopeID) - { - return m_GridServiceConnector.GetDefaultRegions(scopeID); - } - - public List GetFallbackRegions(UUID scopeID, int x, int y) - { - return m_GridServiceConnector.GetFallbackRegions(scopeID, x, y); - } - - public int GetRegionFlags(UUID scopeID, UUID regionID) - { - return m_GridServiceConnector.GetRegionFlags(scopeID, regionID); - } - - #endregion - - - } -} -- cgit v1.1 From 81a6f9a5152f0445c9b48229fa4cd74effed5d0f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 29 Jan 2010 19:33:50 -0800 Subject: On the way to making HG inventory work. Inventory can now be accessed again. Assets are still broken. --- .../Inventory/HGInventoryBroker.cs | 176 ++++++++------------- 1 file changed, 66 insertions(+), 110 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 0c5097a..b6718a8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -50,25 +50,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private bool m_Enabled = false; private bool m_Initialized = false; private Scene m_Scene; - private IUserAccountService m_UserAccountService; // This should change to IUserProfileService + private IUserAccountService m_UserAccountService; private IInventoryService m_GridService; private ISessionAuthInventoryService m_HGService; - private string m_LocalGridInventoryURI = string.Empty; - - private string LocalGridInventory - { - get - { - return string.Empty; - // REFACTORING PROBLEM - //if (m_LocalGridInventoryURI == null || m_LocalGridInventoryURI == "") - // m_LocalGridInventoryURI = m_Scene.CommsManager.NetworkServersInfo.InventoryURL; - //return m_LocalGridInventoryURI; - } - } - public Type ReplaceableInterface { get { return null; } @@ -133,8 +119,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return; } - m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty); - Init(source); m_Enabled = true; @@ -199,22 +183,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override InventoryCollection GetUserInventory(UUID userID) { - if (IsLocalGridUser(userID)) - return m_GridService.GetUserInventory(userID); - else - return null; + return null; } public override void GetUserInventory(UUID userID, InventoryReceiptCallback callback) { - if (IsLocalGridUser(userID)) - m_GridService.GetUserInventory(userID, callback); - else - { - UUID sessionID = GetSessionID(userID); - string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); - m_HGService.GetUserInventory(uri, sessionID, callback); - } } // Inherited. See base @@ -234,19 +207,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override InventoryCollection GetFolderContent(UUID userID, UUID folderID) { - if (IsLocalGridUser(userID)) + string uri = string.Empty; + if (!IsForeignUser(userID, out uri)) return m_GridService.GetFolderContent(userID, folderID); else { UUID sessionID = GetSessionID(userID); - string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); + uri = uri + "/" + userID.ToString(); return m_HGService.GetFolderContent(uri, folderID, sessionID); } } public override Dictionary GetSystemFolders(UUID userID) { - if (IsLocalGridUser(userID)) + string uri = string.Empty; + if (!IsForeignUser(userID, out uri)) { // This is not pretty, but it will have to do for now if (m_GridService is BaseInventoryConnector) @@ -263,7 +238,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory else { UUID sessionID = GetSessionID(userID); - string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); + uri = uri + "/" + userID.ToString(); return m_HGService.GetSystemFolders(uri, sessionID); } } @@ -299,12 +274,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override List GetFolderItems(UUID userID, UUID folderID) { - if (IsLocalGridUser(userID)) + string uri = string.Empty; + if (!IsForeignUser(userID, out uri)) return m_GridService.GetFolderItems(userID, folderID); else { UUID sessionID = GetSessionID(userID); - string uri = GetUserInventoryURI(userID) + "/" + userID; + uri = uri + "/" + userID.ToString(); return m_HGService.GetFolderItems(uri, folderID, sessionID); } } @@ -314,12 +290,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - if (IsLocalGridUser(folder.Owner)) + string uri = string.Empty; + if (!IsForeignUser(folder.Owner, out uri)) return m_GridService.AddFolder(folder); else { UUID sessionID = GetSessionID(folder.Owner); - string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + uri = uri + "/" + folder.Owner.ToString(); return m_HGService.AddFolder(uri, folder, sessionID); } } @@ -329,12 +306,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - if (IsLocalGridUser(folder.Owner)) + string uri = string.Empty; + if (!IsForeignUser(folder.Owner, out uri)) return m_GridService.UpdateFolder(folder); else { UUID sessionID = GetSessionID(folder.Owner); - string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + uri = uri + "/" + folder.Owner.ToString(); return m_HGService.UpdateFolder(uri, folder, sessionID); } } @@ -346,12 +324,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folderIDs.Count == 0) return false; - if (IsLocalGridUser(ownerID)) + string uri = string.Empty; + if (!IsForeignUser(ownerID, out uri)) return m_GridService.DeleteFolders(ownerID, folderIDs); else { UUID sessionID = GetSessionID(ownerID); - string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); + uri = uri + "/" + ownerID.ToString(); return m_HGService.DeleteFolders(uri, folderIDs, sessionID); } } @@ -361,12 +340,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - if (IsLocalGridUser(folder.Owner)) + string uri = string.Empty; + if (!IsForeignUser(folder.Owner, out uri)) return m_GridService.MoveFolder(folder); else { UUID sessionID = GetSessionID(folder.Owner); - string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + uri = uri + "/" + folder.Owner.ToString(); return m_HGService.MoveFolder(uri, folder, sessionID); } } @@ -376,12 +356,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return false; - if (IsLocalGridUser(folder.Owner)) + string uri = string.Empty; + if (!IsForeignUser(folder.Owner, out uri)) return m_GridService.PurgeFolder(folder); else { UUID sessionID = GetSessionID(folder.Owner); - string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + uri = uri + "/" + folder.Owner.ToString(); return m_HGService.PurgeFolder(uri, folder, sessionID); } } @@ -394,14 +375,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (item == null) return false; - if (IsLocalGridUser(item.Owner)) + string uri = string.Empty; + if (!IsForeignUser(item.Owner, out uri)) { return m_GridService.AddItem(item); } else { UUID sessionID = GetSessionID(item.Owner); - string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + uri = uri + "/" + item.Owner.ToString(); return m_HGService.AddItem(uri, item, sessionID); } } @@ -411,12 +393,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (item == null) return false; - if (IsLocalGridUser(item.Owner)) + string uri = string.Empty; + if (!IsForeignUser(item.Owner, out uri)) return m_GridService.UpdateItem(item); else { UUID sessionID = GetSessionID(item.Owner); - string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + uri = uri + "/" + item.Owner.ToString(); return m_HGService.UpdateItem(uri, item, sessionID); } } @@ -428,12 +411,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (items.Count == 0) return true; - if (IsLocalGridUser(ownerID)) + string uri = string.Empty; + if (!IsForeignUser(ownerID, out uri)) return m_GridService.MoveItems(ownerID, items); else { UUID sessionID = GetSessionID(ownerID); - string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); + uri = uri + "/" + ownerID.ToString(); return m_HGService.MoveItems(uri, items, sessionID); } } @@ -447,12 +431,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (itemIDs.Count == 0) return true; - if (IsLocalGridUser(ownerID)) + string uri = string.Empty; + if (!IsForeignUser(ownerID, out uri)) return m_GridService.DeleteItems(ownerID, itemIDs); else { UUID sessionID = GetSessionID(ownerID); - string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString(); + uri = uri + "/" + ownerID.ToString(); return m_HGService.DeleteItems(uri, itemIDs, sessionID); } } @@ -462,12 +447,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (item == null) return null; m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetItem {0} for user {1}", item.ID, item.Owner); - if (IsLocalGridUser(item.Owner)) + string uri = string.Empty; + if (!IsForeignUser(item.Owner, out uri)) return m_GridService.GetItem(item); else { UUID sessionID = GetSessionID(item.Owner); - string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + uri = uri + "/" + item.Owner.ToString(); return m_HGService.QueryItem(uri, item, sessionID); } } @@ -477,12 +463,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (folder == null) return null; - if (IsLocalGridUser(folder.Owner)) + string uri = string.Empty; + if (!IsForeignUser(folder.Owner, out uri)) return m_GridService.GetFolder(folder); else { UUID sessionID = GetSessionID(folder.Owner); - string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + uri = uri + "/" + folder.Owner.ToString(); return m_HGService.QueryFolder(uri, folder, sessionID); } } @@ -499,12 +486,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public override int GetAssetPermissions(UUID userID, UUID assetID) { - if (IsLocalGridUser(userID)) + string uri = string.Empty; + if (!IsForeignUser(userID, out uri)) return m_GridService.GetAssetPermissions(userID, assetID); else { UUID sessionID = GetSessionID(userID); - string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); + uri = uri + "/" + userID.ToString(); return m_HGService.GetAssetPermissions(uri, assetID, sessionID); } } @@ -523,59 +511,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory return UUID.Zero; } - private bool IsLocalGridUser(UUID userID) + private bool IsForeignUser(UUID userID, out string inventoryURL) { - return true; - - // REFACTORING PROBLEM. This needs to be rewritten - - //if (m_UserAccountService == null) - //{ - // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no user account service. Returning false."); - // return false; - //} - - //UserAccount uinfo = m_UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); - //if (uinfo == null) - //{ - // m_log.DebugFormat("[HG INVENTORY CONNECTOR]: IsLocalGridUser, no account for user {0}. Returning false.", userID); - // return false; - //} - - //if ((uinfo.UserProfile.UserInventoryURI == null) || (uinfo.UserProfile.UserInventoryURI == "")) - // // this happens in standalone profiles, apparently - // return true; - - //string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); - - //string uri = LocalGridInventory.TrimEnd('/'); - - //if ((userInventoryServerURI == uri) || (userInventoryServerURI == "")) - //{ - // return true; - //} - //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: user {0} is foreign({1} - {2})", userID, userInventoryServerURI, uri); - //return false; - } - - private string GetUserInventoryURI(UUID userID) - { - string invURI = LocalGridInventory; - // REFACTORING PROBLEM!!! This needs to be rewritten - - //CachedUserInfo uinfo = m_UserAccountService.GetUserDetails(userID); - //if ((uinfo == null) || (uinfo.UserProfile == null)) - // return invURI; - - //string userInventoryServerURI = Util.ServerURI(uinfo.UserProfile.UserInventoryURI); - - //if ((userInventoryServerURI != null) && - // (userInventoryServerURI != "")) - // invURI = userInventoryServerURI; - - return invURI; + inventoryURL = string.Empty; + UserAccount account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + if (account == null) // foreign user + { + ScenePresence sp = null; + m_Scene.TryGetAvatar(userID, out sp); + if (sp != null) + { + AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + if (aCircuit.ServiceURLs.ContainsKey("InventoryServerURI")) + { + inventoryURL = aCircuit.ServiceURLs["InventoryServerURI"].ToString(); + inventoryURL = inventoryURL.Trim(new char[] { '/' }); + return true; + } + } + } + return false; } - } } -- cgit v1.1 From 42f978a478093da579907e15dc29680a3711b27e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 30 Jan 2010 09:23:07 -0800 Subject: * HGScene is no more. * Moved a few key inventory access methods from Scene.Inventory to an IInventoryAccessModule module --- .../Framework/InventoryAccess/HGAssetMapper.cs | 200 +++++++ .../InventoryAccess/HGInventoryAccessModule.cs | 204 +++++++ .../Framework/InventoryAccess/HGUuidGatherer.cs | 57 ++ .../InventoryAccess/InventoryAccessModule.cs | 654 +++++++++++++++++++++ .../Resources/CoreModulePlugin.addin.xml | 2 + .../Simulation/RemoteSimulationConnector.cs | 1 - .../CoreModules/World/WorldMap/MapSearchModule.cs | 1 - 7 files changed, 1117 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs create mode 100644 OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs new file mode 100644 index 0000000..e303a1f --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -0,0 +1,200 @@ +/* + * 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 System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; + +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Services.Interfaces; + +//using HyperGrid.Framework; +//using OpenSim.Region.Communications.Hypergrid; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class HGAssetMapper + { + #region Fields + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + // This maps between inventory server urls and inventory server clients +// private Dictionary m_inventoryServers = new Dictionary(); + + private Scene m_scene; + + #endregion + + #region Constructor + + public HGAssetMapper(Scene scene) + { + m_scene = scene; + } + + #endregion + + #region Internal functions + + public AssetBase FetchAsset(string url, UUID assetID) + { + AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); + + if (asset != null) + { + m_log.DebugFormat("[HG ASSET MAPPER]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); + return asset; + } + return null; + } + + public bool PostAsset(string url, AssetBase asset) + { + if (asset != null) + { + // See long comment in AssetCache.AddAsset + if (!asset.Temporary || asset.Local) + { + // We need to copy the asset into a new asset, because + // we need to set its ID to be URL+UUID, so that the + // HGAssetService dispatches it to the remote grid. + // It's not pretty, but the best that can be done while + // not having a global naming infrastructure + AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); + Copy(asset, asset1); + try + { + asset1.ID = url + "/" + asset.ID; + } + catch + { + m_log.Warn("[HG ASSET MAPPER]: Oops."); + } + + m_scene.AssetService.Store(asset1); + m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); + } + return true; + } + else + m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); + + return false; + } + + private void Copy(AssetBase from, AssetBase to) + { + to.Data = from.Data; + to.Description = from.Description; + to.FullID = from.FullID; + to.ID = from.ID; + to.Local = from.Local; + to.Name = from.Name; + to.Temporary = from.Temporary; + to.Type = from.Type; + + } + + // TODO: unused + // private void Dump(Dictionary lst) + // { + // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); + // foreach (KeyValuePair kvp in lst) + // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); + // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); + // } + + #endregion + + + #region Public interface + + public void Get(UUID assetID, UUID ownerID, string userAssetURL) + { + // Get the item from the remote asset server onto the local AssetCache + // and place an entry in m_assetMap + + m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL); + AssetBase asset = FetchAsset(userAssetURL, assetID); + + if (asset != null) + { + // OK, now fetch the inside. + Dictionary ids = new Dictionary(); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); + uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); + foreach (UUID uuid in ids.Keys) + FetchAsset(userAssetURL, uuid); + + m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); + + } + else + m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL); + } + + + public void Post(UUID assetID, UUID ownerID, string userAssetURL) + { + // Post the item from the local AssetCache onto the remote asset server + // and place an entry in m_assetMap + + m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL); + AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); + if (asset != null) + { + Dictionary ids = new Dictionary(); + HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); + uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); + foreach (UUID uuid in ids.Keys) + { + asset = m_scene.AssetService.Get(uuid.ToString()); + if (asset == null) + m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid); + else + PostAsset(userAssetURL, asset); + } + + // maybe all pieces got there... + m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); + + } + else + m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID); + + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs new file mode 100644 index 0000000..ecd7002 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -0,0 +1,204 @@ +/* + * 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.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Connectors.Hypergrid; +using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class HGInventoryAccessModule : InventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private static HGAssetMapper m_assMapper; + public static HGAssetMapper AssetMapper + { + get { return m_assMapper; } + } + + private bool m_Initialized = false; + + #region INonSharedRegionModule + + public override string Name + { + get { return "HGInventoryAccessModule"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("InventoryAccessModule", ""); + if (name == Name) + { + m_Enabled = true; + m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); + } + } + } + + public override void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + base.AddRegion(scene); + m_assMapper = new HGAssetMapper(scene); + scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; + + } + + #endregion + + #region Event handlers + + public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) + { + string userAssetServer = string.Empty; + if (IsForeignUser(avatarID, out userAssetServer)) + { + m_assMapper.Post(assetID, avatarID, userAssetServer); + } + } + + #endregion + + #region Overrides of Basic Inventory Access methods + /// + /// CapsUpdateInventoryItemAsset + /// + public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) + { + UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); + + UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); + + return newAssetID; + } + + /// + /// DeleteToInventory + /// + public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) + { + UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient); + + if (!assetID.Equals(UUID.Zero)) + { + UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); + } + else + m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); + + return assetID; + } + + /// + /// RezObject + /// + public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, + UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) + { + m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); + + //if (fromTaskID.Equals(UUID.Zero)) + //{ + InventoryItemBase item = new InventoryItemBase(itemID); + item.Owner = remoteClient.AgentId; + item = m_Scene.InventoryService.GetItem(item); + //if (item == null) + //{ // Fetch the item + // item = new InventoryItemBase(); + // item.Owner = remoteClient.AgentId; + // item.ID = itemID; + // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); + //} + string userAssetServer = string.Empty; + if (item != null && IsForeignUser(remoteClient.AgentId, out userAssetServer)) + { + m_assMapper.Get(item.AssetID, remoteClient.AgentId, userAssetServer); + + } + //} + + // OK, we're done fetching. Pass it up to the default RezObject + return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, + RezSelected, RemoveItem, fromTaskID, attachment); + + } + + public override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) + { + string userAssetServer = string.Empty; + if (IsForeignUser(sender, out userAssetServer)) + m_assMapper.Get(item.AssetID, sender, userAssetServer); + + if (IsForeignUser(receiver, out userAssetServer)) + m_assMapper.Post(item.AssetID, receiver, userAssetServer); + } + + #endregion + + public bool IsForeignUser(UUID userID, out string assetServerURL) + { + assetServerURL = string.Empty; + UserAccount account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + if (account == null) // foreign + { + ScenePresence sp = null; + if (m_Scene.TryGetAvatar(userID, out sp)) + { + AgentCircuitData aCircuit = m_Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); + if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) + { + assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); + return true; + } + } + } + + return false; + } + } +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs new file mode 100644 index 0000000..fcb544f --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGUuidGatherer.cs @@ -0,0 +1,57 @@ +/* + * 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 OpenSim.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class HGUuidGatherer : UuidGatherer + { + protected string m_assetServerURL; + protected HGAssetMapper m_assetMapper; + + public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache) + { + m_assetMapper = assMap; + m_assetServerURL = assetServerURL; + } + + protected override AssetBase GetAsset(UUID uuid) + { + if (string.Empty == m_assetServerURL) + return m_assetCache.Get(uuid.ToString()); + else + return m_assetMapper.FetchAsset(m_assetServerURL, uuid); + } + } +} diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs new file mode 100644 index 0000000..d242a34 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -0,0 +1,654 @@ +/* + * 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.Net; +using System.Reflection; +using System.Threading; + +using OpenSim.Framework; +using OpenSim.Framework.Capabilities; +using OpenSim.Framework.Client; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; +using OpenSim.Services.Interfaces; + +using GridRegion = OpenSim.Services.Interfaces.GridRegion; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.Framework.InventoryAccess +{ + public class InventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected bool m_Enabled = false; + protected Scene m_Scene; + + #region INonSharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public virtual string Name + { + get { return "BasicInventoryAcessModule"; } + } + + public virtual void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("InventoryAccessModule", ""); + if (name == Name) + { + m_Enabled = true; + m_log.InfoFormat("[INVENTORY ACCESS MODULE]: {0} enabled.", Name); + } + } + } + + public virtual void PostInitialise() + { + } + + public virtual void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + m_Scene = scene; + + scene.RegisterModuleInterface(this); + scene.EventManager.OnNewClient += OnNewClient; + } + + protected virtual void OnNewClient(IClientAPI client) + { + + } + + public virtual void Close() + { + if (!m_Enabled) + return; + } + + + public virtual void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + m_Scene = null; + } + + public virtual void RegionLoaded(Scene scene) + { + if (!m_Enabled) + return; + + } + + #endregion + + #region Inventory Access + + /// + /// Capability originating call to update the asset of an item in an agent's inventory + /// + /// + /// + /// + /// + public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) + { + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = m_Scene.InventoryService.GetItem(item); + + if (item != null) + { + if ((InventoryType)item.InvType == InventoryType.Notecard) + { + if (!m_Scene.Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) + { + remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); + return UUID.Zero; + } + + remoteClient.SendAgentAlertMessage("Notecard saved", false); + } + else if ((InventoryType)item.InvType == InventoryType.LSL) + { + if (!m_Scene.Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) + { + remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); + return UUID.Zero; + } + + remoteClient.SendAgentAlertMessage("Script saved", false); + } + + AssetBase asset = + CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); + item.AssetID = asset.FullID; + m_Scene.AssetService.Store(asset); + + m_Scene.InventoryService.UpdateItem(item); + + // remoteClient.SendInventoryItemCreateUpdate(item); + return (asset.FullID); + } + else + { + m_log.ErrorFormat( + "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", + itemID); + } + + return UUID.Zero; + } + + /// + /// Delete a scene object from a scene and place in the given avatar's inventory. + /// Returns the UUID of the newly created asset. + /// + /// + /// + /// + /// + public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, + SceneObjectGroup objectGroup, IClientAPI remoteClient) + { + UUID assetID = UUID.Zero; + + Vector3 inventoryStoredPosition = new Vector3 + (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) + ? 250 + : objectGroup.AbsolutePosition.X) + , + (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) + ? 250 + : objectGroup.AbsolutePosition.X, + objectGroup.AbsolutePosition.Z); + + Vector3 originalPosition = objectGroup.AbsolutePosition; + + objectGroup.AbsolutePosition = inventoryStoredPosition; + + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); + + objectGroup.AbsolutePosition = originalPosition; + + // Get the user info of the item destination + // + UUID userID = UUID.Zero; + + if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || + action == DeRezAction.SaveToExistingUserInventoryItem) + { + // Take or take copy require a taker + // Saving changes requires a local user + // + if (remoteClient == null) + return UUID.Zero; + + userID = remoteClient.AgentId; + } + else + { + // All returns / deletes go to the object owner + // + + userID = objectGroup.RootPart.OwnerID; + } + + if (userID == UUID.Zero) // Can't proceed + { + return UUID.Zero; + } + + // If we're returning someone's item, it goes back to the + // owner's Lost And Found folder. + // Delete is treated like return in this case + // Deleting your own items makes them go to trash + // + + InventoryFolderBase folder = null; + InventoryItemBase item = null; + + if (DeRezAction.SaveToExistingUserInventoryItem == action) + { + item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); + item = m_Scene.InventoryService.GetItem(item); + + //item = userInfo.RootFolder.FindItem( + // objectGroup.RootPart.FromUserInventoryItemID); + + if (null == item) + { + m_log.DebugFormat( + "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", + objectGroup.Name, objectGroup.UUID); + return UUID.Zero; + } + } + else + { + // Folder magic + // + if (action == DeRezAction.Delete) + { + // Deleting someone else's item + // + + + if (remoteClient == null || + objectGroup.OwnerID != remoteClient.AgentId) + { + // Folder skeleton may not be loaded and we + // have to wait for the inventory to find + // the destination folder + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + else + { + // Assume inventory skeleton was loaded during login + // and all folders can be found + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + } + } + else if (action == DeRezAction.Return) + { + + // Dump to lost + found unconditionally + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + + if (folderID == UUID.Zero && folder == null) + { + if (action == DeRezAction.Delete) + { + // Deletes go to trash by default + // + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.TrashFolder); + } + else + { + // Catch all. Use lost & found + // + + folder = m_Scene.InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); + } + } + + if (folder == null) // None of the above + { + //folder = userInfo.RootFolder.FindFolder(folderID); + folder = new InventoryFolderBase(folderID); + + if (folder == null) // Nowhere to put it + { + return UUID.Zero; + } + } + + item = new InventoryItemBase(); + item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); + item.ID = UUID.Random(); + item.InvType = (int)InventoryType.Object; + item.Folder = folder.ID; + item.Owner = userID; + } + + AssetBase asset = CreateAsset( + objectGroup.GetPartName(objectGroup.RootPart.LocalId), + objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), + (sbyte)AssetType.Object, + Utils.StringToBytes(sceneObjectXml)); + m_Scene.AssetService.Store(asset); + assetID = asset.FullID; + + if (DeRezAction.SaveToExistingUserInventoryItem == action) + { + item.AssetID = asset.FullID; + m_Scene.InventoryService.UpdateItem(item); + } + else + { + item.AssetID = asset.FullID; + + if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) + { + uint perms = objectGroup.GetEffectivePermissions(); + uint nextPerms = (perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; + + item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions = item.BasePermissions; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; + item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions |= 8; // Slam! + } + else + { + item.BasePermissions = objectGroup.GetEffectivePermissions(); + item.CurrentPermissions = objectGroup.GetEffectivePermissions(); + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + item.GroupPermissions = objectGroup.RootPart.GroupMask; + + item.CurrentPermissions |= 8; // Slam! + } + + // TODO: add the new fields (Flags, Sale info, etc) + item.CreationDate = Util.UnixTimeSinceEpoch(); + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + + m_Scene.InventoryService.AddItem(item); + + if (remoteClient != null && item.Owner == remoteClient.AgentId) + { + remoteClient.SendInventoryItemCreateUpdate(item, 0); + } + else + { + ScenePresence notifyUser = m_Scene.GetScenePresence(item.Owner); + if (notifyUser != null) + { + notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); + } + } + } + + return assetID; + } + + + /// + /// Rez an object into the scene from the user's inventory + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// The SceneObjectGroup rezzed or null if rez was unsuccessful. + public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, + UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) + { + // Work out position details + byte bRayEndIsIntersection = (byte)0; + + if (RayEndIsIntersection) + { + bRayEndIsIntersection = (byte)1; + } + else + { + bRayEndIsIntersection = (byte)0; + } + + Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); + + + Vector3 pos = m_Scene.GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, scale, false); + + // Rez object + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); + item = m_Scene.InventoryService.GetItem(item); + + if (item != null) + { + AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); + + if (rezAsset != null) + { + UUID itemId = UUID.Zero; + + // If we have permission to copy then link the rezzed object back to the user inventory + // item that it came from. This allows us to enable 'save object to inventory' + if (!m_Scene.Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) + { + itemId = item.ID; + } + } + else + { + // Brave new fullperm world + // + itemId = item.ID; + } + + string xmlData = Utils.BytesToString(rezAsset.Data); + SceneObjectGroup group + = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); + + if (!m_Scene.Permissions.CanRezObject( + group.Children.Count, remoteClient.AgentId, pos) + && !attachment) + { + // The client operates in no fail mode. It will + // have already removed the item from the folder + // if it's no copy. + // Put it back if it's not an attachment + // + if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) + remoteClient.SendBulkUpdateInventory(item); + return null; + } + + group.ResetIDs(); + + if (attachment) + { + group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; + group.RootPart.IsAttachment = true; + } + + m_Scene.AddNewSceneObject(group, true); + + // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); + // if attachment we set it's asset id so object updates can reflect that + // if not, we set it's position in world. + if (!attachment) + { + float offsetHeight = 0; + pos = m_Scene.GetNewRezLocation( + RayStart, RayEnd, RayTargetID, Quaternion.Identity, + BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); + pos.Z += offsetHeight; + group.AbsolutePosition = pos; + // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); + + } + else + { + group.SetFromItemID(itemID); + } + + SceneObjectPart rootPart = null; + try + { + rootPart = group.GetChildPart(group.UUID); + } + catch (NullReferenceException) + { + string isAttachment = ""; + + if (attachment) + isAttachment = " Object was an attachment"; + + m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); + } + + // Since renaming the item in the inventory does not affect the name stored + // in the serialization, transfer the correct name from the inventory to the + // object itself before we rez. + rootPart.Name = item.Name; + rootPart.Description = item.Description; + + List partList = new List(group.Children.Values); + + group.SetGroup(remoteClient.ActiveGroupId, remoteClient); + if (rootPart.OwnerID != item.Owner) + { + //Need to kill the for sale here + rootPart.ObjectSaleType = 0; + rootPart.SalePrice = 10; + + if (m_Scene.Permissions.PropagatePermissions()) + { + if ((item.CurrentPermissions & 8) != 0) + { + foreach (SceneObjectPart part in partList) + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + part.GroupMask = 0; // DO NOT propagate here + } + } + group.ApplyNextOwnerPermissions(); + } + } + + foreach (SceneObjectPart part in partList) + { + if (part.OwnerID != item.Owner) + { + part.LastOwnerID = part.OwnerID; + part.OwnerID = item.Owner; + part.Inventory.ChangeInventoryOwner(item.Owner); + } + else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! + { + part.EveryoneMask = item.EveryOnePermissions; + part.NextOwnerMask = item.NextPermissions; + + part.GroupMask = 0; // DO NOT propagate here + } + } + + rootPart.TrimPermissions(); + + if (!attachment) + { + if (group.RootPart.Shape.PCode == (byte)PCode.Prim) + { + group.ClearPartAttachmentData(); + } + } + + if (!attachment) + { + // Fire on_rez + group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0); + + rootPart.ScheduleFullUpdate(); + } + + if (!m_Scene.Permissions.BypassPermissions()) + { + if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + { + // If this is done on attachments, no + // copy ones will be lost, so avoid it + // + if (!attachment) + { + List uuids = new List(); + uuids.Add(item.ID); + m_Scene.InventoryService.DeleteItems(item.Owner, uuids); + } + } + } + + return rootPart.ParentGroup; + } + } + + return null; + } + + public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) + { + } + + #endregion + + #region Misc + + /// + /// Create a new asset data structure. + /// + /// + /// + /// + /// + /// + /// + private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) + { + AssetBase asset = new AssetBase(UUID.Random(), name, assetType); + asset.Description = description; + asset.Data = (data == null) ? new byte[1] : data; + + return asset; + } + + #endregion + } +} diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index e10fa60..bdacc10 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -10,6 +10,8 @@ + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 24b5d6c..2b1f815 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -39,7 +39,6 @@ using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Services.Interfaces; using OpenSim.Services.Connectors.Simulation; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index 56200ec..56b50dc 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs @@ -32,7 +32,6 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; -- cgit v1.1 From a0d79e621cc8ee4935dfc2816da75db9c23c1b84 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 30 Jan 2010 15:43:10 -0800 Subject: Bug fix: change HGBroker to a INonSharedRegionModule --- .../InventoryAccess/HGInventoryAccessModule.cs | 7 +- .../Inventory/BaseInventoryConnector.cs | 11 +- .../Inventory/HGInventoryBroker.cs | 135 +++++++++++---------- 3 files changed, 82 insertions(+), 71 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index ecd7002..09798aa 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -183,7 +183,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public bool IsForeignUser(UUID userID, out string assetServerURL) { assetServerURL = string.Empty; - UserAccount account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + UserAccount account = null; + if (m_Scene.UserAccountService != null) + account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + if (account == null) // foreign { ScenePresence sp = null; @@ -193,7 +196,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { assetServerURL = aCircuit.ServiceURLs["AssetServerURI"].ToString(); - return true; + assetServerURL = assetServerURL.Trim(new char[] { '/' }); return true; } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs index 811569f..1e51187 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs @@ -40,12 +40,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { public abstract class BaseInventoryConnector : IInventoryService { - protected InventoryCache m_cache; + protected static InventoryCache m_cache; + private static bool m_Initialized; protected virtual void Init(IConfigSource source) { - m_cache = new InventoryCache(); - m_cache.Init(source, this); + if (!m_Initialized) + { + m_cache = new InventoryCache(); + m_cache.Init(source, this); + m_Initialized = true; + } } /// diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index b6718a8..c6312e0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -41,20 +41,21 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { - public class HGInventoryBroker : BaseInventoryConnector, ISharedRegionModule, IInventoryService + public class HGInventoryBroker : BaseInventoryConnector, INonSharedRegionModule, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private bool m_Enabled = false; - private bool m_Initialized = false; + private static bool m_Initialized = false; + private static bool m_Enabled = false; + + private static IInventoryService m_GridService; + private static ISessionAuthInventoryService m_HGService; + private Scene m_Scene; private IUserAccountService m_UserAccountService; - private IInventoryService m_GridService; - private ISessionAuthInventoryService m_HGService; - public Type ReplaceableInterface { get { return null; } @@ -67,63 +68,67 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory public void Initialise(IConfigSource source) { - IConfig moduleConfig = source.Configs["Modules"]; - if (moduleConfig != null) + if (!m_Initialized) { - string name = moduleConfig.GetString("InventoryServices", ""); - if (name == Name) + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) { - IConfig inventoryConfig = source.Configs["InventoryService"]; - if (inventoryConfig == null) - { - m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); - return; - } - - string localDll = inventoryConfig.GetString("LocalGridInventoryService", - String.Empty); - string HGDll = inventoryConfig.GetString("HypergridInventoryService", - String.Empty); - - if (localDll == String.Empty) - { - m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService"); - //return; - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); - } - - if (HGDll == String.Empty) + string name = moduleConfig.GetString("InventoryServices", ""); + if (name == Name) { - m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService"); - //return; - throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + IConfig inventoryConfig = source.Configs["InventoryService"]; + if (inventoryConfig == null) + { + m_log.Error("[HG INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); + return; + } + + string localDll = inventoryConfig.GetString("LocalGridInventoryService", + String.Empty); + string HGDll = inventoryConfig.GetString("HypergridInventoryService", + String.Empty); + + if (localDll == String.Empty) + { + m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + if (HGDll == String.Empty) + { + m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + Object[] args = new Object[] { source }; + m_GridService = + ServerUtils.LoadPlugin(localDll, + args); + + m_HGService = + ServerUtils.LoadPlugin(HGDll, + args); + + if (m_GridService == null) + { + m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service"); + return; + } + if (m_HGService == null) + { + m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service"); + return; + } + + Init(source); + + m_Enabled = true; + m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); } - - Object[] args = new Object[] { source }; - m_GridService = - ServerUtils.LoadPlugin(localDll, - args); - - m_HGService = - ServerUtils.LoadPlugin(HGDll, - args); - - if (m_GridService == null) - { - m_log.Error("[HG INVENTORY CONNECTOR]: Can't load local inventory service"); - return; - } - if (m_HGService == null) - { - m_log.Error("[HG INVENTORY CONNECTOR]: Can't load hypergrid inventory service"); - return; - } - - Init(source); - - m_Enabled = true; - m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); } + m_Initialized = true; } } @@ -140,13 +145,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory if (!m_Enabled) return; - if (!m_Initialized) - { - m_Scene = scene; - m_UserAccountService = m_Scene.UserAccountService; - - m_Initialized = true; - } + m_Scene = scene; + m_UserAccountService = m_Scene.UserAccountService; scene.RegisterModuleInterface(this); m_cache.AddRegion(scene); @@ -514,7 +514,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory private bool IsForeignUser(UUID userID, out string inventoryURL) { inventoryURL = string.Empty; - UserAccount account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + UserAccount account = null; + if (m_Scene.UserAccountService != null) + account = m_Scene.UserAccountService.GetUserAccount(m_Scene.RegionInfo.ScopeID, userID); + if (account == null) // foreign user { ScenePresence sp = null; -- cgit v1.1 From 40d8e91008b7d76ce6b9398484c591eb51c85bdb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 11:10:57 -0800 Subject: * Added a few files that were missing in the repo. * New HGInventoryService which allows restricted access to inventory while outside --- .../Inventory/InventoryServiceInConnectorModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index 54c6d89..1bd00f5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs @@ -98,9 +98,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory m_log.Info("[RegionInventoryService]: Starting..."); - Object[] args = new Object[] { m_Config, MainServer.Instance, String.Empty }; + Object[] args = new Object[] { m_Config, MainServer.Instance, "HGInventoryService" }; - ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:InventoryServiceInConnector", args); + ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HGInventoryServiceInConnector", args); } } -- cgit v1.1 From 041594ed075049f804fc157700a6d78e54194c0b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 13:01:23 -0800 Subject: Cleaned up configuration. 'gridmode' and 'hypergrid' are gone, as well as lots of other obsolete configs. --- .../ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs | 5 ----- .../ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs | 4 ---- .../Hypergrid/HypergridServiceInConnectorModule.cs | 4 ---- .../Inventory/InventoryServiceInConnectorModule.cs | 4 ---- 4 files changed, 17 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index 879cc70..2324380 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs @@ -51,11 +51,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset public void Initialise(IConfigSource config) { - //// This module is only on for standalones in hypergrid mode - //enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && - // config.Configs["Startup"].GetBoolean("hypergrid", true)) || - // ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); - //m_log.DebugFormat("[RegionAssetService]: enabled? {0}", enabled); m_Config = config; IConfig moduleConfig = config.Configs["Modules"]; if (moduleConfig != null) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs index 7c9b752..6d975af 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs @@ -53,10 +53,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid public void Initialise(IConfigSource config) { - //// This module is only on for standalones in hypergrid mode - //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && - // config.Configs["Startup"].GetBoolean("hypergrid", true); - //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); m_Config = config; IConfig moduleConfig = config.Configs["Modules"]; if (moduleConfig != null) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs index c737f8b..c6848bb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs @@ -55,10 +55,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid public void Initialise(IConfigSource config) { - //// This module is only on for standalones in hypergrid mode - //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && - // config.Configs["Startup"].GetBoolean("hypergrid", true); - //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); m_Config = config; IConfig moduleConfig = config.Configs["Modules"]; if (moduleConfig != null) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index 1bd00f5..ae03cdf 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs @@ -51,10 +51,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory public void Initialise(IConfigSource config) { - //// This module is only on for standalones in hypergrid mode - //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && - // config.Configs["Startup"].GetBoolean("hypergrid", true); - //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); m_Config = config; IConfig moduleConfig = config.Configs["Modules"]; if (moduleConfig != null) -- cgit v1.1 From 35a245b67a44eaa62dbf7951646ad9818caa8b02 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 22:35:23 -0800 Subject: Assorted bug fixes related to hyperlinking --- .../ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 391e7c8..61a8fff 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -188,7 +188,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return rinfo; } - // Let's not override GetRegionsByName -- let's get them all from the grid server + public override List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + List rinfo = m_LocalGridService.GetRegionsByName(scopeID, name, maxNumber); + List grinfo = base.GetRegionsByName(scopeID, name, maxNumber); + + if (grinfo != null) + rinfo.AddRange(grinfo); + return rinfo; + } + // Let's not override GetRegionRange -- let's get them all from the grid server #endregion -- cgit v1.1 From 8466f13976bacad89e2babe4b7357e35f49a5739 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Feb 2010 07:53:55 -0800 Subject: Bug fix for getting region flags. --- .../ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 61a8fff..2c234d2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -200,6 +200,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Let's not override GetRegionRange -- let's get them all from the grid server + public override int GetRegionFlags(UUID scopeID, UUID regionID) + { + int flags = m_LocalGridService.GetRegionFlags(scopeID, regionID); + if (flags == -1) + flags = base.GetRegionFlags(scopeID, regionID); + + return flags; + } #endregion } } -- cgit v1.1 From f9a61f282500d2ac04919794c5391b98f24dd203 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Feb 2010 10:51:36 +0000 Subject: Some interface and data structure changes, add the missing method in friends --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index a07b6e2..a9388ef 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -40,7 +40,7 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using FriendInfo = OpenSim.Region.Framework.Interfaces.FriendInfo; namespace OpenSim.Region.CoreModules.Avatar.Friends { @@ -88,5 +88,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { return 1; } + + public FriendInfo[] GetFriends(UUID PrincipalID) + { + return new FriendInfo[0]; + } } } -- cgit v1.1 From 0ab8dd61d787e2ed04cf0fd473be8ea6a97ec8d0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 4 Feb 2010 12:21:14 +0000 Subject: Finally cutting the gordian knot. Friends needs to be both a module and a service, and never the twain shall meet. This finally opens up the path to a working friends implementation --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index a9388ef..f383bad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -40,7 +40,6 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; -using FriendInfo = OpenSim.Region.Framework.Interfaces.FriendInfo; namespace OpenSim.Region.CoreModules.Avatar.Friends { @@ -88,10 +87,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { return 1; } - - public FriendInfo[] GetFriends(UUID PrincipalID) - { - return new FriendInfo[0]; - } } } -- cgit v1.1 From 9821c4f566e11c75c8d87721777480c5b2e2bd4e Mon Sep 17 00:00:00 2001 From: Revolution Date: Sun, 14 Feb 2010 15:41:57 -0600 Subject: Revolution is on the roll again! :) Fixes: Undo, T-pose of others on login, modifiedBulletX works again, feet now stand on the ground instead of in the ground, adds checks to CombatModule. Adds: Redo, Land Undo, checks to agentUpdate (so one can not fall off of a region), more vehicle parts. Finishes almost all of LSL (1 function left, 2 events). Direct flames and kudos to Revolution, please Signed-off-by: Melanie --- .../CoreModules/Avatar/Combat/CombatModule.cs | 14 +++++--- .../Region/CoreModules/World/Sound/SoundModule.cs | 14 +++++--- .../CoreModules/World/Terrain/TerrainModule.cs | 41 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 61b6d65..4069991 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -148,13 +148,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) { ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); - if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) + try { - avatar.Invulnerable = false; + if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0) + { + avatar.Invulnerable = false; + } + else + { + avatar.Invulnerable = true; + } } - else + catch (Exception ex) { - avatar.Invulnerable = true; } } } diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 37f1f2e..1f5a4ff 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Sound } public virtual void PlayAttachedSound( - UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags) + UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) { foreach (ScenePresence p in m_scene.GetAvatars()) { @@ -69,14 +69,17 @@ namespace OpenSim.Region.CoreModules.World.Sound continue; // Scale by distance - gain = (float)((double)gain*((100.0 - dis) / 100.0)); + if (radius == 0) + gain = (float)((double)gain * ((100.0 - dis) / 100.0)); + else + gain = (float)((double)gain * ((radius - dis) / radius)); p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); } } public virtual void TriggerSound( - UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle) + UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) { foreach (ScenePresence p in m_scene.GetAvatars()) { @@ -85,7 +88,10 @@ namespace OpenSim.Region.CoreModules.World.Sound continue; // Scale by distance - gain = (float)((double)gain*((100.0 - dis) / 100.0)); + if (radius == 0) + gain = (float)((double)gain * ((100.0 - dis) / 100.0)); + else + gain = (float)((double)gain * ((radius - dis) / radius)); p.ControllingClient.SendTriggeredSound( soundId, ownerID, objectID, parentID, handle, position, (float)gain); diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index a40828b..1e7ea7b 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs @@ -84,6 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain private ITerrainChannel m_revert; private Scene m_scene; private volatile bool m_tainted; + private readonly UndoStack m_undo = new UndoStack(5); #region ICommandableModule Members @@ -174,6 +175,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain #region ITerrainModule Members + public void UndoTerrain(ITerrainChannel channel) + { + m_channel = channel; + } + /// /// Loads a terrain file from disk and installs it in the scene. /// @@ -574,6 +580,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain { client.OnModifyTerrain += client_OnModifyTerrain; client.OnBakeTerrain += client_OnBakeTerrain; + client.OnLandUndo += client_OnLandUndo; } /// @@ -664,6 +671,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain return changesLimited; } + private void client_OnLandUndo(IClientAPI client) + { + lock (m_undo) + { + if (m_undo.Count > 0) + { + LandUndoState goback = m_undo.Pop(); + if (goback != null) + goback.PlaybackState(); + } + } + } + /// /// Sends a copy of the current terrain to the scenes clients /// @@ -718,6 +738,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain } if (allowed) { + StoreUndoState(); m_painteffects[(StandardTerrainEffects) action].PaintEffect( m_channel, allowMask, west, south, height, size, seconds); @@ -758,6 +779,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain if (allowed) { + StoreUndoState(); m_floodeffects[(StandardTerrainEffects) action].FloodEffect( m_channel, fillArea, size); @@ -782,6 +804,25 @@ namespace OpenSim.Region.CoreModules.World.Terrain } } + private void StoreUndoState() + { + lock (m_undo) + { + if (m_undo.Count > 0) + { + LandUndoState last = m_undo.Peek(); + if (last != null) + { + if (last.Compare(m_channel)) + return; + } + } + + LandUndoState nUndo = new LandUndoState(this, m_channel); + m_undo.Push(nUndo); + } + } + #region Console Commands private void InterfaceLoadFile(Object[] args) -- cgit v1.1 From af265e001d3bf043590e480cd6574a14193f6de0 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 15 Feb 2010 19:15:03 +0900 Subject: Formatting cleanup. --- .../Region/CoreModules/Asset/CenomeAssetCache.cs | 2 +- .../Asset/LocalAssetServiceConnector.cs | 2 +- .../CoreModules/World/Access/AccessModule.cs | 2 +- .../World/Archiver/Tests/ArchiverTests.cs | 24 +++++++++++----------- 4 files changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index 1903eb9..b1b7b27 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs @@ -330,7 +330,7 @@ namespace OpenSim.Region.CoreModules.Asset //m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name); if (name != Name) - return; + return; long maxSize = DefaultMaxSize; int maxCount = DefaultMaxCount; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 2f21e6d..50348da 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs @@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset m_Cache.Cache(a); // if (null == a) -// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id); +// m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not asynchronously find asset with id {0}", id); Util.FireAndForget(delegate { handler(assetID, s, a); }); }); diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index 73f7ae3..e4fe352 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs @@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.World { foreach (Scene s in m_SceneList) { - if(!ProcessCommand(s, cmd)) + if (!ProcessCommand(s, cmd)) break; } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index c3e57f0..e77a23b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); Vector3 offsetPosition = new Vector3(5, 10, 15); - return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; + return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; } protected SceneObjectPart CreateSceneObjectPart2() @@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests Vector3 offsetPosition = new Vector3(20, 25, 30); return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; - } + } /// /// Test saving a V0.2 OpenSim Region Archive. @@ -231,7 +231,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests foreach (string name in names) { if (name.EndsWith(".Resources.test-sound.wav")) - soundDataResourceName = name; + soundDataResourceName = name; } Assert.That(soundDataResourceName, Is.Not.Null); @@ -259,7 +259,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests = new TaskInventoryItem { AssetID = soundUuid, ItemID = soundItemUuid, Name = soundItemName }; part1.Inventory.AddInventoryItem(item1, true); } - } + } m_scene.AddNewSceneObject(object1, false); @@ -306,15 +306,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests /// Test loading the region settings of a V0.2 OpenSim Region Archive. /// [Test] - public void TestLoadOarV0_2RegionSettings() + public void TestLoadOarV0_2RegionSettings() { TestHelper.InMethod(); - //log4net.Config.XmlConfigurator.Configure(); + //log4net.Config.XmlConfigurator.Configure(); MemoryStream archiveWriteStream = new MemoryStream(); TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); - tar.WriteDir(ArchiveConstants.TERRAINS_PATH); + tar.WriteDir(ArchiveConstants.TERRAINS_PATH); tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); RegionSettings rs = new RegionSettings(); @@ -329,11 +329,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests rs.DisablePhysics = true; rs.DisableScripts = true; rs.Elevation1NW = 15.9; - rs.Elevation1NE = 45.3; + rs.Elevation1NE = 45.3; rs.Elevation1SE = 49; rs.Elevation1SW = 1.9; rs.Elevation2NW = 4.5; - rs.Elevation2NE = 19.2; + rs.Elevation2NE = 19.2; rs.Elevation2SE = 9.2; rs.Elevation2SW = 2.1; rs.FixedSun = true; @@ -411,7 +411,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests // Quaternion part2RotationOffset = new Quaternion(60, 70, 80, 90); // Vector3 part2OffsetPosition = new Vector3(20, 25, 30); - SceneObjectPart part2 = CreateSceneObjectPart2(); + SceneObjectPart part2 = CreateSceneObjectPart2(); // Create an oar file that we can use for the merge { @@ -420,9 +420,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests TerrainModule terrainModule = new TerrainModule(); Scene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); + SceneSetupHelpers.SetupSceneModules(scene, archiverModule, serialiserModule, terrainModule); - m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); + m_scene.AddNewSceneObject(new SceneObjectGroup(part2), false); // Write out this scene scene.EventManager.OnOarFileSaved += SaveCompleted; -- cgit v1.1 From 95a31c9b6f0ca4308bc74fb0da5572885823451f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Feb 2010 20:57:29 +0000 Subject: minor: fix error inserting field in log message --- .../ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 3883dc6..191e859 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory item = m_InventoryService.GetItem(item); if (null == item) - m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}"); + m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID); return item; } -- cgit v1.1 From 214b1351fbd7287a70e465a4dd83668b1d2c7044 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Feb 2010 21:18:03 +0000 Subject: minor: Make FlotsamAssetCache default loglevel 0 to match that given in bin/config-include/FlotsamCache.ini.example --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 9216e0b..967c0a1 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -69,7 +69,7 @@ namespace Flotsam.RegionModules.AssetCache private readonly List m_InvalidChars = new List(); - private int m_LogLevel = 1; + private int m_LogLevel = 0; private ulong m_HitRateDisplay = 1; // How often to display hit statistics, given in requests private static ulong m_Requests; @@ -156,7 +156,7 @@ namespace Flotsam.RegionModules.AssetCache m_WaitOnInprogressTimeout = assetConfig.GetInt("WaitOnInprogressTimeout", 3000); #endif - m_LogLevel = assetConfig.GetInt("LogLevel", 1); + m_LogLevel = assetConfig.GetInt("LogLevel", 0); m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); -- cgit v1.1 From c767a7901cbdb1f2fe786f1a1632c09606af9c6c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Feb 2010 22:30:46 +0000 Subject: forestall bug reports about the Command error: System.EntryPointNotFoundException: CreateZStream save/load oar/iar issue by telling the user what the likely problem is --- .../Inventory/Archiver/InventoryArchiverModule.cs | 66 ++++++++++++++++++++-- .../World/Archiver/ArchiveReadRequest.cs | 14 ++++- .../Archiver/ArchiveWriteRequestPreparation.cs | 14 ++++- 3 files changed, 86 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ecd60bd..ac3e199 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -131,7 +131,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (CheckPresence(userInfo.UserProfile.ID)) { - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); + try + { + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); + } + catch (EntryPointNotFoundException e) + { + m_log.ErrorFormat( + "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); + m_log.Error(e); + + return false; + } + return true; } else @@ -156,7 +169,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (CheckPresence(userInfo.UserProfile.ID)) { - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); + try + { + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); + } + catch (EntryPointNotFoundException e) + { + m_log.ErrorFormat( + "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); + m_log.Error(e); + + return false; + } + return true; } else @@ -181,8 +207,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (CheckPresence(userInfo.UserProfile.ID)) { - InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); + InventoryArchiveReadRequest request; + + try + { + request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); + } + catch (EntryPointNotFoundException e) + { + m_log.ErrorFormat( + "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); + m_log.Error(e); + + return false; + } + UpdateClientWithLoadedNodes(userInfo, request.Execute()); return true; @@ -209,8 +249,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { if (CheckPresence(userInfo.UserProfile.ID)) { - InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); + InventoryArchiveReadRequest request; + + try + { + request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); + } + catch (EntryPointNotFoundException e) + { + m_log.ErrorFormat( + "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); + m_log.Error(e); + + return false; + } + UpdateClientWithLoadedNodes(userInfo, request.Execute()); return true; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 8ed1913..ad58f40 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -73,7 +73,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) { m_scene = scene; - m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); + + try + { + m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); + } + catch (EntryPointNotFoundException e) + { + m_log.ErrorFormat( + "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); + m_log.Error(e); + } + m_errorMessage = String.Empty; m_merge = merge; m_requestId = requestId; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 71bfe57..b61b341 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -65,7 +65,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) { m_scene = scene; - m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); + + try + { + m_saveStream = new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress); + } + catch (EntryPointNotFoundException e) + { + m_log.ErrorFormat( + "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." + + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); + m_log.Error(e); + } + m_requestId = requestId; } -- cgit v1.1 From 8294fbd069aaec81121c8563cf29d89030066717 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Feb 2010 22:31:53 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 4069991..1a6cd6c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs @@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule avatar.Invulnerable = true; } } - catch (Exception ex) + catch (Exception) { } } -- cgit v1.1 From 552e9e8c7832f41f5a53666d9c3ece62f57be4ba Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 09:09:35 -0800 Subject: * Added SQlite connector for AvatarData. Tested -- works. * Small bug fix in debug message * Set default standalone configs to use SQLite across the board --- .../ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 54e62e2..e97d21f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory item = m_InventoryService.GetItem(item); if (null == item) - m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}"); + m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID); return item; } -- cgit v1.1 From 70de6956ff6a3d833149156b6293122ef734b73d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 18:56:44 -0800 Subject: Small bug fixes for making tests work. --- .../ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 6 +++--- .../ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 2ca90f8..95d8737 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests config.AddConfig("GridService"); config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); - config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); + config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); m_LocalConnector = new LocalGridServicesConnector(config); } @@ -92,7 +92,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests r2.HttpPort = 9002; r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); s = new Scene(new RegionInfo()); - s.RegionInfo.RegionID = r1.RegionID; + s.RegionInfo.RegionID = r2.RegionID; m_LocalConnector.AddRegion(s); GridRegion r3 = new GridRegion(); @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests r3.HttpPort = 9003; r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); s = new Scene(new RegionInfo()); - s.RegionInfo.RegionID = r1.RegionID; + s.RegionInfo.RegionID = r3.RegionID; m_LocalConnector.AddRegion(s); m_LocalConnector.RegisterRegion(UUID.Zero, r1); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index 9ba1bdc..ca42461 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs @@ -56,7 +56,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests config.AddConfig("PresenceService"); config.Configs["Modules"].Set("PresenceServices", "LocalPresenceServicesConnector"); config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); - config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullPresenceData"); + config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); m_LocalConnector = new LocalPresenceServicesConnector(config); } -- cgit v1.1 From 2e7aa387f7a705079df4b534978c0f134591eea9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 19:11:48 -0800 Subject: One more test running. --- OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index d986274..18f77fd 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests SerialiserModule serialiserModule = new SerialiserModule(); TerrainModule terrainModule = new TerrainModule(); - m_scene = SceneSetupHelpers.SetupScene("scene1"); + m_scene = SceneSetupHelpers.SetupScene("useraccounts"); SceneSetupHelpers.SetupSceneModules(m_scene, m_archiverModule, serialiserModule, terrainModule); } -- cgit v1.1 From 2dea162073dbc8622d47d95f5f0b1ca2c619a22a Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Mon, 22 Feb 2010 12:25:59 +0900 Subject: Formatting cleanup. --- .../Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ac3e199..a898992 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -134,7 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); - } + } catch (EntryPointNotFoundException e) { m_log.ErrorFormat( @@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); - } + } catch (EntryPointNotFoundException e) { m_log.ErrorFormat( @@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); - } + } catch (EntryPointNotFoundException e) { m_log.ErrorFormat( @@ -254,7 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); - } + } catch (EntryPointNotFoundException e) { m_log.ErrorFormat( -- cgit v1.1 From 7665aad002ef066fc31fa9497225d2668641c769 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 22 Feb 2010 13:27:17 -0800 Subject: * Adds CreatorID to asset metadata. This is just the plumbing to support CreatorID, it doesn't modify database backends or OAR files to support storing/loading it --- .../CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | 2 +- .../Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 2 +- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 2 +- .../CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | 2 +- .../Framework/InventoryAccess/InventoryAccessModule.cs | 9 +++++---- .../CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 3 ++- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 +- OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs | 2 +- .../Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs | 2 +- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 3 ++- 10 files changed, 16 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index ebe93d5..1320b33 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction bool storeLocal, bool tempFile) { ourClient = remoteClient; - m_asset = new AssetBase(assetID, "blank", type); + m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId); m_asset.Data = data; m_asset.Description = "empty"; m_asset.Local = storeLocal; diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index 7ac8bed..a23e8ce 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -240,7 +240,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { string assetID = "j2kCache_" + AssetId.ToString(); - AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard); + AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID); layerDecodeAsset.Local = true; layerDecodeAsset.Temporary = true; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 65ad703..5756d35 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -416,7 +416,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType); + AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero); asset.Data = data; m_scene.AssetService.Store(asset); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index e303a1f..664f38d 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -90,7 +90,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess // HGAssetService dispatches it to the remote grid. // It's not pretty, but the best that can be done while // not having a global naming infrastructure - AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); + AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID); Copy(asset, asset1); try { diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index d242a34..eec852e 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -161,7 +161,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } AssetBase asset = - CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); + CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId); item.AssetID = asset.FullID; m_Scene.AssetService.Store(asset); @@ -339,7 +339,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess objectGroup.GetPartName(objectGroup.RootPart.LocalId), objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), (sbyte)AssetType.Object, - Utils.StringToBytes(sceneObjectXml)); + Utils.StringToBytes(sceneObjectXml), + objectGroup.OwnerID); m_Scene.AssetService.Store(asset); assetID = asset.FullID; @@ -640,9 +641,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess /// /// /// - private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) + private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID) { - AssetBase asset = new AssetBase(UUID.Random(), name, assetType); + AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID); asset.Description = description; asset.Data = (data == null) ? new byte[1] : data; diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index e3c7bbf..367068e 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -309,7 +309,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture } // Create a new asset for user - AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture); + AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture, + scene.RegionInfo.RegionID); asset.Data = assetData; asset.Description = String.Format("URL image : {0}", Url); asset.Local = false; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 59a1b8f..c4b1817 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType); + AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType, UUID.Zero); asset.Data = data; // We're relying on the asset service to do the sensible thing and not store the asset if it already diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index 2d2c570..8601cae 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs @@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); - AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType); + AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType, UUID.Zero); asset.Description = metadata.Description; asset.Data = data; diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index 2ff635b..d10d4d6 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.World.Estate public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) { - m_asset = new AssetBase(UUID.Zero, pClientFilename, type); + m_asset = new AssetBase(UUID.Zero, pClientFilename, type, pRemoteClient.AgentId); m_asset.Data = new byte[0]; m_asset.Description = "empty"; m_asset.Local = true; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 44a651f..6ae75a8 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1080,7 +1080,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap AssetBase asset = new AssetBase( m_scene.RegionInfo.RegionSettings.TerrainImageID, "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), - (sbyte)AssetType.Texture); + (sbyte)AssetType.Texture, + m_scene.RegionInfo.RegionID); asset.Data = data; asset.Description = m_scene.RegionInfo.RegionName; asset.Temporary = temporary; -- cgit v1.1 From df76e95aa2dc9f3f3a0c546761b7624adc183ed0 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 22 Feb 2010 14:18:59 -0800 Subject: Changed asset CreatorID to a string --- .../Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs | 2 +- OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | 2 +- .../Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 2 +- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 6 +++--- .../CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | 2 +- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 +- OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs | 2 +- OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs | 2 +- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index 1320b33..c791cb4 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction bool storeLocal, bool tempFile) { ourClient = remoteClient; - m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId); + m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString()); m_asset.Data = data; m_asset.Description = "empty"; m_asset.Local = storeLocal; diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index a23e8ce..50c83b5 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs @@ -240,7 +240,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender { string assetID = "j2kCache_" + AssetId.ToString(); - AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID); + AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID.ToString()); layerDecodeAsset.Local = true; layerDecodeAsset.Temporary = true; diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 5756d35..dc7439c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -416,7 +416,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero); + AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); asset.Data = data; m_scene.AssetService.Store(asset); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index eec852e..37f1da9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -161,7 +161,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } AssetBase asset = - CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId); + CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data, remoteClient.AgentId.ToString()); item.AssetID = asset.FullID; m_Scene.AssetService.Store(asset); @@ -340,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), - objectGroup.OwnerID); + objectGroup.OwnerID.ToString()); m_Scene.AssetService.Store(asset); assetID = asset.FullID; @@ -641,7 +641,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess /// /// /// - private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID) + private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, string creatorID) { AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID); asset.Description = description; diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 367068e..643764f 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -310,7 +310,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture // Create a new asset for user AssetBase asset = new AssetBase(UUID.Random(), "DynamicImage" + Util.RandomClass.Next(1, 10000), (sbyte)AssetType.Texture, - scene.RegionInfo.RegionID); + scene.RegionInfo.RegionID.ToString()); asset.Data = assetData; asset.Description = String.Format("URL image : {0}", Url); asset.Local = false; diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index f5eda3a..40d6b23 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -347,7 +347,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType, UUID.Zero); + AssetBase asset = new AssetBase(new UUID(uuid), String.Empty, assetType, UUID.Zero.ToString()); asset.Data = data; // We're relying on the asset service to do the sensible thing and not store the asset if it already diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index 8601cae..2c04008 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs @@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); - AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType, UUID.Zero); + AssetBase asset = new AssetBase(new UUID(filename), metadata.Name, metadata.AssetType, UUID.Zero.ToString()); asset.Description = metadata.Description; asset.Data = data; diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs index d10d4d6..b8d8b10 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateTerrainXferHandler.cs @@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.World.Estate public EstateTerrainXferHandler(IClientAPI pRemoteClient, string pClientFilename) { - m_asset = new AssetBase(UUID.Zero, pClientFilename, type, pRemoteClient.AgentId); + m_asset = new AssetBase(UUID.Zero, pClientFilename, type, pRemoteClient.AgentId.ToString()); m_asset.Data = new byte[0]; m_asset.Description = "empty"; m_asset.Local = true; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 6ae75a8..b63d014 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1081,7 +1081,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scene.RegionInfo.RegionSettings.TerrainImageID, "terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(), (sbyte)AssetType.Texture, - m_scene.RegionInfo.RegionID); + m_scene.RegionInfo.RegionID.ToString()); asset.Data = data; asset.Description = m_scene.RegionInfo.RegionName; asset.Temporary = temporary; -- cgit v1.1 From d506449f6765ec7372615ffd4afefb0075d94af4 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 23 Feb 2010 00:59:24 -0800 Subject: * Removed the unused GridRegion.getInternalEndPointPort() (just use InternalEndPoint.Port). This class is complex enough as it is * Changed the failed to inform neighbor message from a warning to info, since this will fire for every empty neighbor space * Made the EnableSimulator/EstablishAgentCommunication log message more verbose and more clear about what is happening --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 53de269..80c0af8 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1120,10 +1120,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer } #endregion + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: {0} is sending {1} EnableSimulator for neighbor region {2} @ {3} " + + "and EstablishAgentCommunication with seed cap {4}", + m_scene.RegionInfo.RegionName, sp.Name, reg.RegionName, reg.RegionHandle, capsPath); + eq.EnableSimulator(reg.RegionHandle, endPoint, sp.UUID); eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath); - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1} in region {2}", - capsPath, sp.UUID, sp.Scene.RegionInfo.RegionName); } else { -- cgit v1.1 From 4aa37e995d1868e864677f9bd7896433df06b6ce Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 24 Feb 2010 06:28:16 +0000 Subject: Remove the overlooked remnants of core profile support --- .../Avatar/Profiles/AvatarProfilesModule.cs | 169 --------------------- 1 file changed, 169 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs deleted file mode 100644 index 718ee2f..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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; -using System.Globalization; -using System.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.CoreModules.Avatar.Profiles -{ - public class AvatarProfilesModule : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Scene m_scene; - private IProfileModule m_profileModule = null; - private bool m_enabled = true; - - public AvatarProfilesModule() - { - } - - #region IRegionModule Members - - public void Initialise(Scene scene, IConfigSource config) - { - IConfig profileConfig = config.Configs["Profile"]; - if (profileConfig != null) - { - if (profileConfig.GetString("Module", Name) != Name) - { - m_enabled = false; - return; - } - } - - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - } - - public void PostInitialise() - { - if (!m_enabled) - return; - m_profileModule = m_scene.RequestModuleInterface(); - } - - public void Close() - { - } - - public string Name - { - get { return "AvatarProfilesModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - #endregion - - public void NewClient(IClientAPI client) - { - client.OnRequestAvatarProperties += RequestAvatarProperty; - client.OnUpdateAvatarProperties += UpdateAvatarProperties; - } - - public void RemoveClient(IClientAPI client) - { - client.OnRequestAvatarProperties -= RequestAvatarProperty; - client.OnUpdateAvatarProperties -= UpdateAvatarProperties; - } - - /// - /// - /// - /// - /// - public void RequestAvatarProperty(IClientAPI remoteClient, UUID avatarID) - { - // FIXME: finish adding fields such as url, masking, etc. - UserProfileData profile = null; // m_scene.CommsManager.UserService.GetUserProfile(avatarID); - if (null != profile) - { - Byte[] charterMember; - if (profile.CustomType == "") - { - charterMember = new Byte[1]; - charterMember[0] = (Byte)((profile.UserFlags & 0xf00) >> 8); - } - else - { - charterMember = Utils.StringToBytes(profile.CustomType); - } - - if (m_profileModule != null) - { - Hashtable profileData = m_profileModule.GetProfileData(remoteClient.AgentId); - if (profileData["ProfileUrl"] != null) - profile.ProfileUrl = profileData["ProfileUrl"].ToString(); - } - remoteClient.SendAvatarProperties(profile.ID, profile.AboutText, - Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), - charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff), - profile.FirstLifeImage, profile.Image, profile.ProfileUrl, profile.Partner); - } - else - { - m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString()); - } - } - - public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile) - { - return; - //UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); - - //// if it's the profile of the user requesting the update, then we change only a few things. - //if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) - //{ - // Profile.Image = newProfile.Image; - // Profile.FirstLifeImage = newProfile.FirstLifeImage; - // Profile.AboutText = newProfile.AboutText; - // Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; - // Profile.ProfileUrl = newProfile.ProfileUrl; - //} - //else - //{ - // return; - //} - - //if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) - //{ - // RequestAvatarProperty(remoteClient, newProfile.ID); - //} - } - } -} -- cgit v1.1 From 267f3b81471bd36fab5c8da538a17bf59e98d9c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 24 Feb 2010 08:03:30 -0800 Subject: Fixed typo that was affecting the BasicInventoryAccessModule --- .../CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 2 +- .../CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 4 ++-- OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 09798aa..25f5154 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -44,7 +44,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { - public class HGInventoryAccessModule : InventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule + public class HGInventoryAccessModule : BasicInventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 37f1da9..e0df288 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -47,7 +47,7 @@ using Nini.Config; namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { - public class InventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule + public class BasicInventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess public virtual string Name { - get { return "BasicInventoryAcessModule"; } + get { return "BasicInventoryAccessModule"; } } public virtual void Initialise(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index bdacc10..0195c03 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -10,7 +10,7 @@ - + -- cgit v1.1 From c7b1e76eb5fbc73ccbde6f91718e5454a1e3a228 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 01:46:34 +0000 Subject: Add the stream handler/listener and requisite methods to the friends module for the friends interregion comms. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 106 ++++++++++++++++++++- 1 file changed, 103 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f383bad..fe027c6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -26,9 +26,10 @@ */ using System; +using System.IO; using System.Collections; using System.Collections.Generic; -using System.Net; +using System.Xml; using System.Reflection; using log4net; using Nini.Config; @@ -36,17 +37,38 @@ using Nwc.XmlRpc; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; - using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Framework.Servers.HttpServer; +using log4net; namespace OpenSim.Region.CoreModules.Avatar.Friends { - public class FriendsModule : ISharedRegionModule, IFriendsModule + public class FriendsModule : BaseStreamHandler, ISharedRegionModule, IFriendsModule { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected int m_Port = 0; + + public FriendsModule() + : base("POST", "/friends") + { + } + public void Initialise(IConfigSource config) { + IConfig friendsConfig = config.Configs["Friends"]; + if (friendsConfig != null) + { + m_Port = friendsConfig.GetInt("Port", m_Port); + } + + IHttpServer server = MainServer.GetHttpServer((uint)m_Port); + + server.AddStreamHandler(this); + } public void PostInitialise() @@ -69,6 +91,41 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { } + 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); + + try + { + Dictionary request = + ServerUtils.ParseQueryString(body); + + if (!request.ContainsKey("METHOD")) + return FailureResult(); + + string method = request["METHOD"].ToString(); + request.Remove("METHOD"); + + switch (method) + { + case "TEST": + break; + } + } + catch (Exception e) + { + m_log.Debug("[FRIENDS]: Exception {0}" + e.ToString()); + } + + return FailureResult(); + } + public string Name { get { return "FriendsModule"; } @@ -87,5 +144,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { return 1; } + + private byte[] FailureResult() + { + return BoolResult(false); + } + + private byte[] SuccessResult() + { + return BoolResult(true); + } + + private byte[] BoolResult(bool value) + { + 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(value.ToString())); + + 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(); + } } } -- cgit v1.1 From e776bf93169c0231dcdaf4e197ae61ec656e00e1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 03:07:46 +0000 Subject: Grab the presence module and load the friends connector into the friends module --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index fe027c6..6134416 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -52,6 +52,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected int m_Port = 0; + protected List m_Scenes = new List(); + + protected IPresenceService m_PresenceService = null; + protected IFriendsService m_FriendsService = null; + + protected IPresenceService PresenceService + { + get + { + if (m_PresenceService == null) + { + if (m_Scenes.Count > 0) + m_PresenceService = m_Scenes[0].RequestModuleInterface(); + } + + return m_PresenceService; + } + } + public FriendsModule() : base("POST", "/friends") { @@ -63,6 +82,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (friendsConfig != null) { m_Port = friendsConfig.GetInt("Port", m_Port); + + string connector = friendsConfig.GetString("Connector", String.Empty); + Object[] args = new Object[] { config }; + + m_FriendsService = ServerUtils.LoadPlugin(connector, args); + } + + if (m_FriendsService == null) + { + m_log.Error("[FRIENDS]: No Connector defined in section Friends, or filed to load, cannot continue"); + throw new Exception("Connector load error"); } IHttpServer server = MainServer.GetHttpServer((uint)m_Port); @@ -81,6 +111,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public void AddRegion(Scene scene) { + m_Scenes.Add(scene); + scene.RegisterModuleInterface(this); } public void RegionLoaded(Scene scene) @@ -89,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public void RemoveRegion(Scene scene) { + m_Scenes.Remove(scene); } public override byte[] Handle(string path, Stream requestData, -- cgit v1.1 From b97f3860cbda43b28b1ac76d9472823924cc5a16 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 03:55:21 +0000 Subject: Begin tracking users and friends --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 6134416..df0be97 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -43,11 +43,20 @@ using OpenSim.Services.Interfaces; using OpenSim.Server.Base; using OpenSim.Framework.Servers.HttpServer; using log4net; +using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; namespace OpenSim.Region.CoreModules.Avatar.Friends { public class FriendsModule : BaseStreamHandler, ISharedRegionModule, IFriendsModule { + protected class UserFriendData + { + public UUID PrincipalID; + public FriendInfo[] Friends; + public int Refcount; + public UUID RegionID; + } + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected int m_Port = 0; @@ -56,6 +65,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected IPresenceService m_PresenceService = null; protected IFriendsService m_FriendsService = null; + protected Dictionary m_Friends = + new Dictionary(); protected IPresenceService PresenceService { @@ -113,6 +124,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { m_Scenes.Add(scene); scene.RegisterModuleInterface(this); + + scene.EventManager.OnNewClient += OnNewClient; + scene.EventManager.OnClientClosed += OnClientClosed; + scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; + scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; } public void RegionLoaded(Scene scene) @@ -220,5 +236,70 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return ms.ToArray(); } + + private void OnNewClient(IClientAPI client) + { + client.OnLogout += OnLogout; + + if (m_Friends.ContainsKey(client.AgentId)) + { + m_Friends[client.AgentId].Refcount++; + return; + } + + UserFriendData newFriends = new UserFriendData(); + + newFriends.PrincipalID = client.AgentId; + newFriends.Friends = m_FriendsService.GetFriends(client.AgentId); + newFriends.Refcount = 1; + newFriends.RegionID = UUID.Zero; + + m_Friends.Add(client.AgentId, newFriends); + } + + private void OnClientClosed(UUID agentID, Scene scene) + { + if (m_Friends.ContainsKey(agentID)) + { + if (m_Friends[agentID].Refcount == 1) + m_Friends.Remove(agentID); + else + m_Friends[agentID].Refcount--; + } + } + + private void OnLogout(IClientAPI client) + { + m_Friends.Remove(client.AgentId); + } + + private void OnMakeRootAgent(ScenePresence sp) + { + UUID agentID = sp.ControllingClient.AgentId; + + if (m_Friends.ContainsKey(agentID)) + { + if (m_Friends[agentID].RegionID == UUID.Zero) + { + m_Friends[agentID].Friends = + m_FriendsService.GetFriends(agentID); + } + m_Friends[agentID].RegionID = + sp.ControllingClient.Scene.RegionInfo.RegionID; + } + } + + + private void OnMakeChildAgent(ScenePresence sp) + { + UUID agentID = sp.ControllingClient.AgentId; + + if (m_Friends.ContainsKey(agentID)) + { + if (m_Friends[agentID].RegionID == sp.ControllingClient.Scene.RegionInfo.RegionID) + m_Friends[agentID].RegionID = UUID.Zero; + } + } + } } -- cgit v1.1 From f2b36f8e7604465ef8357c9b42f359f1877ddd7c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 04:02:03 +0000 Subject: Implement friend perms --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index df0be97..0d9fd94 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -191,7 +191,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public uint GetFriendPerms(UUID principalID, UUID friendID) { - return 1; + if (!m_Friends.ContainsKey(principalID)) + return 0; + + UserFriendData data = m_Friends[principalID]; + + foreach (FriendInfo fi in data.Friends) + { + if (fi.Friend == friendID.ToString()) + return (uint)fi.TheirFlags; + } + return 0; } private byte[] FailureResult() -- cgit v1.1 From 44d5b2910ff7f794c960d90006149522c0844c5f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 04:22:51 +0000 Subject: Implement initial online notifications --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 0d9fd94..7c81d6a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -44,6 +44,7 @@ using OpenSim.Server.Base; using OpenSim.Framework.Servers.HttpServer; using log4net; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; namespace OpenSim.Region.CoreModules.Avatar.Friends { @@ -250,6 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnNewClient(IClientAPI client) { client.OnLogout += OnLogout; + client.OnEconomyDataRequest += SendPresence; if (m_Friends.ContainsKey(client.AgentId)) { @@ -311,5 +313,67 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } + private void SendPresence(UUID agentID) + { + if (!m_Friends.ContainsKey(agentID)) + return; + + IClientAPI client = LocateClientObject(agentID); + if (client == null) + return; + + List friendList = new List(); + + foreach (FriendInfo fi in m_Friends[agentID].Friends) + friendList.Add(fi.Friend); + + PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); + + List online = new List(); + + foreach (PresenceInfo pi in presence) + { + if (pi.Online) + online.Add(new UUID(pi.UserID)); + } + + client.SendAgentOnline(online.ToArray()); + } + + // + // Find the client for a ID + // + private IClientAPI LocateClientObject(UUID agentID) + { + Scene scene=GetClientScene(agentID); + if(scene == null) + return null; + + ScenePresence presence=scene.GetScenePresence(agentID); + if(presence == null) + return null; + + return presence.ControllingClient; + } + + // + // Find the scene for an agent + // + private Scene GetClientScene(UUID agentId) + { + lock (m_Scenes) + { + foreach (Scene scene in m_Scenes) + { + ScenePresence presence = scene.GetScenePresence(agentId); + if (presence != null) + { + if (!presence.IsChildAgent) + return scene; + } + } + } + return null; + } } } -- cgit v1.1 From 161d16405de3c8a3e0216df36de32a2ddcf6db51 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 23:04:05 +0000 Subject: Check flags on initial login --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7c81d6a..e654b1f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -325,7 +325,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends List friendList = new List(); foreach (FriendInfo fi in m_Friends[agentID].Friends) - friendList.Add(fi.Friend); + { + if ((fi.TheirFlags & 1) != 0) + friendList.Add(fi.Friend); + } PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); -- cgit v1.1 From 1a3ad3ae80a3b01c08008e2aca0bfaccb497ac5c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 25 Feb 2010 23:32:38 +0000 Subject: Implement local online/offline notifications --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index e654b1f..8b15abb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -56,6 +56,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public FriendInfo[] Friends; public int Refcount; public UUID RegionID; + + public bool IsFriend(string friend) + { + foreach (FriendInfo fi in Friends) + { + if (fi.Friend == friend) + return true; + } + + return false; + } } private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -267,6 +278,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends newFriends.RegionID = UUID.Zero; m_Friends.Add(client.AgentId, newFriends); + + StatusChange(client.AgentId, true); } private void OnClientClosed(UUID agentID, Scene scene) @@ -283,6 +296,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnLogout(IClientAPI client) { m_Friends.Remove(client.AgentId); + + StatusChange(client.AgentId, false); } private void OnMakeRootAgent(ScenePresence sp) @@ -378,5 +393,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } return null; } + + private void StatusChange(UUID agentID, bool online) + { + foreach (UserFriendData fd in m_Friends.Values) + { + // Is this a root agent? If not, they will get updates + // through the root and this next check is redundant + // + if (fd.RegionID == UUID.Zero) + continue; + + if (fd.IsFriend(agentID.ToString())) + { + UUID[] changed = new UUID[] { agentID }; + IClientAPI client = LocateClientObject(fd.PrincipalID); + if (online) + client.SendAgentOnline(changed); + else + client.SendAgentOffline(changed); + } + } + } } } -- cgit v1.1 From 93967d4a1c500ede1431e2aa56d5d3a6b0da0130 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Feb 2010 18:30:05 +0000 Subject: fix bug where region settings loaded via an oar (water height, terrain textures, etc.) were not being persisted to the database this meant that the loaded settings would disappear after a restart --- OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index ad58f40..381c8f7 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -435,6 +435,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver currentRegionSettings.TerrainTexture4 = loadedRegionSettings.TerrainTexture4; currentRegionSettings.UseEstateSun = loadedRegionSettings.UseEstateSun; currentRegionSettings.WaterHeight = loadedRegionSettings.WaterHeight; + + currentRegionSettings.Save(); IEstateModule estateModule = m_scene.RequestModuleInterface(); -- cgit v1.1 From bbb43f9bdeda4994653c72fac62f9023d6dbdcdc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Feb 2010 10:35:23 -0800 Subject: Now showing friends online upon grid login. --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 8b15abb..d38ce68 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -331,11 +331,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void SendPresence(UUID agentID) { if (!m_Friends.ContainsKey(agentID)) + { + m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID); return; + } IClientAPI client = LocateClientObject(agentID); if (client == null) + { + m_log.DebugFormat("[FRIENDS MODULE]: agent's client {0} not found in local scene", agentID); return; + } List friendList = new List(); -- cgit v1.1 From dfc17a531fe69dd1152127271d721ae8d4fccd8d Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 26 Feb 2010 21:37:07 +0000 Subject: Add the client message handlers. The calling card handlers that are part of the old friends module are omitted intentionally, as I believe those should be in a calling card module, not bundled with friends. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index d38ce68..f2ab174 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -261,6 +261,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnNewClient(IClientAPI client) { + client.OnInstantMessage += OnInstantMessage; + client.OnApproveFriendRequest += OnApproveFriendRequest; + client.OnDenyFriendRequest += OnDenyFriendRequest; + client.OnTerminateFriendship += OnTerminateFriendship; + + client.OnGrantUserRights += OnGrantUserRights; + client.OnLogout += OnLogout; client.OnEconomyDataRequest += SendPresence; @@ -421,5 +428,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } } + + private void OnInstantMessage(IClientAPI client, GridInstantMessage im) + { + } + + private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) + { + } + + private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) + { + } + + private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) + { + } + + private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) + { + } } } -- cgit v1.1 From dc88dc2c3dde7c90e2e2fc094d91bb0915ff1c2f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Feb 2010 17:33:08 -0800 Subject: More flesh to FriendsModule. Still incomplete. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f2ab174..7094213 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -45,6 +45,7 @@ using OpenSim.Framework.Servers.HttpServer; using log4net; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.Friends { @@ -94,6 +95,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } + protected IFriendsService FriendsService + { + get + { + if (m_FriendsService == null) + { + if (m_Scenes.Count > 0) + m_FriendsService = m_Scenes[0].RequestModuleInterface(); + } + + return m_FriendsService; + } + } + + protected IGridService GridService + { + get + { + return m_Scenes[0].GridService; + } + } + public FriendsModule() : base("POST", "/friends") { @@ -431,22 +454,66 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnInstantMessage(IClientAPI client, GridInstantMessage im) { + if (im.dialog == (byte)OpenMetaverse.InstantMessageDialog.FriendshipOffered) + { + // we got a friendship offer + UUID principalID = new UUID(im.fromAgentID); + UUID friendID = new UUID(im.toAgentID); + + // this user wants to be friends with the other user + FriendsService.StoreFriend(principalID, friendID.ToString(), 1); + + // Now let's ask the other user to be friends with this user + ForwardFriendshipOffer(principalID, friendID, im); + } + } + + private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) + { + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + friendClient.SendInstantMessage(im); + // we're done + return; + } + + // The prospective friend is not here [as root]. Let's forward. + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + // ... + // m_FriendsSimConnector.FriendshipOffered(region, agentID, friemdID, im.message); + } } private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { + FriendsService.StoreFriend(agentID, friendID.ToString(), 1); + + // TODO: Notify the new friend } private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { + // TODO: Notify the friend-wanna-be } private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) { + FriendsService.Delete(agentID, exfriendID.ToString()); + + // TODO: Notify the exfriend } private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) { + FriendsService.StoreFriend(requester, target.ToString(), rights); + + // TODO: Notify the friend } } } -- cgit v1.1 From 25870e80497bdd5823354a7472f0364cfa446888 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Feb 2010 20:35:45 -0800 Subject: * Friendship offers starting to work in the same sim. Not quite right yet. * Added skeleton for out Connectors/Friends/FriendsSimConnector.cs * Moved request handler to its own file --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 211 +++++++++++---------- .../Avatar/Friends/FriendsRequestHandler.cs | 134 +++++++++++++ 2 files changed, 243 insertions(+), 102 deletions(-) create mode 100644 OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7094213..1d7889d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -26,10 +26,8 @@ */ using System; -using System.IO; using System.Collections; using System.Collections.Generic; -using System.Xml; using System.Reflection; using log4net; using Nini.Config; @@ -40,16 +38,16 @@ using OpenSim.Framework.Communications; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using OpenSim.Services.Connectors.Friends; using OpenSim.Server.Base; using OpenSim.Framework.Servers.HttpServer; -using log4net; using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.Friends { - public class FriendsModule : BaseStreamHandler, ISharedRegionModule, IFriendsModule + public class FriendsModule : ISharedRegionModule, IFriendsModule { protected class UserFriendData { @@ -72,12 +70,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected int m_Port = 0; - protected List m_Scenes = new List(); protected IPresenceService m_PresenceService = null; protected IFriendsService m_FriendsService = null; + protected FriendsSimConnector m_FriendsSimConnector; + protected Dictionary m_Friends = new Dictionary(); @@ -117,22 +115,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - public FriendsModule() - : base("POST", "/friends") - { - } - public void Initialise(IConfigSource config) { IConfig friendsConfig = config.Configs["Friends"]; if (friendsConfig != null) { - m_Port = friendsConfig.GetInt("Port", m_Port); + int mPort = friendsConfig.GetInt("Port", 0); string connector = friendsConfig.GetString("Connector", String.Empty); Object[] args = new Object[] { config }; m_FriendsService = ServerUtils.LoadPlugin(connector, args); + m_FriendsSimConnector = new FriendsSimConnector(); + + // Instantiate the request handler + IHttpServer server = MainServer.GetHttpServer((uint)mPort); + server.AddStreamHandler(new FriendsRequestHandler(this)); + } if (m_FriendsService == null) @@ -141,10 +140,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends throw new Exception("Connector load error"); } - IHttpServer server = MainServer.GetHttpServer((uint)m_Port); - - server.AddStreamHandler(this); - } public void PostInitialise() @@ -175,41 +170,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_Scenes.Remove(scene); } - 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); - - try - { - Dictionary request = - ServerUtils.ParseQueryString(body); - - if (!request.ContainsKey("METHOD")) - return FailureResult(); - - string method = request["METHOD"].ToString(); - request.Remove("METHOD"); - - switch (method) - { - case "TEST": - break; - } - } - catch (Exception e) - { - m_log.Debug("[FRIENDS]: Exception {0}" + e.ToString()); - } - - return FailureResult(); - } - public string Name { get { return "FriendsModule"; } @@ -239,49 +199,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return 0; } - private byte[] FailureResult() - { - return BoolResult(false); - } - - private byte[] SuccessResult() - { - return BoolResult(true); - } - - private byte[] BoolResult(bool value) - { - 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(value.ToString())); - - 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(); - } - private void OnNewClient(IClientAPI client) { client.OnInstantMessage += OnInstantMessage; @@ -460,8 +377,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); - // this user wants to be friends with the other user + // This user wants to be friends with the other user. + // Let's add both relations to the DB, but one of them is inactive (-1) FriendsService.StoreFriend(principalID, friendID.ToString(), 1); + FriendsService.StoreFriend(friendID, principalID.ToString(), -1); // Now let's ask the other user to be friends with this user ForwardFriendshipOffer(principalID, friendID, im); @@ -476,7 +395,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // the prospective friend in this sim as root agent friendClient.SendInstantMessage(im); // we're done - return; + return ; } // The prospective friend is not here [as root]. Let's forward. @@ -485,35 +404,123 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - // ... - // m_FriendsSimConnector.FriendshipOffered(region, agentID, friemdID, im.message); + m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); } + + // If the prospective friend is not online, he'll get the message upon login. } private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { FriendsService.StoreFriend(agentID, friendID.ToString(), 1); - // TODO: Notify the new friend + // + // Notify the friend + // + + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + GridInstantMessage im = new GridInstantMessage(client.Scene, client.AgentId, client.Name, friendID, + (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, client.AgentId.ToString(), false, Vector3.Zero); + friendClient.SendInstantMessage(im); + // we're done + return; + } + + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipApproved(region, agentID, friendID); + } } private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { - // TODO: Notify the friend-wanna-be + FriendsService.Delete(agentID, friendID.ToString()); + FriendsService.Delete(friendID, agentID.ToString()); + + // + // Notify the friend + // + + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + + GridInstantMessage im = new GridInstantMessage(client.Scene, client.AgentId, client.Name, friendID, + (byte)OpenMetaverse.InstantMessageDialog.FriendshipDeclined, client.AgentId.ToString(), false, Vector3.Zero); + friendClient.SendInstantMessage(im); + // we're done + return; + } + + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipDenied(region, agentID, friendID); + } } private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) { FriendsService.Delete(agentID, exfriendID.ToString()); + FriendsService.Delete(exfriendID, agentID.ToString()); + + client.SendTerminateFriend(exfriendID); - // TODO: Notify the exfriend + // + // Notify the friend + // + + IClientAPI friendClient = LocateClientObject(exfriendID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + friendClient.SendTerminateFriend(exfriendID); + // we're done + return; + } + + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); + } } private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) { FriendsService.StoreFriend(requester, target.ToString(), rights); - // TODO: Notify the friend + // + // Notify the friend + // + + IClientAPI friendClient = LocateClientObject(target); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + //friendClient.???; + // we're done + return; + } + + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.GrantRights(region, requester, target); + } } } } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs new file mode 100644 index 0000000..cde54ed --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs @@ -0,0 +1,134 @@ +/* + * 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.IO; +using System.Reflection; +using System.Xml; + +using OpenSim.Framework; +using OpenSim.Server.Base; +using OpenSim.Framework.Servers.HttpServer; + +using OpenMetaverse; +using log4net; + +namespace OpenSim.Region.CoreModules.Avatar.Friends +{ + public class FriendsRequestHandler : BaseStreamHandler + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private FriendsModule m_FriendsModule; + + public FriendsRequestHandler(FriendsModule fmodule) + : base("POST", "/friends") + { + m_FriendsModule = fmodule; + } + + 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); + + try + { + Dictionary request = + ServerUtils.ParseQueryString(body); + + if (!request.ContainsKey("METHOD")) + return FailureResult(); + + string method = request["METHOD"].ToString(); + request.Remove("METHOD"); + + switch (method) + { + case "TEST": + break; + } + } + catch (Exception e) + { + m_log.Debug("[FRIENDS]: Exception {0}" + e.ToString()); + } + + return FailureResult(); + } + + private byte[] FailureResult() + { + return BoolResult(false); + } + + private byte[] SuccessResult() + { + return BoolResult(true); + } + + private byte[] BoolResult(bool value) + { + 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(value.ToString())); + + 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(); + } + + } +} -- cgit v1.1 From de5c2801e8c8c0274de97370531dc93f5c57077b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 27 Feb 2010 08:14:37 -0800 Subject: Friendships established. --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 1d7889d..1719447 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -377,6 +377,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UUID principalID = new UUID(im.fromAgentID); UUID friendID = new UUID(im.toAgentID); + m_log.DebugFormat("[FRIENDS]: {0} offered friendship to {1}", principalID, friendID); + // This user wants to be friends with the other user. // Let's add both relations to the DB, but one of them is inactive (-1) FriendsService.StoreFriend(principalID, friendID.ToString(), 1); @@ -389,6 +391,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) { + // !!!!!!!! + im.imSessionID = im.fromAgentID; + IClientAPI friendClient = LocateClientObject(friendID); if (friendClient != null) { @@ -414,6 +419,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { FriendsService.StoreFriend(agentID, friendID.ToString(), 1); + m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID); + // // Notify the friend // -- cgit v1.1 From 6f770af5fb7f6eecbb215ec4b176105d29376ae0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 27 Feb 2010 15:25:51 +0000 Subject: Implement a handler for requestonlinenotification generic message --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 1719447..b6225ae 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -211,6 +211,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends client.OnLogout += OnLogout; client.OnEconomyDataRequest += SendPresence; + client.AddGenericPacketHandler("requestonlinenotification", OnRequestOnlineNotification); + if (m_Friends.ContainsKey(client.AgentId)) { m_Friends[client.AgentId].Refcount++; @@ -529,5 +531,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_FriendsSimConnector.GrantRights(region, requester, target); } } + + public void OnRequestOnlineNotification(Object sender, string method, List args) + { + } } } -- cgit v1.1 From 0ab65899e407804210666d233e67570b9ffd2401 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 27 Feb 2010 15:37:00 +0000 Subject: Move requestonlinenotification generic message to presence module --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 6 ----- .../Avatar/InstantMessage/PresenceModule.cs | 30 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index b6225ae..1719447 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -211,8 +211,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends client.OnLogout += OnLogout; client.OnEconomyDataRequest += SendPresence; - client.AddGenericPacketHandler("requestonlinenotification", OnRequestOnlineNotification); - if (m_Friends.ContainsKey(client.AgentId)) { m_Friends[client.AgentId].Refcount++; @@ -531,9 +529,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_FriendsSimConnector.GrantRights(region, requester, target); } } - - public void OnRequestOnlineNotification(Object sender, string method, List args) - { - } } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index 267a90a..5f51ce1 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -36,6 +36,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage @@ -48,12 +49,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage public event PresenceChange OnPresenceChange; public event BulkPresenceData OnBulkPresenceData; + protected List m_Scenes = new List(); + + protected IPresenceService m_PresenceService = null; + + protected IPresenceService PresenceService + { + get + { + if (m_PresenceService == null) + { + if (m_Scenes.Count > 0) + m_PresenceService = m_Scenes[0].RequestModuleInterface(); + } + + return m_PresenceService; + } + } + public void Initialise(IConfigSource config) { } public void AddRegion(Scene scene) { + m_Scenes.Add(scene); + + scene.EventManager.OnNewClient += OnNewClient; + + scene.RegisterModuleInterface(this); } public void RegionLoaded(Scene scene) @@ -62,6 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage public void RemoveRegion(Scene scene) { + m_Scenes.Remove(scene); } public void PostInitialise() @@ -88,6 +113,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage public void OnNewClient(IClientAPI client) { + client.AddGenericPacketHandler("requestonlinenotification", OnRequestOnlineNotification); + } + + public void OnRequestOnlineNotification(Object sender, string method, List args) + { } } } -- cgit v1.1 From a4472ceeac7d95997d9a143bfc002da22de416c6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 27 Feb 2010 15:50:41 +0000 Subject: Implement the requestonlinenotification method --- .../Avatar/InstantMessage/PresenceModule.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index 5f51ce1..4e57394 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -38,6 +38,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { @@ -118,6 +119,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage public void OnRequestOnlineNotification(Object sender, string method, List args) { + if (!(sender is IClientAPI)) + return; + + IClientAPI client = (IClientAPI)sender; + + PresenceInfo[] status = PresenceService.GetAgents(args.ToArray()); + + List online = new List(); + List offline = new List(); + + foreach (PresenceInfo pi in status) + { + if (pi.Online) + online.Add(new UUID(pi.UserID)); + else + offline.Add(new UUID(pi.UserID)); + } + + if (online.Count > 0) + client.SendAgentOnline(online.ToArray()); + if (offline.Count > 0) + client.SendAgentOffline(offline.ToArray()); } } } -- cgit v1.1 From 3906a14857eb3fbef9705240763afb9af1c9e303 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 27 Feb 2010 10:24:55 -0800 Subject: Friends online notifications upon friendship now working (same sim only). --- .../Region/CoreModules/Avatar/Friends/FriendsModule.cs | 3 +++ .../CoreModules/Avatar/InstantMessage/PresenceModule.cs | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 1719447..34f14df 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -432,6 +432,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends GridInstantMessage im = new GridInstantMessage(client.Scene, client.AgentId, client.Name, friendID, (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, client.AgentId.ToString(), false, Vector3.Zero); friendClient.SendInstantMessage(im); + client.SendAgentOnline(new UUID[] { friendID }); // we're done return; } @@ -442,7 +443,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); m_FriendsSimConnector.FriendshipApproved(region, agentID, friendID); + client.SendAgentOnline(new UUID[] { friendID }); } + } private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index 4e57394..bafad82 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -123,6 +123,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage return; IClientAPI client = (IClientAPI)sender; + m_log.DebugFormat("[PRESENCE MODULE]: OnlineNotification requested by {0}", client.Name); PresenceInfo[] status = PresenceService.GetAgents(args.ToArray()); @@ -131,10 +132,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage foreach (PresenceInfo pi in status) { + UUID uuid = new UUID(pi.UserID); if (pi.Online) - online.Add(new UUID(pi.UserID)); + { + if (!online.Contains(uuid)) + { + online.Add(uuid); + if (offline.Contains(uuid)) + offline.Remove(uuid); + } + } else - offline.Add(new UUID(pi.UserID)); + { + if (!online.Contains(uuid) && !offline.Contains(uuid)) + offline.Add(uuid); + } } if (online.Count > 0) -- cgit v1.1 From a234672db8190cea2e31f2a09b8a93fa26557d96 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 27 Feb 2010 10:57:57 -0800 Subject: * Finished implementation of FriendsService.Delete * Deny now working --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 34f14df..8f1b5d7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -391,7 +391,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void ForwardFriendshipOffer(UUID agentID, UUID friendID, GridInstantMessage im) { - // !!!!!!!! + // !!!!!!!! This is a hack so that we don't have to keep state (transactionID/imSessionID) + // We stick this agent's ID as imSession, so that it's directly available on the receiving end im.imSessionID = im.fromAgentID; IClientAPI friendClient = LocateClientObject(friendID); @@ -450,6 +451,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { + m_log.DebugFormat("[FRIENDS]: {0} denied friendship to {1}", agentID, friendID); + FriendsService.Delete(agentID, friendID.ToString()); FriendsService.Delete(friendID, agentID.ToString()); -- cgit v1.1 From 593fd54fc77bc712d89b8b95c2813491419fc6aa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 27 Feb 2010 11:23:31 -0800 Subject: Update the local cache upon friendship acceptance. Logout notifications working. --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 8f1b5d7..a750c92 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -419,6 +419,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { FriendsService.StoreFriend(agentID, friendID.ToString(), 1); + // update the local cache + m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); m_log.DebugFormat("[FRIENDS]: {0} accepted friendship from {1}", agentID, friendID); @@ -434,6 +436,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, client.AgentId.ToString(), false, Vector3.Zero); friendClient.SendInstantMessage(im); client.SendAgentOnline(new UUID[] { friendID }); + // update the local cache + m_Friends[friendID].Friends = FriendsService.GetFriends(friendID); // we're done return; } -- cgit v1.1 From 1daabc3473aa7696a8ff5d63eb31736ce2158642 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 27 Feb 2010 18:16:31 -0800 Subject: Status notification (online/offline) working for same sim. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 84 +++++++++++++++++----- 1 file changed, 66 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index a750c92..7e7d9e9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -226,7 +226,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_Friends.Add(client.AgentId, newFriends); - StatusChange(client.AgentId, true); + //StatusChange(client.AgentId, true); } private void OnClientClosed(UUID agentID, Scene scene) @@ -242,9 +242,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnLogout(IClientAPI client) { - m_Friends.Remove(client.AgentId); - StatusChange(client.AgentId, false); + m_Friends.Remove(client.AgentId); } private void OnMakeRootAgent(ScenePresence sp) @@ -253,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (m_Friends.ContainsKey(agentID)) { - if (m_Friends[agentID].RegionID == UUID.Zero) + if (m_Friends[agentID].RegionID == UUID.Zero && m_Friends[agentID].Friends == null) { m_Friends[agentID].Friends = m_FriendsService.GetFriends(agentID); @@ -290,9 +289,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; } + List online = GetOnlineFriends(agentID); + + m_log.DebugFormat("[FRIENDS]: User {0} has {1} friends online", agentID, online.Count); + client.SendAgentOnline(online.ToArray()); + + // Now inform the friends that this user is online + StatusChange(agentID, true); + } + + List GetOnlineFriends(UUID userID) + { List friendList = new List(); - foreach (FriendInfo fi in m_Friends[agentID].Friends) + foreach (FriendInfo fi in m_Friends[userID].Friends) { if ((fi.TheirFlags & 1) != 0) friendList.Add(fi.Friend); @@ -308,7 +318,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends online.Add(new UUID(pi.UserID)); } - client.SendAgentOnline(online.ToArray()); + return online; } // @@ -347,25 +357,58 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return null; } + /// + /// Caller beware! Call this only for root agents. + /// + /// + /// private void StatusChange(UUID agentID, bool online) { - foreach (UserFriendData fd in m_Friends.Values) + if (m_Friends.ContainsKey(agentID)) { - // Is this a root agent? If not, they will get updates - // through the root and this next check is redundant - // - if (fd.RegionID == UUID.Zero) - continue; + List friendList = new List(); + foreach (FriendInfo fi in m_Friends[agentID].Friends) + { + if ((fi.MyFlags & 1) != 0) + friendList.Add(fi); + } + foreach (FriendInfo fi in friendList) + { + // Notify about this user status + StatusNotify(fi, agentID, online); + } + } + } - if (fd.IsFriend(agentID.ToString())) + private void StatusNotify(FriendInfo friend, UUID userID, bool online) + { + UUID friendID = UUID.Zero; + + if (UUID.TryParse(friend.Friend, out friendID)) + { + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) { - UUID[] changed = new UUID[] { agentID }; - IClientAPI client = LocateClientObject(fd.PrincipalID); + //m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online); + // the friend in this sim as root agent if (online) - client.SendAgentOnline(changed); + friendClient.SendAgentOnline(new UUID[] { userID }); else - client.SendAgentOffline(changed); + friendClient.SendAgentOffline(new UUID[] { userID }); + // we're done + return; } + + // The friend is not here [as root]. Let's forward. + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); + } + + // Friend is not online. Ignore. } } @@ -490,6 +533,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends FriendsService.Delete(agentID, exfriendID.ToString()); FriendsService.Delete(exfriendID, agentID.ToString()); + // Update local cache + m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); + client.SendTerminateFriend(exfriendID); // @@ -499,8 +545,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends IClientAPI friendClient = LocateClientObject(exfriendID); if (friendClient != null) { - // the prospective friend in this sim as root agent + // the friend in this sim as root agent friendClient.SendTerminateFriend(exfriendID); + // update local cache + m_Friends[exfriendID].Friends = FriendsService.GetFriends(exfriendID); // we're done return; } -- cgit v1.1 From db24e57cab88217e49c3c564a2c025a44199520e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 28 Feb 2010 08:36:13 -0800 Subject: Friends connectors finished. Status notification working across the board. One last bug: friends online upon login are not being sent to the user. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 185 ++++++++++++++------- .../Avatar/Friends/FriendsRequestHandler.cs | 155 ++++++++++++++++- 2 files changed, 282 insertions(+), 58 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7e7d9e9..cc3a3ee 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -115,6 +115,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } + public IScene Scene + { + get + { + if (m_Scenes.Count > 0) + return m_Scenes[0]; + else + return null; + } + } + public void Initialise(IConfigSource config) { IConfig friendsConfig = config.Configs["Friends"]; @@ -276,6 +287,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void SendPresence(UUID agentID) { + // Inform the friends that this user is online + StatusChange(agentID, true); + + // Now send the list of online friends to this user if (!m_Friends.ContainsKey(agentID)) { m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID); @@ -291,11 +306,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends List online = GetOnlineFriends(agentID); - m_log.DebugFormat("[FRIENDS]: User {0} has {1} friends online", agentID, online.Count); + m_log.DebugFormat("[FRIENDS]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); client.SendAgentOnline(online.ToArray()); - // Now inform the friends that this user is online - StatusChange(agentID, true); } List GetOnlineFriends(UUID userID) @@ -315,7 +328,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends foreach (PresenceInfo pi in presence) { if (pi.Online) + { online.Add(new UUID(pi.UserID)); + //m_log.DebugFormat("[XXX] {0} friend online {1}", userID, pi.UserID); + } } return online; @@ -324,13 +340,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // // Find the client for a ID // - private IClientAPI LocateClientObject(UUID agentID) + public IClientAPI LocateClientObject(UUID agentID) { - Scene scene=GetClientScene(agentID); + Scene scene = GetClientScene(agentID); if(scene == null) return null; - ScenePresence presence=scene.GetScenePresence(agentID); + ScenePresence presence = scene.GetScenePresence(agentID); if(presence == null) return null; @@ -386,19 +402,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (UUID.TryParse(friend.Friend, out friendID)) { - IClientAPI friendClient = LocateClientObject(friendID); - if (friendClient != null) - { - //m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online); - // the friend in this sim as root agent - if (online) - friendClient.SendAgentOnline(new UUID[] { userID }); - else - friendClient.SendAgentOffline(new UUID[] { userID }); - // we're done + // Try local + if (LocalStatusNotification(userID, friendID, online)) return; - } - + // The friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); @@ -438,14 +445,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // We stick this agent's ID as imSession, so that it's directly available on the receiving end im.imSessionID = im.fromAgentID; - IClientAPI friendClient = LocateClientObject(friendID); - if (friendClient != null) - { - // the prospective friend in this sim as root agent - friendClient.SendInstantMessage(im); - // we're done - return ; - } + // Try the local sim + if (LocalFriendshipOffered(friendID, im)) + return; // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); @@ -471,26 +473,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Notify the friend // - IClientAPI friendClient = LocateClientObject(friendID); - if (friendClient != null) + // Try Local + if (LocalFriendshipApproved(agentID, client.Name, friendID)) { - // the prospective friend in this sim as root agent - GridInstantMessage im = new GridInstantMessage(client.Scene, client.AgentId, client.Name, friendID, - (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, client.AgentId.ToString(), false, Vector3.Zero); - friendClient.SendInstantMessage(im); client.SendAgentOnline(new UUID[] { friendID }); - // update the local cache - m_Friends[friendID].Friends = FriendsService.GetFriends(friendID); - // we're done return; } + // The friend is not here PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipApproved(region, agentID, friendID); + m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); client.SendAgentOnline(new UUID[] { friendID }); } @@ -507,24 +503,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Notify the friend // - IClientAPI friendClient = LocateClientObject(friendID); - if (friendClient != null) - { - // the prospective friend in this sim as root agent - - GridInstantMessage im = new GridInstantMessage(client.Scene, client.AgentId, client.Name, friendID, - (byte)OpenMetaverse.InstantMessageDialog.FriendshipDeclined, client.AgentId.ToString(), false, Vector3.Zero); - friendClient.SendInstantMessage(im); - // we're done + // Try local + if (LocalFriendshipDenied(agentID, client.Name, friendID)) return; - } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipDenied(region, agentID, friendID); + m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); } } @@ -542,16 +530,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // Notify the friend // - IClientAPI friendClient = LocateClientObject(exfriendID); - if (friendClient != null) - { - // the friend in this sim as root agent - friendClient.SendTerminateFriend(exfriendID); - // update local cache - m_Friends[exfriendID].Friends = FriendsService.GetFriends(exfriendID); - // we're done + // Try local + if (LocalFriendshipTerminated(exfriendID)) return; - } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); @@ -587,5 +568,97 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_FriendsSimConnector.GrantRights(region, requester, target); } } + + #region Local + + public bool LocalFriendshipOffered(UUID toID, GridInstantMessage im) + { + IClientAPI friendClient = LocateClientObject(toID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + friendClient.SendInstantMessage(im); + // we're done + return true; + } + return false; + } + + public bool LocalFriendshipApproved(UUID userID, string userName, UUID friendID) + { + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID, + (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero); + friendClient.SendInstantMessage(im); + // update the local cache + m_Friends[friendID].Friends = FriendsService.GetFriends(friendID); + // we're done + return true; + } + + return false; + } + + public bool LocalFriendshipDenied(UUID userID, string userName, UUID friendID) + { + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + // the prospective friend in this sim as root agent + + GridInstantMessage im = new GridInstantMessage(Scene, userID, userName, friendID, + (byte)OpenMetaverse.InstantMessageDialog.FriendshipDeclined, userID.ToString(), false, Vector3.Zero); + friendClient.SendInstantMessage(im); + // we're done + return true; + } + + return false; + } + + public bool LocalFriendshipTerminated(UUID exfriendID) + { + IClientAPI friendClient = LocateClientObject(exfriendID); + if (friendClient != null) + { + // the friend in this sim as root agent + friendClient.SendTerminateFriend(exfriendID); + // update local cache + m_Friends[exfriendID].Friends = FriendsService.GetFriends(exfriendID); + // we're done + return true; + } + + return false; + } + + public bool LocalGrantRights() + { + // TODO + return true; + } + + public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) + { + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + //m_log.DebugFormat("[FRIENDS]: Notify {0} that user {1} is {2}", friend.Friend, userID, online); + // the friend in this sim as root agent + if (online) + friendClient.SendAgentOnline(new UUID[] { userID }); + else + friendClient.SendAgentOffline(new UUID[] { userID }); + // we're done + return true; + } + + return false; + } + #endregion + } } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index cde54ed..e7b74a9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs @@ -75,8 +75,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends switch (method) { - case "TEST": - break; + case "friendship_offered": + return FriendshipOffered(request); + case "friendship_approved": + return FriendshipApproved(request); + case "friendship_denied": + return FriendshipDenied(request); + case "friendship_terminated": + return FriendshipTerminated(request); + case "grant_rights": + return GrantRights(request); + case "status": + return StatusNotification(request); } } catch (Exception e) @@ -87,6 +97,146 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return FailureResult(); } + byte[] FriendshipOffered(Dictionary request) + { + UUID fromID = UUID.Zero; + UUID toID = UUID.Zero; + string message = string.Empty; + + if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) + return FailureResult(); + + message = request["Message"].ToString(); + + if (!UUID.TryParse(request["FromID"].ToString(), out fromID)) + return FailureResult(); + + if (!UUID.TryParse(request["ToID"].ToString(), out toID)) + return FailureResult(); + + GridInstantMessage im = new GridInstantMessage(m_FriendsModule.Scene, fromID, "", toID, + (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero); + + if (m_FriendsModule.LocalFriendshipOffered(toID, im)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] FriendshipApproved(Dictionary request) + { + UUID fromID = UUID.Zero; + UUID toID = UUID.Zero; + string fromName = string.Empty; + + if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) + return FailureResult(); + + if (!UUID.TryParse(request["FromID"].ToString(), out fromID)) + return FailureResult(); + + if (!UUID.TryParse(request["ToID"].ToString(), out toID)) + return FailureResult(); + + if (request.ContainsKey("FromName")) + fromName = request["FromName"].ToString(); + + if (m_FriendsModule.LocalFriendshipApproved(fromID, fromName, toID)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] FriendshipDenied(Dictionary request) + { + UUID fromID = UUID.Zero; + UUID toID = UUID.Zero; + string fromName = string.Empty; + + if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) + return FailureResult(); + + if (!UUID.TryParse(request["FromID"].ToString(), out fromID)) + return FailureResult(); + + if (!UUID.TryParse(request["ToID"].ToString(), out toID)) + return FailureResult(); + + if (request.ContainsKey("FromName")) + fromName = request["FromName"].ToString(); + + if (m_FriendsModule.LocalFriendshipDenied(fromID, fromName, toID)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] FriendshipTerminated(Dictionary request) + { + UUID fromID = UUID.Zero; + UUID toID = UUID.Zero; + + if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) + return FailureResult(); + + if (!UUID.TryParse(request["FromID"].ToString(), out fromID)) + return FailureResult(); + + if (!UUID.TryParse(request["ToID"].ToString(), out toID)) + return FailureResult(); + + if (m_FriendsModule.LocalFriendshipTerminated(toID)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] GrantRights(Dictionary request) + { + UUID fromID = UUID.Zero; + UUID toID = UUID.Zero; + + if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) + return FailureResult(); + + if (!UUID.TryParse(request["FromID"].ToString(), out fromID)) + return FailureResult(); + + if (!UUID.TryParse(request["ToID"].ToString(), out toID)) + return FailureResult(); + + if (m_FriendsModule.LocalGrantRights(/* ??? */)) + return SuccessResult(); + + return FailureResult(); + } + + byte[] StatusNotification(Dictionary request) + { + UUID fromID = UUID.Zero; + UUID toID = UUID.Zero; + bool online = false; + + if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID") || !request.ContainsKey("Online")) + return FailureResult(); + + if (!UUID.TryParse(request["FromID"].ToString(), out fromID)) + return FailureResult(); + + if (!UUID.TryParse(request["ToID"].ToString(), out toID)) + return FailureResult(); + + if (!Boolean.TryParse(request["Online"].ToString(), out online)) + return FailureResult(); + + if (m_FriendsModule.LocalStatusNotification(fromID, toID, online)) + return SuccessResult(); + + return FailureResult(); + } + + #region Misc + private byte[] FailureResult() { return BoolResult(false); @@ -130,5 +280,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return ms.ToArray(); } + #endregion } } -- cgit v1.1 From 5c5966545d14de43500b95109e8ce81058ebe2c3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 28 Feb 2010 12:07:38 -0800 Subject: Initial Online friends notification seems to be working reliably now. All this needs more testing, but everything is there. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 54 +++++++++++++++------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index cc3a3ee..8aa5b91 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -79,6 +79,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends protected Dictionary m_Friends = new Dictionary(); + protected List m_NeedsListOfFriends = new List(); + protected IPresenceService PresenceService { get @@ -170,6 +172,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends scene.EventManager.OnClientClosed += OnClientClosed; scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; scene.EventManager.OnMakeChildAgent += OnMakeChildAgent; + scene.EventManager.OnClientLogin += OnClientLogin; } public void RegionLoaded(Scene scene) @@ -220,7 +223,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends client.OnGrantUserRights += OnGrantUserRights; client.OnLogout += OnLogout; - client.OnEconomyDataRequest += SendPresence; if (m_Friends.ContainsKey(client.AgentId)) { @@ -285,30 +287,50 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } - private void SendPresence(UUID agentID) + private void OnClientLogin(IClientAPI client) { + UUID agentID = client.AgentId; + // Inform the friends that this user is online StatusChange(agentID, true); - // Now send the list of online friends to this user - if (!m_Friends.ContainsKey(agentID)) - { - m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID); - return; - } + // Register that we need to send the list of online friends to this user + lock (m_NeedsListOfFriends) + if (!m_NeedsListOfFriends.Contains(agentID)) + { + m_NeedsListOfFriends.Add(agentID); + } + } - IClientAPI client = LocateClientObject(agentID); - if (client == null) + public void SendFriendsOnlineIfNeeded(IClientAPI client) + { + UUID agentID = client.AgentId; + if (m_NeedsListOfFriends.Contains(agentID)) { - m_log.DebugFormat("[FRIENDS MODULE]: agent's client {0} not found in local scene", agentID); - return; - } + if (!m_Friends.ContainsKey(agentID)) + { + m_log.DebugFormat("[FRIENDS MODULE]: agent {0} not found in local cache", agentID); + return; + } + + client = LocateClientObject(agentID); + if (client == null) + { + m_log.DebugFormat("[FRIENDS MODULE]: agent's client {0} not found in local scene", agentID); + return; + } - List online = GetOnlineFriends(agentID); + List online = GetOnlineFriends(agentID); - m_log.DebugFormat("[FRIENDS]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); - client.SendAgentOnline(online.ToArray()); + if (online.Count > 0) + { + m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); + client.SendAgentOnline(online.ToArray()); + } + lock (m_NeedsListOfFriends) + m_NeedsListOfFriends.Remove(agentID); + } } List GetOnlineFriends(UUID userID) -- cgit v1.1 From adb9cc2af9c3910ae1bae714907b26b1beac9fd6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Feb 2010 23:26:13 +0000 Subject: Implement rights changes locall (UNTESTED) --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 48 +++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 8aa5b91..3a86a46 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -567,19 +567,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) { - FriendsService.StoreFriend(requester, target.ToString(), rights); + if (!m_Friends.ContainsKey(remoteClient.AgentId)) + return; - // - // Notify the friend - // + UserFriendData fd = m_Friends[remoteClient.AgentId]; - IClientAPI friendClient = LocateClientObject(target); - if (friendClient != null) + FriendsService.StoreFriend(requester, target.ToString(), rights); + + foreach (FriendInfo fi in fd.Friends) { - // the prospective friend in this sim as root agent - //friendClient.???; - // we're done - return; + if (fi.Friend == target.ToString()) + { + IClientAPI friendClient = LocateClientObject(target); + + int delta = rights ^ fi.MyFlags; + if ((delta & ~1) != 0) + { + remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); + // + // Notify the friend + // + + if (friendClient != null) + { + friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); + } + } + if ((delta & 1) != 0) + { + if (friendClient != null) + { + if ((rights & 1) != 0) + friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) } ); + else + friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) } ); + } + } + if (friendClient != null) // Local, we're done + return; + } } PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); @@ -587,6 +613,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (friendSession != null) { GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + // TODO: You might want to send the delta to save the lookup + // on the other end!! m_FriendsSimConnector.GrantRights(region, requester, target); } } -- cgit v1.1 From bfcc57c0712170e3431617bcb09999bfbb96b8dd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 1 Mar 2010 00:02:14 +0000 Subject: Change friends to handle offers as it was originally designed. This may need to be changed in SQLite & MSSQL as well --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 3a86a46..32c2a43 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -194,10 +194,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends get { return null; } } - public void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage) - { - } - public uint GetFriendPerms(UUID principalID, UUID friendID) { if (!m_Friends.ContainsKey(principalID)) @@ -453,8 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // This user wants to be friends with the other user. // Let's add both relations to the DB, but one of them is inactive (-1) - FriendsService.StoreFriend(principalID, friendID.ToString(), 1); - FriendsService.StoreFriend(friendID, principalID.ToString(), -1); + FriendsService.StoreFriend(principalID, friendID.ToString(), 0); // Now let's ask the other user to be friends with this user ForwardFriendshipOffer(principalID, friendID, im); @@ -486,6 +481,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private void OnApproveFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) { FriendsService.StoreFriend(agentID, friendID.ToString(), 1); + FriendsService.StoreFriend(friendID, agentID.ToString(), 1); // update the local cache m_Friends[agentID].Friends = FriendsService.GetFriends(agentID); -- cgit v1.1 From 65fadd2f67f46f8a62aea5be167b73471f58b7fe Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 1 Mar 2010 00:20:34 +0000 Subject: Should have things the right way around, better that way --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 32c2a43..cc324fe 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -449,7 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // This user wants to be friends with the other user. // Let's add both relations to the DB, but one of them is inactive (-1) - FriendsService.StoreFriend(principalID, friendID.ToString(), 0); + FriendsService.StoreFriend(friendID, principalID.ToString(), 0); // Now let's ask the other user to be friends with this user ForwardFriendshipOffer(principalID, friendID, im); -- cgit v1.1 From dc22e7403356334c9c4b489d360a11b46f38c8b9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 1 Mar 2010 02:54:18 +0000 Subject: Small tweak --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index cc324fe..72909a5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -403,7 +403,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends List friendList = new List(); foreach (FriendInfo fi in m_Friends[agentID].Friends) { - if ((fi.MyFlags & 1) != 0) + if (((fi.MyFlags & 1) != 0) && (fi.TheirFlags != -1)) friendList.Add(fi); } foreach (FriendInfo fi in friendList) -- cgit v1.1 From b8d89ac6daa1fe82f95e324010243c3cfa4d643b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 1 Mar 2010 02:57:25 +0000 Subject: Fix -1 checks for login case --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 72909a5..7ec4a9c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends foreach (FriendInfo fi in m_Friends[userID].Friends) { - if ((fi.TheirFlags & 1) != 0) + if (((fi.TheirFlags & 1) != 0) && (fi.TheirFlags != -1)) friendList.Add(fi.Friend); } -- cgit v1.1 From cfaf087b89d8d90322a4a86237c246534c26f961 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Mar 2010 09:23:33 -0800 Subject: More work on GrantRights. Still not right. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 141 ++++++++++++++------- .../Avatar/Friends/FriendsRequestHandler.cs | 4 +- 2 files changed, 101 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7ec4a9c..61116a7 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -566,52 +566,64 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (!m_Friends.ContainsKey(remoteClient.AgentId)) return; + m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target); + // Let's find the friend in this user's friend list UserFriendData fd = m_Friends[remoteClient.AgentId]; - - FriendsService.StoreFriend(requester, target.ToString(), rights); - + FriendInfo friend = new FriendInfo(); foreach (FriendInfo fi in fd.Friends) - { if (fi.Friend == target.ToString()) - { - IClientAPI friendClient = LocateClientObject(target); + friend = fi; - int delta = rights ^ fi.MyFlags; - if ((delta & ~1) != 0) - { - remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); - // - // Notify the friend - // - - if (friendClient != null) - { - friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); - } - } - if ((delta & 1) != 0) - { - if (friendClient != null) - { - if ((rights & 1) != 0) - friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) } ); - else - friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) } ); - } - } - if (friendClient != null) // Local, we're done - return; + if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it + { + FriendsService.StoreFriend(requester, target.ToString(), rights); + + bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0; + if (!onlineBitChanged) + { + remoteClient.SendChangeUserRights(requester, target, rights); } - } - PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) - { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - // TODO: You might want to send the delta to save the lookup - // on the other end!! - m_FriendsSimConnector.GrantRights(region, requester, target); + // Try local + if (LocalGrantRights(requester, target, friend.MyFlags, rights)) + return; + + + //int delta = rights ^ friend.MyFlags; + //if ((delta & ~1) != 0) + //{ + // //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); + // // + // // Notify the friend + // // + + // if (friendClient != null) + // { + // friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); + // } + //} + //if ((delta & 1) != 0) + //{ + // if (friendClient != null) + // { + // if ((rights & 1) != 0) + // friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) }); + // else + // friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) }); + // } + //} + //if (friendClient != null) // Local, we're done + // return; + + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); + PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + // TODO: You might want to send the delta to save the lookup + // on the other end!! + m_FriendsSimConnector.GrantRights(region, requester, target); + } } } @@ -681,10 +693,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return false; } - public bool LocalGrantRights() + public bool LocalGrantRights(UUID userID, UUID friendID, int myFlags, int rights) { - // TODO - return true; + m_log.DebugFormat("XXX Trying to locate {0}", friendID); + IClientAPI friendClient = LocateClientObject(friendID); + if (friendClient != null) + { + bool onlineBitChanged = ((rights ^ myFlags) & (int)FriendRights.CanSeeOnline) == 0; + if (!onlineBitChanged) + friendClient.SendChangeUserRights(userID, friendID, rights); + else + { + if ((rights & (int)FriendRights.CanSeeOnline) == 1) + friendClient.SendAgentOnline(new UUID[] { new UUID(userID) }); + else + friendClient.SendAgentOffline(new UUID[] { new UUID(userID) }); + } + return true; + } + + return false; + + //int delta = rights ^ friend.MyFlags; + //if ((delta & ~1) != 0) + //{ + // //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); + // // + // // Notify the friend + // // + + // if (friendClient != null) + // { + // friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); + // } + //} + //if ((delta & 1) != 0) + //{ + // if (friendClient != null) + // { + // if ((rights & 1) != 0) + // friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) }); + // else + // friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) }); + // } + //} + //if (friendClient != null) // Local, we're done + // return; + } public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index e7b74a9..140660b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs @@ -34,6 +34,7 @@ using System.Xml; using OpenSim.Framework; using OpenSim.Server.Base; using OpenSim.Framework.Servers.HttpServer; +using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; using OpenMetaverse; using log4net; @@ -205,7 +206,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (!UUID.TryParse(request["ToID"].ToString(), out toID)) return FailureResult(); - if (m_FriendsModule.LocalGrantRights(/* ??? */)) + // !!! + if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0)) return SuccessResult(); return FailureResult(); -- cgit v1.1 From c6a5ff26fff6a1d0c3ab916a526cf0dd4e4142bc Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Mar 2010 21:32:55 -0800 Subject: Friends rights under control. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 93 ++++++---------------- .../Avatar/Friends/FriendsRequestHandler.cs | 10 ++- 2 files changed, 33 insertions(+), 70 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 61116a7..555fb00 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -569,51 +569,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_log.DebugFormat("[FRIENDS MODULE]: User {0} changing rights to {1} for friend {2}", requester, rights, target); // Let's find the friend in this user's friend list UserFriendData fd = m_Friends[remoteClient.AgentId]; - FriendInfo friend = new FriendInfo(); + FriendInfo friend = null; foreach (FriendInfo fi in fd.Friends) if (fi.Friend == target.ToString()) friend = fi; - if (!friend.PrincipalID.Equals(UUID.Zero)) // Found it + if (friend != null) // Found it { + // Store it on the DB FriendsService.StoreFriend(requester, target.ToString(), rights); - bool onlineBitChanged = ((rights ^ friend.MyFlags) & (int)FriendRights.CanSeeOnline) == 0; - if (!onlineBitChanged) - { - remoteClient.SendChangeUserRights(requester, target, rights); - } + // Store it in the local cache + int myFlags = friend.MyFlags; + friend.MyFlags = rights; - // Try local - if (LocalGrantRights(requester, target, friend.MyFlags, rights)) - return; + // Always send this back to the original client + remoteClient.SendChangeUserRights(requester, target, rights); + // + // Notify the friend + // - //int delta = rights ^ friend.MyFlags; - //if ((delta & ~1) != 0) - //{ - // //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); - // // - // // Notify the friend - // // - - // if (friendClient != null) - // { - // friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); - // } - //} - //if ((delta & 1) != 0) - //{ - // if (friendClient != null) - // { - // if ((rights & 1) != 0) - // friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) }); - // else - // friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) }); - // } - //} - //if (friendClient != null) // Local, we're done - // return; + // Try local + if (LocalGrantRights(requester, target, myFlags, rights)) + return; PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); @@ -622,7 +601,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); // TODO: You might want to send the delta to save the lookup // on the other end!! - m_FriendsSimConnector.GrantRights(region, requester, target); + m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); } } } @@ -693,53 +672,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return false; } - public bool LocalGrantRights(UUID userID, UUID friendID, int myFlags, int rights) + public bool LocalGrantRights(UUID userID, UUID friendID, int userFlags, int rights) { - m_log.DebugFormat("XXX Trying to locate {0}", friendID); IClientAPI friendClient = LocateClientObject(friendID); if (friendClient != null) { - bool onlineBitChanged = ((rights ^ myFlags) & (int)FriendRights.CanSeeOnline) == 0; - if (!onlineBitChanged) - friendClient.SendChangeUserRights(userID, friendID, rights); - else + bool onlineBitChanged = ((rights ^ userFlags) & (int)FriendRights.CanSeeOnline) != 0; + if (onlineBitChanged) { if ((rights & (int)FriendRights.CanSeeOnline) == 1) friendClient.SendAgentOnline(new UUID[] { new UUID(userID) }); else friendClient.SendAgentOffline(new UUID[] { new UUID(userID) }); } + else + { + bool canEditObjectsChanged = ((rights ^ userFlags) & (int)FriendRights.CanModifyObjects) != 0; + if (canEditObjectsChanged) + friendClient.SendChangeUserRights(userID, friendID, rights); + } + return true; } return false; - //int delta = rights ^ friend.MyFlags; - //if ((delta & ~1) != 0) - //{ - // //remoteClient.SendChangeUserRights(remoteClient.AgentId, target, rights & ~1); - // // - // // Notify the friend - // // - - // if (friendClient != null) - // { - // friendClient.SendChangeUserRights(target, remoteClient.AgentId, rights & ~1); - // } - //} - //if ((delta & 1) != 0) - //{ - // if (friendClient != null) - // { - // if ((rights & 1) != 0) - // friendClient.SendAgentOnline(new UUID[] { new UUID(remoteClient.AgentId) }); - // else - // friendClient.SendAgentOffline(new UUID[] { new UUID(remoteClient.AgentId) }); - // } - //} - //if (friendClient != null) // Local, we're done - // return; - } public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs index 140660b..0883c5b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs @@ -196,6 +196,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends { UUID fromID = UUID.Zero; UUID toID = UUID.Zero; + int rights = 0, userFlags = 0; if (!request.ContainsKey("FromID") || !request.ContainsKey("ToID")) return FailureResult(); @@ -206,8 +207,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (!UUID.TryParse(request["ToID"].ToString(), out toID)) return FailureResult(); - // !!! - if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, 0, 0)) + if (!Int32.TryParse(request["UserFlags"].ToString(), out userFlags)) + return FailureResult(); + + if (!Int32.TryParse(request["Rights"].ToString(), out rights)) + return FailureResult(); + + if (m_FriendsModule.LocalGrantRights(UUID.Zero, UUID.Zero, userFlags, rights)) return SuccessResult(); return FailureResult(); -- cgit v1.1 From 00e6739b7db00397e8e8824040c7d72c408281b9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 1 Mar 2010 22:21:33 -0800 Subject: Offline friendship offers now working. --- .../CoreModules/Avatar/Friends/FriendsModule.cs | 49 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 555fb00..de324c0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -309,21 +309,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; } - client = LocateClientObject(agentID); - if (client == null) - { - m_log.DebugFormat("[FRIENDS MODULE]: agent's client {0} not found in local scene", agentID); - return; - } - + // + // Send the friends online + // List online = GetOnlineFriends(agentID); - if (online.Count > 0) { m_log.DebugFormat("[FRIENDS MODULE]: User {0} in region {1} has {2} friends online", client.AgentId, client.Scene.RegionInfo.RegionName, online.Count); client.SendAgentOnline(online.ToArray()); } + // + // Send outstanding friendship offers + // + if (m_Friends.ContainsKey(agentID)) + { + List outstanding = new List(); + + foreach (FriendInfo fi in m_Friends[agentID].Friends) + if (fi.TheirFlags == -1) + outstanding.Add(fi.Friend); + + GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, "", agentID, (byte)InstantMessageDialog.FriendshipOffered, "Will you be my friend?", true, Vector3.Zero); + foreach (string fid in outstanding) + { + try + { + im.fromAgentID = new Guid(fid); + } + catch + { + continue; + } + + UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, new UUID(im.fromAgentID)); + im.fromAgentName = account.FirstName + " " + account.LastName; + + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid }); + PresenceInfo presence = PresenceInfo.GetOnlinePresence(presences); + if (presence != null) + im.offline = 0; + + im.imSessionID = im.fromAgentID; + + // Finally + LocalFriendshipOffered(agentID, im); + } + } + lock (m_NeedsListOfFriends) m_NeedsListOfFriends.Remove(agentID); } -- cgit v1.1