/Aurora/Services/GenericServices/CapsService/CAPModules/MeshUploadFlag.cs
C# | 92 lines | 55 code | 10 blank | 27 comment | 1 complexity | 20f13e18cfadb80f02d0552104908b2a MD5 | raw file
1/* 2 * Copyright (c) Contributors, http://aurora-sim.org/ 3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * * Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * * Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * * Neither the name of the Aurora-Sim Project nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28using Aurora.Framework; 29using Aurora.Framework.DatabaseInterfaces; 30using Aurora.Framework.Servers.HttpServer; 31using Aurora.Framework.Servers.HttpServer.Implementation; 32using Aurora.Framework.Services; 33using Aurora.Framework.Services.ClassHelpers.Profile; 34using OpenMetaverse; 35using OpenMetaverse.StructuredData; 36using System.IO; 37 38namespace Aurora.Services 39{ 40 public class MeshUploadFlag : ICapsServiceConnector 41 { 42 private IProfileConnector m_profileConnector; 43 private IRegionClientCapsService m_service; 44 private IUserAccountService m_userService; 45 46 #region ICapsServiceConnector Members 47 48 public void RegisterCaps(IRegionClientCapsService service) 49 { 50 m_service = service; 51 m_userService = service.Registry.RequestModuleInterface<IUserAccountService>(); 52 m_profileConnector = Framework.Utilities.DataManager.RequestPlugin<IProfileConnector>(); 53 m_service.AddStreamHandler("MeshUploadFlag", 54 new GenericStreamHandler("GET", m_service.CreateCAPS("MeshUploadFlag", ""), 55 MeshUploadFlagCAP)); 56 } 57 58 public void DeregisterCaps() 59 { 60 m_service.RemoveStreamHandler("MeshUploadFlag", "GET"); 61 } 62 63 public void EnteringRegion() 64 { 65 } 66 67 #endregion 68 69 private byte[] MeshUploadFlagCAP(string path, Stream request, 70 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 71 { 72 OSDMap data = new OSDMap(); 73 IUserProfileInfo info = m_profileConnector.GetUserProfile(m_service.AgentID); 74 75 data["id"] = m_service.AgentID; 76 data["username"] = m_service.ClientCaps.AccountInfo.Name; 77 data["display_name"] = info.DisplayName; 78 data["display_name_next_update"] = Utils.UnixTimeToDateTime(0); 79 data["legacy_first_name"] = m_service.ClientCaps.AccountInfo.FirstName; 80 data["legacy_last_name"] = m_service.ClientCaps.AccountInfo.LastName; 81 data["mesh_upload_status"] = "valid"; // add if account has ability to upload mesh? 82 bool isDisplayNameNDefault = (info.DisplayName == m_service.ClientCaps.AccountInfo.Name) || 83 (info.DisplayName == 84 m_service.ClientCaps.AccountInfo.FirstName + "." + 85 m_service.ClientCaps.AccountInfo.LastName); 86 data["is_display_name_default"] = isDisplayNameNDefault; 87 88 //Send back data 89 return OSDParser.SerializeLLSDXmlBytes(data); 90 } 91 } 92}