change EstateAccess

master
UbitUmarov 2020-04-25 18:54:01 +01:00
parent 8fb4b2f4e3
commit 830b034b81
1 changed files with 23 additions and 27 deletions

View File

@ -29,6 +29,7 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Net;
using System.Text; using System.Text;
using log4net; using log4net;
@ -126,38 +127,33 @@ namespace OpenSim.Region.ClientStack.Linden
public void RegisterCaps(UUID agentID, Caps caps) public void RegisterCaps(UUID agentID, Caps caps)
{ {
string capUrl = "/CAPS/" + UUID.Random() + "/"; caps.RegisterSimpleHandler("EstateAccess",
new SimpleStreamHandler("/" + UUID.Random() + "/",
caps.RegisterHandler( delegate(IOSHttpRequest request, IOSHttpResponse response)
"EstateAccess", {
new RestHTTPHandler( ProcessRequest(request, response, agentID);
"GET", }));
capUrl,
httpMethod => ProcessGetRequest(httpMethod, agentID, caps),
"EstateAccessGet",
agentID.ToString())); ;
} }
public Hashtable ProcessGetRequest(Hashtable request, UUID AgentId, Caps cap) public void ProcessRequest(IOSHttpRequest request, IOSHttpResponse response, UUID AgentId)
{ {
Hashtable responsedata = new Hashtable(); if(request.HttpMethod != "GET")
responsedata["int_response_code"] = 200; //501; //410; //404;
responsedata["content_type"] = "text/plain";
ScenePresence avatar;
if (!m_scene.TryGetScenePresence(AgentId, out avatar))
{ {
responsedata["str_response_string"] = "<llsd><array /></llsd>"; ; response.StatusCode = (int)HttpStatusCode.NotFound;
responsedata["keepalive"] = false; return;
return responsedata;
} }
if (m_scene.RegionInfo == null ScenePresence avatar;
|| m_scene.RegionInfo.EstateSettings == null if (!m_scene.TryGetScenePresence(AgentId, out avatar) || m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null)
||!m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
{ {
responsedata["str_response_string"] = "<llsd><array /></llsd>"; ; response.StatusCode = (int)HttpStatusCode.Gone;
return responsedata; return;
}
if (!m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
{
response.StatusCode = (int)HttpStatusCode.Unauthorized;
return;
} }
EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings; EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings;
@ -242,9 +238,9 @@ namespace OpenSim.Region.ClientStack.Linden
LLSDxmlEncode.AddEmptyArray("Managers", sb); LLSDxmlEncode.AddEmptyArray("Managers", sb);
LLSDxmlEncode.AddEndMap(sb); LLSDxmlEncode.AddEndMap(sb);
responsedata["str_response_string"] = LLSDxmlEncode.End(sb);
return responsedata; response.RawBuffer = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb));
response.StatusCode = (int)HttpStatusCode.OK;
} }
} }
} }