add caps HomeLocation ; add client SendAlertMessage(string message, string info), where info in info message field. only minimal testing done

LSLKeyTest
UbitUmarov 2016-08-18 12:45:11 +01:00
parent e58e6daf4a
commit ac542715f1
6 changed files with 171 additions and 3 deletions

View File

@ -1256,9 +1256,11 @@ namespace OpenSim.Framework
void SendAttachedSoundGainChange(UUID objectID, float gain); void SendAttachedSoundGainChange(UUID objectID, float gain);
void SendNameReply(UUID profileId, string firstname, string lastname); void SendNameReply(UUID profileId, string firstname, string lastname);
void SendAlertMessage(string message);
void SendAlertMessage(string message);
void SendAlertMessage(string message, string into);
void SendAgentAlertMessage(string message, bool modal); void SendAgentAlertMessage(string message, bool modal);
void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url); void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url);
/// <summary> /// <summary>

View File

@ -193,8 +193,7 @@ namespace OpenSim.Region.ClientStack.Linden
public string GetNewCapPath() public string GetNewCapPath()
{ {
UUID tmpid = UUID.Random(); return "/CAPS/" + UUID.Random();
return "/CAPS/" + tmpid.ToString();
} }
/// <summary> /// <summary>
@ -242,6 +241,10 @@ namespace OpenSim.Region.ClientStack.Linden
m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req);
m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); m_HostCapsObj.RegisterHandler("UpdateScriptTask", req);
IRequestHandler HomeLocationHandler = new RestStreamHandler(
"POST", GetNewCapPath(), HomeLocation, "HomeLocation", null);
m_HostCapsObj.RegisterHandler("HomeLocation", HomeLocationHandler);
// IRequestHandler animSetRequestHandler // IRequestHandler animSetRequestHandler
// = new RestStreamHandler( // = new RestStreamHandler(
// "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null); // "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null);
@ -1504,6 +1507,144 @@ namespace OpenSim.Region.ClientStack.Linden
string response = OSDParser.SerializeLLSDXmlString(resp); string response = OSDParser.SerializeLLSDXmlString(resp);
return response; return response;
} }
public bool OSDMapTOVector3(OSDMap map, out Vector3 v)
{
v = Vector3.Zero;
if(!map.ContainsKey("X"))
return false;
if(!map.ContainsKey("Y"))
return false;
if(!map.ContainsKey("Z"))
return false;
v.X = (float)map["X"].AsReal();
v.Y = (float)map["Y"].AsReal();
v.Z = (float)map["Z"].AsReal();
return true;
}
public string HomeLocation(string request, string path, string param, IOSHttpRequest httpRequest,
IOSHttpResponse httpResponse)
{
OSDMap resp = new OSDMap();
resp["success"] = "false";
bool fail = true;
string message = "Set Home request failed";
int locationID = 1;
Vector3 pos = Vector3.Zero;
Vector3 lookAt = Vector3.Zero;
IClientAPI client = null;
ScenePresence sp;
while(true)
{
if(m_Scene.GridUserService == null)
break;
if(m_Scene.UserManagementModule == null)
break;
m_Scene.TryGetScenePresence(m_AgentID, out sp);
if(sp == null || sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit)
break;
client = sp.ControllingClient;
if(!m_Scene.UserManagementModule.IsLocalGridUser(m_AgentID))
break;
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
if(!req.ContainsKey("HomeLocation"))
break;
OSDMap HLocation = (OSDMap)req["HomeLocation"];
if(!HLocation.ContainsKey("LocationPos"))
break;
if(!HLocation.ContainsKey("LocationLookAt"))
break;
locationID = HLocation["LocationId"].AsInteger();
if(!OSDMapTOVector3((OSDMap)HLocation["LocationPos"], out pos))
break;
if(!OSDMapTOVector3((OSDMap)HLocation["LocationLookAt"], out lookAt))
break;
ILandObject land = m_Scene.LandChannel.GetLandObject(pos);
if(land == null)
break;
ulong gpowers = client.GetGroupPowers(land.LandData.GroupID);
SceneObjectGroup telehub = null;
if (m_Scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero)
// Does the telehub exist in the scene?
telehub = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject);
if (!m_Scene.Permissions.IsAdministrator(m_AgentID) && // (a) gods and land managers can set home
!m_Scene.Permissions.IsGod(m_AgentID) &&
m_AgentID != land.LandData.OwnerID && // (b) land owners can set home
// (c) members of the land-associated group in roles that can set home
((gpowers & (ulong)GroupPowers.AllowSetHome) != (ulong)GroupPowers.AllowSetHome) &&
// (d) parcels with telehubs can be the home of anyone
(telehub == null || !land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y)))
{
message = "You are not allowed to set your home location in this parcel.";
break;
}
string userId;
UUID test;
if (!m_Scene.UserManagementModule.GetUserUUI(m_AgentID, out userId))
{
message = "Set Home request failed. (User Lookup)";
break;
}
if (!UUID.TryParse(userId, out test))
{
message = "Set Home request failed. (HG visitor)";
break;
}
if (m_Scene.GridUserService.SetHome(userId, land.RegionUUID, pos, lookAt))
fail = false;
break;
}
string response;
if(fail)
{
if(client != null)
client.SendAlertMessage(message, "HomePositionSet");
response = OSDParser.SerializeLLSDXmlString(resp);
return response;
}
// so its http but still needs a udp reply to inform user? crap :p
if(client != null)
client.SendAlertMessage("Home position set.","HomePositionSet");
resp["success"] = "true";
OSDMap homeloc = new OSDMap();
OSDMap homelocpos = new OSDMap();
// for some odd reason viewers send pos as reals but read as integer
homelocpos["X"] = new OSDReal(pos.X);
homelocpos["Y"] = new OSDReal(pos.Y);
homelocpos["Z"] = new OSDReal(pos.Z);
homeloc["LocationPos"] = homelocpos;
resp["HomeLocation"] = homeloc;
response = OSDParser.SerializeLLSDXmlString(resp);
return response;
}
} }
public class AssetUploader public class AssetUploader

View File

@ -2411,6 +2411,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(alertPack, ThrottleOutPacketType.Task); OutPacket(alertPack, ThrottleOutPacketType.Task);
} }
public void SendAlertMessage(string message, string info)
{
AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
alertPack.AlertData.Message = Util.StringToBytes256(message);
alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[1];
alertPack.AlertInfo[0] = new AlertMessagePacket.AlertInfoBlock();
alertPack.AlertInfo[0].Message = Util.StringToBytes256(info);
alertPack.AlertInfo[0].ExtraParams = new Byte[0];
OutPacket(alertPack, ThrottleOutPacketType.Task);
}
/// <summary> /// <summary>
/// Send an agent alert message to the client. /// Send an agent alert message to the client.
/// </summary> /// </summary>

View File

@ -1217,6 +1217,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
} }
public void SendAlertMessage(string message, string info)
{
}
public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
{ {
IRC_SendChannelPrivmsg(objectname,url); IRC_SendChannelPrivmsg(objectname,url);

View File

@ -885,6 +885,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{ {
} }
public void SendAlertMessage(string message, string info)
{
}
public void SendSystemAlertMessage(string message) public void SendSystemAlertMessage(string message)
{ {
} }

View File

@ -861,6 +861,10 @@ namespace OpenSim.Tests.Common
{ {
} }
public void SendAlertMessage(string message, string info)
{
}
public void SendSystemAlertMessage(string message) public void SendSystemAlertMessage(string message)
{ {
} }