From e1cf34d6fb2d43261ad66262af091574c075f489 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 4 Dec 2016 15:50:48 +0000 Subject: replace GetDisplaynames by a handler really usable as a client cap. Most capabilities.handlers are so it all things not propor PER CLIENT CAP handlers --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 84 ++++++++++++ .../Linden/Caps/GetDisplayNamesModule.cs | 143 --------------------- 2 files changed, 84 insertions(+), 143 deletions(-) delete mode 100644 OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 60bfaa5..f96ae8b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -29,9 +29,11 @@ using System; using System.Timers; using System.Collections; using System.Collections.Generic; +using System.Collections.Specialized; using System.IO; using System.Reflection; using System.Text; +using System.Web; using OpenMetaverse; using OpenMetaverse.StructuredData; @@ -125,6 +127,8 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_AllowCapHomeLocation = true; private bool m_AllowCapGroupMemberData = true; + private IUserManagement m_UserManager; + private enum FileAgentInventoryState : int { @@ -196,6 +200,7 @@ namespace OpenSim.Region.ClientStack.Linden m_assetService = m_Scene.AssetService; m_regionName = m_Scene.RegionInfo.RegionName; + m_UserManager = m_Scene.RequestModuleInterface(); RegisterHandlers(); @@ -229,6 +234,7 @@ namespace OpenSim.Region.ClientStack.Linden RegisterRegionServiceHandlers(); RegisterInventoryServiceHandlers(); + RegisterOtherHandlers(); } public void RegisterRegionServiceHandlers() @@ -314,6 +320,19 @@ namespace OpenSim.Region.ClientStack.Linden } } + public void RegisterOtherHandlers() + { + try + { + IRequestHandler GetDisplayNamesHandler = new RestStreamHandler( + "GET", GetNewCapPath(), GetDisplayNames, "GetDisplayNames", null); + m_HostCapsObj.RegisterHandler("GetDisplayNames", GetDisplayNamesHandler); + } + catch (Exception e) + { + m_log.Error("[CAPS]: " + e.ToString()); + } + } /// /// Construct a client response detailing all the capabilities this server can provide. /// @@ -1794,6 +1813,71 @@ namespace OpenSim.Region.ClientStack.Linden response = OSDParser.SerializeLLSDXmlString(resp); return response; } + + public string GetDisplayNames(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NoContent; + httpResponse.ContentType = "text/plain"; + + ScenePresence sp = m_Scene.GetScenePresence(m_AgentID); + if(sp == null || sp.IsDeleted) + return ""; + + NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); + string[] ids = query.GetValues("ids"); + + if (m_UserManager == null) + { + m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component"); + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; + return ""; + } + + Dictionary names = m_UserManager.GetUsersNames(ids); + + OSDMap osdReply = new OSDMap(); + OSDArray agents = new OSDArray(); + + osdReply["agents"] = agents; + foreach (KeyValuePair kvp in names) + { + if (string.IsNullOrEmpty(kvp.Value)) + continue; + if(kvp.Key == UUID.Zero) + continue; + + string[] parts = kvp.Value.Split(new char[] {' '}); + OSDMap osdname = new OSDMap(); + if(parts[0] == "Unknown") + { + osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddHours(1)); + osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddHours(2)); + } + else + { + osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8)); + osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddMonths(1)); + } + osdname["display_name"] = OSD.FromString(kvp.Value); + osdname["legacy_first_name"] = parts[0]; + osdname["legacy_last_name"] = parts[1]; + osdname["username"] = OSD.FromString(kvp.Value); + osdname["id"] = OSD.FromUUID(kvp.Key); + osdname["is_display_name_default"] = OSD.FromBoolean(true); + + agents.Add(osdname); + } + + // Full content request + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; + //httpResponse.ContentLength = ??; + httpResponse.ContentType = "application/llsd+xml"; + + string reply = OSDParser.SerializeLLSDXmlString(osdReply); + return reply; + } } public class AssetUploader diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs deleted file mode 100644 index bf559d3..0000000 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs +++ /dev/null @@ -1,143 +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.Specialized; -using System.Drawing; -using System.Drawing.Imaging; -using System.Reflection; -using System.IO; -using System.Web; -using log4net; -using Nini.Config; -using Mono.Addins; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using OpenMetaverse.Imaging; -using OpenSim.Framework; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Services.Interfaces; -using Caps = OpenSim.Framework.Capabilities.Caps; -using OpenSim.Capabilities.Handlers; - -namespace OpenSim.Region.ClientStack.Linden -{ - - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetDisplayNamesModule")] - public class GetDisplayNamesModule : INonSharedRegionModule - { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - protected Scene m_scene; - protected IUserManagement m_UserManager; - - protected bool m_Enabled = false; - - protected string m_URL; - - #region ISharedRegionModule Members - - public virtual void Initialise(IConfigSource source) - { - IConfig config = source.Configs["ClientStack.LindenCaps"]; - if (config == null) - return; - - m_URL = config.GetString("Cap_GetDisplayNames", string.Empty); - if (m_URL != string.Empty) - m_Enabled = true; - } - - public virtual void AddRegion(Scene s) - { - if (!m_Enabled) - return; - - m_scene = s; - } - - public virtual void RemoveRegion(Scene s) - { - if (!m_Enabled) - return; - - m_scene.EventManager.OnRegisterCaps -= RegisterCaps; - m_scene = null; - } - - public virtual void RegionLoaded(Scene s) - { - if (!m_Enabled) - return; - - m_UserManager = m_scene.RequestModuleInterface(); - m_scene.EventManager.OnRegisterCaps += RegisterCaps; - } - - public virtual void PostInitialise() - { - } - - public virtual void Close() { } - - public virtual string Name { get { return "GetDisplayNamesModule"; } } - - public virtual Type ReplaceableInterface - { - get { return null; } - } - - #endregion - - public virtual void RegisterCaps(UUID agentID, Caps caps) - { - if (m_URL == "localhost") - { - string capUrl = "/CAPS/" + UUID.Random() + "/"; -// m_log.DebugFormat("[GET_DISPLAY_NAMES]: {0} in region {1}", capUrl, m_scene.RegionInfo.RegionName); - caps.RegisterHandler( - "GetDisplayNames", - new GetDisplayNamesHandler(capUrl, m_UserManager, "GetDisplayNames", agentID.ToString())); - } - else - { -// m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); - IExternalCapsModule handler = m_scene.RequestModuleInterface(); - if (handler != null) - handler.RegisterExternalUserCapsHandler(agentID,caps,"GetDisplayNames", m_URL); - else - caps.RegisterHandler("GetDisplayNames", m_URL); - } - } - - } -} -- cgit v1.1 From fcd1e36ed6177f3b3e83d7fd829df3a5325c5e9c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 4 Dec 2016 17:01:49 +0000 Subject: a few changes to new GetDisplaynames and friends --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index f96ae8b..2481d11 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -201,6 +201,8 @@ namespace OpenSim.Region.ClientStack.Linden m_assetService = m_Scene.AssetService; m_regionName = m_Scene.RegionInfo.RegionName; m_UserManager = m_Scene.RequestModuleInterface(); + if (m_UserManager == null) + m_log.Error("[CAPS]: GetDisplayNames disabled because user management component not found"); RegisterHandlers(); @@ -324,9 +326,12 @@ namespace OpenSim.Region.ClientStack.Linden { try { - IRequestHandler GetDisplayNamesHandler = new RestStreamHandler( + if (m_UserManager != null) + { + IRequestHandler GetDisplayNamesHandler = new RestStreamHandler( "GET", GetNewCapPath(), GetDisplayNames, "GetDisplayNames", null); - m_HostCapsObj.RegisterHandler("GetDisplayNames", GetDisplayNamesHandler); + m_HostCapsObj.RegisterHandler("GetDisplayNames", GetDisplayNamesHandler); + } } catch (Exception e) { @@ -1818,23 +1823,24 @@ namespace OpenSim.Region.ClientStack.Linden string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - httpResponse.StatusCode = (int)System.Net.HttpStatusCode.NoContent; + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.Gone; httpResponse.ContentType = "text/plain"; ScenePresence sp = m_Scene.GetScenePresence(m_AgentID); if(sp == null || sp.IsDeleted) return ""; - NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); - string[] ids = query.GetValues("ids"); - - if (m_UserManager == null) + if(sp.IsInTransit) { - m_log.Error("[GET_DISPLAY_NAMES]: Cannot fetch display names without a user management component"); - httpResponse.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; + httpResponse.StatusCode = (int)System.Net.HttpStatusCode.ServiceUnavailable; + httpResponse.AddHeader("Retry-After","30"); return ""; } + NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); + string[] ids = query.GetValues("ids"); + + Dictionary names = m_UserManager.GetUsersNames(ids); OSDMap osdReply = new OSDMap(); -- cgit v1.1 From 7c566dca5a41cd3a9cb0336b00bdf7d63e24d2e9 Mon Sep 17 00:00:00 2001 From: Mandarinka Tasty Date: Sun, 4 Dec 2016 07:10:13 +0100 Subject: The new Constant: integer OBJECT_REZZER_KEY = 32; Signed-off-by: Mandarinka Tasty Signed-off-by: UbitUmarov --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 2 ++ .../ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs | 1 + 2 files changed, 3 insertions(+) (limited to 'OpenSim/Region/ClientStack') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 2481d11..032104d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1046,6 +1046,7 @@ namespace OpenSim.Region.ClientStack.Linden prim.OwnerID = owner_id; prim.GroupID = UUID.Zero; prim.LastOwnerID = creatorID; + prim.RezzerID = creatorID; prim.CreationDate = Util.UnixTimeSinceEpoch(); if (grp == null) @@ -1093,6 +1094,7 @@ namespace OpenSim.Region.ClientStack.Linden { grp = new SceneObjectGroup(prim); grp.LastOwnerID = creatorID; + grp.RezzerID = creatorID; } else grp.AddPart(prim); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index 769fe28..713125c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs @@ -284,6 +284,7 @@ namespace OpenSim.Region.ClientStack.Linden prim.OwnerID = AgentId; prim.GroupID = obj.GroupID; prim.LastOwnerID = prim.OwnerID; + prim.RezzerID = AgentId; prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.Name = obj.Name; prim.Description = ""; -- cgit v1.1