replace Enviroment response encoding ( runprebuild needed)
parent
a1a8b5f4a7
commit
942fd5e653
|
@ -1,68 +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 OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Framework.Capabilities
|
||||
{
|
||||
[OSDMap]
|
||||
public class LLSDEnvironmentRequest
|
||||
{
|
||||
public UUID messageID;
|
||||
public UUID regionID;
|
||||
}
|
||||
|
||||
[OSDMap]
|
||||
public class LLSDEnvironmentSetResponse
|
||||
{
|
||||
public UUID regionID;
|
||||
public UUID messageID;
|
||||
public Boolean success;
|
||||
public String fail_reason;
|
||||
}
|
||||
|
||||
public class EnvironmentSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// generates a empty llsd settings response for viewer
|
||||
/// </summary>
|
||||
/// <param name="messageID">the message UUID</param>
|
||||
/// <param name="regionID">the region UUID</param>
|
||||
public static string EmptySettings(UUID messageID, UUID regionID)
|
||||
{
|
||||
OSDArray arr = new OSDArray();
|
||||
LLSDEnvironmentRequest msg = new LLSDEnvironmentRequest();
|
||||
msg.messageID = messageID;
|
||||
msg.regionID = regionID;
|
||||
arr.Array.Add(msg);
|
||||
return LLSDHelpers.SerialiseLLSDReply(arr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Capabilities;
|
||||
|
@ -55,8 +56,6 @@ namespace OpenSim.Region.CoreModules.World.LightShare
|
|||
private static readonly string capsName = "EnvironmentSettings";
|
||||
private static readonly string capsBase = "/CAPS/0020/";
|
||||
|
||||
private LLSDEnvironmentSetResponse setResponse = null;
|
||||
|
||||
#region INonSharedRegionModule
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
|
@ -105,7 +104,6 @@ namespace OpenSim.Region.CoreModules.World.LightShare
|
|||
if (!Enabled)
|
||||
return;
|
||||
|
||||
setResponse = new LLSDEnvironmentSetResponse();
|
||||
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
|
||||
}
|
||||
|
||||
|
@ -179,7 +177,16 @@ namespace OpenSim.Region.CoreModules.World.LightShare
|
|||
}
|
||||
|
||||
if (String.IsNullOrEmpty(env))
|
||||
env = EnvironmentSettings.EmptySettings(UUID.Zero, regionID);
|
||||
{
|
||||
StringBuilder sb = LLSDxmlEncode.Start();
|
||||
LLSDxmlEncode.AddArray(sb);
|
||||
LLSDxmlEncode.AddMap(sb);
|
||||
LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
|
||||
LLSDxmlEncode.AddElem("regionID", regionID, sb);
|
||||
LLSDxmlEncode.AddEndMap(sb);
|
||||
LLSDxmlEncode.AddEndArray(sb);
|
||||
env = LLSDxmlEncode.End(sb);
|
||||
}
|
||||
|
||||
return env;
|
||||
}
|
||||
|
@ -191,33 +198,42 @@ namespace OpenSim.Region.CoreModules.World.LightShare
|
|||
// m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}",
|
||||
// Name, agentID, caps.RegionName);
|
||||
|
||||
setResponse.regionID = regionID;
|
||||
setResponse.success = false;
|
||||
bool success = false;
|
||||
string fail_reason = "";
|
||||
|
||||
if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
|
||||
{
|
||||
setResponse.fail_reason = "Insufficient estate permissions, settings has not been saved.";
|
||||
return LLSDHelpers.SerialiseLLSDReply(setResponse);
|
||||
fail_reason = "Insufficient estate permissions, settings has not been saved.";
|
||||
}
|
||||
|
||||
try
|
||||
else
|
||||
{
|
||||
m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request);
|
||||
setResponse.success = true;
|
||||
try
|
||||
{
|
||||
m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request);
|
||||
success = true;
|
||||
|
||||
m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
|
||||
Name, agentID, caps.RegionName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
|
||||
Name, caps.RegionName, e.Message, e.StackTrace);
|
||||
m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}",
|
||||
Name, agentID, caps.RegionName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}]: Environment settings has not been saved for region {1}, Exception: {2} - {3}",
|
||||
Name, caps.RegionName, e.Message, e.StackTrace);
|
||||
|
||||
setResponse.success = false;
|
||||
setResponse.fail_reason = String.Format("Environment Set for region {0} has failed, settings has not been saved.", caps.RegionName);
|
||||
success = false;
|
||||
fail_reason = String.Format("Environment Set for region {0} has failed, settings not saved.", caps.RegionName);
|
||||
}
|
||||
}
|
||||
|
||||
return LLSDHelpers.SerialiseLLSDReply(setResponse);
|
||||
StringBuilder sb = LLSDxmlEncode.Start();
|
||||
LLSDxmlEncode.AddMap(sb);
|
||||
LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
|
||||
LLSDxmlEncode.AddElem("regionID", regionID, sb);
|
||||
LLSDxmlEncode.AddElem("success", success, sb);
|
||||
if(!success)
|
||||
LLSDxmlEncode.AddElem("fail_reason", fail_reason, sb);
|
||||
LLSDxmlEncode.AddEndMap(sb);
|
||||
return LLSDxmlEncode.End(sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue