コード例 #1
0
        public void ChatterBoxSessionStartReply(UUID sessionID, string sessionName, int type,
                                                bool voiceEnabled, bool voiceModerated, UUID tmpSessionID,
                                                bool sucess, string error,
                                                UUID toAgent)
        {
            StringBuilder sb = StartEvent("ChatterBoxSessionStartReply");

            LLSDxmlEncode.AddElem("session_id", sessionID, sb);
            LLSDxmlEncode.AddElem("temp_session_id", tmpSessionID, sb);
            LLSDxmlEncode.AddElem("success", sucess, sb);
            if (sucess)
            {
                LLSDxmlEncode.AddMap("session_info", sb);
                LLSDxmlEncode.AddMap("moderated_mode", sb);
                LLSDxmlEncode.AddElem("voice", voiceModerated, sb);
                LLSDxmlEncode.AddEndMap(sb);
                LLSDxmlEncode.AddElem("session_name", sessionName, sb);
                LLSDxmlEncode.AddElem("type", type, sb);
                LLSDxmlEncode.AddElem("voice_enabled", voiceEnabled, sb);
                LLSDxmlEncode.AddEndMap(sb);
            }
            else
            {
                LLSDxmlEncode.AddElem("error", String.IsNullOrEmpty(error) ? "" : error, sb);
            }

            Enqueue(EndEventToBytes(sb), toAgent);
        }
コード例 #2
0
        public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID toAgent, List <GroupChatListAgentUpdateData> updates)
        {
            StringBuilder sb = StartEvent("ChatterBoxSessionAgentListUpdates", 1024);

            LLSDxmlEncode.AddMap("agent_updates", sb);
            foreach (GroupChatListAgentUpdateData up in updates)
            {
                LLSDxmlEncode.AddMap(up.agentID.ToString(), sb);
                LLSDxmlEncode.AddMap("info", sb);
                LLSDxmlEncode.AddElem("can_voice_chat", up.canVoice, sb);
                LLSDxmlEncode.AddElem("is_moderator", up.isModerator, sb);
                LLSDxmlEncode.AddMap("mutes", sb);
                LLSDxmlEncode.AddElem("text", up.mutedText, sb);
                LLSDxmlEncode.AddEndMap(sb);     // mutes
                LLSDxmlEncode.AddEndMap(sb);     // info
                if (up.enterOrLeave)
                {
                    LLSDxmlEncode.AddElem("transition", "ENTER", sb);
                }
                else
                {
                    LLSDxmlEncode.AddElem("transition", "LEAVE", sb);
                }
                LLSDxmlEncode.AddEndMap(sb); //agentid
            }
            LLSDxmlEncode.AddEndMap(sb);     // agent_updates
            LLSDxmlEncode.AddEmptyMap("updates", sb);
            LLSDxmlEncode.AddElem("session_id", sessionID, sb);

            Enqueue(EndEventToBytes(sb), toAgent);
        }
コード例 #3
0
        private string GetEnvironmentSettings(string request, string path, string param,
                                              UUID agentID, Caps caps)
        {
            //            m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}",
            //                Name, agentID, caps.RegionName);

            string env = String.Empty;

            try
            {
                env = m_scene.SimulationDataService.LoadRegionEnvironmentSettings(regionID);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[{0}]: Unable to load environment settings for region {1}, Exception: {2} - {3}",
                                  Name, caps.RegionName, e.Message, e.StackTrace);
            }

            if (String.IsNullOrEmpty(env))
            {
                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);
        }
コード例 #4
0
        public void WindlightRefreshEvent(int interpolate, UUID avatarID)
        {
            StringBuilder sb = StartEvent("WindLightRefresh");

            LLSDxmlEncode.AddElem("Interpolate", interpolate > 0 ? 1 : 0, sb);
            Enqueue(EndEventToBytes(sb), avatarID);
        }
コード例 #5
0
        public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
                                        IPEndPoint newRegionExternalEndPoint,
                                        string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>",
                                  LogHeader, handle, avatarID, regionSizeX, regionSizeY);
            }

            StringBuilder sb = StartEvent("CrossedRegion");

            LLSDxmlEncode.AddArrayAndMap("AgentData", sb);
            LLSDxmlEncode.AddElem("AgentID", avatarID, sb);
            LLSDxmlEncode.AddElem("SessionID", sessionID, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            LLSDxmlEncode.AddArrayAndMap("Info", sb);
            LLSDxmlEncode.AddElem("LookAt", lookAt, sb);
            LLSDxmlEncode.AddElem("Position", pos, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            LLSDxmlEncode.AddArrayAndMap("RegionData", sb);
            LLSDxmlEncode.AddElem("RegionHandle", handle, sb);
            LLSDxmlEncode.AddElem("SeedCapability", capsURL, sb);
            LLSDxmlEncode.AddElem("SimIP", newRegionExternalEndPoint.Address.GetAddressBytes(), sb);
            LLSDxmlEncode.AddElem("SimPort", newRegionExternalEndPoint.Port, sb);
            LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb);
            LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, avatarID);
        }
コード例 #6
0
        public void FetchInventorySimpleRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, OSDMap requestmap, ExpiringKey <UUID> BadRequests)
        {
            //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);

            if (BadRequests == null)
            {
                httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            OSDArray itemsRequested = (OSDArray)requestmap["items"];

            UUID[] itemIDs = new UUID[itemsRequested.Count];
            int    i       = 0;

            foreach (OSDMap osdItemId in itemsRequested)
            {
                UUID id = osdItemId["item_id"].AsUUID();
                if (!BadRequests.ContainsKey(id))
                {
                    itemIDs[i++] = id;
                }
            }

            InventoryItemBase[] items = null;
            try
            {
                // badrequests still not filled
                items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
            }
            catch { }

            StringBuilder lsl = LLSDxmlEncode.Start(4096);

            LLSDxmlEncode.AddMap(lsl);

            LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);

            if (items == null || items.Length == 0)
            {
                LLSDxmlEncode.AddEmptyArray("items", lsl);
            }
            else
            {
                LLSDxmlEncode.AddArray("items", lsl);
                foreach (InventoryItemBase item in items)
                {
                    if (item != null)
                    {
                        item.ToLLSDxml(lsl, 0xff);
                    }
                }
                LLSDxmlEncode.AddEndArray(lsl);
            }

            LLSDxmlEncode.AddEndMap(lsl);
            httpResponse.RawBuffer  = Util.UTF8.GetBytes(LLSDxmlEncode.End(lsl));
            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }
コード例 #7
0
        public void ChatterBoxForceClose(UUID toAgent, UUID sessionID, string reason)
        {
            StringBuilder sb = StartEvent("ForceCloseChatterBoxSession");

            LLSDxmlEncode.AddElem("session_id", sessionID, sb);
            LLSDxmlEncode.AddElem("reason", reason, sb);

            Enqueue(EndEventToBytes(sb), toAgent);
        }
コード例 #8
0
        public StringBuilder StartEvent(string eventName, int cap)
        {
            StringBuilder sb = osStringBuilderCache.Acquire();

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("message", eventName, sb);
            LLSDxmlEncode.AddMap("body", sb);

            return(sb);
        }
コード例 #9
0
ファイル: EventQueueHelper.cs プロジェクト: osCore2/osCore2
        }                             // no construction possible, it's an utility class

        public static StringBuilder StartEvent(string eventName)
        {
            StringBuilder sb = new StringBuilder(256);

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("message", eventName, sb);
            LLSDxmlEncode.AddMap("body", sb);

            return(sb);
        }
コード例 #10
0
        public static string KeepAliveEvent()
        {
            StringBuilder sb = new StringBuilder(256);

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("message", "FAKEEVENT", sb);
            LLSDxmlEncode.AddMap("body", sb);
            LLSDxmlEncode.AddEndMap(sb); // close body
            LLSDxmlEncode.AddEndMap(sb); // close event
            return(sb.ToString());
        }
コード例 #11
0
        public void ScriptRunningEvent(UUID objectID, UUID itemID, bool running, UUID avatarID)
        {
            StringBuilder sb = StartEvent("ScriptRunningReply");

            LLSDxmlEncode.AddArrayAndMap("Script", sb);
            LLSDxmlEncode.AddElem("ObjectID", objectID, sb);
            LLSDxmlEncode.AddElem("ItemID", itemID, sb);
            LLSDxmlEncode.AddElem("Running", running, sb);
            LLSDxmlEncode.AddElem("Mono", true, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            Enqueue(EndEventToBytes(sb), avatarID);
        }
コード例 #12
0
        private void GetEnvironmentSettings(IOSHttpResponse response, UUID agentID)
        {
            // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}",
            //      Name, agentID, caps.RegionName);

            ViewerEnvironment VEnv = null;
            ScenePresence     sp   = m_scene.GetScenePresence(agentID);

            if (sp != null && sp.Environment != null)
            {
                VEnv = sp.Environment;
            }
            else
            {
                if (m_scene.RegionInfo.EstateSettings.AllowEnvironmentOverride)
                {
                    ILandObject land = m_scene.LandChannel.GetLandObject(sp.AbsolutePosition.X, sp.AbsolutePosition.Y);
                    if (land != null && land.LandData != null && land.LandData.Environment != null)
                    {
                        VEnv = land.LandData.Environment;
                    }
                }
                if (VEnv == null)
                {
                    VEnv = GetRegionEnvironment();
                }
            }

            //OSD d = VEnv.ToWLOSD(UUID.Zero, regionID);
            //string env = OSDParser.SerializeLLSDXmlString(d);

            //if (String.IsNullOrEmpty(env))
            byte[] envBytes = VEnv.ToCapWLBytes(UUID.Zero, regionID);
            if (envBytes == null)
            {
                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);
                response.RawBuffer = LLSDxmlEncode.EndToNBBytes(sb);
            }
            else
            {
                response.RawBuffer = envBytes;
            }

            response.StatusCode = (int)HttpStatusCode.OK;
        }
コード例 #13
0
        public string toLLSDxml(StringBuilder sb = null)
        {
            const float scale    = 10000f;
            bool        fullLLSD = false;

            if (sb == null)
            {
                sb       = LLSDxmlEncode.Start(1024, false);
                fullLLSD = true;
            }

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("NormMap", NormalMapID, sb);
            LLSDxmlEncode.AddElem("NormOffsetX", (int)(scale * NormalOffsetX + 0.5f), sb);
            LLSDxmlEncode.AddElem("NormOffsetY", (int)(scale * NormalOffsetY + 0.5f), sb);
            LLSDxmlEncode.AddElem("NormRepeatX", (int)(scale * NormalRepeatX + 0.5f), sb);
            LLSDxmlEncode.AddElem("NormRepeatY", (int)(scale * NormalRepeatY + 0.5f), sb);
            LLSDxmlEncode.AddElem("NormRotation", (int)(scale * NormalRotation + 0.5f), sb);

            LLSDxmlEncode.AddElem("SpecMap", SpecularMapID, sb);
            LLSDxmlEncode.AddElem("SpecOffsetX", (int)(scale * SpecularOffsetX + 0.5f), sb);
            LLSDxmlEncode.AddElem("SpecOffsetY", (int)(scale * SpecularOffsetY + 0.5f), sb);
            LLSDxmlEncode.AddElem("SpecRepeatX", (int)(scale * SpecularRepeatX + 0.5f), sb);
            LLSDxmlEncode.AddElem("SpecRepeatY", (int)(scale * SpecularRepeatY + 0.5f), sb);
            LLSDxmlEncode.AddElem("SpecRotation", (int)(scale * SpecularRotation + 0.5f), sb);

            LLSDxmlEncode.AddArray("SpecColor", sb);
            LLSDxmlEncode.AddElem(SpecularLightColorR, sb);
            LLSDxmlEncode.AddElem(SpecularLightColorG, sb);
            LLSDxmlEncode.AddElem(SpecularLightColorB, sb);
            LLSDxmlEncode.AddElem(255, sb);
            LLSDxmlEncode.AddEndArray(sb);

            LLSDxmlEncode.AddElem("SpecExp", SpecularLightExponent, sb);
            LLSDxmlEncode.AddElem("EnvIntensity", EnvironmentIntensity, sb);
            LLSDxmlEncode.AddElem("DiffuseAlphaMode", DiffuseAlphaMode, sb);
            LLSDxmlEncode.AddElem("AlphaMaskCutoff", AlphaMaskCutoff, sb);

            LLSDxmlEncode.AddEndMap(sb);

            if (fullLLSD)
            {
                return(LLSDxmlEncode.End(sb));
            }
            else
            {
                return(String.Empty); // ignored if appending
            }
        }
コード例 #14
0
        public void partPhysicsProperties(uint localID, byte physhapetype,
                                          float density, float friction, float bounce, float gravmod, UUID avatarID)
        {
            StringBuilder sb = StartEvent("ObjectPhysicsProperties");

            LLSDxmlEncode.AddArrayAndMap("ObjectData", sb);
            LLSDxmlEncode.AddElem("LocalID", (int)localID, sb);
            LLSDxmlEncode.AddElem("Density", density, sb);
            LLSDxmlEncode.AddElem("Friction", friction, sb);
            LLSDxmlEncode.AddElem("GravityMultiplier", gravmod, sb);
            LLSDxmlEncode.AddElem("Restitution", bounce, sb);
            LLSDxmlEncode.AddElem("PhysicsShapeType", (int)physhapetype, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            Enqueue(EndEventToBytes(sb), avatarID);
        }
コード例 #15
0
        private string SetEnvironmentSettings(string request, string path, string param,
                                              UUID agentID, Caps caps)
        {
            //            m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}",
            //                Name, agentID, caps.RegionName);

            bool   success     = false;
            string fail_reason = "";

            if (!m_scene.Permissions.CanIssueEstateCommand(agentID, false))
            {
                fail_reason = "Insufficient estate permissions, settings has not been saved.";
            }
            else
            {
                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);

                    success     = false;
                    fail_reason = String.Format("Environment Set for region {0} has failed, settings not saved.", caps.RegionName);
                }
            }

            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));
        }
コード例 #16
0
        public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data)
        {
            StringBuilder sb = StartEvent("AgentGroupDataUpdate");

            LLSDxmlEncode.AddArrayAndMap("AgentData", sb);
            LLSDxmlEncode.AddElem("AgentID", AgentID, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            if (data.Length == 0)
            {
                LLSDxmlEncode.AddEmptyArray("GroupData", sb);
                LLSDxmlEncode.AddEmptyArray("NewGroupData", sb);
            }
            else
            {
                List <bool> lstInProfiles = new List <bool>(data.Length);
                LLSDxmlEncode.AddArray("GroupData", sb);
                foreach (GroupMembershipData m in data)
                {
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("GroupID", m.GroupID, sb);
                    LLSDxmlEncode.AddElem("GroupPowers", m.GroupPowers, sb);
                    LLSDxmlEncode.AddElem("AcceptNotices", m.AcceptNotices, sb);
                    LLSDxmlEncode.AddElem("GroupInsigniaID", m.GroupPicture, sb);
                    LLSDxmlEncode.AddElem("Contribution", m.Contribution, sb);
                    LLSDxmlEncode.AddElem("GroupName", m.GroupName, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                    lstInProfiles.Add(m.ListInProfile);
                }
                LLSDxmlEncode.AddEndArray(sb);

                LLSDxmlEncode.AddArray("NewGroupData", sb);
                foreach (bool b in lstInProfiles)
                {
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("ListInProfile", b, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, AgentID);
        }
コード例 #17
0
        public void ChatterboxInvitation(UUID sessionID, string sessionName,
                                         UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog,
                                         uint timeStamp, bool offline, int parentEstateID, Vector3 position,
                                         uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket)
        {
            StringBuilder sb = StartEvent("ChatterBoxInvitation");

            LLSDxmlEncode.AddElem("session_id", sessionID, sb);
            LLSDxmlEncode.AddElem("from_name", fromName, sb);
            LLSDxmlEncode.AddElem("session_name", sessionName, sb);
            LLSDxmlEncode.AddElem("from_id", fromAgent, sb);

            LLSDxmlEncode.AddLLSD(InstantMessageBody(fromAgent, message, toAgent,
                                                     fromName, dialog, timeStamp, offline, parentEstateID, position,
                                                     ttl, transactionID, fromGroup, binaryBucket, true, 0, true), sb);

            Enqueue(EndEventToBytes(sb), toAgent);
        }
コード例 #18
0
        public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}",
                                  LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY);
            }

            StringBuilder sb = StartEvent("EnableSimulator");

            LLSDxmlEncode.AddArrayAndMap("SimulatorInfo", sb);
            LLSDxmlEncode.AddElem("Handle", handle, sb);
            LLSDxmlEncode.AddElem("IP", endPoint.Address.GetAddressBytes(), sb);
            LLSDxmlEncode.AddElem("Port", endPoint.Port, sb);
            LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb);
            LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            Enqueue(EndEventToBytes(sb), avatarID);
        }
コード例 #19
0
        public void PlacesQueryReply(UUID avatarID, UUID queryID, UUID transactionID, PlacesReplyData[] replyDataArray)
        {
            StringBuilder sb = new StringBuilder(256);

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("message", "PlacesReplyMessage", sb);
            LLSDxmlEncode.AddMap("QueryData[]", sb); LLSDxmlEncode.AddArray(sb);
            LLSDxmlEncode.AddArray("AgentData", sb);
            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("AgentID", avatarID, sb);
            LLSDxmlEncode.AddElem("QueryID", queryID, sb);
            LLSDxmlEncode.AddElem("TransactionID", transactionID, sb);
            LLSDxmlEncode.AddEndMap(sb);
            LLSDxmlEncode.AddEndArray(sb);

            LLSDxmlEncode.AddArray("QueryData", sb);

            for (int i = 0; i < replyDataArray.Length; ++i)
            {
                PlacesReplyData data = replyDataArray[i];
                LLSDxmlEncode.AddMap(sb);
                LLSDxmlEncode.AddElem("ActualArea", data.ActualArea, sb);
                LLSDxmlEncode.AddElem("BillableArea", data.BillableArea, sb);
                LLSDxmlEncode.AddElem("Description", data.Desc, sb);
                LLSDxmlEncode.AddElem("Dwell", data.Dwell, sb);
                LLSDxmlEncode.AddElem("Flags", data.Flags, sb);
                LLSDxmlEncode.AddElem("GlobalX", data.GlobalX, sb);
                LLSDxmlEncode.AddElem("GlobalY", data.GlobalY, sb);
                LLSDxmlEncode.AddElem("GlobalZ", data.GlobalZ, sb);
                LLSDxmlEncode.AddElem("Name", data.Name, sb);
                LLSDxmlEncode.AddElem("OwnerID", data.OwnerID, sb);
                LLSDxmlEncode.AddElem("SimName", data.SimName, sb);
                LLSDxmlEncode.AddElem("SnapShotID", data.SnapshotID, sb);
                LLSDxmlEncode.AddElem("ProductSku", (int)0, sb);
                LLSDxmlEncode.AddElem("Price", data.Price, sb);
                LLSDxmlEncode.AddEndMap(sb);
            }
            LLSDxmlEncode.AddEndArray(sb);

            Enqueue(EndEventToBytes(sb), avatarID);
        }
コード例 #20
0
        public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath,
                                                        ulong regionHandle, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}",
                                  LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY);
            }

            StringBuilder sb = StartEvent("EstablishAgentCommunication");

            LLSDxmlEncode.AddElem("agent-id", avatarID, sb);
            LLSDxmlEncode.AddElem("sim-ip-and-port", endPoint.ToString(), sb);
            LLSDxmlEncode.AddElem("seed-capability", capsPath, sb);
            // current viewers ignore this, also not needed its sent on enablesim
            //LLSDxmlEncode.AddElem("region-handle", regionHandle, sb);
            //LLSDxmlEncode.AddElem("region-size-x", (uint)regionSizeX, sb);
            //LLSDxmlEncode.AddElem("region-size-y", (uint)regionSizeY, sb);

            Enqueue(EndEventToBytes(sb), avatarID);
        }
コード例 #21
0
        private static string InstantMessageBody(UUID fromAgent, string message, UUID toAgent,
                                                 string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID,
                                                 Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket,
                                                 bool checkEstate, int godLevel, bool limitedToEstate)
        {
            StringBuilder sb = new StringBuilder(512);

            LLSDxmlEncode.AddMap("instantmessage", sb);
            LLSDxmlEncode.AddMap("message_params", sb); //messageParams
            LLSDxmlEncode.AddElem("type", dialog, sb);
            LLSDxmlEncode.AddElem("position", position, sb);
            LLSDxmlEncode.AddElem("region_id", UUID.Zero, sb);
            LLSDxmlEncode.AddElem("to_id", toAgent, sb);
            LLSDxmlEncode.AddElem("source", 0, sb);

            LLSDxmlEncode.AddMap("data", sb); //messageParams data
            LLSDxmlEncode.AddElem("binary_bucket", binaryBucket, sb);
            LLSDxmlEncode.AddEndMap(sb);      //messageParams data

            LLSDxmlEncode.AddElem("message", message, sb);
            LLSDxmlEncode.AddElem("id", transactionID, sb);
            LLSDxmlEncode.AddElem("from_name", fromName, sb);
            LLSDxmlEncode.AddElem("timestamp", timeStamp, sb);
            LLSDxmlEncode.AddElem("offline", (offline ? 1 : 0), sb);
            LLSDxmlEncode.AddElem("parent_estate_id", parentEstateID, sb);
            LLSDxmlEncode.AddElem("ttl", (int)ttl, sb);
            LLSDxmlEncode.AddElem("from_id", fromAgent, sb);
            LLSDxmlEncode.AddElem("from_group", fromGroup, sb);
            LLSDxmlEncode.AddEndMap(sb); //messageParams

            LLSDxmlEncode.AddMap("agent_params", sb);
            LLSDxmlEncode.AddElem("agent_id", fromAgent, sb);
            LLSDxmlEncode.AddElem("check_estate", checkEstate, sb);
            LLSDxmlEncode.AddElem("god_level", godLevel, sb);
            LLSDxmlEncode.AddElem("limited_to_estate", limitedToEstate, sb);
            LLSDxmlEncode.AddEndMap(sb); // agent params
            LLSDxmlEncode.AddEndMap(sb);

            return(sb.ToString());
        }
コード例 #22
0
        public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess,
                                                IPEndPoint regionExternalEndPoint,
                                                uint locationID, uint flags, string capsURL,
                                                UUID avatarID, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}",
                                  LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY);
            }

            // not sure why flags get overwritten here
            if ((flags & (uint)TeleportFlags.IsFlying) != 0)
            {
                flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying;
            }
            else
            {
                flags = (uint)TeleportFlags.ViaLocation;
            }

            StringBuilder sb = StartEvent("TeleportFinish");

            LLSDxmlEncode.AddArrayAndMap("Info", sb);
            LLSDxmlEncode.AddElem("AgentID", avatarID, sb);
            LLSDxmlEncode.AddElem("LocationID", (uint)4, sb);     // TODO what is this?
            LLSDxmlEncode.AddElem("SimIP", regionExternalEndPoint.Address.GetAddressBytes(), sb);
            LLSDxmlEncode.AddElem("SimPort", regionExternalEndPoint.Port, sb);
            LLSDxmlEncode.AddElem("RegionHandle", regionHandle, sb);
            LLSDxmlEncode.AddElem("SeedCapability", capsURL, sb);
            LLSDxmlEncode.AddElem("SimAccess", (int)simAccess, sb);
            LLSDxmlEncode.AddElem("TeleportFlags", flags, sb);
            LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb);
            LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, avatarID);
        }
コード例 #23
0
        private void DeleteExtEnvironmentSettings(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID agentID)
        {
            int parcel = -1;

            if (httpRequest.Query.Count > 0)
            {
                if (httpRequest.Query.ContainsKey("parcelid"))
                {
                    Int32.TryParse((string)httpRequest.Query["parcelid"], out parcel);
                }
            }

            if (parcel == -1)
            {
                StoreOnRegion(null);
                WindlightRefresh(0);
            }
            else
            {
                ILandObject land = m_scene.LandChannel.GetLandObject(parcel);
                if (land != null && land.LandData != null)
                {
                    land.StoreEnvironment(null);
                    WindlightRefresh(0, false);
                }
            }

            StringBuilder sb = LLSDxmlEncode.Start();

            LLSDxmlEncode.AddMap(sb);
            LLSDxmlEncode.AddElem("messageID", UUID.Zero, sb);
            LLSDxmlEncode.AddElem("regionID", regionID, sb);
            LLSDxmlEncode.AddElem("success", true, sb);
            LLSDxmlEncode.AddEndMap(sb);
            httpResponse.RawBuffer  = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb));
            httpResponse.StatusCode = (int)HttpStatusCode.OK;
        }
コード例 #24
0
        public void FetchInventoryDescendentsRequest(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, ExpiringKey <UUID> BadRequests)
        {
            //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);

            List <LLSDFetchInventoryDescendents> folders = null;
            List <UUID> bad_folders = new List <UUID>();

            try
            {
                OSDArray foldersrequested = null;
                OSD      tmp = OSDParser.DeserializeLLSDXml(httpRequest.InputStream);
                httpRequest.InputStream.Dispose();

                OSDMap map = (OSDMap)tmp;
                if (map.TryGetValue("folders", out tmp) && tmp is OSDArray)
                {
                    foldersrequested = tmp as OSDArray;
                }

                if (foldersrequested == null || foldersrequested.Count == 0)
                {
                    httpResponse.RawBuffer = EmptyResponse;
                    return;
                }

                folders = new List <LLSDFetchInventoryDescendents>(foldersrequested.Count);
                for (int i = 0; i < foldersrequested.Count; i++)
                {
                    OSDMap mfolder = foldersrequested[i] as OSDMap;
                    UUID   id      = mfolder["folder_id"].AsUUID();
                    if (BadRequests.ContainsKey(id))
                    {
                        bad_folders.Add(id);
                    }
                    else
                    {
                        LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
                        try
                        {
                            llsdRequest.folder_id     = id;
                            llsdRequest.owner_id      = mfolder["owner_id"].AsUUID();
                            llsdRequest.sort_order    = mfolder["sort_order"].AsInteger();
                            llsdRequest.fetch_folders = mfolder["fetch_folders"].AsBoolean();
                            llsdRequest.fetch_items   = mfolder["fetch_items"].AsBoolean();
                        }
                        catch (Exception e)
                        {
                            m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e.Message);
                            continue;
                        }
                        folders.Add(llsdRequest);
                    }
                }
                foldersrequested = null;
                map.Clear();
                map = null;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FETCH INV DESC]: fail parsing request: {0}", e.Message);
                httpResponse.RawBuffer = EmptyResponse;
                return;
            }

            if (folders == null || folders.Count == 0)
            {
                if (bad_folders.Count == 0)
                {
                    httpResponse.RawBuffer = EmptyResponse;
                    return;
                }

                StringBuilder sb = osStringBuilderCache.Acquire();
                sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by ");
                sb.Append("Unknown");
                sb.Append(" :");
                int limit = 5;
                int count = 0;
                foreach (UUID bad in bad_folders)
                {
                    if (BadRequests.ContainsKey(bad))
                    {
                        continue;
                    }
                    sb.Append(" ");
                    sb.Append(bad.ToString());
                    ++count;
                    if (--limit < 0)
                    {
                        break;
                    }
                }

                if (count > 0)
                {
                    if (limit < 0)
                    {
                        sb.Append(" ...");
                    }
                    m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb));
                }
                else
                {
                    osStringBuilderCache.Release(sb);
                }

                sb = osStringBuilderCache.Acquire();
                sb.Append("<llsd><map><key>folders</key><array /></map><map><key>bad_folders</key><array>");
                foreach (UUID bad in bad_folders)
                {
                    sb.Append("<map><key>folder_id</key><uuid>");
                    sb.Append(bad.ToString());
                    sb.Append("</uuid><key>error</key><string>Unknown</string></map>");
                }
                sb.Append("</array></map></llsd>");
                httpResponse.RawBuffer = Util.UTF8NBGetbytes(osStringBuilderCache.GetStringAndRelease(sb));
                return;
            }

            int total_folders = 0;
            int total_items   = 0;

            UUID requester = folders[0].owner_id;

            List <InventoryCollection> invcollSet = Fetch(folders, bad_folders, ref total_folders, ref total_items);
            //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count);

            int invcollSetCount = 0;

            if (invcollSet != null)
            {
                invcollSetCount = invcollSet.Count;
            }

            int mem = 8192 + ((256 * invcollSetCount +
                               384 * total_folders +
                               1024 * total_items +
                               128 * bad_folders.Count) & 0x7ffff000);

            StringBuilder lastresponse = new StringBuilder(mem);

            lastresponse.Append("<llsd>");

            if (invcollSetCount > 0)
            {
                lastresponse.Append("<map><key>folders</key><array>");
                int i = 0;
                InventoryCollection thiscoll;
                for (i = 0; i < invcollSetCount; i++)
                {
                    thiscoll      = invcollSet[i];
                    invcollSet[i] = null;

                    LLSDxmlEncode.AddMap(lastresponse);
                    LLSDxmlEncode.AddElem("agent_id", thiscoll.OwnerID, lastresponse);
                    LLSDxmlEncode.AddElem("descendents", thiscoll.Descendents, lastresponse);
                    LLSDxmlEncode.AddElem("folder_id", thiscoll.FolderID, lastresponse);

                    if (thiscoll.Folders == null || thiscoll.Folders.Count == 0)
                    {
                        LLSDxmlEncode.AddEmptyArray("categories", lastresponse);
                    }
                    else
                    {
                        LLSDxmlEncode.AddArray("categories", lastresponse);
                        foreach (InventoryFolderBase invFolder in thiscoll.Folders)
                        {
                            LLSDxmlEncode.AddMap(lastresponse);

                            LLSDxmlEncode.AddElem("folder_id", invFolder.ID, lastresponse);
                            LLSDxmlEncode.AddElem("parent_id", invFolder.ParentID, lastresponse);
                            LLSDxmlEncode.AddElem("name", invFolder.Name, lastresponse);
                            LLSDxmlEncode.AddElem("type", invFolder.Type, lastresponse);
                            LLSDxmlEncode.AddElem("preferred_type", (int)-1, lastresponse);
                            LLSDxmlEncode.AddElem("version", invFolder.Version, lastresponse);

                            LLSDxmlEncode.AddEndMap(lastresponse);
                        }
                        LLSDxmlEncode.AddEndArray(lastresponse);
                    }

                    if (thiscoll.Items == null || thiscoll.Items.Count == 0)
                    {
                        LLSDxmlEncode.AddEmptyArray("items", lastresponse);
                    }
                    else
                    {
                        LLSDxmlEncode.AddArray("items", lastresponse);
                        foreach (InventoryItemBase invItem in thiscoll.Items)
                        {
                            invItem.ToLLSDxml(lastresponse);
                        }

                        LLSDxmlEncode.AddEndArray(lastresponse);
                    }

                    LLSDxmlEncode.AddElem("owner_id", thiscoll.OwnerID, lastresponse);
                    LLSDxmlEncode.AddElem("version", thiscoll.Version, lastresponse);

                    LLSDxmlEncode.AddEndMap(lastresponse);
                    invcollSet[i] = null;
                }
                lastresponse.Append("</array></map>");
                thiscoll = null;
            }
            else
            {
                lastresponse.Append("<map><key>folders</key><array /></map>");
            }

            if (bad_folders.Count > 0)
            {
                lastresponse.Append("<map><key>bad_folders</key><array>");
                foreach (UUID bad in bad_folders)
                {
                    BadRequests.Add(bad);
                    lastresponse.Append("<map><key>folder_id</key><uuid>");
                    lastresponse.Append(bad.ToString());
                    lastresponse.Append("</uuid><key>error</key><string>Unknown</string></map>");
                }
                lastresponse.Append("</array></map>");

                StringBuilder sb = osStringBuilderCache.Acquire();
                sb.Append("[WEB FETCH INV DESC HANDLER]: Unable to fetch folders owned by ");
                sb.Append(requester.ToString());
                sb.Append(" :");
                int limit = 9;
                foreach (UUID bad in bad_folders)
                {
                    sb.Append(" ");
                    sb.Append(bad.ToString());
                    if (--limit < 0)
                    {
                        break;
                    }
                }
                if (limit < 0)
                {
                    sb.Append(" ...");
                }
                m_log.Warn(osStringBuilderCache.GetStringAndRelease(sb));
            }
            lastresponse.Append("</llsd>");

            httpResponse.RawBuffer = Util.UTF8NBGetbytes(lastresponse.ToString());
        }
コード例 #25
0
        public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request);

            OSDMap   requestmap     = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
            OSDArray itemsRequested = (OSDArray)requestmap["items"];

            UUID[] itemIDs = new UUID[itemsRequested.Count];
            int    i       = 0;

            foreach (OSDMap osdItemId in itemsRequested)
            {
                itemIDs[i++] = osdItemId["item_id"].AsUUID();
            }

            InventoryItemBase[] items = null;

            if (m_agentID != UUID.Zero)
            {
                items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
            }
            else
            {
                items = new InventoryItemBase[itemsRequested.Count];
                foreach (UUID id in itemIDs)
                {
                    items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
                }
            }

            StringBuilder lsl = LLSDxmlEncode.Start(4096);

            LLSDxmlEncode.AddMap(lsl);

            if (m_agentID == UUID.Zero && items.Length > 0)
            {
                LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl);
            }
            else
            {
                LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
            }

            if (items == null || items.Length == 0)
            {
                LLSDxmlEncode.AddEmptyArray("items", lsl);
            }
            else
            {
                LLSDxmlEncode.AddArray("items", lsl);
                foreach (InventoryItemBase item in items)
                {
                    if (item != null)
                    {
                        item.ToLLSDxml(lsl, 0xff);
                    }
                }
                LLSDxmlEncode.AddEndArray(lsl);
            }

            LLSDxmlEncode.AddEndMap(lsl);
            return(LLSDxmlEncode.End(lsl));;
        }
コード例 #26
0
ファイル: EventQueueHelper.cs プロジェクト: osCore2/osCore2
 public static string EndEvent(StringBuilder sb)
 {
     LLSDxmlEncode.AddEndMap(sb); // close body
     LLSDxmlEncode.AddEndMap(sb); // close event
     return(sb.ToString());
 }
コード例 #27
0
        public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap)
        {
            Hashtable responsedata = new Hashtable();

            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>";;
                responsedata["keepalive"]           = false;
                return(responsedata);
            }

            if (m_scene.RegionInfo == null ||
                m_scene.RegionInfo.EstateSettings == null ||
                !m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
            {
                responsedata["str_response_string"] = "<llsd><array /></llsd>";;
                return(responsedata);
            }

            EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings;

            UUID[]      managers   = regionSettings.EstateManagers;
            UUID[]      allowed    = regionSettings.EstateAccess;
            UUID[]      groups     = regionSettings.EstateGroups;
            EstateBan[] EstateBans = regionSettings.EstateBans;

            StringBuilder sb = LLSDxmlEncode.Start();

            LLSDxmlEncode.AddMap(sb);

            if (allowed != null && allowed.Length > 0)
            {
                LLSDxmlEncode.AddArray("AllowedAgents", sb);
                for (int i = 0; i < allowed.Length; ++i)
                {
                    UUID id = allowed[i];
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("id", id, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }

            if (groups != null && groups.Length > 0)
            {
                LLSDxmlEncode.AddArray("AllowedGroups", sb);
                for (int i = 0; i < groups.Length; ++i)
                {
                    UUID id = groups[i];
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("id", id, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }

            if (EstateBans != null && EstateBans.Length > 0)
            {
                LLSDxmlEncode.AddArray("BannedAgents", sb);
                for (int i = 0; i < EstateBans.Length; ++i)
                {
                    EstateBan ban = EstateBans[i];
                    UUID      id  = ban.BannedUserID;
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("id", id, sb);
                    LLSDxmlEncode.AddElem("banning_id", ban.BanningUserID, sb);
                    LLSDxmlEncode.AddElem("last_login_date", "na", sb);     // We will not have this. This information is far at grid
                    if (ban.BanTime == 0)
                    {
                        LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00", sb);
                    }
                    else
                    {
                        LLSDxmlEncode.AddElem("ban_date", (Util.ToDateTime(ban.BanTime)).ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), sb);
                    }
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }

            if (managers != null && managers.Length > 0)
            {
                LLSDxmlEncode.AddArray("Managers", sb);
                for (int i = 0; i < managers.Length; ++i)
                {
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("agent_id", managers[i], sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }

            LLSDxmlEncode.AddEndMap(sb);
            responsedata["str_response_string"] = LLSDxmlEncode.End(sb);

            return(responsedata);
        }
コード例 #28
0
        public void ProcessRequest(IOSHttpRequest request, IOSHttpResponse response, UUID AgentId)
        {
            if (request.HttpMethod != "GET")
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                return;
            }

            ScenePresence avatar;

            if (!m_scene.TryGetScenePresence(AgentId, out avatar) || m_scene.RegionInfo == null || m_scene.RegionInfo.EstateSettings == null)
            {
                response.StatusCode = (int)HttpStatusCode.Gone;
                return;
            }

            if (!m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
            {
                response.StatusCode = (int)HttpStatusCode.Unauthorized;
                return;
            }

            EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings;

            UUID[]      managers   = regionSettings.EstateManagers;
            UUID[]      allowed    = regionSettings.EstateAccess;
            UUID[]      groups     = regionSettings.EstateGroups;
            EstateBan[] EstateBans = regionSettings.EstateBans;

            StringBuilder sb = LLSDxmlEncode.Start();

            LLSDxmlEncode.AddMap(sb);

            if (allowed != null && allowed.Length > 0)
            {
                LLSDxmlEncode.AddArray("AllowedAgents", sb);
                for (int i = 0; i < allowed.Length; ++i)
                {
                    UUID id = allowed[i];
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("id", id, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }
            else
            {
                LLSDxmlEncode.AddEmptyArray("AllowedAgents", sb);
            }

            if (groups != null && groups.Length > 0)
            {
                LLSDxmlEncode.AddArray("AllowedGroups", sb);
                for (int i = 0; i < groups.Length; ++i)
                {
                    UUID id = groups[i];
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("id", id, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }
            else
            {
                LLSDxmlEncode.AddEmptyArray("AllowedGroups", sb);
            }

            if (EstateBans != null && EstateBans.Length > 0)
            {
                LLSDxmlEncode.AddArray("BannedAgents", sb);
                for (int i = 0; i < EstateBans.Length; ++i)
                {
                    EstateBan ban = EstateBans[i];
                    UUID      id  = ban.BannedUserID;
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("id", id, sb);
                    LLSDxmlEncode.AddElem("banning_id", ban.BanningUserID, sb);
                    LLSDxmlEncode.AddElem("last_login_date", "na", sb); // We will not have this. This information is far at grid
                    if (ban.BanTime == 0)
                    {
                        LLSDxmlEncode.AddElem("ban_date", "0000-00-00 00:00", sb);
                    }
                    else
                    {
                        LLSDxmlEncode.AddElem("ban_date", (Util.ToDateTime(ban.BanTime)).ToString("yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture), sb);
                    }
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }
            else
            {
                LLSDxmlEncode.AddEmptyArray("BannedAgents", sb);
            }

            if (managers != null && managers.Length > 0)
            {
                LLSDxmlEncode.AddArray("Managers", sb);
                for (int i = 0; i < managers.Length; ++i)
                {
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("agent_id", managers[i], sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }
            else
            {
                LLSDxmlEncode.AddEmptyArray("Managers", sb);
            }

            LLSDxmlEncode.AddEndMap(sb);

            response.RawBuffer  = Util.UTF8.GetBytes(LLSDxmlEncode.End(sb));
            response.StatusCode = (int)HttpStatusCode.OK;
        }
コード例 #29
0
        public Hashtable ProcessRequest(Hashtable request, UUID AgentId, Caps cap)
        {
            Hashtable responsedata = new Hashtable();

            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>";;
                responsedata["keepalive"]           = false;
                return(responsedata);
            }

            if (m_scene.RegionInfo == null ||
                m_scene.RegionInfo.EstateSettings == null ||
                !m_scene.Permissions.CanIssueEstateCommand(AgentId, false))
            {
                responsedata["str_response_string"] = "<llsd><array /></llsd>";;
                return(responsedata);
            }

            EstateSettings regionSettings = m_scene.RegionInfo.EstateSettings;

            UUID[]      managers   = regionSettings.EstateManagers;
            UUID[]      allowed    = regionSettings.EstateAccess;
            UUID[]      groups     = regionSettings.EstateGroups;
            EstateBan[] EstateBans = regionSettings.EstateBans;

            StringBuilder sb = LLSDxmlEncode.Start();

            LLSDxmlEncode.AddArray(sb);

            if (allowed != null && allowed.Length > 0)
            {
                LLSDxmlEncode.AddMap("AllowedAgents", sb);
                for (int i = 0; i < allowed.Length; ++i)
                {
                    UUID id = allowed[i];
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddElem("id", id, sb);
                }
                LLSDxmlEncode.AddEndMap(sb);
            }

            if (groups != null && groups.Length > 0)
            {
                LLSDxmlEncode.AddMap("AllowedGroups", sb);
                for (int i = 0; i < groups.Length; ++i)
                {
                    UUID id = groups[i];
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddElem("id", id, sb);
                }
                LLSDxmlEncode.AddEndMap(sb);
            }

            if (EstateBans != null && EstateBans.Length > 0)
            {
                LLSDxmlEncode.AddMap("BannedAgents", sb);
                for (int i = 0; i < EstateBans.Length; ++i)
                {
                    UUID id = EstateBans[i].BannedUserID;
                    if (id == UUID.Zero)
                    {
                        continue;
                    }
                    LLSDxmlEncode.AddElem("id", id, sb);
                }
                LLSDxmlEncode.AddEndMap(sb);
            }

            if (managers != null && managers.Length > 0)
            {
                LLSDxmlEncode.AddMap("Managers", sb);
                for (int i = 0; i < managers.Length; ++i)
                {
                    LLSDxmlEncode.AddElem("id", managers[i], sb);
                }
                LLSDxmlEncode.AddEndMap(sb);
            }

            LLSDxmlEncode.AddEndArray(sb);
            responsedata["str_response_string"] = LLSDxmlEncode.End(sb);

            return(responsedata);
        }
コード例 #30
0
        public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            //m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);

            ArrayList foldersrequested = null;

            try
            {
                Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request));
                foldersrequested = (ArrayList)hash["folders"];
                hash             = null;
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[FETCH INV DESC]: fail parsing request: '{0}'; path: '{1}'; exception: '{2}'", request, path, e.Message);
                foldersrequested = null;
            }

            if (foldersrequested == null || foldersrequested.Count == 0)
            {
                return("<llsd><map><key>folders</key><array /></map></llsd>");
            }

            List <LLSDFetchInventoryDescendents> folders = new List <LLSDFetchInventoryDescendents>();

            for (int i = 0; i < foldersrequested.Count; i++)
            {
                Hashtable inventoryhash = (Hashtable)foldersrequested[i];
                LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();

                try
                {
                    LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest);
                }
                catch (Exception e)
                {
                    m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e.Message);
                    continue;
                }

                folders.Add(llsdRequest);
            }

            foldersrequested.Clear();

            if (folders.Count == 0)
            {
                return("<llsd><map><key>folders</key><array /></map></llsd>");
            }

            List <UUID> bad_folders = new List <UUID>();

            int total_folders = 0;
            int total_items   = 0;
            List <InventoryCollection> invcollSet = Fetch(folders, bad_folders, ref total_folders, ref total_items);
            //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count);

            int invcollSetCount = 0;

            if (invcollSet != null)
            {
                invcollSetCount = invcollSet.Count;
            }

            int mem = 8192 + ((256 * invcollSetCount +
                               384 * total_folders +
                               1024 * total_items +
                               128 * bad_folders.Count) & 0x7ffff000);

            StringBuilder lastresponse = new StringBuilder(mem);

            lastresponse.Append("<llsd>");

            if (invcollSetCount > 0)
            {
                lastresponse.Append("<map><key>folders</key><array>");
                int i = 0;
                InventoryCollection thiscoll;
                for (i = 0; i < invcollSetCount; i++)
                {
                    thiscoll      = invcollSet[i];
                    invcollSet[i] = null;

                    LLSDxmlEncode.AddMap(lastresponse);
                    LLSDxmlEncode.AddElem("agent_id", thiscoll.OwnerID, lastresponse);
                    LLSDxmlEncode.AddElem("descendents", thiscoll.Descendents, lastresponse);
                    LLSDxmlEncode.AddElem("folder_id", thiscoll.FolderID, lastresponse);

                    if (thiscoll.Folders == null || thiscoll.Folders.Count == 0)
                    {
                        LLSDxmlEncode.AddEmptyArray("categories", lastresponse);
                    }
                    else
                    {
                        LLSDxmlEncode.AddArray("categories", lastresponse);
                        foreach (InventoryFolderBase invFolder in thiscoll.Folders)
                        {
                            LLSDxmlEncode.AddMap(lastresponse);

                            LLSDxmlEncode.AddElem("folder_id", invFolder.ID, lastresponse);
                            LLSDxmlEncode.AddElem("parent_id", invFolder.ParentID, lastresponse);
                            LLSDxmlEncode.AddElem("name", invFolder.Name, lastresponse);
                            LLSDxmlEncode.AddElem("type", invFolder.Type, lastresponse);
                            LLSDxmlEncode.AddElem("preferred_type", (int)-1, lastresponse);
                            LLSDxmlEncode.AddElem("version", invFolder.Version, lastresponse);

                            LLSDxmlEncode.AddEndMap(lastresponse);
                        }
                        LLSDxmlEncode.AddEndArray(lastresponse);
                    }

                    if (thiscoll.Items == null || thiscoll.Items.Count == 0)
                    {
                        LLSDxmlEncode.AddEmptyArray("items", lastresponse);
                    }
                    else
                    {
                        LLSDxmlEncode.AddArray("items", lastresponse);
                        foreach (InventoryItemBase invItem in thiscoll.Items)
                        {
                            invItem.ToLLSDxml(lastresponse);
                        }

                        LLSDxmlEncode.AddEndArray(lastresponse);
                    }

                    LLSDxmlEncode.AddElem("owner_id", thiscoll.OwnerID, lastresponse);
                    LLSDxmlEncode.AddElem("version", thiscoll.Version, lastresponse);

                    LLSDxmlEncode.AddEndMap(lastresponse);
                    invcollSet[i] = null;
                }
                lastresponse.Append("</array></map>");
                thiscoll = null;
            }
            else
            {
                lastresponse.Append("<map><key>folders</key><array /></map>");
            }

            //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders));
            if (bad_folders.Count > 0)
            {
                lastresponse.Append("<map><key>bad_folders</key><array>");
                foreach (UUID bad in bad_folders)
                {
                    lastresponse.Append("<map><key>folder_id</key><uuid>");
                    lastresponse.Append(bad.ToString());
                    lastresponse.Append("</uuid><key>error</key><string>Unknown</string></map>");
                }
                lastresponse.Append("</array></map>");
            }
            lastresponse.Append("</llsd>");

            return(lastresponse.ToString());
        }