Ejemplo n.º 1
0
        private void ProcessAvatarPickerRequest(ViewerAgent agent, AgentCircuit circuit, Message m)
        {
            var req   = (AvatarPickerRequest)m;
            var res   = new AvatarPickerReply();
            var scene = circuit.Scene;

            if (scene == null)
            {
                return;
            }

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

            res.AgentID = req.AgentID;
            res.QueryID = req.QueryID;
            if (string.IsNullOrEmpty(req.Name) || req.Name.Length < 3)
            {
                agent.SendMessageAlways(res, scene.ID);
                return;
            }

            string[] names = req.Name.Split(' ');

            if (names.Length < 1 || names.Length > 2)
            {
                agent.SendMessageAlways(res, scene.ID);
                return;
            }

            var results = scene.AvatarNameService.Search(names);

            for (int offset = 0; offset < results.Count && offset < 100; ++offset)
            {
                string[] sp = results[offset].FullName.Split(new char[] { ' ' }, 2);
                var      d  = new AvatarPickerReply.DataEntry
                {
                    AvatarID  = results[offset].ID,
                    FirstName = sp[0],
                    LastName  = (sp.Length > 1) ?
                                sp[1] :
                                string.Empty
                };
                res.Data.Add(d);
            }
            agent.SendMessageAlways(res, scene.ID);
        }
Ejemplo n.º 2
0
        private void HandleClassifiedInfoRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (ClassifiedInfoRequest)m;

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

            KeyValuePair <UGUI, int> kvp;

            if (!m_ClassifiedQueryCache.TryGetValue(req.ClassifiedID, out kvp))
            {
                return;
            }

            ProfileServiceData serviceData;
            UGUI uui;

            try
            {
                serviceData = LookupProfileService(scene, kvp.Key.ID, out uui);
            }
            catch
            {
                return;
            }

            try
            {
                ProfileClassified cls = serviceData.ProfileService.Classifieds[kvp.Key, req.ClassifiedID];
                var reply             = new ClassifiedInfoReply
                {
                    AgentID = req.AgentID,

                    ClassifiedID    = cls.ClassifiedID,
                    CreatorID       = cls.Creator.ID,
                    CreationDate    = cls.CreationDate,
                    ExpirationDate  = cls.ExpirationDate,
                    Category        = cls.Category,
                    Name            = cls.Name,
                    Description     = cls.Description,
                    ParcelID        = cls.ParcelID,
                    ParentEstate    = cls.ParentEstate,
                    SnapshotID      = cls.SnapshotID,
                    SimName         = cls.SimName,
                    PosGlobal       = cls.GlobalPos,
                    ParcelName      = cls.ParcelName,
                    ClassifiedFlags = cls.Flags,
                    PriceForListing = cls.Price
                };
                agent.SendMessageAlways(reply, scene.ID);
            }
            catch
            {
                /* do not expose exceptions to caller */
            }
        }
Ejemplo n.º 3
0
        private void SendMapBlocks(ViewerAgent agent, SceneInterface scene, MapAgentFlags mapflags, List <MapBlockReply.DataEntry> mapBlocks)
        {
            mapBlocks.Add(new MapBlockReply.DataEntry
            {
                Agents      = 0,
                Access      = RegionAccess.NonExistent,
                MapImageID  = UUID.Zero,
                Name        = string.Empty,
                RegionFlags = RegionOptionFlags.None, /* this is same region flags as seen on a sim */
                WaterHeight = 0,
                X           = 0,
                Y           = 0
            });

            MapBlockReply replymsg          = null;
            int           mapBlockReplySize = 20;

            foreach (var d in mapBlocks)
            {
                int mapBlockDataSize = 27 + d.Name.Length;
                if (mapBlockReplySize + mapBlockDataSize > 1400 && replymsg != null)
                {
                    agent.SendMessageAlways(replymsg, scene.ID);
                    replymsg = null;
                }

                if (replymsg == null)
                {
                    replymsg = new MapBlockReply
                    {
                        AgentID = agent.ID,
                        Flags   = mapflags
                    };
                    mapBlockReplySize = 20;
                }

                mapBlockReplySize += mapBlockDataSize;
                replymsg.Data.Add(d);
            }

            if (replymsg != null)
            {
                agent.SendMessageAlways(replymsg, scene.ID);
            }
        }
Ejemplo n.º 4
0
        private void ProcessDirFindQuery_People(ViewerAgent agent, SceneInterface scene, DirFindQuery req)
        {
            DirPeopleReply res = null;
            var            t   = new UDPPacket();

            foreach (UGUIWithName uui in scene.AvatarNameService.Search(req.QueryText.Split(new char[] { ' ' }, 2)))
            {
                if (res == null)
                {
                    res = new DirPeopleReply
                    {
                        AgentID = req.AgentID,
                        QueryID = req.QueryID
                    };
                }

                var d = new DirPeopleReply.QueryReplyData
                {
                    AgentID = uui.ID
                };
                string[] parts = uui.FullName.Split(' ');
                d.FirstName = parts[0];
                if (parts.Length > 1)
                {
                    d.LastName = parts[1];
                }
                //d.Group
                //d.Online
                d.Reputation = 0;
                res.QueryReplies.Add(d);

                t.Reset();
                res.Serialize(t);
                if (t.DataLength >= 1400)
                {
                    agent.SendMessageAlways(res, scene.ID);
                    res = null;
                }
            }
            if (res != null)
            {
                agent.SendMessageAlways(res, scene.ID);
            }
        }
Ejemplo n.º 5
0
        private void HandleAvatarNotesRequest(ViewerAgent agent, SceneInterface scene, GenericMessage m)
        {
            if (m.AgentID != m.CircuitAgentID ||
                m.SessionID != m.CircuitSessionID)
            {
                return;
            }

            if (m.ParamList.Count < 1)
            {
                return;
            }
            string arg = Encoding.UTF8.GetString(m.ParamList[0]);
            UUID   targetuuid;

            if (!UUID.TryParse(arg, out targetuuid))
            {
                return;
            }

            UGUI targetuui;

            try
            {
                targetuui = scene.AvatarNameService[targetuuid];
            }
            catch
            {
                targetuui = new UGUI(targetuuid);
            }

            var reply = new AvatarNotesReply
            {
                AgentID  = m.AgentID,
                TargetID = targetuui.ID
            };

            try
            {
                reply.Notes = agent.ProfileService.Notes[agent.Owner, targetuui];
            }
            catch /* yes, we are catching a NullReferenceException here too */
            {
                reply.Notes = string.Empty;
            }
            agent.SendMessageAlways(reply, scene.ID);
        }
        private UUID CreateInventoryItemFromNotecard(InventoryFolder destinationFolder, NotecardInventoryItem ncitem, uint callbackID)
        {
            var item = new InventoryItem(ncitem)
            {
                ParentFolderID = destinationFolder.ID
            };

            item.SetNewID(UUID.Random);

            if (item.Owner.EqualsGrid(m_Agent.Owner))
            {
                item.LastOwner = item.Owner;
                item.Owner     = m_Agent.Owner;
            }

            m_Agent.InventoryService.Item.Add(item);
            m_Agent.SendMessageAlways(new Messages.Inventory.UpdateCreateInventoryItem(m_Agent.ID, true, UUID.Zero, item, callbackID), m_Scene.ID);
            return(item.AssetID);
        }
Ejemplo n.º 7
0
        private void HandleUserInfoRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (UserInfoRequest)m;

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

            ProfilePreferences prefs;

            try
            {
                prefs = agent.ProfileService.Preferences[agent.Owner];
            }
            catch /* yes, we are catching a NullReferenceException here too */
            {
                prefs = new ProfilePreferences
                {
                    IMviaEmail = false,
                    Visible    = false,
                    User       = agent.Owner
                };
            }

            var reply = new UserInfoReply
            {
                AgentID             = req.AgentID,
                DirectoryVisibility = (prefs.Visible) ?
                                      "default" :
                                      "hidden",
                EMail      = string.Empty,
                IMViaEmail = prefs.IMviaEmail
            };

            agent.SendMessageAlways(reply, scene.ID);
        }
Ejemplo n.º 8
0
        private void ProcessDirFindQuery_Groups(ViewerAgent agent, SceneInterface scene, DirFindQuery req)
        {
            DirGroupsReply res = null;

            var groupsService = scene.GroupsService;

            if (groupsService == null)
            {
                res = new DirGroupsReply
                {
                    AgentID = req.AgentID,
                    QueryID = req.QueryID
                };
                agent.SendMessageAlways(res, scene.ID);
                return;
            }

            var gis = groupsService.Groups.GetGroupsByName(agent.Owner, req.QueryText);

            if (gis.Count == 0)
            {
                res = new DirGroupsReply
                {
                    AgentID = req.AgentID,
                    QueryID = req.QueryID
                };
                agent.SendMessageAlways(res, scene.ID);
                return;
            }
            var t = new UDPPacket();

            foreach (var gi in gis)
            {
                if (res == null)
                {
                    res = new DirGroupsReply
                    {
                        AgentID = req.AgentID,
                        QueryID = req.QueryID
                    };
                }

                var d = new DirGroupsReply.QueryReplyData
                {
                    GroupID     = gi.ID.ID,
                    GroupName   = gi.ID.GroupName,
                    Members     = gi.MemberCount,
                    SearchOrder = gi.SearchOrder
                };
                res.QueryReplies.Add(d);

                t.Reset();
                res.Serialize(t);
                if (t.DataLength >= 1400)
                {
                    agent.SendMessageAlways(res, scene.ID);
                    res = null;
                }
            }
            if (res != null)
            {
                agent.SendMessageAlways(res, scene.ID);
            }
        }
Ejemplo n.º 9
0
        private void HandlePickInfoRequest(ViewerAgent agent, SceneInterface scene, GenericMessage m)
        {
            if (m.AgentID != m.CircuitAgentID ||
                m.SessionID != m.CircuitSessionID)
            {
                return;
            }

            if (m.ParamList.Count < 2)
            {
                return;
            }
            string arg = Encoding.UTF8.GetString(m.ParamList[0]);
            UUID   targetuuid;

            if (!UUID.TryParse(arg, out targetuuid))
            {
                return;
            }

            arg = Encoding.UTF8.GetString(m.ParamList[1]);
            UUID pickid;

            if (!UUID.TryParse(arg, out pickid))
            {
                return;
            }

            ProfileServiceData serviceData;
            UGUI uui;

            try
            {
                serviceData = LookupProfileService(scene, targetuuid, out uui);
            }
            catch
            {
                return;
            }

            try
            {
                var pick  = serviceData.ProfileService.Picks[uui, pickid];
                var reply = new PickInfoReply
                {
                    AgentID      = m.AgentID,
                    CreatorID    = pick.Creator.ID,
                    Description  = pick.Description,
                    IsEnabled    = pick.Enabled,
                    Name         = pick.Name,
                    OriginalName = pick.OriginalName,
                    ParcelID     = pick.ParcelID,
                    PickID       = pick.PickID,
                    PosGlobal    = pick.GlobalPosition,
                    SnapshotID   = pick.SnapshotID,
                    SortOrder    = pick.SortOrder,
                    TopPick      = pick.TopPick,
                    User         = string.Empty
                };
                agent.SendMessageAlways(reply, scene.ID);
            }
            catch
            {
                /* do not expose exceptions to caller */
            }
        }
Ejemplo n.º 10
0
        private void HandleAvatarPicksRequest(ViewerAgent agent, SceneInterface scene, GenericMessage m)
        {
            if (m.AgentID != m.CircuitAgentID ||
                m.SessionID != m.CircuitSessionID)
            {
                return;
            }

            if (m.ParamList.Count < 1)
            {
                return;
            }
            string arg = Encoding.UTF8.GetString(m.ParamList[0]);
            UUID   targetuuid;

            if (!UUID.TryParse(arg, out targetuuid))
            {
                return;
            }

            ProfileServiceData serviceData;
            UGUI uui;

            try
            {
                serviceData = LookupProfileService(scene, targetuuid, out uui);
            }
            catch
            {
                return;
            }

            int messageFill        = 0;
            AvatarPicksReply reply = null;

            Dictionary <UUID, string> picks;

            try
            {
                picks = serviceData.ProfileService.Picks.GetPicks(uui);
            }
            catch
            {
                reply = new AvatarPicksReply
                {
                    AgentID  = m.AgentID,
                    TargetID = targetuuid
                };
                agent.SendMessageAlways(reply, scene.ID);
                return;
            }
            foreach (var pick in picks)
            {
                int entryLen = pick.Value.Length + 18;
                if ((entryLen + messageFill > 1400 || reply.Data.Count == 255) && reply != null)
                {
                    agent.SendMessageAlways(reply, scene.ID);
                    reply = null;
                }
                if (reply == null)
                {
                    reply = new AvatarPicksReply
                    {
                        AgentID  = m.AgentID,
                        TargetID = targetuuid
                    };
                    messageFill = 0;
                }

                var d = new AvatarPicksReply.PickData
                {
                    PickID = pick.Key,
                    Name   = pick.Value
                };
                reply.Data.Add(d);
                messageFill += entryLen;
            }

            if (reply != null)
            {
                agent.SendMessageAlways(reply, scene.ID);
            }
        }
Ejemplo n.º 11
0
        private void HandleAvatarClassifiedsRequest(ViewerAgent agent, SceneInterface scene, GenericMessage m)
        {
            if (m.AgentID != m.CircuitAgentID ||
                m.SessionID != m.CircuitSessionID)
            {
                return;
            }

            if (m.ParamList.Count < 1)
            {
                return;
            }
            string arg = Encoding.UTF8.GetString(m.ParamList[0]);
            UUID   targetuuid;

            if (!UUID.TryParse(arg, out targetuuid))
            {
                return;
            }

            ProfileServiceData serviceData;
            UGUI uui;

            try
            {
                serviceData = LookupProfileService(scene, targetuuid, out uui);
            }
            catch
            {
                return;
            }

            int messageFill             = 0;
            AvatarClassifiedReply reply = null;

            Dictionary <UUID, string> classifieds;

            try
            {
                classifieds = serviceData.ProfileService.Classifieds.GetClassifieds(uui);
            }
            catch
            {
                reply = new AvatarClassifiedReply
                {
                    AgentID  = m.AgentID,
                    TargetID = targetuuid
                };
                agent.SendMessageAlways(reply, scene.ID);
                return;
            }
            foreach (KeyValuePair <UUID, string> classified in classifieds)
            {
                int entryLen = classified.Value.Length + 18;
                if ((entryLen + messageFill > 1400 || reply.Data.Count == 255) && reply != null)
                {
                    agent.SendMessageAlways(reply, scene.ID);
                    reply = null;
                }
                if (reply == null)
                {
                    reply = new AvatarClassifiedReply
                    {
                        AgentID  = m.AgentID,
                        TargetID = targetuuid
                    };
                    messageFill = 0;
                }

                var d = new AvatarClassifiedReply.ClassifiedData
                {
                    ClassifiedID = classified.Key,
                    Name         = classified.Value
                };
                reply.Data.Add(d);
                m_ClassifiedQueryCache[classified.Key] = new KeyValuePair <UGUI, int>(uui, Environment.TickCount);
                messageFill += entryLen;
            }

            if (reply != null)
            {
                agent.SendMessageAlways(reply, scene.ID);
            }
        }
Ejemplo n.º 12
0
        private void HandleAvatarPropertiesRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (AvatarPropertiesRequest)m;

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

            ProfileServiceData serviceData;
            UGUI uui;

            try
            {
                serviceData = LookupProfileService(scene, req.AvatarID, out uui);
            }
            catch
            {
                return;
            }

            UserAgentServiceInterface.UserInfo userInfo;
            ProfileProperties props;

            try
            {
                userInfo = serviceData.UserAgentService.GetUserInfo(uui);
            }
            catch
#if DEBUG
            (Exception e)
#endif
            {
#if DEBUG
                m_Log.Debug("Exception at userinfo request", e);
#endif
                userInfo = new UserAgentServiceInterface.UserInfo
                {
                    FirstName   = string.Empty,
                    LastName    = string.Empty,
                    UserFlags   = 0,
                    UserCreated = new Date(),
                    UserTitle   = string.Empty
                };
            }

            try
            {
                props = serviceData.ProfileService.Properties[uui];
            }
            catch
#if DEBUG
            (Exception e)
#endif
            {
#if DEBUG
                m_Log.Debug("Exception at properties request", e);
#endif
                props = new ProfileProperties
                {
                    ImageID          = "5748decc-f629-461c-9a36-a35a221fe21f",
                    FirstLifeImageID = "5748decc-f629-461c-9a36-a35a221fe21f",
                    User             = uui,
                    Partner          = UGUI.Unknown,
                    AboutText        = string.Empty,
                    FirstLifeText    = string.Empty,
                    Language         = string.Empty,
                    WantToText       = string.Empty,
                    SkillsText       = string.Empty,
                    WebUrl           = string.Empty
                };
            }

            var res = new AvatarPropertiesReply
            {
                AgentID  = req.AgentID,
                AvatarID = req.AvatarID,

                ImageID       = props.ImageID,
                FLImageID     = props.FirstLifeImageID,
                PartnerID     = props.Partner.ID,
                AboutText     = props.AboutText,
                FLAboutText   = props.FirstLifeText,
                BornOn        = userInfo.UserCreated.ToString("M/d/yyyy", CultureInfo.InvariantCulture),
                ProfileURL    = props.WebUrl,
                CharterMember = new byte[] { 0 },
                Flags         = 0
            };
            agent.SendMessageAlways(res, scene.ID);

            var res2 = new AvatarInterestsReply
            {
                AgentID  = req.AgentID,
                AvatarID = req.AvatarID
            };
            agent.SendMessageAlways(res2, scene.ID);

            var res3 = new AvatarGroupsReply
            {
                AgentID  = req.AgentID,
                AvatarID = req.AvatarID
            };
            /* when the scene has a groups service, we check which groups the avatar has */
            if (scene.GroupsService != null)
            {
                try
                {
                    foreach (var gmem in scene.GroupsService.Memberships[uui, uui])
                    {
                        res3.GroupData.Add(new AvatarGroupsReply.GroupDataEntry
                        {
                            GroupPowers     = gmem.GroupPowers,
                            AcceptNotices   = gmem.IsAcceptNotices,
                            GroupTitle      = gmem.GroupTitle,
                            GroupName       = gmem.Group.GroupName,
                            GroupInsigniaID = gmem.GroupInsigniaID,
                            ListInProfile   = gmem.IsListInProfile
                        });
                    }
                }
                catch (GroupsServiceNotFoundException)
                {
                    /* intentionally ignored */
                }
                catch
#if DEBUG
                (Exception e)
#endif
                {
                    /* do not expose exceptions to caller */
#if DEBUG
                    m_Log.Debug("Exception at groups request", e);
#endif
                }
            }
            agent.SendMessageAlways(res3, scene.ID);
        }
Ejemplo n.º 13
0
        private void HandleMapItemRequest(ViewerAgent agent, SceneInterface scene, Message m)
        {
            var req = (MapItemRequest)m;

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

            var reply = new MapItemReply
            {
                AgentID  = agent.ID,
                Flags    = req.Flags,
                ItemType = req.ItemType
            };
            SceneInterface accessScene = null;

            if (req.Location.RegionHandle == 0 ||
                req.Location.Equals(scene.GridPosition))
            {
                accessScene = scene;
            }
            else
            {
                try
                {
                    accessScene = m_Scenes[req.Location];
                }
                catch
                {
                    accessScene = null; /* remote */
                }
            }

            switch (req.ItemType)
            {
            case MapItemType.AgentLocations:
                if (accessScene != null)
                {
                    /* local */
                    foreach (var sceneagent in accessScene.Agents)
                    {
                        if (sceneagent.IsInScene(accessScene) && !sceneagent.Owner.Equals(agent.Owner) && sceneagent is ViewerAgent)
                        {
                            var d = new MapItemReply.DataEntry
                            {
                                X      = (ushort)sceneagent.GlobalPosition.X,
                                Y      = (ushort)sceneagent.GlobalPosition.Y,
                                ID     = UUID.Zero,
                                Name   = sceneagent.NamedOwner.FullName,
                                Extra  = 1,
                                Extra2 = 0
                            };
                            reply.Data.Add(d);
                        }
                    }
                }
                else
                {
                    /* remote */
                }
                break;

            case MapItemType.LandForSale:
                if (accessScene != null)
                {
                    /* local */
                    foreach (var parcel in accessScene.Parcels)
                    {
                        if ((parcel.Flags & ParcelFlags.ForSale) != 0)
                        {
                            var    d = new MapItemReply.DataEntry();
                            double x = (parcel.AABBMin.X + parcel.AABBMax.X) / 2;
                            double y = (parcel.AABBMin.Y + parcel.AABBMax.Y) / 2;
                            d.X      = (ushort)x;
                            d.Y      = (ushort)y;
                            d.ID     = parcel.ID;
                            d.Name   = parcel.Name;
                            d.Extra  = parcel.Area;
                            d.Extra2 = parcel.SalePrice;
                            reply.Data.Add(d);
                        }
                    }
                }
                else
                {
                    /* remote */
                }
                break;

            case MapItemType.Telehub:
                if (accessScene != null)
                {
                    /* local */
                }
                else
                {
                    /* remote */
                }
                break;
            }
            agent.SendMessageAlways(reply, scene.ID);
        }