Exemple #1
0
        /// <summary>
        /// Look up the given user id to check whether it's one that is valid for this grid.
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        private bool ResolveUserUuid(UUID uuid)
        {
            if (!m_validUserUuids.ContainsKey(uuid))
            {
                try
                {
                    UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(uuid);
                    if (profile != null)
                    {
                        m_validUserUuids.Add(uuid, true);
                    }
                    else
                    {
                        //what about group ids?
                        GroupRecord grpRec = m_GroupsModule.GetGroupRecord(uuid);

                        if (grpRec != null)
                        {
                            m_validUserUuids.Add(uuid, true);
                        }
                        else
                        {
                            m_validUserUuids.Add(uuid, false);
                        }
                    }
                }
                catch (UserProfileException)
                {
                    //what about group ids?
                    GroupRecord grpRec = m_GroupsModule.GetGroupRecord(uuid);

                    if (grpRec != null)
                    {
                        m_validUserUuids.Add(uuid, true);
                    }
                    else
                    {
                        m_validUserUuids.Add(uuid, false);
                    }
                }
            }

            if (m_validUserUuids[uuid])
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// Look up the given group id to check whether it's one that is valid for this grid.
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        private bool ResolveGroupUuid(UUID uuid)
        {
            if (uuid == UUID.Zero)
            {
                return(true);    // this means the object has no group
            }
            lock (m_validGroupUuids)
            {
                if (!m_validGroupUuids.ContainsKey(uuid))
                {
                    bool exists;
                    if (m_groupsModule == null)
                    {
                        exists = false;
                    }
                    else
                    {
                        // Note: we call GetGroupRecord() inside the lock because this GroupID is likely
                        // to occur many times, and we only want to query the groups service once.
                        exists = (m_groupsModule.GetGroupRecord(uuid) != null);
                    }
                    m_validGroupUuids.Add(uuid, exists);
                }

                return(m_validGroupUuids[uuid]);
            }
        }
Exemple #3
0
        private void GetOwnerName(UUID ownerID, out string ownerFirstName, out string ownerLastName)
        {
            ownerFirstName = string.Empty;
            ownerLastName  = string.Empty;
            string username = m_scene.UserManagementModule.GetUserName(ownerID);

            if (!string.IsNullOrEmpty(username) && !username.StartsWith("UnknownUMM2", StringComparison.InvariantCulture))
            {
                string[] parts = username.Split(' ');
                ownerFirstName = parts[0];
                if (parts.Length > 1)
                {
                    ownerLastName = parts[1];
                }
            }
            else
            {
                IGroupsModule groups = m_scene.RequestModuleInterface <IGroupsModule>();
                if (groups != null)
                {
                    GroupRecord grprec = groups.GetGroupRecord(ownerID);
                    if (grprec != null && !string.IsNullOrEmpty(grprec.GroupName))
                    {
                        ownerFirstName = grprec.GroupName;
                    }
                }
            }
            if (string.IsNullOrEmpty(ownerFirstName))
            {
                ownerFirstName = "(unknown)";
                ownerLastName  = string.Empty;
            }
        }
Exemple #4
0
        private void HandleOnInstantMessage(IClientAPI client, GridInstantMessage msg)
        {
//            m_log.DebugFormat(
//                "[EVENT RECORDER]: Handling IM from {0} {1}, type {2}",
//                client.Name, client.AgentId, (InstantMessageDialog)msg.dialog);

            if (msg.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
                msg.dialog != (byte)InstantMessageDialog.SessionSend)
            {
                return;
            }

            bool toGroup = msg.dialog == (byte)InstantMessageDialog.SessionSend;

            if (toGroup)
            {
                if (!RecordUserToGroupImEvents)
                {
                    return;
                }
            }
            else
            {
                if (!RecordUserToUserImEvents)
                {
                    return;
                }
            }

            string receiverName = "UNKNOWN";
            UUID   receiverId;

            if (toGroup)
            {
                receiverId = new UUID(msg.imSessionID);

                if (m_groupsModule != null)
                {
                    GroupRecord gr = m_groupsModule.GetGroupRecord(receiverId);

                    if (gr != null)
                    {
                        receiverName = gr.GroupName;
                    }
                }
            }
            else
            {
                receiverId   = new UUID(msg.fromAgentID);
                receiverName = m_userManagementModule.GetUserName(new UUID(msg.toAgentID));
            }

            m_recorder.RecordEvent(
                new UserImEvent(
                    new UUID(msg.fromAgentID), msg.fromAgentName, receiverId, receiverName,
                    toGroup, msg.message, m_gridId, client.Scene.Name));
        }
Exemple #5
0
        /// <summary>
        /// Updates the userpicks
        /// </summary>
        /// <param name='remoteClient'>
        /// Remote client.
        /// </param>
        /// <param name='pickID'>
        /// Pick I.
        /// </param>
        /// <param name='creatorID'>
        /// the creator of the pick
        /// </param>
        /// <param name='topPick'>
        /// Top pick.
        /// </param>
        /// <param name='name'>
        /// Name.
        /// </param>
        /// <param name='desc'>
        /// Desc.
        /// </param>
        /// <param name='snapshotID'>
        /// Snapshot I.
        /// </param>
        /// <param name='sortOrder'>
        /// Sort order.
        /// </param>
        /// <param name='enabled'>
        /// Enabled.
        /// </param>
        public void PickInfoUpdate(IClientAPI remoteClient, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
        {
            m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString());
            UserProfilePick pick      = new UserProfilePick();
            string          serverURI = string.Empty;

            GetUserProfileServerURI(remoteClient.AgentId, out serverURI);
            ScenePresence p = FindPresence(remoteClient.AgentId);

            Vector3 avaPos = p.AbsolutePosition;
            // Getting the global position for the Avatar
            Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX * Constants.RegionSize + avaPos.X,
                                            remoteClient.Scene.RegionInfo.RegionLocY * Constants.RegionSize + avaPos.Y,
                                            avaPos.Z);

            string      landOwnerName = string.Empty;
            ILandObject land          = p.Scene.LandChannel.GetLandObject(avaPos.X, avaPos.Y);

            if (land.LandData.IsGroupOwned)
            {
                IGroupsModule groupMod    = p.Scene.RequestModuleInterface <IGroupsModule>();
                UUID          groupId     = land.LandData.GroupID;
                GroupRecord   groupRecord = groupMod.GetGroupRecord(groupId);
                landOwnerName = groupRecord.GroupName;
            }
            else
            {
                IUserAccountService accounts = p.Scene.RequestModuleInterface <IUserAccountService>();
                UserAccount         user     = accounts.GetUserAccount(p.Scene.RegionInfo.ScopeID, land.LandData.OwnerID);
                landOwnerName = user.Name;
            }

            pick.PickId     = pickID;
            pick.CreatorId  = creatorID;
            pick.TopPick    = topPick;
            pick.Name       = name;
            pick.Desc       = desc;
            pick.ParcelId   = p.currentParcelUUID;
            pick.SnapshotId = snapshotID;
            pick.User       = landOwnerName;
            pick.SimName    = remoteClient.Scene.RegionInfo.RegionName;
            pick.GlobalPos  = posGlobal.ToString();
            pick.SortOrder  = sortOrder;
            pick.Enabled    = enabled;

            object Pick = (object)pick;

            if (!JsonRpcRequest(ref Pick, "picks_update", serverURI, UUID.Random().ToString()))
            {
                remoteClient.SendAgentAlertMessage(
                    "Error updating pick", false);
            }

            m_log.DebugFormat("[PROFILES]: Finish PickInfoUpdate {0} {1}", pick.Name, pick.PickId.ToString());
        }
Exemple #6
0
 /// <summary>
 /// Look up the given group id to check whether it's one that is valid for this grid.
 /// </summary>
 /// <param name="uuid"></param>
 /// <returns></returns>
 private bool ResolveGroupUuid(UUID uuid)
 {
     if (m_groupsModule == null)
     {
         return(false);
     }
     return(m_validGroupUuids.GetOrAddIfNotExists(uuid, delegate()
     {
         return (m_groupsModule.GetGroupRecord(uuid) != null);
     }));
 }
Exemple #7
0
        /// <summary>
        /// Get the given group.
        /// </summary>
        /// <exception cref="GroupsSetupException">Thrown if the group cannot be found</exception>
        /// <param name="groupName"></param>
        protected GroupRecord GetGroup(string groupName)
        {
            GroupRecord group = m_groupsModule.GetGroupRecord(groupName);

            if (null == group)
            {
                throw new GroupsSetupException(
                          string.Format("Could not find group {0}.  Please create it", groupName));
            }

            return(group);
        }
Exemple #8
0
        /**
         * @brief Allow any member of group given by config SetParcelMusicURLGroup to set music URL.
         *        Code modelled after llSetParcelMusicURL().
         * @param newurl = new URL to set (or "" to leave it alone)
         * @returns previous URL string
         */
        public string xmrSetParcelMusicURLGroup(string newurl)
        {
            string groupname = m_ScriptEngine.Config.GetString("SetParcelMusicURLGroup", "");

            if (groupname == "")
            {
                throw new ApplicationException("no SetParcelMusicURLGroup config param set");
            }

            IGroupsModule igm = World.RequestModuleInterface <IGroupsModule> ();

            if (igm == null)
            {
                throw new ApplicationException("no GroupsModule loaded");
            }

            GroupRecord grouprec = igm.GetGroupRecord(groupname);

            if (grouprec == null)
            {
                throw new ApplicationException("no such group " + groupname);
            }

            GroupMembershipData gmd = igm.GetMembershipData(grouprec.GroupID, m_host.OwnerID);

            if (gmd == null)
            {
                throw new ApplicationException("not a member of group " + groupname);
            }

            ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);

            if (land == null)
            {
                throw new ApplicationException("no land at " + m_host.AbsolutePosition.ToString());
            }
            string oldurl = land.GetMusicUrl();

            if (oldurl == null)
            {
                oldurl = "";
            }
            if ((newurl != null) && (newurl != ""))
            {
                land.SetMusicUrl(newurl);
            }
            return(oldurl);
        }
        public string ResolveGroupName(UUID groupID)
        {
            Scene         scene = GetRandomScene();
            IGroupsModule gm    = scene.RequestModuleInterface <IGroupsModule>();

            try
            {
                string @group = gm.GetGroupRecord(groupID).GroupName;
                if (@group != null)
                {
                    m_log.DebugFormat("[OMECONOMY]: Resolved group {0} to {1}", groupID, @group);
                    return(@group);
                }
            }
            catch (Exception)
            {
                m_log.ErrorFormat("[OMECONOMY]: Could not resolve group {0}", groupID);
            }

            return(String.Empty);
        }
Exemple #10
0
        /// <summary>
        /// Look up the given group id to check whether it's one that is valid for this grid.
        /// </summary>
        /// <param name="uuid"></param>
        /// <returns></returns>
        private bool ResolveGroupUuid(UUID uuid)
        {
            if (uuid == UUID.Zero)
            {
                return(true);    // this means the object has no group
            }
            if (!m_validGroupUuids.ContainsKey(uuid))
            {
                bool exists;

                if (m_groupsModule == null)
                {
                    exists = false;
                }
                else
                {
                    exists = (m_groupsModule.GetGroupRecord(uuid) != null);
                }

                m_validGroupUuids.Add(uuid, exists);
            }

            return(m_validGroupUuids[uuid]);
        }
        UUID ResolveGroupUuid(UUID GroupID)
        {
            UUID u;

            if (!m_validGroupUuids.TryGetValue(GroupID, out u))
            {
                IGroupsModule groups = m_scene.RequestModuleInterface <IGroupsModule> ();
                if (groups != null)
                {
                    GroupRecord gr = groups.GetGroupRecord(GroupID);
                    if (gr != null)
                    {
                        m_validGroupUuids.Add(GroupID, GroupID);
                    }
                    else
                    {
                        m_validGroupUuids.Add(GroupID, UUID.Zero);          // GroupID does not exist.. keep track
                    }
                }
                return(m_validGroupUuids [GroupID]);
            }

            return(u);
        }
Exemple #12
0
        public string resolveName(UUID objecUUID)
        {
            // try avatar username surname
            UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, objecUUID);

            if (account != null)
            {
                return(account.Name);
            }

            // try an scene object
            ISceneChildEntity SOP = World.GetSceneObjectPart(objecUUID);

            if (SOP != null)
            {
                return(SOP.Name);
            }

            ISceneChildEntity SensedObject;

            if (!World.TryGetPart(objecUUID, out SensedObject))
            {
                IGroupsModule groups = World.RequestModuleInterface <IGroupsModule>();
                if (groups != null)
                {
                    GroupRecord gr = groups.GetGroupRecord(objecUUID);
                    if (gr != null)
                    {
                        return(gr.GroupName);
                    }
                }
                return(String.Empty);
            }

            return(SensedObject.Name);
        }
        protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            Dictionary <string, object> request = new Dictionary <string, object>();

            foreach (string name in httpRequest.QueryString)
            {
                request[name] = httpRequest.QueryString[name];
            }

            httpResponse.ContentType = "application/json";

            mainDataSet _dataSet = new mainDataSet();

            foreach (Scene _scene in m_scenes)
            {
                try
                {
                    if (_scene != null)
                    {
                        regionDataSet _regionData = new regionDataSet();

                        _regionData.RegionName              = ToUTF8(_scene.Name);
                        _regionData.RegionEstate            = ToUTF8(_scene.RegionInfo.EstateSettings.EstateName);
                        _regionData.RegionImageUUID         = _scene.RegionInfo.lastMapUUID.ToString();
                        _regionData.RegionPosition          = _scene.RegionInfo.WorldLocX + "/" + _scene.RegionInfo.WorldLocY;
                        _regionData.RegionPublicAccess      = _scene.RegionInfo.EstateSettings.PublicAccess;
                        _regionData.RegionSize              = _scene.RegionInfo.RegionSizeX.ToString();
                        _regionData.RegionUUID              = _scene.RegionInfo.RegionID.ToString();
                        _regionData.RegionIsVisibleInSearch = true;

                        if (m_config.Configs["Hypergrid"] != null)
                        {
                            _regionData.RegionHomeURI = m_config.Configs["Hypergrid"].GetString("HomeURI", string.Empty);
                        }

                        _dataSet.RegionData.Add(_regionData);

                        List <ILandObject> _landData = _scene.LandChannel.AllParcels();
                        foreach (ILandObject _parcel in _landData)
                        {
                            try
                            {
                                parcelDataSet _parcelSet = new parcelDataSet();

                                if (_parcel.LandData != null)
                                {
                                    _parcelSet.ParcelName            = ToUTF8(_parcel.LandData.Name);
                                    _parcelSet.ParcelDescription     = ToUTF8(_parcel.LandData.Description);
                                    _parcelSet.ImageUUID             = _parcel.LandData.SnapshotID.ToString();
                                    _parcelSet.ParcelDwell           = (int)_parcel.LandData.Dwell;
                                    _parcelSet.ParcelGroup           = _parcel.LandData.GroupID.ToString();
                                    _parcelSet.ParcelOwner.OwnerUUID = _parcel.LandData.OwnerID.ToString();

                                    if (_parcelSet.ParcelOwner.OwnerUUID != _parcelSet.ParcelGroup)
                                    {
                                        if (m_userManager != null)
                                        {
                                            _parcelSet.ParcelOwner.OwnerName    = m_userManager.GetUserName(_parcel.LandData.OwnerID);
                                            _parcelSet.ParcelOwner.OwnerHomeURI = m_userManager.GetUserHomeURL(_parcel.LandData.OwnerID);

                                            if (_parcelSet.ParcelOwner.OwnerHomeURI == String.Empty)
                                            {
                                                _parcelSet.ParcelOwner.OwnerHomeURI = _regionData.RegionHomeURI;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (_parcelSet.ParcelOwner.OwnerUUID == _parcelSet.ParcelGroup)
                                        {
                                            IGroupsModule groups = _scene.RequestModuleInterface <IGroupsModule>();

                                            if (groups != null)
                                            {
                                                GroupRecord _group = groups.GetGroupRecord(_parcel.LandData.GroupID);

                                                if (_group != null)
                                                {
                                                    _parcelSet.ParcelOwner.OwnerName    = _group.GroupName;
                                                    _parcelSet.ParcelOwner.OwnerHomeURI = _regionData.RegionHomeURI;

                                                    if (_dataSet.GroupData.Find(x => x.GroupUUID == _group.GroupID.ToString()) == null)
                                                    {
                                                        GroupDataSet _groupData = new GroupDataSet();

                                                        _groupData.GroupName         = _group.GroupName;
                                                        _groupData.GroupHomeURI      = _regionData.RegionHomeURI;
                                                        _groupData.GroupUUID         = _group.GroupID.ToString();
                                                        _groupData.GroupImage        = _group.GroupPicture.ToString();
                                                        _groupData.GroupShowInList   = _group.ShowInList;
                                                        _groupData.GroupAllowPublish = _group.AllowPublish;
                                                        _groupData.GroupFounder      = _group.FounderID.ToString();

                                                        _dataSet.GroupData.Add(_groupData);
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    _parcelSet.ParcelPosition = _parcel.CenterPoint.X + "/" + _parcel.CenterPoint.Y;

                                    if (_parcel.LandData.LandingType == (byte)LandingType.LandingPoint)
                                    {
                                        if (_parcel.LandData.UserLocation.X != 0 && _parcel.LandData.UserLocation.X != 0 && _parcel.LandData.UserLocation.X != 0)
                                        {
                                            _parcelSet.ParcelPosition = _parcel.LandData.UserLocation.X + "/" + _parcel.LandData.UserLocation.Y + "/" + _parcel.LandData.UserLocation.Z;
                                        }
                                    }

                                    _parcelSet.ParcelPrims = _parcel.GetParcelMaxPrimCount();

                                    _parcelSet.ParcelSize              = _parcel.LandData.Area;
                                    _parcelSet.ParcelBitmap            = Convert.ToBase64String(_parcel.LandData.Bitmap);
                                    _parcelSet.ParcelPrice             = _parcel.LandData.SalePrice;
                                    _parcelSet.ParcelIsVisibleInSearch = getStatusForSearch(_parcel);
                                    _parcelSet.ParcelIsForSale         = getStatusForSale(_parcel);
                                    _parcelSet.ParentUUID              = _scene.RegionInfo.RegionID.ToString();
                                    _parcelSet.ParcelUUID              = _parcel.LandData.GlobalID.ToString();

                                    _dataSet.ParcelData.Add(_parcelSet);
                                }
                            }
                            catch
                            {
                                m_log.Error("Error while fetching land data.");
                            }
                        }

                        foreach (SceneObjectGroup _cog in _scene.GetSceneObjectGroups())
                        {
                            try
                            {
                                if (_cog != null)
                                {
                                    if (_cog.IsTemporary == false && _cog.IsAttachment == false)
                                    {
                                        objectDataSet _objectData = new objectDataSet();

                                        _objectData.ObjectName        = ToUTF8(_cog.Name);
                                        _objectData.ObjectDescription = ToUTF8(_cog.Description);
                                        _objectData.ObjectUUID        = _cog.RootPart.UUID.ToString();
                                        _objectData.ParentUUID        = _scene.LandChannel.GetLandObject(_cog.RootPart.AbsolutePosition.X, _cog.RootPart.AbsolutePosition.Y).LandData.GlobalID.ToString();
                                        _objectData.ObjectIsForSale   = false;
                                        _objectData.ObjectSalePrice   = _cog.RootPart.SalePrice;

                                        if (_cog.RootPart.ObjectSaleType != (byte)0)
                                        {
                                            _objectData.ObjectIsForSale = true;
                                        }

                                        _objectData.ObjectIsForCopy       = getStatusForCopy(_cog);
                                        _objectData.ObjectGroupUUID       = _cog.GroupID.ToString();
                                        _objectData.ObjectItemUUID        = _cog.FromItemID.ToString();
                                        _objectData.ObjectOwner.OwnerUUID = _cog.OwnerID.ToString();

                                        _objectData.Textures = getAllTextures(_cog);

                                        foreach (SceneObjectPart part in _cog.Parts)
                                        {
                                            foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems())
                                            {
                                                inventoryDataSet data = new inventoryDataSet();
                                                data.AssetID       = item.AssetID.ToString();
                                                data.ItemID        = item.ItemID.ToString();
                                                data.Name          = item.Name;
                                                data.Description   = item.Description;
                                                data.InventoryType = item.InvType;
                                                _objectData.Inventory.Add(data);
                                            }
                                        }

                                        if (_objectData.ObjectOwner.OwnerUUID != _objectData.ObjectGroupUUID)
                                        {
                                            if (m_userManager != null)
                                            {
                                                _objectData.ObjectOwner.OwnerName    = m_userManager.GetUserName(_cog.OwnerID);
                                                _objectData.ObjectOwner.OwnerHomeURI = m_userManager.GetUserHomeURL(_cog.OwnerID);

                                                if (_objectData.ObjectOwner.OwnerHomeURI == String.Empty)
                                                {
                                                    _objectData.ObjectOwner.OwnerHomeURI = _regionData.RegionHomeURI;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (_objectData.ObjectOwner.OwnerUUID == _objectData.ObjectGroupUUID)
                                            {
                                                IGroupsModule groups = _scene.RequestModuleInterface <IGroupsModule>();

                                                if (groups != null)
                                                {
                                                    GroupRecord _group = groups.GetGroupRecord(_cog.RootPart.GroupID);

                                                    if (_group != null)
                                                    {
                                                        _objectData.ObjectOwner.OwnerName    = _group.GroupName;
                                                        _objectData.ObjectOwner.OwnerHomeURI = _regionData.RegionHomeURI;

                                                        if (_dataSet.GroupData.Find(x => x.GroupUUID == _group.GroupID.ToString()) == null)
                                                        {
                                                            GroupDataSet _groupData = new GroupDataSet();

                                                            _groupData.GroupName         = _group.GroupName;
                                                            _groupData.GroupHomeURI      = _regionData.RegionHomeURI;
                                                            _groupData.GroupUUID         = _group.GroupID.ToString();
                                                            _groupData.GroupImage        = _group.GroupPicture.ToString();
                                                            _groupData.GroupShowInList   = _group.ShowInList;
                                                            _groupData.GroupAllowPublish = _group.AllowPublish;
                                                            _groupData.GroupFounder      = _group.FounderID.ToString();

                                                            _dataSet.GroupData.Add(_groupData);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        _objectData.ObjectPosition          = _cog.RootPart.AbsolutePosition.X + "/" + _cog.RootPart.AbsolutePosition.Y + "/" + _cog.RootPart.AbsolutePosition.Z;
                                        _objectData.ObjectImageUUID         = GuessImage(_cog);
                                        _objectData.ObjectIsVisibleInSearch = getStatusForSearch(_cog);

                                        _dataSet.ObjectData.Add(_objectData);
                                    }
                                }
                            }
                            catch
                            {
                                m_log.Error("Error while fetching scene object groups.");
                            }
                        }

                        foreach (ScenePresence _presence in _scene.GetScenePresences())
                        {
                            try
                            {
                                if (_presence.PresenceType == PresenceType.User)
                                {
                                    agentDataSet _agentData = new agentDataSet();
                                    _agentData.AgentName = _presence.Name;

                                    if (_presence.AbsolutePosition != null)
                                    {
                                        _agentData.AgentPosition = _presence.AbsolutePosition.X + "/" + _presence.AbsolutePosition.Y + "/" + _presence.AbsolutePosition.Z;
                                    }

                                    _agentData.AgentUUID    = _presence.UUID.ToString();
                                    _agentData.AgentHomeURI = _scene.GetAgentHomeURI(_presence.UUID);

                                    if (_scene.LandChannel != null && _presence.AbsolutePosition != null)
                                    {
                                        _agentData.ParentUUID = _scene.LandChannel.GetLandObject(_presence.AbsolutePosition.X, _presence.AbsolutePosition.Y).LandData.GlobalID.ToString();
                                    }

                                    _dataSet.AvatarData.Add(_agentData);
                                }
                            }
                            catch
                            {
                                m_log.Error("Error while fetching presence data.");
                            }
                        }
                    }
                }catch
                {
                    m_log.Error("Error while fetching scene data.");
                }
            }

            return(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(_dataSet, Formatting.Indented)));
        }
        private void ProcessMessageFromGroupSession(GridInstantMessage msg)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
            }

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID);
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID);
                break;

            case (byte)InstantMessageDialog.SessionSend:
                if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) &&
                    !m_agentsDroppedSession.ContainsKey(msg.toAgentID))
                {
                    // Agent not in session and hasn't dropped from session
                    // Add them to the session for now, and Invite them
                    AddAgentToGroupSession(msg.toAgentID, msg.imSessionID);

                    UUID       toAgentID    = new UUID(msg.toAgentID);
                    IClientAPI activeClient = GetActiveClient(toAgentID);
                    if (activeClient != null)
                    {
                        UUID groupID = new UUID(msg.fromAgentID);

                        GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled)
                            {
                                m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                            }

                            // Force? open the group session dialog???
                            IEventQueue eq = activeClient.Scene.RequestModuleInterface <IEventQueue>();
                            eq.ChatterboxInvitation(
                                groupID
                                , groupInfo.GroupName
                                , new UUID(msg.fromAgentID)
                                , msg.message, new UUID(msg.toAgentID)
                                , msg.fromAgentName
                                , msg.dialog
                                , msg.timestamp
                                , msg.offline == 1
                                , (int)msg.ParentEstateID
                                , msg.Position
                                , 1
                                , new UUID(msg.imSessionID)
                                , msg.fromGroup
                                , Utils.StringToBytes(groupInfo.GroupName)
                                );

                            eq.ChatterBoxSessionAgentListUpdates(
                                new UUID(groupID)
                                , new UUID(msg.fromAgentID)
                                , new UUID(msg.toAgentID)
                                , false     //canVoiceChat
                                , false     //isModerator
                                , false     //text mute
                                );
                        }
                    }
                }
                else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID))
                {
                    // User hasn't dropped, so they're in the session,
                    // maybe we should deliver it.
                    IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
                    if (client != null)
                    {
                        // Deliver locally, directly
                        if (m_debugEnabled)
                        {
                            m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name);
                        }
                        client.SendInstantMessage(msg);
                    }
                    else
                    {
                        m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
                    }
                }
                break;

            default:
                m_log.WarnFormat("[GROUPS-MESSAGING]: I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString());
                break;
            }
        }
Exemple #15
0
        public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
        {
            XmlNode      parent      = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", "");
            ILandChannel landChannel = m_scene.LandChannel;

            if (landChannel == null)
            {
                return(parent);
            }

            List <ILandObject> parcels = landChannel.AllParcels();

            IDwellModule dwellModule = m_scene.RequestModuleInterface <IDwellModule>();

            if (parcels != null)
            {
                //foreach (KeyValuePair<int, Land> curParcel in m_landIndexed)
                foreach (ILandObject parcel_interface in parcels)
                {
                    // Play it safe
                    if (!(parcel_interface is LandObject))
                    {
                        continue;
                    }

                    LandObject land = (LandObject)parcel_interface;

                    LandData parcel = land.LandData;
                    if (m_parent.ExposureLevel.Equals("all") ||
                        (m_parent.ExposureLevel.Equals("minimum") &&
                         (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory))
                    {
                        //TODO: make better method of marshalling data from LandData to XmlNode
                        XmlNode xmlparcel = nodeFactory.CreateNode(XmlNodeType.Element, "parcel", "");

                        // Attributes of the parcel node
                        XmlAttribute scripts_attr = nodeFactory.CreateAttribute("scripts");
                        scripts_attr.Value = GetScriptsPermissions(parcel);
                        XmlAttribute build_attr = nodeFactory.CreateAttribute("build");
                        build_attr.Value = GetBuildPermissions(parcel);
                        XmlAttribute public_attr = nodeFactory.CreateAttribute("public");
                        public_attr.Value = GetPublicPermissions(parcel);
                        // Check the category of the Parcel
                        XmlAttribute category_attr = nodeFactory.CreateAttribute("category");
                        category_attr.Value = ((int)parcel.Category).ToString();
                        // Check if the parcel is for sale
                        XmlAttribute forsale_attr = nodeFactory.CreateAttribute("forsale");
                        forsale_attr.Value = CheckForSale(parcel);
                        XmlAttribute sales_attr = nodeFactory.CreateAttribute("salesprice");
                        sales_attr.Value = parcel.SalePrice.ToString();

                        XmlAttribute directory_attr = nodeFactory.CreateAttribute("showinsearch");
                        directory_attr.Value = GetShowInSearch(parcel);
                        //XmlAttribute entities_attr = nodeFactory.CreateAttribute("entities");
                        //entities_attr.Value = land.primsOverMe.Count.ToString();
                        xmlparcel.Attributes.Append(directory_attr);
                        xmlparcel.Attributes.Append(scripts_attr);
                        xmlparcel.Attributes.Append(build_attr);
                        xmlparcel.Attributes.Append(public_attr);
                        xmlparcel.Attributes.Append(category_attr);
                        xmlparcel.Attributes.Append(forsale_attr);
                        xmlparcel.Attributes.Append(sales_attr);
                        //xmlparcel.Attributes.Append(entities_attr);


                        //name, description, area, and UUID
                        XmlNode name = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
                        name.InnerText = parcel.Name;
                        xmlparcel.AppendChild(name);

                        XmlNode desc = nodeFactory.CreateNode(XmlNodeType.Element, "description", "");
                        desc.InnerText = parcel.Description;
                        xmlparcel.AppendChild(desc);

                        XmlNode uuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
                        uuid.InnerText = parcel.GlobalID.ToString();
                        xmlparcel.AppendChild(uuid);

                        XmlNode area = nodeFactory.CreateNode(XmlNodeType.Element, "area", "");
                        area.InnerText = parcel.Area.ToString();
                        xmlparcel.AppendChild(area);

                        //default location
                        XmlNode tpLocation = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
                        Vector3 loc        = parcel.UserLocation;
                        if (loc.Equals(Vector3.Zero)) // This test is moot at this point: the location is wrong by default
                        {
                            loc = new Vector3((parcel.AABBMax.X + parcel.AABBMin.X) / 2, (parcel.AABBMax.Y + parcel.AABBMin.Y) / 2, (parcel.AABBMax.Z + parcel.AABBMin.Z) / 2);
                        }
                        tpLocation.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString();
                        xmlparcel.AppendChild(tpLocation);

                        XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", "");
                        uint    x = (uint)loc.X, y = (uint)loc.Y;
                        findPointInParcel(land, ref x, ref y); // find a suitable spot
                        infouuid.InnerText = Util.BuildFakeParcelID(
                            m_scene.RegionInfo.RegionHandle, x, y).ToString();
                        xmlparcel.AppendChild(infouuid);

                        XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", "");
                        if (dwellModule != null)
                        {
                            dwell.InnerText = dwellModule.GetDwell(parcel.GlobalID).ToString();
                        }
                        else
                        {
                            dwell.InnerText = "0";
                        }
                        xmlparcel.AppendChild(dwell);

                        //TODO: figure how to figure out teleport system landData.landingType

                        //land texture snapshot uuid
                        if (parcel.SnapshotID != UUID.Zero)
                        {
                            XmlNode textureuuid = nodeFactory.CreateNode(XmlNodeType.Element, "image", "");
                            textureuuid.InnerText = parcel.SnapshotID.ToString();
                            xmlparcel.AppendChild(textureuuid);
                        }

                        string groupName = String.Empty;

                        //attached user and group
                        if (parcel.GroupID != UUID.Zero)
                        {
                            XmlNode groupblock = nodeFactory.CreateNode(XmlNodeType.Element, "group", "");
                            XmlNode groupuuid  = nodeFactory.CreateNode(XmlNodeType.Element, "groupuuid", "");
                            groupuuid.InnerText = parcel.GroupID.ToString();
                            groupblock.AppendChild(groupuuid);

                            IGroupsModule gm = m_scene.RequestModuleInterface <IGroupsModule>();
                            if (gm != null)
                            {
                                GroupRecord g = gm.GetGroupRecord(parcel.GroupID);
                                if (g != null)
                                {
                                    groupName = g.GroupName;
                                }
                            }

                            XmlNode groupname = nodeFactory.CreateNode(XmlNodeType.Element, "groupname", "");
                            groupname.InnerText = groupName;
                            groupblock.AppendChild(groupname);

                            xmlparcel.AppendChild(groupblock);
                        }

                        XmlNode userblock = nodeFactory.CreateNode(XmlNodeType.Element, "owner", "");

                        UUID userOwnerUUID = parcel.OwnerID;

                        XmlNode useruuid = nodeFactory.CreateNode(XmlNodeType.Element, "uuid", "");
                        useruuid.InnerText = userOwnerUUID.ToString();
                        userblock.AppendChild(useruuid);

                        if (!parcel.IsGroupOwned)
                        {
                            try
                            {
                                XmlNode     username = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
                                UserAccount account  = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID);
                                if (account != null)
                                {
                                    username.InnerText = account.FirstName + " " + account.LastName;
                                }
                                else
                                {
                                    username.InnerText = "UnKnown";
                                }
                                userblock.AppendChild(username);
                            }
                            catch (Exception)
                            {
                                //m_log.Info("[DATASNAPSHOT]: Cannot find owner name; ignoring this parcel");
                            }
                        }
                        else
                        {
                            XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
                            username.InnerText = groupName;
                            userblock.AppendChild(username);
                        }

                        xmlparcel.AppendChild(userblock);

                        parent.AppendChild(xmlparcel);
                    }
                }
                //snap.AppendChild(parent);
            }

            this.Stale = false;
            return(parent);
        }
        private void ProcessMessageFromGroupSession(GridInstantMessage msg)
        {
            if (m_debugEnabled)
            {
                m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
            }

            switch (msg.dialog)
            {
            case (byte)InstantMessageDialog.SessionAdd:
                AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID);
                NotifyNewSessionUserOfExisting(msg.imSessionID, msg.fromAgentID);
                NotifySessionUserTransition(msg.imSessionID, msg.fromAgentID, msg.dialog);
                break;

            case (byte)InstantMessageDialog.SessionDrop:
                RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID);
                NotifySessionUserTransition(msg.imSessionID, msg.fromAgentID, msg.dialog);
                break;

            case (byte)InstantMessageDialog.SessionSend:
                bool needsSessionAdd     = false;
                bool agentDroppedSession = false;

                lock (m_sessionLock)
                {
                    needsSessionAdd     = (!HasAgentBeenInvited(msg.toAgentID, msg.imSessionID)) && (!HasAgentDroppedSession(msg.toAgentID, msg.imSessionID));
                    agentDroppedSession = HasAgentDroppedSession(msg.toAgentID, msg.imSessionID);
                }

                if (needsSessionAdd)
                {
                    // Agent not in session and hasn't dropped from session
                    // Add them to the session for now, and Invite them
                    AddAgentToGroupSession(msg.toAgentID, msg.imSessionID);

                    UUID       toAgentID    = new UUID(msg.toAgentID);
                    IClientAPI activeClient = GetActiveClient(toAgentID);
                    if (activeClient != null)
                    {
                        UUID groupID = new UUID(msg.imSessionID);       // caller passes the group ID here

                        GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
                        if (groupInfo != null)
                        {
                            if (m_debugEnabled)
                            {
                                m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
                            }

                            // UUID sessionID = new UUID(groupInfo.GroupID);
                            // msg.imSessionID = sessionID.Guid;
                            UUID sessionID = new UUID(msg.imSessionID);

                            // Force? open the group session dialog???
                            IEventQueue eq = activeClient.Scene.RequestModuleInterface <IEventQueue>();
                            eq.ChatterboxInvitation(
                                sessionID                                  // session ID
                                , groupInfo.GroupName                      // session name
                                , new UUID(msg.fromAgentID)                // from agent ID
                                , msg.message                              // message text
                                , new UUID(msg.toAgentID)                  // to agent ID
                                , msg.fromAgentName                        // from agent name
                                , msg.dialog                               // IM dialog type
                                , msg.timestamp                            // time stamp
                                , msg.offline == 1                         // offline
                                , 0                                        // parent estate ID
                                , Vector3.Zero                             // agent position
                                , 1                                        // TTL
                                , groupID                                  // transaction ID (caller passes the group ID here)
                                , msg.fromGroup                            // from group boolean (true)
                                , Utils.StringToBytes(groupInfo.GroupName) // binary bucket
                                );

                            NotifyNewSessionUserOfExisting(msg.imSessionID, msg.fromAgentID);
                            NotifySessionUserTransition(msg.imSessionID, msg.fromAgentID, (byte)InstantMessageDialog.SessionAdd);

                            ((Scene)activeClient.Scene).EventManager.TriggerOnChatToClient(msg.message,
                                                                                           UUID.Parse(msg.fromAgentID.ToString()), UUID.Parse(msg.toAgentID.ToString()),
                                                                                           activeClient.Scene.RegionInfo.RegionID, msg.timestamp,
                                                                                           ChatToClientType.GroupMessage);
                        }
                    }
                }
                else if (!agentDroppedSession)
                {
                    // User hasn't dropped, so they're in the session,
                    // maybe we should deliver it.
                    IClientAPI client = GetActiveClient(new UUID(msg.toAgentID));
                    if (client != null)
                    {
                        // Deliver locally, directly
                        if (m_debugEnabled)
                        {
                            m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name);
                        }
                        client.SendInstantMessage(msg);
                    }
                    else
                    {
                        m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
                    }
                }
                break;

            default:
                m_log.WarnFormat("[GROUPS-MESSAGING]: I don't know how to proccess a {0} message.", ((InstantMessageDialog)msg.dialog).ToString());
                break;
            }
        }