diff options
author | UbitUmarov | 2016-08-18 12:45:11 +0100 |
---|---|---|
committer | UbitUmarov | 2016-08-18 12:45:11 +0100 |
commit | ac542715f1712eaba298a0a8e42c3ce9b0c7f24a (patch) | |
tree | aaf1736359a74b0f1572c6a5f387837770fbd1af /OpenSim/Region/ClientStack | |
parent | several changes on BunchOfCaps. Move some mesh cost initialization to its cla... (diff) | |
download | opensim-SC_OLD-ac542715f1712eaba298a0a8e42c3ce9b0c7f24a.zip opensim-SC_OLD-ac542715f1712eaba298a0a8e42c3ce9b0c7f24a.tar.gz opensim-SC_OLD-ac542715f1712eaba298a0a8e42c3ce9b0c7f24a.tar.bz2 opensim-SC_OLD-ac542715f1712eaba298a0a8e42c3ce9b0c7f24a.tar.xz |
add caps HomeLocation ; add client SendAlertMessage(string message, string info), where info in info message field. only minimal testing done
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 145 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 12 |
2 files changed, 155 insertions, 2 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index c5164ca..bedd3d0 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -193,8 +193,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
193 | 193 | ||
194 | public string GetNewCapPath() | 194 | public string GetNewCapPath() |
195 | { | 195 | { |
196 | UUID tmpid = UUID.Random(); | 196 | return "/CAPS/" + UUID.Random(); |
197 | return "/CAPS/" + tmpid.ToString(); | ||
198 | } | 197 | } |
199 | 198 | ||
200 | /// <summary> | 199 | /// <summary> |
@@ -242,6 +241,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
242 | m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); | 241 | m_HostCapsObj.RegisterHandler("UpdateScriptTaskInventory", req); |
243 | m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); | 242 | m_HostCapsObj.RegisterHandler("UpdateScriptTask", req); |
244 | 243 | ||
244 | IRequestHandler HomeLocationHandler = new RestStreamHandler( | ||
245 | "POST", GetNewCapPath(), HomeLocation, "HomeLocation", null); | ||
246 | m_HostCapsObj.RegisterHandler("HomeLocation", HomeLocationHandler); | ||
247 | |||
245 | // IRequestHandler animSetRequestHandler | 248 | // IRequestHandler animSetRequestHandler |
246 | // = new RestStreamHandler( | 249 | // = new RestStreamHandler( |
247 | // "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null); | 250 | // "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null); |
@@ -1504,6 +1507,144 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1504 | string response = OSDParser.SerializeLLSDXmlString(resp); | 1507 | string response = OSDParser.SerializeLLSDXmlString(resp); |
1505 | return response; | 1508 | return response; |
1506 | } | 1509 | } |
1510 | |||
1511 | public bool OSDMapTOVector3(OSDMap map, out Vector3 v) | ||
1512 | { | ||
1513 | v = Vector3.Zero; | ||
1514 | if(!map.ContainsKey("X")) | ||
1515 | return false; | ||
1516 | if(!map.ContainsKey("Y")) | ||
1517 | return false; | ||
1518 | if(!map.ContainsKey("Z")) | ||
1519 | return false; | ||
1520 | v.X = (float)map["X"].AsReal(); | ||
1521 | v.Y = (float)map["Y"].AsReal(); | ||
1522 | v.Z = (float)map["Z"].AsReal(); | ||
1523 | return true; | ||
1524 | } | ||
1525 | |||
1526 | public string HomeLocation(string request, string path, string param, IOSHttpRequest httpRequest, | ||
1527 | IOSHttpResponse httpResponse) | ||
1528 | { | ||
1529 | OSDMap resp = new OSDMap(); | ||
1530 | |||
1531 | resp["success"] = "false"; | ||
1532 | |||
1533 | |||
1534 | bool fail = true; | ||
1535 | string message = "Set Home request failed"; | ||
1536 | int locationID = 1; | ||
1537 | Vector3 pos = Vector3.Zero; | ||
1538 | Vector3 lookAt = Vector3.Zero; | ||
1539 | |||
1540 | IClientAPI client = null; | ||
1541 | ScenePresence sp; | ||
1542 | |||
1543 | while(true) | ||
1544 | { | ||
1545 | if(m_Scene.GridUserService == null) | ||
1546 | break; | ||
1547 | |||
1548 | if(m_Scene.UserManagementModule == null) | ||
1549 | break; | ||
1550 | |||
1551 | m_Scene.TryGetScenePresence(m_AgentID, out sp); | ||
1552 | if(sp == null || sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit) | ||
1553 | break; | ||
1554 | |||
1555 | client = sp.ControllingClient; | ||
1556 | |||
1557 | if(!m_Scene.UserManagementModule.IsLocalGridUser(m_AgentID)) | ||
1558 | break; | ||
1559 | |||
1560 | OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
1561 | if(!req.ContainsKey("HomeLocation")) | ||
1562 | break; | ||
1563 | |||
1564 | OSDMap HLocation = (OSDMap)req["HomeLocation"]; | ||
1565 | if(!HLocation.ContainsKey("LocationPos")) | ||
1566 | break; | ||
1567 | if(!HLocation.ContainsKey("LocationLookAt")) | ||
1568 | break; | ||
1569 | |||
1570 | locationID = HLocation["LocationId"].AsInteger(); | ||
1571 | |||
1572 | if(!OSDMapTOVector3((OSDMap)HLocation["LocationPos"], out pos)) | ||
1573 | break; | ||
1574 | |||
1575 | if(!OSDMapTOVector3((OSDMap)HLocation["LocationLookAt"], out lookAt)) | ||
1576 | break; | ||
1577 | |||
1578 | ILandObject land = m_Scene.LandChannel.GetLandObject(pos); | ||
1579 | if(land == null) | ||
1580 | break; | ||
1581 | |||
1582 | ulong gpowers = client.GetGroupPowers(land.LandData.GroupID); | ||
1583 | SceneObjectGroup telehub = null; | ||
1584 | if (m_Scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero) | ||
1585 | // Does the telehub exist in the scene? | ||
1586 | telehub = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject); | ||
1587 | |||
1588 | if (!m_Scene.Permissions.IsAdministrator(m_AgentID) && // (a) gods and land managers can set home | ||
1589 | !m_Scene.Permissions.IsGod(m_AgentID) && | ||
1590 | m_AgentID != land.LandData.OwnerID && // (b) land owners can set home | ||
1591 | // (c) members of the land-associated group in roles that can set home | ||
1592 | ((gpowers & (ulong)GroupPowers.AllowSetHome) != (ulong)GroupPowers.AllowSetHome) && | ||
1593 | // (d) parcels with telehubs can be the home of anyone | ||
1594 | (telehub == null || !land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y))) | ||
1595 | { | ||
1596 | message = "You are not allowed to set your home location in this parcel."; | ||
1597 | break; | ||
1598 | } | ||
1599 | |||
1600 | string userId; | ||
1601 | UUID test; | ||
1602 | if (!m_Scene.UserManagementModule.GetUserUUI(m_AgentID, out userId)) | ||
1603 | { | ||
1604 | message = "Set Home request failed. (User Lookup)"; | ||
1605 | break; | ||
1606 | } | ||
1607 | |||
1608 | if (!UUID.TryParse(userId, out test)) | ||
1609 | { | ||
1610 | message = "Set Home request failed. (HG visitor)"; | ||
1611 | break; | ||
1612 | } | ||
1613 | |||
1614 | if (m_Scene.GridUserService.SetHome(userId, land.RegionUUID, pos, lookAt)) | ||
1615 | fail = false; | ||
1616 | |||
1617 | break; | ||
1618 | } | ||
1619 | |||
1620 | string response; | ||
1621 | |||
1622 | if(fail) | ||
1623 | { | ||
1624 | if(client != null) | ||
1625 | client.SendAlertMessage(message, "HomePositionSet"); | ||
1626 | response = OSDParser.SerializeLLSDXmlString(resp); | ||
1627 | return response; | ||
1628 | } | ||
1629 | |||
1630 | // so its http but still needs a udp reply to inform user? crap :p | ||
1631 | if(client != null) | ||
1632 | client.SendAlertMessage("Home position set.","HomePositionSet"); | ||
1633 | |||
1634 | resp["success"] = "true"; | ||
1635 | OSDMap homeloc = new OSDMap(); | ||
1636 | OSDMap homelocpos = new OSDMap(); | ||
1637 | // for some odd reason viewers send pos as reals but read as integer | ||
1638 | homelocpos["X"] = new OSDReal(pos.X); | ||
1639 | homelocpos["Y"] = new OSDReal(pos.Y); | ||
1640 | homelocpos["Z"] = new OSDReal(pos.Z); | ||
1641 | homeloc["LocationPos"] = homelocpos; | ||
1642 | |||
1643 | resp["HomeLocation"] = homeloc; | ||
1644 | |||
1645 | response = OSDParser.SerializeLLSDXmlString(resp); | ||
1646 | return response; | ||
1647 | } | ||
1507 | } | 1648 | } |
1508 | 1649 | ||
1509 | public class AssetUploader | 1650 | public class AssetUploader |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 6275f19..f580e5a 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -2411,6 +2411,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
2411 | OutPacket(alertPack, ThrottleOutPacketType.Task); | 2411 | OutPacket(alertPack, ThrottleOutPacketType.Task); |
2412 | } | 2412 | } |
2413 | 2413 | ||
2414 | public void SendAlertMessage(string message, string info) | ||
2415 | { | ||
2416 | AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage); | ||
2417 | alertPack.AlertData = new AlertMessagePacket.AlertDataBlock(); | ||
2418 | alertPack.AlertData.Message = Util.StringToBytes256(message); | ||
2419 | alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[1]; | ||
2420 | alertPack.AlertInfo[0] = new AlertMessagePacket.AlertInfoBlock(); | ||
2421 | alertPack.AlertInfo[0].Message = Util.StringToBytes256(info); | ||
2422 | alertPack.AlertInfo[0].ExtraParams = new Byte[0]; | ||
2423 | OutPacket(alertPack, ThrottleOutPacketType.Task); | ||
2424 | } | ||
2425 | |||
2414 | /// <summary> | 2426 | /// <summary> |
2415 | /// Send an agent alert message to the client. | 2427 | /// Send an agent alert message to the client. |
2416 | /// </summary> | 2428 | /// </summary> |