/// <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);
 }
예제 #2
0
파일: MapCAPS.cs 프로젝트: kow/Aurora-Sim
        /// <summary>
        /// Callback for a map layer request
        /// </summary>
        /// <param name="request"></param>
        /// <param name="path"></param>
        /// <param name="param"></param>
        /// <param name="agentID"></param>
        /// <param name="caps"></param>
        /// <returns></returns>
        public string MapLayerRequest(string request, string path, string param,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID agentID)
        {
            int bottom = (m_service.RegionY / Constants.RegionSize) - 100;
            int top = (int)(m_service.RegionY / Constants.RegionSize) + 100;
            int left = (int)(m_service.RegionX / Constants.RegionSize) - 100;
            int right = (int)(m_service.RegionX / Constants.RegionSize) + 100;

            OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(request);

            int flags = map["Flags"].AsInteger();

            OSDArray layerData = new OSDArray();
            layerData.Add(GetOSDMapLayerResponse(bottom, left, right, top, new UUID("00000000-0000-1111-9999-000000000006")));
            OSDArray mapBlocksData = new OSDArray();

            List<MapBlockData> mapBlocks = new List<MapBlockData>();
            if (m_allowCapsMessage)
            {
                if (m_mapLayer != null && m_mapLayer.Count != 0)
                {
                    mapBlocks = m_mapLayer;
                }
                else
                {
                    List<GridRegion> regions = m_gridService.GetRegionRange (UUID.Zero,
                            left * (int)Constants.RegionSize,
                            right * (int)Constants.RegionSize,
                            bottom * (int)Constants.RegionSize,
                            top * (int)Constants.RegionSize);
                    foreach (GridRegion r in regions)
                    {
                        if (flags == 0) //Map
                            mapBlocks.Add (MapBlockFromGridRegion (r));
                        else
                            mapBlocks.Add (TerrainBlockFromGridRegion (r));
                    }
                    m_mapLayer = mapBlocks;
                }
            }
            foreach (MapBlockData block in m_mapLayer)
            {
                //Add to the array
                mapBlocksData.Add(block.ToOSD());
            }
            OSDMap response = MapLayerResponce(layerData, mapBlocksData, flags);
            string resp = OSDParser.SerializeLLSDXmlString(response);
            return resp;
        }
예제 #3
0
        public string HandleFetchLib(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", AgentID);

                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

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

                string response = "";
                OSDMap map = new OSDMap();
                map.Add("agent_id", OSD.FromUUID(AgentID));
                OSDArray items = new OSDArray();
                for (int i = 0; i < foldersrequested.Count; i++)
                {
                    OSDMap requestedFolders = (OSDMap)foldersrequested[i];
                    UUID owner_id = requestedFolders["owner_id"].AsUUID();
                    UUID item_id = requestedFolders["item_id"].AsUUID();
                    InventoryItemBase item = null;
                    if (m_libraryService != null && m_libraryService.LibraryRootFolder != null)
                    {
                        item = m_libraryService.LibraryRootFolder.FindItem(item_id);
                    }
                    if (item == null) //Try normal inventory them
                        item = m_inventoryService.GetItem(new InventoryItemBase(item_id, owner_id));
                    if (item != null)
                    {
                        items.Add(ConvertInventoryItem(item, owner_id));
                    }
                }
                map.Add("items", items);

                response = OSDParser.SerializeLLSDXmlString(map);
                return response;
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();
            rmap["folders"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlString(rmap);
        }
예제 #4
0
        protected void HandleSaveAvatarArchive(string module, string[] cmdparams)
        {
            if (cmdparams.Length != 7)
            {
                m_log.Debug("[AvatarArchive] Not enough parameters!");
            }
            UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]);
            if (account == null)
            {
                m_log.Error("[AvatarArchive] User not found!");
                return;
            }

            AvatarData avatarData = AvatarService.GetAvatar(account.PrincipalID);
            AvatarAppearance appearance = avatarData.ToAvatarAppearance(account.PrincipalID);
            OSDMap map = new OSDMap();
            OSDMap body = new OSDMap();
            OSDMap assets = new OSDMap();
            OSDMap items = new OSDMap();
            body.Add("AvatarHeight", OSD.FromReal(appearance.AvatarHeight));
            body.Add("BodyAsset", OSD.FromUUID(appearance.BodyAsset));
            body.Add("BodyItem", OSD.FromUUID(appearance.BodyItem));
            body.Add("EyesAsset", OSD.FromUUID(appearance.EyesAsset));
            body.Add("EyesItem", OSD.FromUUID(appearance.EyesItem));
            body.Add("GlovesAsset", OSD.FromUUID(appearance.GlovesAsset));
            body.Add("GlovesItem", OSD.FromUUID(appearance.GlovesItem));
            body.Add("HairAsset", OSD.FromUUID(appearance.HairAsset));
            body.Add("HairItem", OSD.FromUUID(appearance.HairItem));
            body.Add("HipOffset", OSD.FromReal(appearance.HipOffset));
            body.Add("JacketAsset", OSD.FromUUID(appearance.JacketAsset));
            body.Add("JacketItem", OSD.FromUUID(appearance.JacketItem));
            body.Add("Owner", OSD.FromUUID(appearance.Owner));
            body.Add("PantsAsset", OSD.FromUUID(appearance.PantsAsset));
            body.Add("Serial", OSD.FromInteger(appearance.Serial));
            body.Add("ShirtAsset", OSD.FromUUID(appearance.ShirtAsset));
            body.Add("ShirtItem", OSD.FromUUID(appearance.ShirtItem));
            body.Add("ShoesAsset", OSD.FromUUID(appearance.ShoesAsset));
            body.Add("ShoesItem", OSD.FromUUID(appearance.ShoesItem));
            body.Add("SkinAsset", OSD.FromUUID(appearance.SkinAsset));
            body.Add("SkirtAsset", OSD.FromUUID(appearance.SkirtAsset));
            body.Add("SkirtItem", OSD.FromUUID(appearance.SkirtItem));
            body.Add("SocksAsset", OSD.FromUUID(appearance.SocksAsset));
            body.Add("SocksItem", OSD.FromUUID(appearance.SocksItem));
            body.Add("UnderPantsAsset", OSD.FromUUID(appearance.UnderPantsAsset));
            body.Add("UnderPantsItem", OSD.FromUUID(appearance.UnderPantsItem));
            body.Add("UnderShirtAsset", OSD.FromUUID(appearance.UnderShirtAsset));
            body.Add("UnderShirtItem", OSD.FromUUID(appearance.UnderShirtItem));
            body.Add("TattooAsset", OSD.FromUUID(appearance.TattooAsset));
            body.Add("TattooItem", OSD.FromUUID(appearance.TattooItem));
            body.Add("AlphaAsset", OSD.FromUUID(appearance.AlphaAsset));
            body.Add("AlphaItem", OSD.FromUUID(appearance.AlphaItem));
            body.Add("FolderName", OSD.FromString(cmdparams[6]));
            body.Add("VisualParams", OSD.FromBinary(appearance.VisualParams));

            OSDArray wearables = new OSDArray();
            foreach (AvatarWearable wear in appearance.Wearables)
            {
                OSDMap wearable = new OSDMap();
                if (wear.AssetID != UUID.Zero)
                {
                    SaveAsset(wear.AssetID, assets);
                    SaveItem(wear.ItemID, items);
                }
                wearable.Add("Asset", wear.AssetID);
                wearable.Add("Item", wear.ItemID);
                wearables.Add(wearable);
            }
            body.Add("AvatarWearables", wearables);

            body.Add("Texture", appearance.Texture.GetOSD());

            OSDArray attachmentsArray = new OSDArray();

            Hashtable attachments = appearance.GetAttachments();
            if (attachments != null)
            {
                foreach (DictionaryEntry element in attachments)
                {
                    Hashtable attachInfo = (Hashtable)element.Value;
                    InventoryItemBase IB = new InventoryItemBase(UUID.Parse(attachInfo["item"].ToString()));
                    OSDMap attachment = new OSDMap();
                    SaveAsset(IB.AssetID, assets);
                    SaveItem(UUID.Parse(attachInfo["item"].ToString()), items);
                    attachment.Add("Asset", OSD.FromUUID(IB.AssetID));
                    attachment.Add("Item", OSD.FromUUID(UUID.Parse(attachInfo["item"].ToString())));
                    attachment.Add("Point", OSD.FromInteger((int)element.Key));
                    attachmentsArray.Add(attachment);
                }
            }

            body.Add("Attachments", attachmentsArray);

            map.Add("Body", body);
            map.Add("Assets", assets);
            map.Add("Items", items);
            //Write the map

            if (cmdparams[5].EndsWith(".database"))
            {
                //Remove the .database
                string ArchiveName = cmdparams[5].Substring(0, cmdparams[5].Length - 9);
                string ArchiveXML = OSDParser.SerializeLLSDXmlString(map);

                AvatarArchive archive = new AvatarArchive();
                archive.ArchiveXML = ArchiveXML;
                archive.Name = ArchiveName;

                DataManager.RequestPlugin<IAvatarArchiverConnector>().SaveAvatarArchive(archive);

                m_log.Debug("[AvatarArchive] Saved archive to database " + cmdparams[5]);
            }
            else
            {
                StreamWriter writer = new StreamWriter(cmdparams[5]);
                writer.Write(OSDParser.SerializeLLSDXmlString(map));
                writer.Close();
                writer.Dispose();
                m_log.Debug("[AvatarArchive] Saved archive to " + cmdparams[5]);
            }
        }
예제 #5
0
파일: MapCAPS.cs 프로젝트: kow/Aurora-Sim
 protected static OSDMap MapLayerResponce(OSDArray layerData, OSDArray mapBlocksData, int flags)
 {
     OSDMap map = new OSDMap();
     OSDMap agentMap = new OSDMap();
     agentMap["Flags"] = flags;
     map["AgentData"] = agentMap;
     map["LayerData"] = layerData;
     map["MapBlocks"] = mapBlocksData;
     return map;
 }
예제 #6
0
        public byte[] HandleFetchLib(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received FetchLib request for {0}", AgentID);

                OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

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

                OSDMap map = new OSDMap();
                map.Add("agent_id", OSD.FromUUID(AgentID));
                OSDArray items = new OSDArray();
                for (int i = 0; i < foldersrequested.Count; i++)
                {
                    OSDMap requestedFolders = (OSDMap)foldersrequested[i];
                    //UUID owner_id = requestedFolders["owner_id"].AsUUID();
                    UUID item_id = requestedFolders["item_id"].AsUUID();
                    OSDArray item = m_inventoryService.GetItem(item_id);
                    if(item != null && item.Count > 0)
                        items.Add(item[0]);
                }
                map.Add("items", items);

                byte[] response = OSDParser.SerializeLLSDXmlBytes(map);
                map.Clear();
                return response;
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();
            rmap["items"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlBytes(rmap);
        }
예제 #7
0
        public byte[] HandleWebFetchInventoryDescendents(string request, UUID AgentID)
        {
            OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml (request);
            OSDArray foldersrequested = (OSDArray)map["folders"];
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received WebFetchInventoryDescendents request for {0}", AgentID);

                return Aurora.DataManager.DataManager.RequestPlugin<IInventoryData>().FetchInventoryReply(foldersrequested, AgentID);
            }
            catch(Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            finally
            {
                map = null;
                foldersrequested = null;
            }
            OSDMap rmap = new OSDMap();
            rmap["folders"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlBytes(rmap);
        }
예제 #8
0
 public bool RequestHandler(string response, OSDArray events, UUID avatarID, ulong RegionHandle)
 {
     OSD r = OSDParser.DeserializeJson(response);
     if (r.Type == OSDType.Map)
     {
         OSDMap result = (OSDMap)r;
         if (result != null)
         {
             bool success = result["success"].AsBoolean();
             if (!success)
             {
                 m_log.Warn("[EventQueueServicesConnector]: Failed to post EQMessage for user " + avatarID);
             }
             else
                 return success;
         }
     }
     return false;
 }
예제 #9
0
        private byte[] ProcessAvatarPickerSearch(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
            string amt = query.GetOne("page-size");
            string name = query.GetOne("names");
            List<UserAccount> accounts = m_service.Registry.RequestModuleInterface<IUserAccountService>().GetUserAccounts(UUID.Zero, name);

            if (accounts == null)
                accounts = new List<UserAccount>(0);
            OSDMap body = new OSDMap();
            OSDArray array = new OSDArray();
            foreach (UserAccount account in accounts)
            {
                OSDMap map = new OSDMap();
                map["agent_id"] = account.PrincipalID;
                IUserProfileInfo profileInfo = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector>().GetUserProfile(account.PrincipalID);
                map["display_name"] = (profileInfo == null || profileInfo.DisplayName == "") ? account.Name : profileInfo.DisplayName;
                map["username"] = account.Name;
                array.Add(map);
            }

            body["agents"] = array;
            byte[] m = OSDParser.SerializeLLSDXmlBytes(body);
            httpResponse.Body.Write(m, 0, m.Length);
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            httpResponse.Send();
            return null;
        }
예제 #10
0
        private void PackUserInfo(IUserProfileInfo info, UserAccount account, ref OSDArray agents)
        {
            OSDMap agentMap = new OSDMap ();
            agentMap["username"] = account.Name;
            agentMap["display_name"] = info.DisplayName;
            agentMap["display_name_next_update"] = OSD.FromDate (DateTime.ParseExact ("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", System.Globalization.DateTimeFormatInfo.InvariantInfo).ToUniversalTime ());
            agentMap["legacy_first_name"] = account.FirstName;
            agentMap["legacy_last_name"] = account.LastName;
            agentMap["id"] = info.PrincipalID;
            agentMap["is_display_name_default"] = isDefaultDisplayName (account.FirstName, account.LastName, account.Name, info.DisplayName);

            agents.Add (agentMap);
        }
예제 #11
0
        /// <summary>
        /// Get the user's display name, currently not used?
        /// </summary>
        /// <param name="mDhttpMethod"></param>
        /// <param name="agentID"></param>
        /// <returns></returns>
        private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            //I've never seen this come in, so for now... do nothing
            NameValueCollection query = HttpUtility.ParseQueryString (httpRequest.Url.Query);
            string[] ids = query.GetValues ("ids");
            string username = query.GetOne ("username");

            OSDMap map = new OSDMap ();
            OSDArray agents = new OSDArray ();
            OSDArray bad_ids = new OSDArray ();
            OSDArray bad_usernames = new OSDArray ();

            if (ids != null)
            {
                foreach (string id in ids)
                {
                    UserAccount account = m_userService.GetUserAccount (UUID.Zero, UUID.Parse (id));
                    if (account != null)
                    {
                        IUserProfileInfo info = Aurora.DataManager.DataManager.RequestPlugin<IProfileConnector> ().GetUserProfile (UUID.Parse (id));
                        if (info != null)
                            PackUserInfo (info, account, ref agents);
                        else
                            bad_ids.Add (id);
                    }
                }
            }
            //TODO: usernames

            map["agents"] = agents;
            map["bad_ids"] = bad_ids;
            map["bad_usernames"] = bad_usernames;

            byte[] m = OSDParser.SerializeLLSDXmlBytes (map);
            httpResponse.Body.Write (m, 0, m.Length);
            httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK;
            httpResponse.Send ();
            return null;
        }
 public bool RequestHandler(string response, OSDArray events, UUID avatarID, ulong RegionHandle)
 {
     OSD r = OSDParser.DeserializeJson(response);
     if (r.Type == OSDType.Map)
     {
         OSDMap result = (OSDMap)r;
         if (result != null)
         {
             bool success = result["success"].AsBoolean();
             if (!success)
             {
                 //We need to save the EQMs so that we can try again later
                 foreach (OSD o in events)
                 {
                     if (o != null)
                         lock (m_eventsNotSentPasswordDoesNotExist)
                             m_eventsNotSentPasswordDoesNotExist[avatarID].AddNewEvent(RegionHandle, o);
                 }
             }
             else
                 return success;
         }
     }
     return false;
 }
        private bool AddToQueue(OSD ev, UUID avatarID, ulong regionHandle, bool async)
        {
            //m_log.DebugFormat("[EVENTQUEUE]: Enqueuing event for {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName);
            
            if (ev == null)
                return false;
            try
            {
                lock (m_eventsNotSentPasswordDoesNotExist)
                {
                    //Make sure these exist
                    if (!m_eventsNotSentPasswordDoesNotExist.ContainsKey(avatarID))
                        m_eventsNotSentPasswordDoesNotExist.Add(avatarID, new EventQueueClient());
                }

                UUID Password;
                if (!FindAndPopulateEQMPassword(avatarID, regionHandle, out Password))
                {
                    lock (m_eventsNotSentPasswordDoesNotExist)
                    {
                        m_eventsNotSentPasswordDoesNotExist[avatarID].AddNewEvent(regionHandle, OSDParser.SerializeLLSDXmlString(ev));
                    }
                    m_log.Info("[EventQueueServiceConnector]: Could not find password for agent " + avatarID +
                                ", all Caps will fail if this is not resolved!");
                    return false;
                }

                OSDMap request = new OSDMap();
                request.Add("AgentID", avatarID);
                request.Add("RegionHandle", regionHandle);
                request.Add("Password", Password);
                OSDArray events = new OSDArray();
                //Note: we HAVE to convert it to xml, otherwise things like byte[] arrays will not be passed through correctly!
                events.Add(OSDParser.SerializeLLSDXmlString(ev)); //Add this event

                //Clear the queue above if the password was just found now
                //Fire all of them sync for now... if this becomes a large problem, we can deal with it later
                lock (m_eventsNotSentPasswordDoesNotExist)
                {
                    foreach (OSD EQMessage in m_eventsNotSentPasswordDoesNotExist[avatarID].GetEvents(regionHandle))
                    {
                        try
                        {
                            if (EQMessage == null)
                                continue;
                            //We do NOT enqueue disable simulator as it will kill things badly, and they get in here
                            //  because we can't
                            OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(EQMessage.AsString());
                            if (!map.ContainsKey("message") || (map.ContainsKey("message") && map["message"] != "DisableSimulator"))
                                events.Add(EQMessage);
                            else
                                m_log.Warn("[EventQueueServicesConnector]: Found DisableSimulator in the not sent queue, not sending");
                        }
                        catch (Exception e)
                        {
                            m_log.Error("[EVENTQUEUE] Caught event not found exception: " + e.ToString());
                            return false;
                        }
                    }
                    //Clear it for now... we'll readd if it fails
                    m_eventsNotSentPasswordDoesNotExist[avatarID].ClearEvents(regionHandle);
                }

                request.Add("Events", events);

                List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(avatarID.ToString(), "EventQueueServiceURI");
                foreach (string serverURI in serverURIs)
                {
                    if (async)
                    {
                        AsynchronousRestObjectRequester.MakeRequest("POST", serverURI + "/CAPS/EQMPOSTER",
                            OSDParser.SerializeJsonString(request),
                            delegate(string resp)
                            {
                                return RequestHandler(resp, events, avatarID, regionHandle);
                            });

                        return true;
                    }
                    else
                    {
                        string resp = SynchronousRestFormsRequester.MakeRequest("POST", serverURI + "/CAPS/EQMPOSTER",
                            OSDParser.SerializeJsonString(request));
                        return RequestHandler(resp, events, avatarID, regionHandle);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Error("[EVENTQUEUE] Caught exception: " + e.ToString());
            }

            return false;
        }
예제 #14
0
        /// <summary>
        ///   Get the user's display name, currently not used?
        /// </summary>
        /// <param name = "mDhttpMethod"></param>
        /// <param name = "agentID"></param>
        /// <returns></returns>
        private byte[] ProcessGetDisplayName(string path, Stream request, OSHttpRequest httpRequest,
                                             OSHttpResponse httpResponse)
        {
            //I've never seen this come in, so for now... do nothing
            NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
            string[] ids = query.GetValues("ids");
            string username = query.GetOne("username");

            OSDMap map = new OSDMap();
            OSDArray agents = new OSDArray();
            OSDArray bad_ids = new OSDArray();
            OSDArray bad_usernames = new OSDArray();

            if (ids != null)
            {
                foreach (string id in ids)
                {
                    UserAccount account = m_userService.GetUserAccount(UUID.Zero, UUID.Parse(id));
                    if (account != null)
                    {
                        IUserProfileInfo info =
                            DataManager.RequestPlugin<IProfileConnector>().GetUserProfile(account.PrincipalID);
                        if (info != null)
                            PackUserInfo(info, account, ref agents);
                        else
                            PackUserInfo(info, account, ref agents);
                        //else //Technically is right, but needs to be packed no matter what for OS based grids
                        //    bad_ids.Add (id);
                    }
                }
            }
            else if (username != null)
            {
                UserAccount account = m_userService.GetUserAccount(UUID.Zero, username.Replace('.', ' '));
                if (account != null)
                {
                    IUserProfileInfo info =
                        DataManager.RequestPlugin<IProfileConnector>().GetUserProfile(account.PrincipalID);
                    if (info != null)
                        PackUserInfo(info, account, ref agents);
                    else
                        bad_usernames.Add(username);
                }
            }

            map["agents"] = agents;
            map["bad_ids"] = bad_ids;
            map["bad_usernames"] = bad_usernames;

            byte[] m = OSDParser.SerializeLLSDXmlBytes(map);
            httpResponse.Body.Write(m, 0, m.Length);
            httpResponse.StatusCode = (int) HttpStatusCode.OK;
            httpResponse.Send();
            return null;
        }
예제 #15
0
        /// <summary>
        /// Construct an LLSD reply packet to a CAPS inventory request
        /// </summary>
        /// <param name="invFetch"></param>
        /// <returns></returns>
        private string FetchInventoryReply(OSDArray fetchRequest, UUID AgentID, bool Library)
        {
            OSDMap contents = new OSDMap();
            OSDArray folders = new OSDArray();

            foreach (OSD m in fetchRequest)
            {
                OSDMap invFetch = (OSDMap)m;
                OSDMap internalContents = new OSDMap();

                UUID agent_id = invFetch["agent_id"].AsUUID();
                UUID owner_id = invFetch["owner_id"].AsUUID();
                UUID folder_id = invFetch["folder_id"].AsUUID();
                bool fetch_folders = invFetch["fetch_folders"].AsBoolean();
                bool fetch_items = invFetch["fetch_items"].AsBoolean();
                int sort_order = invFetch["sort_order"].AsInteger();

                //Set the normal stuff
                internalContents["agent_id"] = AgentID;
                internalContents["owner_id"] = owner_id;
                internalContents["folder_id"] = folder_id;


                InventoryCollection inv = new InventoryCollection();
                inv.Folders = new List<InventoryFolderBase>();
                inv.Items = new List<InventoryItemBase>();
                int version = 0;
                inv = HandleFetchInventoryDescendentsCAPS(AgentID, folder_id, owner_id, fetch_folders, fetch_items, sort_order, Library, out version);

                OSDArray categories = new OSDArray();
                if (inv.Folders != null)
                {
                    foreach (InventoryFolderBase invFolder in inv.Folders)
                    {
                        categories.Add(ConvertInventoryFolder(invFolder));
                    }
                }
                internalContents["categories"] = categories;

                OSDArray items = new OSDArray();
                if (inv.Items != null)
                {
                    foreach (InventoryItemBase invItem in inv.Items)
                    {
                        items.Add(ConvertInventoryItem(invItem, AgentID));
                    }
                }
                internalContents["items"] = items;

                internalContents["descendents"] = items.Count + categories.Count;
                internalContents["version"] = version;

                //Now add it to the folder array
                folders.Add(internalContents);
            }

            contents["folders"] = folders;
            return OSDParser.SerializeLLSDXmlString(contents);
        }
예제 #16
0
        public string HandleWebFetchInventoryDescendents(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received WebFetchInventoryDescendents request for {0}", AgentID);

                OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

                OSDArray foldersrequested = (OSDArray)map["folders"];

                string response = FetchInventoryReply(foldersrequested, AgentID, false);
                return response;
            }
            catch(Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();
            rmap["folders"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlString(rmap);
        }
        private Hashtable RetrieveWindLightSettings(Hashtable m_dhttpMethod, UUID agentID)
        {
            Hashtable responsedata = new Hashtable();
            responsedata["int_response_code"] = 200; //501; //410; //404;
            responsedata["content_type"] = "text/plain";
            responsedata["keepalive"] = false;
            responsedata["str_response_string"] = "";

            IScenePresence SP = m_scene.GetScenePresence(agentID);
            if (SP == null)
                return responsedata; //They don't exist
            IParcelManagementModule parcelManagement = m_scene.RequestModuleInterface<IParcelManagementModule>();
                        
            OSDMap rm = (OSDMap)OSDParser.DeserializeLLSDXml((string)m_dhttpMethod["requestbody"]);
            OSDMap retVal = new OSDMap();
            if (rm.ContainsKey("RegionID"))
            {
                //For the region, just add all of them
                OSDArray array = new OSDArray();
                foreach (RegionLightShareData rlsd in m_WindlightSettings.Values)
                {
                    OSDMap m = rlsd.ToOSD();
                    m.Add("Name", OSD.FromString("(Region Settings), Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude));
                    array.Add(m);
                }
                retVal.Add("WindLight", array);
                retVal.Add("Type", OSD.FromInteger(1));
            }
            else if (rm.ContainsKey("ParcelID"))
            {
                OSDArray retVals = new OSDArray();
                //-1 is all parcels
                if (rm["ParcelID"].AsInteger() == -1)
                {
                    //All parcels
                    if (parcelManagement != null)
                    {
                        foreach (ILandObject land in parcelManagement.AllParcels())
                        {
                            OSDMap map = land.LandData.GenericDataMap;
                            if (map.ContainsKey("WindLight"))
                            {
                                OSDMap parcelWindLight = (OSDMap)map["WindLight"];
                                foreach (OSD innerMap in parcelWindLight.Values)
                                {
                                    RegionLightShareData rlsd = new RegionLightShareData();
                                    rlsd.FromOSD((OSDMap)innerMap);
                                    OSDMap imap = new OSDMap();
                                    imap = rlsd.ToOSD();
                                    imap.Add("Name", OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude));
                                    retVals.Add(imap);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //Only the given parcel parcel given by localID
                    if (parcelManagement != null)
                    {
                        ILandObject land = parcelManagement.GetLandObject(rm["ParcelID"].AsInteger());
                        OSDMap map = land.LandData.GenericDataMap;
                        if (map.ContainsKey("WindLight"))
                        {
                            OSDMap parcelWindLight = (OSDMap)map["WindLight"];
                            foreach (OSD innerMap in parcelWindLight.Values)
                            {
                                RegionLightShareData rlsd = new RegionLightShareData();
                                rlsd.FromOSD((OSDMap)innerMap);
                                OSDMap imap = new OSDMap();
                                imap = rlsd.ToOSD();
                                imap.Add("Name", OSD.FromString(land.LandData.Name + ", Min: " + rlsd.minEffectiveAltitude + ", Max: " + rlsd.maxEffectiveAltitude));
                                retVals.Add(imap);
                            }
                        }
                    }
                }
                retVal.Add("WindLight", retVals);
                retVal.Add("Type", OSD.FromInteger(2));
            }

            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(retVal);
            return responsedata;
        }
예제 #18
0
        private bool AddToQueue(OSD ev, UUID avatarID, ulong regionHandle, bool runasync)
        {
            //m_log.DebugFormat("[EVENTQUEUE]: Enqueuing event for {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName);
            
            if (ev == null)
                return false;
            try
            {
                OSDMap request = new OSDMap();
                request.Add("AgentID", avatarID);
                request.Add("RegionHandle", regionHandle);
                OSDArray events = new OSDArray();
                //Note: we HAVE to convert it to xml, otherwise things like byte[] arrays will not be passed through correctly!
                events.Add(OSDParser.SerializeLLSDXmlString(ev)); //Add this event

                request.Add("Events", events);

                List<string> serverURIs = m_registry.RequestModuleInterface<IConfigurationService>().FindValueOf(avatarID.ToString(), regionHandle.ToString(), "EventQueueServiceURI");
                foreach (string serverURI in serverURIs)
                {
                    if (runasync)
                    {
                        /*AsynchronousRestObjectRequester.MakeRequest("POST", serverURI + "/CAPS/EQMPOSTER",
                            OSDParser.SerializeJsonString(request),
                            delegate(string resp)
                            {
                                return RequestHandler(resp, events, avatarID, regionHandle);
                            });

                        return true;*/
                        string resp = SynchronousRestFormsRequester.MakeRequest("POST", serverURI + "/CAPS/EQMPOSTER",
                            OSDParser.SerializeJsonString(request));
                        return RequestHandler(resp, events, avatarID, regionHandle);
                    }
                    else
                    {
                        string resp = SynchronousRestFormsRequester.MakeRequest("POST", serverURI + "/CAPS/EQMPOSTER",
                            OSDParser.SerializeJsonString(request));
                        return RequestHandler(resp, events, avatarID, regionHandle);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Error("[EVENTQUEUE] Caught exception: " + e.ToString());
            }

            return false;
        }
예제 #19
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="data"></param>
            /// <param name="path"></param>
            /// <param name="param"></param>
            /// <returns></returns>
            public string uploaderCaps(byte[] data, string path, string param)
            {
                try
                {
                    //                    m_log.InfoFormat("[CAPS]: " +
                    //                                     "TaskInventoryScriptUpdater received data: {0}, path: {1}, param: {2}",
                    //                                     data, path, param));

                    string res = String.Empty;
                    IClientAPI client;
                    m_scene.TryGetClient(AgentID, out client);
                    ArrayList errors = CapsUpdateTaskInventoryScriptAsset(client, inventoryItemID, primID, isScriptRunning, data);

                    OSDMap map = new OSDMap();
                    map["new_asset"] = inventoryItemID;
                    map["compiled"] = errors.Count > 0 ? false : true;
                    map["state"] = "complete";
                    OSDArray array = new OSDArray();
                    foreach (object o in errors)
                    {
                        array.Add(OSD.FromObject(o));
                    }
                    map["errors"] = array;
                    res = OSDParser.SerializeLLSDXmlString(map);

                    httpListener.RemoveStreamHandler("POST", uploaderPath);

                    //                    m_log.InfoFormat("[CAPS]: TaskInventoryScriptUpdater.uploaderCaps res: {0}", res);

                    return res;
                }
                catch (Exception e)
                {
                    m_log.Error("[CAPS]: " + e.ToString());
                }

                // XXX Maybe this should be some meaningful error packet
                return null;
            }
예제 #20
0
        private string ProcessParcelMediaURLFilterList(string request, string path, string param, UUID agentID)
        {
            IClientAPI client;
            if (!m_scene.ClientManager.TryGetValue(agentID, out client))
            {
                m_log.WarnFormat("[LAND] unable to retrieve IClientAPI for {0}", agentID.ToString());
                return OSDParser.SerializeLLSDXmlString(new OSDMap());
            }
            OSDMap args = (OSDMap)OSDParser.DeserializeLLSDXml(request);

            ILandObject o = GetLandObject(args["local-id"].AsInteger());

            OSDArray respList = new OSDArray();
            OSDMap resp = new OSDMap();
            resp["local-id"] = o.LandData.LocalID;
            resp["list"] = respList;

            return OSDParser.SerializeLLSDXmlString(resp);
        }
예제 #21
0
 public OSDArray ArrayListToOSDArray(ArrayList arrlst)
 {
     OSDArray llsdBack = new OSDArray();
     foreach (Hashtable ht in arrlst)
     {
         OSDMap mp = new OSDMap();
         foreach (DictionaryEntry deHt in ht)
         {
             mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
         }
         llsdBack.Add(mp);
     }
     return llsdBack;
 }
예제 #22
0
        public byte[] HandleFetchLibDescendents(string request, UUID AgentID)
        {
            try
            {
                //m_log.DebugFormat("[InventoryCAPS]: Received FetchLibDescendents request for {0}", AgentID);

                OSDMap map = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

                OSDArray foldersrequested = (OSDArray)map["folders"];

                return Aurora.DataManager.DataManager.RequestPlugin<IInventoryData>().FetchInventoryReply(foldersrequested, m_libraryService.LibraryOwner);
            }
            catch (Exception ex)
            {
                m_log.Warn("[InventoryCaps]: SERIOUS ISSUE! " + ex.ToString());
            }
            OSDMap rmap = new OSDMap();
            rmap["folders"] = new OSDArray();
            return OSDParser.SerializeLLSDXmlBytes(rmap);
        }
예제 #23
0
 private static OSDArray WrapOSDMap(OSDMap wrapMe)
 {
     OSDArray array = new OSDArray();
     array.Add(wrapMe);
     return array;
 }
예제 #24
0
        /// <summary>
        /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
        /// </summary>
        private void SendGroupMembershipInfoViaCaps(IClientAPI remoteClient, UUID dataForAgentID, GroupMembershipData[] data)
        {
            if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);

            OSDArray AgentData = new OSDArray(1);
            OSDMap AgentDataMap = new OSDMap(1);
            AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID));
            AgentData.Add(AgentDataMap);


            OSDArray GroupData = new OSDArray(data.Length);
            OSDArray NewGroupData = new OSDArray(data.Length);

            foreach (GroupMembershipData membership in data)
            {
                if (GetRequestingAgentID(remoteClient) != dataForAgentID)
                {
                    if (!membership.ListInProfile)
                    {
                        // If we're sending group info to remoteclient about another agent, 
                        // filter out groups the other agent doesn't want to share.
                        continue;
                    }
                }

                OSDMap GroupDataMap = new OSDMap(6);
                OSDMap NewGroupDataMap = new OSDMap(1);

                GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID));
                GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers));
                GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices));
                GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture));
                GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution));
                GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName));
                NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile));

                GroupData.Add(GroupDataMap);
                NewGroupData.Add(NewGroupDataMap);
            }

            OSDMap llDataStruct = new OSDMap(3);
            llDataStruct.Add("AgentData", AgentData);
            llDataStruct.Add("GroupData", GroupData);
            llDataStruct.Add("NewGroupData", NewGroupData);

            if (m_debugEnabled)
            {
                m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
            }

            IEventQueueService queue = remoteClient.Scene.RequestModuleInterface<IEventQueueService>();

            if (queue != null)
            {
                queue.Enqueue(buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient), remoteClient.Scene.RegionInfo.RegionHandle);
            }
        }
예제 #25
0
        public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request)
        {
            OSDMap events = new OSDMap();
            try
            {
                OSD element;
                lock (queue)
                {
                    if (queue.Count == 0)
                        return NoEvents(requestID, pAgentId);
                    element = queue.Dequeue(); // 15s timeout
                }

                OSDArray array = new OSDArray();
                if (element == null) // didn't have an event in 15s
                {
                    //return NoEvents(requestID, pAgentId);
                    // Send it a fake event to keep the client polling!   It doesn't like 502s like the proxys say!
                    OSDMap keepAliveEvent = new OSDMap(2);
                    keepAliveEvent.Add("body", new OSDMap());
                    keepAliveEvent.Add("message", new OSDString("FAKEEVENT"));
                    element = keepAliveEvent;
                    array.Add(keepAliveEvent);
                    //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName);
                }

                array.Add(element);
                lock (queue)
                {
                    while (queue.Count > 0)
                    {
                        array.Add(queue.Dequeue());
                        m_ids++;
                    }
                }

                //Look for disable Simulator EQMs so that we can disable ourselves safely
                foreach (OSD ev in array)
                {
                    try
                    {
                        if (ev.Type == OSDType.Map)
                        {
                            OSDMap map = (OSDMap)ev;
                            if (map.ContainsKey("message") && map["message"] == "DisableSimulator")
                            {
                                //This will be the last bunch of EQMs that go through, so we can safely die now
                                m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle);
                                m_log.Warn("[EQService]: Disabling Simulator " + m_service.RegionHandle);
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                events.Add("events", array);

                events.Add("id", new OSDInteger(m_ids));
                m_ids++;
            }
            catch
            {
            }
            Hashtable responsedata = new Hashtable();
            responsedata["int_response_code"] = 200;
            responsedata["content_type"] = "application/xml";
            responsedata["keepalive"] = false;
            responsedata["reusecontext"] = false;
            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
            //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
            return responsedata;
        }
예제 #26
0
        public Hashtable ProcessQueue(Hashtable request, UUID agentID)
        {
            // TODO: this has to be redone to not busy-wait (and block the thread),
            // TODO: as soon as we have a non-blocking way to handle HTTP-requests.

            //            if (m_log.IsDebugEnabled)
            //            { 
            //                String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [  ";
            //                foreach (object key in request.Keys)
            //                {
            //                    debug += key.ToString() + "=" + request[key].ToString() + "  ";
            //                }
            //                m_log.DebugFormat(debug + "  ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name);
            //            }
            //m_log.Warn("Got EQM get at " + m_handler.CapsURL);
            OSD element = null;
            lock (queue)
            {
                if (queue.Count != 0)
                    element = queue.Dequeue(); // 15s timeout
            }

            Hashtable responsedata = new Hashtable();

            if (element == null)
            {
                //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
                return NoEvents(UUID.Zero, agentID);
            }

            OSDArray array = new OSDArray();
            array.Add(element);
            lock (queue)
            {
                while (queue.Count > 0)
                {
                    OSD item = queue.Dequeue();
                    if (item != null)
                    {
                        array.Add(item);
                        m_ids++;
                    }
                }
            }
            //Look for disable Simulator EQMs so that we can disable ourselves safely
            foreach (OSD ev in array)
            {
                try
                {
                    OSDMap map = (OSDMap)ev;
                    if (map.ContainsKey("message") && map["message"] == "DisableSimulator")
                    {
                        //This will be the last bunch of EQMs that go through, so we can safely die now
                        m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle);
                    }
                }
                catch
                {
                }
            }

            OSDMap events = new OSDMap();
            events.Add("events", array);

            events.Add("id", new OSDInteger(m_ids));
            m_ids++;

            responsedata["int_response_code"] = 200;
            responsedata["content_type"] = "application/xml";
            responsedata["keepalive"] = false;
            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
            //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);

            return responsedata;
        }
예제 #27
0
        public string HandleFetchInventory(string request, UUID AgentID)
        {
            m_log.DebugFormat("[InventoryCAPS]: Received FetchInventory request for {0}", AgentID);

            OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(OpenMetaverse.Utils.StringToBytes(request));

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

            string response = "";
            OSDMap map = new OSDMap();
            //We have to send the agent_id in the main map as well as all the items
            map.Add("agent_id", OSD.FromUUID(AgentID));

            OSDArray items = new OSDArray();
            for (int i = 0; i < foldersrequested.Count; i++)
            {
                OSDMap requestedFolders = (OSDMap)foldersrequested[i];
                UUID owner_id = requestedFolders["owner_id"].AsUUID();
                UUID item_id = requestedFolders["item_id"].AsUUID();
                InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(item_id, owner_id));
                if (item != null)
                {
                    items.Add(ConvertInventoryItem(item, owner_id));
                }
            }
            map.Add("items", items);

            response = OSDParser.SerializeLLSDXmlString(map);
            return response;
        }