aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps
diff options
context:
space:
mode:
authorUbitUmarov2016-08-19 02:26:49 +0100
committerUbitUmarov2016-08-19 02:26:49 +0100
commitd701de402101f8ecc4a1892bb2d7cf296bd9b990 (patch)
tree897d89adff3c5ff6f451bd02d72ad2a908101292 /OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps
parentMerge branch 'master' of opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-d701de402101f8ecc4a1892bb2d7cf296bd9b990.zip
opensim-SC-d701de402101f8ecc4a1892bb2d7cf296bd9b990.tar.gz
opensim-SC-d701de402101f8ecc4a1892bb2d7cf296bd9b990.tar.bz2
opensim-SC-d701de402101f8ecc4a1892bb2d7cf296bd9b990.tar.xz
add cap GroupMemberData
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs133
1 files changed, 132 insertions, 1 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index f5b46bd..c3305cf 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -41,6 +41,7 @@ using log4net;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Framework.Capabilities; 42using OpenSim.Framework.Capabilities;
43using OpenSim.Region.Framework; 43using OpenSim.Region.Framework;
44using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Scenes.Serialization; 46using OpenSim.Region.Framework.Scenes.Serialization;
46using OpenSim.Framework.Servers; 47using OpenSim.Framework.Servers;
@@ -123,6 +124,7 @@ namespace OpenSim.Region.ClientStack.Linden
123 private float m_PrimScaleMin = 0.001f; 124 private float m_PrimScaleMin = 0.001f;
124 125
125 private bool m_AllowCapHomeLocation = true; 126 private bool m_AllowCapHomeLocation = true;
127 private bool m_AllowCapGroupMemberData = true;
126 128
127 private enum FileAgentInventoryState : int 129 private enum FileAgentInventoryState : int
128 { 130 {
@@ -185,7 +187,10 @@ namespace OpenSim.Region.ClientStack.Linden
185 string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost"); 187 string homeLocationUrl = CapsConfig.GetString("Cap_HomeLocation", "localhost");
186 if(homeLocationUrl == String.Empty) 188 if(homeLocationUrl == String.Empty)
187 m_AllowCapHomeLocation = false; 189 m_AllowCapHomeLocation = false;
188 190
191 string GroupMemberDataUrl = CapsConfig.GetString("Cap_GroupMemberData", "localhost");
192 if(GroupMemberDataUrl == String.Empty)
193 m_AllowCapGroupMemberData = false;
189 } 194 }
190 } 195 }
191 196
@@ -258,6 +263,15 @@ namespace OpenSim.Region.ClientStack.Linden
258 "POST", GetNewCapPath(), HomeLocation, "HomeLocation", null); 263 "POST", GetNewCapPath(), HomeLocation, "HomeLocation", null);
259 m_HostCapsObj.RegisterHandler("HomeLocation", HomeLocationHandler); 264 m_HostCapsObj.RegisterHandler("HomeLocation", HomeLocationHandler);
260 } 265 }
266
267 if(m_AllowCapGroupMemberData)
268 {
269 IRequestHandler GroupMemberDataHandler = new RestStreamHandler(
270 "POST", GetNewCapPath(), GroupMemberData, "GroupMemberData", null);
271 m_HostCapsObj.RegisterHandler("GroupMemberData", GroupMemberDataHandler);
272 }
273
274
261// IRequestHandler animSetRequestHandler 275// IRequestHandler animSetRequestHandler
262// = new RestStreamHandler( 276// = new RestStreamHandler(
263// "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null); 277// "POST", capsBase + m_animSetTaskUpdatePath, AnimSetTaskInventory, "UpdateScript", null);
@@ -1658,6 +1672,123 @@ namespace OpenSim.Region.ClientStack.Linden
1658 response = OSDParser.SerializeLLSDXmlString(resp); 1672 response = OSDParser.SerializeLLSDXmlString(resp);
1659 return response; 1673 return response;
1660 } 1674 }
1675
1676 private static int CompareRolesByMembersDesc(GroupRolesData x, GroupRolesData y)
1677 {
1678 return -(x.Members.CompareTo(y.Members));
1679 }
1680
1681 public string GroupMemberData(string request, string path, string param, IOSHttpRequest httpRequest,
1682 IOSHttpResponse httpResponse)
1683 {
1684 OSDMap resp = new OSDMap();
1685
1686 string response;
1687
1688 bool fail = true;
1689 IClientAPI client = null;
1690 ScenePresence sp;
1691 IGroupsModule m_GroupsModule;
1692 UUID groupID = UUID.Zero;
1693
1694 while(true)
1695 {
1696 m_GroupsModule = m_Scene.RequestModuleInterface<IGroupsModule>();
1697 if(m_GroupsModule == null)
1698 break;
1699
1700 m_Scene.TryGetScenePresence(m_AgentID, out sp);
1701 if(sp == null || sp.IsChildAgent || sp.IsDeleted || sp.IsInTransit)
1702 break;
1703
1704 client = sp.ControllingClient;
1705
1706 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
1707 if(!req.ContainsKey("group_id"))
1708 break;
1709
1710 groupID = req["group_id"].AsUUID();
1711 if(groupID == UUID.Zero)
1712 break;
1713
1714 List<GroupRolesData> roles = m_GroupsModule.GroupRoleDataRequest(client, groupID);
1715 if(roles == null || roles.Count == 0)
1716 break;
1717
1718 List<GroupMembersData> members = m_GroupsModule.GroupMembersRequest(client, groupID);
1719 if(members == null || members.Count == 0)
1720 break;
1721
1722 int memberCount = members.Count;
1723
1724 Dictionary<string,int> titles = new Dictionary<string,int>();
1725 int i = 0;
1726
1727 ulong defaultPowers = 0;
1728
1729
1730 // build titles array and index
1731 roles.Sort(CompareRolesByMembersDesc);
1732
1733 OSDArray osdtitles = new OSDArray();
1734 foreach(GroupRolesData grd in roles)
1735 {
1736 string title = grd.Title;
1737 if(i==0)
1738 defaultPowers = grd.Powers;
1739
1740 if(!titles.ContainsKey(title))
1741 {
1742 titles[title] = i++;
1743 osdtitles.Add(new OSDString(title));
1744 }
1745 }
1746
1747 OSDMap osdmembers = new OSDMap();
1748 foreach(GroupMembersData gmd in members)
1749 {
1750 OSDMap m = new OSDMap();
1751 if(gmd.OnlineStatus != null && gmd.OnlineStatus != "")
1752 m["last_login"] = new OSDString(gmd.OnlineStatus);
1753 if(gmd.AgentPowers != defaultPowers)
1754 m["powers"] = new OSDString((gmd.AgentPowers).ToString("X"));
1755 if(titles.ContainsKey(gmd.Title) && titles[gmd.Title] != 0)
1756 m["title"] = new OSDInteger(titles[gmd.Title]);
1757 if(gmd.IsOwner)
1758 m["owner"] = new OSDString("true");
1759 if(gmd.Contribution != 0)
1760 m["donated_square_meters"] = new OSDInteger(gmd.Contribution);
1761
1762 osdmembers[(gmd.AgentID).ToString()] = m;
1763 }
1764
1765 OSDMap osddefaults = new OSDMap();
1766 osddefaults["default_powers"] = new OSDString(defaultPowers.ToString("X"));
1767
1768 resp["group_id"] = new OSDUUID(groupID);
1769 resp["agent_id"] = new OSDUUID(m_AgentID);
1770 resp["member_count"] = new OSDInteger(memberCount);
1771 resp["defaults"] = osddefaults;
1772 resp["titles"] = osdtitles;
1773 resp["members"] = osdmembers;
1774
1775 fail = false;
1776 break;
1777 }
1778
1779 if(fail)
1780 {
1781 resp["group_id"] = new OSDUUID(groupID);
1782 resp["agent_id"] = new OSDUUID(m_AgentID);
1783 resp["member_count"] = new OSDInteger(0);
1784 resp["defaults"] = new OSDMap();
1785 resp["titles"] = new OSDArray();
1786 resp["members"] = new OSDMap();
1787 }
1788
1789 response = OSDParser.SerializeLLSDXmlString(resp);
1790 return response;
1791 }
1661 } 1792 }
1662 1793
1663 public class AssetUploader 1794 public class AssetUploader