From 6be614ba844ee988859fe7f63db76ef13b9f4962 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 28 Jul 2013 09:54:34 -0700 Subject: [PATCH] This makes people search work. --- .../UserManagement/UserManagementModule.cs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 53bd2e2de2..295ad643d8 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -46,6 +46,8 @@ using log4net; using Nini.Config; using Mono.Addins; +using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; + namespace OpenSim.Region.CoreModules.Framework.UserManagement { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserManagementModule")] @@ -98,6 +100,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement scene.RegisterModuleInterface(this); scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); + scene.EventManager.OnMakeRootAgent += new Action(EventManager_OnMakeRootAgent); + scene.EventManager.OnMakeChildAgent += new EventManager.OnMakeChildAgentDelegate(EventManager_OnMakeChildAgent); } } @@ -153,6 +157,43 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); } + void EventManager_OnMakeRootAgent(ScenePresence sp) + { + sp.ControllingClient.OnDirFindQuery += OnDirFindQuery; + } + + void EventManager_OnMakeChildAgent(ScenePresence sp) + { + sp.ControllingClient.OnDirFindQuery -= OnDirFindQuery; + } + + void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) + { + if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People) + { + if (string.IsNullOrEmpty(queryText)) + remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]); + + List accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText); + DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count]; + int i = 0; + foreach (UserAccount acc in accounts) + { + DirPeopleReplyData d = new DirPeopleReplyData(); + d.agentID = acc.PrincipalID; + d.firstName = acc.FirstName; + d.lastName = acc.LastName; + d.online = false; + + hits[i++] = d; + } + + // TODO: This currently ignores pretty much all the query flags including Mature and sort order + remoteClient.SendDirPeopleReply(queryID, hits); + } + + } + void HandleUUIDNameRequest(UUID uuid, IClientAPI client) { // m_log.DebugFormat(