Ejemplo n.º 1
0
        private void HandleClassifiedInfoUpdate(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (ClassifiedInfoUpdate)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            try
            {
                var classified = agent.ProfileService.Classifieds[agent.Owner, req.ClassifiedID];
                classified.ClassifiedID = req.ClassifiedID;
                classified.Category     = req.Category;
                classified.Name         = req.Name;
                classified.Description  = req.Description;
                classified.ParcelID     = req.ParcelID;
                classified.ParentEstate = req.ParentEstate;
                classified.SnapshotID   = req.SnapshotID;
                classified.GlobalPos    = req.PosGlobal;
                classified.Flags        = req.ClassifiedFlags;
                classified.Price        = req.PriceForListing;
                agent.ProfileService.Classifieds.Update(classified);
            }
            catch
            {
                agent.SendAlertMessage("Error updating classified", scene.ID);
            }
        }
Ejemplo n.º 2
0
        private void HandlePickInfoUpdate(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (PickInfoUpdate)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            try
            {
                var pick = agent.ProfileService.Picks[agent.Owner, req.PickID];
                pick.TopPick        = req.TopPick;
                pick.ParcelID       = req.ParcelID;
                pick.Name           = req.Name;
                pick.Description    = req.Description;
                pick.SnapshotID     = req.SnapshotID;
                pick.GlobalPosition = req.PosGlobal;
                pick.SortOrder      = req.SortOrder;
                pick.Enabled        = req.IsEnabled;
                agent.ProfileService.Picks.Update(pick);
            }
            catch
            {
                agent.SendAlertMessage("Error updating pick", scene.ID);
            }
        }
Ejemplo n.º 3
0
        private void HandleUpdateUserInfo(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (UpdateUserInfo)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            var prefs = new ProfilePreferences
            {
                User       = agent.Owner,
                IMviaEmail = req.IMViaEmail,
                Visible    = req.DirectoryVisibility != "hidden"
            };

            try
            {
                agent.ProfileService.Preferences[agent.Owner] = prefs;
            }
            catch
            {
                agent.SendAlertMessage("Error updating preferences", scene.ID);
            }
        }
Ejemplo n.º 4
0
        private void HandleAvatarPropertiesUpdate(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (AvatarPropertiesUpdate)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            var props = new ProfileProperties
            {
                ImageID          = UUID.Zero,
                FirstLifeImageID = UUID.Zero,
                Partner          = UGUI.Unknown,
                User             = agent.Owner,
                SkillsText       = string.Empty,
                WantToText       = string.Empty,
                Language         = string.Empty,

                AboutText     = req.AboutText,
                FirstLifeText = req.FLAboutText
            };

            props.ImageID        = req.ImageID;
            props.PublishMature  = req.MaturePublish;
            props.PublishProfile = req.AllowPublish;
            props.WebUrl         = req.ProfileURL;

            try
            {
                agent.ProfileService.Properties[agent.Owner, ProfileServiceInterface.PropertiesUpdateFlags.Properties] = props;
            }
            catch
            {
                agent.SendAlertMessage("Error updating properties", scene.ID);
            }
        }
Ejemplo n.º 5
0
        private void HandleAvatarInterestsUpdate(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (AvatarInterestsUpdate)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            var props = new ProfileProperties
            {
                ImageID          = UUID.Zero,
                FirstLifeImageID = UUID.Zero,
                FirstLifeText    = string.Empty,
                AboutText        = string.Empty,
                Partner          = UGUI.Unknown,
                User             = agent.Owner,
                SkillsMask       = req.SkillsMask,
                SkillsText       = req.SkillsText,
                WantToMask       = req.WantToMask,
                WantToText       = req.WantToText,
                Language         = req.LanguagesText
            };

            try
            {
                agent.ProfileService.Properties[agent.Owner, ProfileServiceInterface.PropertiesUpdateFlags.Interests] = props;
            }
            catch
            {
                agent.SendAlertMessage("Error updating interests", scene.ID);
            }
        }
Ejemplo n.º 6
0
        private void HandlePickDelete(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (PickDelete)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            try
            {
                agent.ProfileService.Picks.Delete(req.PickID);
            }
            catch
            {
                agent.SendAlertMessage("Error deleting pick", scene.ID);
            }
        }
Ejemplo n.º 7
0
        private void HandleAvatarNotesUpdate(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (AvatarNotesUpdate)m;

            if (req.AgentID != req.CircuitAgentID ||
                req.SessionID != req.CircuitSessionID)
            {
                return;
            }

            if (agent.ProfileService == null)
            {
                return;
            }

            try
            {
                agent.ProfileService.Notes[agent.Owner, new UGUI(req.TargetID)] = req.Notes;
            }
            catch
            {
                agent.SendAlertMessage("Error updating notes", scene.ID);
            }
        }
Ejemplo n.º 8
0
        public void HandleUserInfoRequest(ViewerAgent agent, AgentCircuit circuit, HttpRequest req)
        {
            if (req.CallerIP != circuit.RemoteIP)
            {
                req.ErrorResponse(HttpStatusCode.Forbidden, "Forbidden");
                return;
            }
            if (req.Method == "GET")
            {
                ProfilePreferences prefs;
                Map resmap;
                try
                {
                    prefs  = agent.ProfileService.Preferences[agent.Owner];
                    resmap = new Map
                    {
                        { "success", true },
                        { "im_via_email", prefs.IMviaEmail },
                        { "is_verified", false },
                        { "email", string.Empty },
                        { "directory_visibility", prefs.Visible }
                    };
                }
                catch /* yes, we are catching a NullReferenceException here too */
                {
                    resmap = new Map
                    {
                        { "success", false }
                    };
                }


                using (HttpResponse res = req.BeginResponse("application/llsd+xml"))
                    using (Stream s = res.GetOutputStream())
                    {
                        LlsdXml.Serialize(resmap, s);
                    }
            }
            else if (req.Method == "POST")
            {
                Map reqmap;
                try
                {
                    reqmap = LlsdXml.Deserialize(req.Body) as Map;
                }
                catch
                {
                    req.ErrorResponse(HttpStatusCode.BadRequest, "Bad request");
                    return;
                }

                if (reqmap == null)
                {
                    req.ErrorResponse(HttpStatusCode.BadRequest, "Bad request");
                    return;
                }

                if (agent.ProfileService == null)
                {
                    return;
                }

                var prefs = new ProfilePreferences
                {
                    User       = agent.Owner,
                    IMviaEmail = reqmap["im_via_email"].AsBoolean,
                    Visible    = reqmap["dir_visibility"].ToString() != "hidden"
                };
                Map resmap;
                try
                {
                    agent.ProfileService.Preferences[agent.Owner] = prefs;
                    resmap = new Map {
                        { "success", true }
                    };
                }
                catch
                {
                    agent.SendAlertMessage("Error updating preferences", circuit.Scene?.ID ?? UUID.Zero);
                    resmap = new Map {
                        { "success", false }
                    };
                }
                using (HttpResponse res = req.BeginResponse("application/llsd+xml"))
                    using (Stream s = res.GetOutputStream())
                    {
                        LlsdXml.Serialize(resmap, s);
                    }
            }
            else
            {
                req.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed");
            }
        }
Ejemplo n.º 9
0
        private void HandleMapNameRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (MapNameRequest)m;

            if (req.CircuitAgentID != req.AgentID ||
                req.CircuitSessionID != req.SessionID)
            {
                return;
            }

#if DEBUG
            m_Log.InfoFormat("MapNameRequest for {0}", req.Name);
#endif
            var results = new List <MapBlockReply.DataEntry>();

            var regionAddress = new RegionAddress(req.Name);
            /* checking for targetting grid simplifies usability since user has not to think about from where */
            if (regionAddress.IsForeignGrid && !regionAddress.TargetsGatekeeperUri(scene.GatekeeperURI))
            {
#if DEBUG
                m_Log.InfoFormat("MapNameRequest for foreign at {0} region={1}", regionAddress.GatekeeperUri, regionAddress.RegionName);
#endif

                RegionInfo ri = null;
                var        foundRegionButWrongProtocol = false;
                var        foundProtocolName           = string.Empty;
                string     message;
                foreach (var foreignGrid in m_ForeignGridConnectorPlugins)
                {
#if DEBUG
                    m_Log.DebugFormat("Testing foreign grid protocol \"{0}\"", foreignGrid.DisplayName);
#endif
                    if (foreignGrid.IsProtocolSupported(regionAddress.GatekeeperUri))
                    {
                        try
                        {
                            if (!foreignGrid.Instantiate(regionAddress.GatekeeperUri).TryGetValue(regionAddress.RegionName, out ri, out message))
                            {
#if DEBUG
                                m_Log.DebugFormat("Foreign grid \"{0}\" does not have the region \"{1}\"", regionAddress.GatekeeperUri, regionAddress.RegionName);
#endif
                                continue;
                            }
                        }
                        catch (Exception e)
                        {
                            m_Log.Error("Failed to connect to grid " + regionAddress.GatekeeperUri, e);
                            continue;
                        }

                        if (!foreignGrid.IsAgentSupported(agent.SupportedGridTypes))
                        {
                            foundRegionButWrongProtocol = true;
                            foundProtocolName           = agent.DisplayName;
                            ri = null;
                        }
                        else
                        {
#if DEBUG
                            m_Log.DebugFormat("Selected protocol \"{0}\" region => \"{1}\"", foreignGrid.Name, ri.Name);
#endif
                            break;
                        }
                    }
                    else
                    {
#if DEBUG
                        m_Log.DebugFormat("Foreign grid protocol \"{0}\" not supported for \"{1}\"", foreignGrid.DisplayName, regionAddress.GatekeeperUri);
#endif
                    }
                }

                if (ri == null && foundRegionButWrongProtocol)
                {
                    agent.SendAlertMessage(string.Format(this.GetLanguageString(agent.CurrentCulture, "YourHomeGridDoesNotSupportSelectedTargetGrid0", "Your home grid does not support the selected target grid (running {0})."), foundProtocolName), scene.ID);
                }
                else if (ri != null)
                {
                    var hgLoc = agent.CacheInterGridDestination(ri);
                    results.Add(new MapBlockReply.DataEntry
                    {
                        /* we map foreign grid locations in specific agent only */
                        X           = hgLoc.GridX,
                        Y           = hgLoc.GridY,
                        SizeX       = ri.Size.GridX,
                        SizeY       = ri.Size.GridY,
                        Name        = req.Name,
                        Access      = ri.Access,
                        RegionFlags = RegionOptionFlags.None, /* this is same region flags as seen on a sim */
                        WaterHeight = 21,
                        Agents      = 0,
                        MapImageID  = ri.RegionMapTexture
                    });
                }
            }
            else if (string.IsNullOrEmpty(regionAddress.RegionName))
            {
                agent.SendAlertMessage(this.GetLanguageString(agent.CurrentCulture, "PleaseEnterAString", "Please enter a string"), scene.ID);
            }
            else
            {
#if DEBUG
                m_Log.InfoFormat("MapNameRequest for {0} at local grid", regionAddress.RegionName);
#endif

                var service = scene.GridService;
                if (service != null)
                {
                    List <RegionInfo> ris;
                    try
                    {
                        ris = service.SearchRegionsByName(regionAddress.RegionName);
                    }
                    catch
                    {
                        ris = new List <RegionInfo>();
                    }

                    foreach (var ri in ris)
                    {
                        results.Add(new MapBlockReply.DataEntry
                        {
                            X     = ri.Location.GridX,
                            Y     = ri.Location.GridY,
                            SizeX = ri.Size.GridX,
                            SizeY = ri.Size.GridY,

                            Name        = ri.Name,
                            Access      = ri.Access,
                            RegionFlags = RegionOptionFlags.None, /* this is same region flags as seen on a sim */
                            WaterHeight = 21,
                            Agents      = 0,
                            MapImageID  = ri.RegionMapTexture
                        });
                    }
                }
            }

            SendMapBlocks(agent, scene, req.Flags, results);
        }