Beispiel #1
0
 public UserInfo[] GetUserInfos(string[] userIDs)
 {
     UserInfo[] info = m_localService.GetUserInfos(userIDs);
     if (info == null)
     {
         info = m_remoteService.GetUserInfos(userIDs);
     }
     return(info);
 }
        public List <UserInfo> GetUserInfos(List <string> userIDs)
        {
            List <UserInfo> info = m_localService.GetUserInfos(userIDs);

            if (info == null)
            {
                info = (List <UserInfo>)DoRemoteForced(userIDs);
            }
            return(info);
        }
Beispiel #3
0
        private void DoPresenceUpdate(IScenePresence presence)
        {
            ReportAgent(presence);
            IFriendsModule    friendsModule = m_scene.RequestModuleInterface <IFriendsModule>();
            IAgentInfoService aservice      = m_scene.RequestModuleInterface <IAgentInfoService>();

            if (friendsModule != null)
            {
                Interfaces.FriendInfo[] friends = friendsModule.GetFriends(presence.UUID);
                List <string>           s       = new List <string>();
                for (int i = 0; i < friends.Length; i++)
                {
                    s.Add(friends[i].Friend);
                }
                List <UserInfo> infos = aservice.GetUserInfos(s);
                foreach (UserInfo u in infos)
                {
                    if (u != null && u.IsOnline)
                    {
                        friendsModule.SendFriendsStatusMessage(presence.UUID, UUID.Parse(u.UserID), true);
                    }
                }
                foreach (UserInfo u in infos)
                {
                    if (u != null && u.IsOnline)
                    {
                        if (!IsLocal(u, presence))
                        {
                            DoNonLocalPresenceUpdateCall(u, presence);
                        }
                        else
                        {
                            friendsModule.SendFriendsStatusMessage(UUID.Parse(u.UserID), presence.UUID, true);
                        }
                    }
                }
            }
        }
        private byte[] GetUserInfos(OSDMap request)
        {
            OSDArray userIDs = (OSDArray)request["userIDs"];

            string[] users = new string[userIDs.Count];
            for (int i = 0; i < userIDs.Count; i++)
            {
                users[i] = userIDs[i];
            }

            UserInfo[] result = m_AgentInfoService.GetUserInfos(users);

            OSDArray resultArray = new OSDArray();

            foreach (UserInfo info in result)
            {
                resultArray.Add(info != null ? info.ToOSD() : new OSD());
            }

            OSDMap resultMap = new OSDMap();

            resultMap["Result"] = resultArray;
            return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(resultMap)));
        }
Beispiel #5
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            if (httpRequest.Query.ContainsKey("regionid"))
            {
                var regionService = webInterface.Registry.RequestModuleInterface <IGridService>();
                var region        = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query["regionid"].ToString()));

                IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
                EstateSettings   estate          = null;

                if (estateConnector != null)
                {
                    estate = estateConnector.GetRegionEstateSettings(region.RegionID);
                }

                if (estate != null)
                {
                    vars.Add("OwnerUUID", estate.EstateOwner);
                    var estateOwnerAccount = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                                             GetUserAccount(null, estate.EstateOwner);
                    vars.Add("OwnerName", estateOwnerAccount == null ? "No account found" : estateOwnerAccount.Name);
                }
                else
                {
                    vars.Add("OwnerUUID", "Unknown");
                    vars.Add("OwnerName", "Unknown");
                }

                vars.Add("RegionName", region.RegionName);
                vars.Add("RegionLocX", region.RegionLocX / Constants.RegionSize);
                vars.Add("RegionLocY", region.RegionLocY / Constants.RegionSize);
                vars.Add("RegionSizeX", region.RegionSizeX);
                vars.Add("RegionSizeY", region.RegionSizeY);
                vars.Add("RegionType", region.RegionType);
                vars.Add("RegionTerrain", region.RegionTerrain);
                vars.Add("RegionMaturity", Utilities.GetRegionMaturity(region.Access));

                bool regionIsOnline = (region.Flags & (int)RegionFlags.RegionOnline) == (int)RegionFlags.RegionOnline;
                vars.Add("RegionOnline",
                         regionIsOnline
                    ? translator.GetTranslatedString("Online")
                    : translator.GetTranslatedString("Offline"));

                IAgentInfoService   agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService>();
                IUserAccountService userService      = webInterface.Registry.RequestModuleInterface <IUserAccountService>();

                if (agentInfoService != null)
                {
                    List <UserInfo> usersInRegion = agentInfoService.GetUserInfos(region.RegionID);
                    vars.Add("NumberOfUsersInRegion", usersInRegion != null ? usersInRegion.Count : 0);
                    List <Dictionary <string, object> > users = new List <Dictionary <string, object> >();

                    if (userService != null)
                    {
                        foreach (var client in usersInRegion)
                        {
                            UserAccount account = userService.GetUserAccount(null, (UUID)client.UserID);

                            if (account == null)
                            {
                                continue;
                            }

                            Dictionary <string, object> user = new Dictionary <string, object>();
                            user.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
                            user.Add("UserUUID", client.UserID);
                            user.Add("UserName", account.Name);
                            users.Add(user);
                        }
                    }

                    vars.Add("UsersInRegion", users);
                }
                else
                {
                    vars.Add("NumberOfUsersInRegion", 0);
                    vars.Add("UsersInRegion", new List <Dictionary <string, object> >());
                }

                IDirectoryServiceConnector directoryConnector = Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector>();

                if (directoryConnector != null)
                {
                    List <LandData> parcelData = directoryConnector.GetParcelsByRegion(0, 10, region.RegionID, UUID.Zero, ParcelFlags.None, ParcelCategory.Any);

                    if (parcelData != null)
                    {
                        vars.Add("NumberOfParcelsInRegion", parcelData.Count);
                    }
                    else
                    {
                        vars.Add("NumberOfParcelsInRegion", 0);
                    }
                }

                IWebHttpTextureService webTextureService = webInterface.Registry.RequestModuleInterface <IWebHttpTextureService>();
                var regionMapURL = "../images/icons/no_terrain.jpg";

                if (webTextureService != null && region.TerrainMapImage != UUID.Zero)
                {
                    regionMapURL = webTextureService.GetTextureURL(region.TerrainMapImage);
                }

                vars.Add("RegionImageURL", regionMapURL);

                // worldview
                IConfig worldViewConfig  = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs["WorldViewModule"];
                bool    worldViewEnabled = false;

                if (worldViewConfig != null)
                {
                    worldViewEnabled = worldViewConfig.GetBoolean("Enabled", true);
                }

                if (webTextureService != null && worldViewEnabled && regionIsOnline)
                {
                    vars.Add("RegionWorldViewURL", webTextureService.GetRegionWorldViewURL(region.RegionID));
                }
                else
                {
                    vars.Add("RegionWorldViewURL", regionMapURL);
                }

                // Menu Region
                vars.Add("MenuRegionTitle", translator.GetTranslatedString("MenuRegionTitle"));
                vars.Add("TooltipsMenuRegion", translator.GetTranslatedString("TooltipsMenuRegion"));
                vars.Add("MenuParcelTitle", translator.GetTranslatedString("MenuParcelTitle"));
                vars.Add("TooltipsMenuParcel", translator.GetTranslatedString("TooltipsMenuParcel"));
                vars.Add("MenuOwnerTitle", translator.GetTranslatedString("MenuOwnerTitle"));
                vars.Add("TooltipsMenuOwner", translator.GetTranslatedString("TooltipsMenuOwner"));

                vars.Add("RegionInformationText", translator.GetTranslatedString("RegionInformationText"));
                vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText"));
                vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText"));
                vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText"));
                vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText"));
                vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText"));
                vars.Add("RegionMaturityText", translator.GetTranslatedString("RegionMaturityText"));
                vars.Add("RegionTerrainText", translator.GetTranslatedString("RegionTerrainText"));
                vars.Add("RegionInfoText", translator.GetTranslatedString("RegionInfoText"));
                vars.Add("RegionOnlineText", translator.GetTranslatedString("RegionOnlineText"));
                vars.Add("NumberOfUsersInRegionText", translator.GetTranslatedString("NumberOfUsersInRegionText"));
                vars.Add("ParcelsInRegionText", translator.GetTranslatedString("ParcelsInRegionText"));
                vars.Add("MainServerURL", webInterface.GridURL);
            }

            return(vars);
        }
Beispiel #6
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object> ();

            if (httpRequest.Query.ContainsKey("regionid"))
            {
                IAgentInfoService   agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> ();
                IUserAccountService userService      = webInterface.Registry.RequestModuleInterface <IUserAccountService> ();

                var regionService = webInterface.Registry.RequestModuleInterface <IGridService> ();
                var region        = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query ["regionid"].ToString()));

                IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
                var ownerUUID = UUID.Zero;
                var ownerName = "Unknown";
                if (estateConnector != null)
                {
                    EstateSettings estate = estateConnector.GetRegionEstateSettings(region.RegionID);
                    if (estate != null)
                    {
                        ownerUUID = estate.EstateOwner;
                        UserAccount estateOwnerAcct = new UserAccount();
                        if (userService != null)
                        {
                            estateOwnerAcct = userService.GetUserAccount(null, estate.EstateOwner);
                        }
                        ownerName = estateOwnerAcct.Valid ? estateOwnerAcct.Name : "No account found";
                    }
                }
                vars.Add("OwnerUUID", ownerUUID);
                vars.Add("OwnerName", ownerName);

                vars.Add("RegionName", region.RegionName);
                vars.Add("RegionLocX", region.RegionLocX / Constants.RegionSize);
                vars.Add("RegionLocY", region.RegionLocY / Constants.RegionSize);
                vars.Add("RegionSizeX", region.RegionSizeX);
                vars.Add("RegionSizeY", region.RegionSizeY);
                vars.Add("RegionType", region.RegionType);
                vars.Add("RegionTerrain", region.RegionTerrain);
                vars.Add("RegionOnline",
                         (region.Flags & (int)RegionFlags.RegionOnline) ==
                         (int)RegionFlags.RegionOnline
                             ? translator.GetTranslatedString("Online")
                             : translator.GetTranslatedString("Offline"));

                if (agentInfoService != null)
                {
                    List <UserInfo> usersInRegion = agentInfoService.GetUserInfos(region.RegionID);
                    if (usersInRegion.Count == 0)
                    {
                        vars.Add("NumberOfUsersInRegion", 0);
                        vars.Add("UsersInRegion", new List <Dictionary <string, object> > ());
                    }
                    else
                    {
                        vars.Add("NumberOfUsersInRegion", usersInRegion.Count);
                        List <Dictionary <string, object> > users = new List <Dictionary <string, object> > ();
                        foreach (var client in usersInRegion)
                        {
                            if (userService != null)
                            {
                                UserAccount userAcct = userService.GetUserAccount(null, client.UserID);
                                if (userAcct.Valid)
                                {
                                    Dictionary <string, object> user = new Dictionary <string, object> ();
                                    user.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
                                    user.Add("UserUUID", client.UserID);
                                    user.Add("UserName", userAcct.Name);
                                    users.Add(user);
                                }
                            }
                        }
                        vars.Add("UsersInRegion", users);
                    }
                }
                else
                {
                    vars.Add("NumberOfUsersInRegion", 0);
                    vars.Add("UsersInRegion", new List <Dictionary <string, object> > ());
                }
                IDirectoryServiceConnector directoryConnector =
                    Framework.Utilities.DataManager.RequestPlugin <IDirectoryServiceConnector> ();

                if (directoryConnector != null)
                {
                    List <LandData> data = directoryConnector.GetParcelsByRegion(0, 10, region.RegionID, UUID.Zero,
                                                                                 ParcelFlags.None, ParcelCategory.Any);
                    List <Dictionary <string, object> > parcels = new List <Dictionary <string, object> > ();
                    if (data != null)
                    {
                        foreach (var p in data)
                        {
                            Dictionary <string, object> parcel = new Dictionary <string, object> ();
                            parcel.Add("ParcelNameText", translator.GetTranslatedString("ParcelNameText"));
                            parcel.Add("ParcelOwnerText", translator.GetTranslatedString("ParcelOwnerText"));
                            parcel.Add("ParcelUUID", p.GlobalID);
                            parcel.Add("ParcelName", p.Name);
                            parcel.Add("ParcelOwnerUUID", p.OwnerID);
                            if (userService != null)
                            {
                                var parcelownerAcct = userService.GetUserAccount(null, p.OwnerID);
                                if (parcelownerAcct.Valid)
                                {
                                    parcel.Add("ParcelOwnerName", parcelownerAcct.Name);
                                }
                                else
                                {
                                    parcel.Add("ParcelOwnerName", translator.GetTranslatedString("NoAccountFound"));
                                }
                            }
                            parcels.Add(parcel);
                        }
                    }
                    vars.Add("ParcelInRegion", parcels);
                    vars.Add("NumberOfParcelsInRegion", parcels.Count);
                }
                IWebHttpTextureService webTextureService = webInterface.Registry.
                                                           RequestModuleInterface <IWebHttpTextureService> ();
                if (webTextureService != null && region.TerrainMapImage != UUID.Zero)
                {
                    vars.Add("RegionImageURL", webTextureService.GetTextureURL(region.TerrainMapImage));
                }
                else
                {
                    vars.Add("RegionImageURL", "images/icons/no_picture.jpg");
                }

                // Menu Region
                vars.Add("MenuRegionTitle", translator.GetTranslatedString("MenuRegionTitle"));
                vars.Add("MenuParcelTitle", translator.GetTranslatedString("MenuParcelTitle"));
                vars.Add("MenuOwnerTitle", translator.GetTranslatedString("MenuOwnerTitle"));

                vars.Add("RegionInformationText", translator.GetTranslatedString("RegionInformationText"));
                vars.Add("OwnerNameText", translator.GetTranslatedString("OwnerNameText"));
                vars.Add("RegionLocationText", translator.GetTranslatedString("RegionLocationText"));
                vars.Add("RegionSizeText", translator.GetTranslatedString("RegionSizeText"));
                vars.Add("RegionNameText", translator.GetTranslatedString("RegionNameText"));
                vars.Add("RegionTypeText", translator.GetTranslatedString("RegionTypeText"));
                vars.Add("RegionTerrainText", translator.GetTranslatedString("RegionTerrainText"));
                vars.Add("RegionInfoText", translator.GetTranslatedString("RegionInfoText"));
                vars.Add("RegionOnlineText", translator.GetTranslatedString("RegionOnlineText"));
                vars.Add("NumberOfUsersInRegionText", translator.GetTranslatedString("NumberOfUsersInRegionText"));
                vars.Add("ParcelsInRegionText", translator.GetTranslatedString("ParcelsInRegionText"));

                // Style Switcher
                vars.Add("styles1", translator.GetTranslatedString("styles1"));
                vars.Add("styles2", translator.GetTranslatedString("styles2"));
                vars.Add("styles3", translator.GetTranslatedString("styles3"));
                vars.Add("styles4", translator.GetTranslatedString("styles4"));
                vars.Add("styles5", translator.GetTranslatedString("styles5"));

                vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText"));
                vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText"));
                vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText"));

                // Language Switcher
                vars.Add("en", translator.GetTranslatedString("en"));
                vars.Add("fr", translator.GetTranslatedString("fr"));
                vars.Add("de", translator.GetTranslatedString("de"));
                vars.Add("it", translator.GetTranslatedString("it"));
                vars.Add("es", translator.GetTranslatedString("es"));
                vars.Add("nl", translator.GetTranslatedString("nl"));

                var settings = webInterface.GetWebUISettings();
                vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar);
                vars.Add("ShowStyleBar", !settings.HideStyleBar);
            }

            return(vars);
        }
        public List <UUID> StatusNotification(List <string> friends, UUID foreignUserID, bool online)
        {
            if (m_FriendsService == null || m_PresenceService == null)
            {
                MainConsole.Instance.WarnFormat("[USER AGENT SERVICE]: Unable to perform status notifications because friends or presence services are missing");
                return(new List <UUID> ());
            }

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

            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends", foreignUserID, friends.Count);

            // First, let's double check that the reported friends are, indeed, friends of that user
            // And let's check that the secret matches
            List <string> usersToBeNotified = new List <string> ();

            foreach (string uui in friends)
            {
                UUID   localUserID;
                string secret = string.Empty, tmp = string.Empty;
                if (HGUtil.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret))
                {
                    List <FriendInfo> friendInfos = m_FriendsService.GetFriends(localUserID);
                    foreach (FriendInfo finfo in friendInfos)
                    {
                        if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret))
                        {
                            // great!
                            usersToBeNotified.Add(localUserID.ToString());
                        }
                    }
                }
            }

            // Now, let's send the notifications
            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count);

            // First, let's send notifications to local users who are online in the home grid

            //Send "" because if we pass the UUID, it will get the locations for all friends, even on the grid they came from
            List <UserInfo> friendSessions = m_PresenceService.GetUserInfos(usersToBeNotified);

            foreach (UserInfo friend in friendSessions)
            {
                if (friend.IsOnline)
                {
                    GridRegion ourRegion = m_GridService.GetRegionByUUID(null, friend.CurrentRegionID);
                    if (ourRegion != null)
                    {
                        m_asyncPostService.Post(ourRegion.RegionHandle,
                                                SyncMessageHelper.AgentStatusChange(foreignUserID, UUID.Parse(friend.UserID), true));
                    }
                }
            }

            // Lastly, let's notify the rest who may be online somewhere else
            foreach (string user in usersToBeNotified)
            {
                UUID id = new UUID(user);
                if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName)
                {
                    string url = m_TravelingAgents[id].GridExternalName;
                    // forward
                    MainConsole.Instance.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
                }
            }

            // and finally, let's send the online friends
            if (online)
            {
                return(localFriendsOnline);
            }
            else
            {
                return(new List <UUID> ());
            }
        }