diff options
Diffstat (limited to 'OpenSim/Region')
4 files changed, 206 insertions, 55 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs b/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs new file mode 100644 index 0000000..a089447 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/Search/BasicSearchModule.cs | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | |||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Framework.Monitoring; | ||
36 | using OpenSim.Region.ClientStack.LindenUDP; | ||
37 | using OpenSim.Region.Framework; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Services.Connectors.Hypergrid; | ||
42 | |||
43 | using OpenMetaverse; | ||
44 | using OpenMetaverse.Packets; | ||
45 | using log4net; | ||
46 | using Nini.Config; | ||
47 | using Mono.Addins; | ||
48 | |||
49 | using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; | ||
50 | |||
51 | namespace OpenSim.Region.CoreModules.Framework.Search | ||
52 | { | ||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicSearchModule")] | ||
54 | public class BasicSearchModule : ISharedRegionModule | ||
55 | { | ||
56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
57 | |||
58 | protected bool m_Enabled; | ||
59 | protected List<Scene> m_Scenes = new List<Scene>(); | ||
60 | |||
61 | private IGroupsModule m_GroupsService = null; | ||
62 | |||
63 | #region ISharedRegionModule | ||
64 | |||
65 | public void Initialise(IConfigSource config) | ||
66 | { | ||
67 | string umanmod = config.Configs["Modules"].GetString("SearchModule", Name); | ||
68 | if (umanmod == Name) | ||
69 | { | ||
70 | m_Enabled = true; | ||
71 | m_log.DebugFormat("[BASIC SEARCH MODULE]: {0} is enabled", Name); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public bool IsSharedModule | ||
76 | { | ||
77 | get { return true; } | ||
78 | } | ||
79 | |||
80 | public virtual string Name | ||
81 | { | ||
82 | get { return "BasicSearchModule"; } | ||
83 | } | ||
84 | |||
85 | public Type ReplaceableInterface | ||
86 | { | ||
87 | get { return null; } | ||
88 | } | ||
89 | |||
90 | public void AddRegion(Scene scene) | ||
91 | { | ||
92 | if (m_Enabled) | ||
93 | { | ||
94 | m_Scenes.Add(scene); | ||
95 | |||
96 | scene.EventManager.OnMakeRootAgent += new Action<ScenePresence>(EventManager_OnMakeRootAgent); | ||
97 | scene.EventManager.OnMakeChildAgent += new EventManager.OnMakeChildAgentDelegate(EventManager_OnMakeChildAgent); | ||
98 | } | ||
99 | } | ||
100 | |||
101 | public void RemoveRegion(Scene scene) | ||
102 | { | ||
103 | if (m_Enabled) | ||
104 | { | ||
105 | m_Scenes.Remove(scene); | ||
106 | |||
107 | scene.EventManager.OnMakeRootAgent -= new Action<ScenePresence>(EventManager_OnMakeRootAgent); | ||
108 | scene.EventManager.OnMakeChildAgent -= new EventManager.OnMakeChildAgentDelegate(EventManager_OnMakeChildAgent); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | public void RegionLoaded(Scene s) | ||
113 | { | ||
114 | if (!m_Enabled) | ||
115 | return; | ||
116 | |||
117 | if (m_GroupsService == null) | ||
118 | { | ||
119 | m_GroupsService = s.RequestModuleInterface<IGroupsModule>(); | ||
120 | |||
121 | // No Groups Service Connector, then group search won't work... | ||
122 | if (m_GroupsService == null) | ||
123 | m_log.Warn("[BASIC SEARCH MODULE]: Could not get IGroupsModule"); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public void PostInitialise() | ||
128 | { | ||
129 | } | ||
130 | |||
131 | public void Close() | ||
132 | { | ||
133 | m_Scenes.Clear(); | ||
134 | } | ||
135 | |||
136 | #endregion ISharedRegionModule | ||
137 | |||
138 | |||
139 | #region Event Handlers | ||
140 | |||
141 | void EventManager_OnMakeRootAgent(ScenePresence sp) | ||
142 | { | ||
143 | sp.ControllingClient.OnDirFindQuery += OnDirFindQuery; | ||
144 | } | ||
145 | |||
146 | void EventManager_OnMakeChildAgent(ScenePresence sp) | ||
147 | { | ||
148 | sp.ControllingClient.OnDirFindQuery -= OnDirFindQuery; | ||
149 | } | ||
150 | |||
151 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) | ||
152 | { | ||
153 | m_log.Debug("[ZZZ]: Got here"); | ||
154 | if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People) | ||
155 | { | ||
156 | if (string.IsNullOrEmpty(queryText)) | ||
157 | remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]); | ||
158 | |||
159 | List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText); | ||
160 | DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count]; | ||
161 | int i = 0; | ||
162 | foreach (UserAccount acc in accounts) | ||
163 | { | ||
164 | DirPeopleReplyData d = new DirPeopleReplyData(); | ||
165 | d.agentID = acc.PrincipalID; | ||
166 | d.firstName = acc.FirstName; | ||
167 | d.lastName = acc.LastName; | ||
168 | d.online = false; | ||
169 | |||
170 | hits[i++] = d; | ||
171 | } | ||
172 | |||
173 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | ||
174 | remoteClient.SendDirPeopleReply(queryID, hits); | ||
175 | } | ||
176 | else if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) | ||
177 | { | ||
178 | if (m_GroupsService == null) | ||
179 | { | ||
180 | m_log.Warn("[BASIC SEARCH MODULE]: Groups service is not available. Unable to search groups."); | ||
181 | remoteClient.SendAlertMessage("Groups search is not enabled"); | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | if (string.IsNullOrEmpty(queryText)) | ||
186 | remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]); | ||
187 | |||
188 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | ||
189 | remoteClient.SendDirGroupsReply(queryID, m_GroupsService.FindGroups(remoteClient, queryText).ToArray()); | ||
190 | } | ||
191 | |||
192 | } | ||
193 | |||
194 | #endregion Event Handlers | ||
195 | |||
196 | } | ||
197 | |||
198 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 295ad64..7adb203 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -100,8 +100,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
100 | scene.RegisterModuleInterface<IPeople>(this); | 100 | scene.RegisterModuleInterface<IPeople>(this); |
101 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); | 101 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); |
102 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); | 102 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); |
103 | scene.EventManager.OnMakeRootAgent += new Action<ScenePresence>(EventManager_OnMakeRootAgent); | ||
104 | scene.EventManager.OnMakeChildAgent += new EventManager.OnMakeChildAgentDelegate(EventManager_OnMakeChildAgent); | ||
105 | } | 103 | } |
106 | } | 104 | } |
107 | 105 | ||
@@ -157,43 +155,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
157 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); | 155 | client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest); |
158 | } | 156 | } |
159 | 157 | ||
160 | void EventManager_OnMakeRootAgent(ScenePresence sp) | ||
161 | { | ||
162 | sp.ControllingClient.OnDirFindQuery += OnDirFindQuery; | ||
163 | } | ||
164 | |||
165 | void EventManager_OnMakeChildAgent(ScenePresence sp) | ||
166 | { | ||
167 | sp.ControllingClient.OnDirFindQuery -= OnDirFindQuery; | ||
168 | } | ||
169 | |||
170 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) | ||
171 | { | ||
172 | if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People) | ||
173 | { | ||
174 | if (string.IsNullOrEmpty(queryText)) | ||
175 | remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]); | ||
176 | |||
177 | List<UserAccount> accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText); | ||
178 | DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count]; | ||
179 | int i = 0; | ||
180 | foreach (UserAccount acc in accounts) | ||
181 | { | ||
182 | DirPeopleReplyData d = new DirPeopleReplyData(); | ||
183 | d.agentID = acc.PrincipalID; | ||
184 | d.firstName = acc.FirstName; | ||
185 | d.lastName = acc.LastName; | ||
186 | d.online = false; | ||
187 | |||
188 | hits[i++] = d; | ||
189 | } | ||
190 | |||
191 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | ||
192 | remoteClient.SendDirPeopleReply(queryID, hits); | ||
193 | } | ||
194 | |||
195 | } | ||
196 | |||
197 | void HandleUUIDNameRequest(UUID uuid, IClientAPI client) | 158 | void HandleUUIDNameRequest(UUID uuid, IClientAPI client) |
198 | { | 159 | { |
199 | // m_log.DebugFormat( | 160 | // m_log.DebugFormat( |
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs index 6885327..9ae5e87 100644 --- a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs | |||
@@ -97,5 +97,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
97 | void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID); | 97 | void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID); |
98 | void InviteGroup(IClientAPI remoteClient, UUID agentID, UUID GroupID, UUID InviteeID, UUID RoleID); | 98 | void InviteGroup(IClientAPI remoteClient, UUID agentID, UUID GroupID, UUID InviteeID, UUID RoleID); |
99 | void NotifyChange(UUID GroupID); | 99 | void NotifyChange(UUID GroupID); |
100 | |||
101 | List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query); | ||
100 | } | 102 | } |
101 | } \ No newline at end of file | 103 | } \ No newline at end of file |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index 32fb54b..f4734b7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -250,7 +250,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
250 | 250 | ||
251 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | 251 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; |
252 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | 252 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; |
253 | client.OnDirFindQuery += OnDirFindQuery; | ||
254 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; | 253 | client.OnRequestAvatarProperties += OnRequestAvatarProperties; |
255 | 254 | ||
256 | // Used for Notices and Group Invites/Accept/Reject | 255 | // Used for Notices and Group Invites/Accept/Reject |
@@ -303,21 +302,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
303 | } | 302 | } |
304 | */ | 303 | */ |
305 | 304 | ||
306 | void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart) | ||
307 | { | ||
308 | if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) | ||
309 | { | ||
310 | if (m_debugEnabled) | ||
311 | m_log.DebugFormat( | ||
312 | "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", | ||
313 | System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); | ||
314 | |||
315 | // TODO: This currently ignores pretty much all the query flags including Mature and sort order | ||
316 | remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray()); | ||
317 | } | ||
318 | |||
319 | } | ||
320 | |||
321 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) | 305 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) |
322 | { | 306 | { |
323 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 307 | if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
@@ -1178,6 +1162,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
1178 | } | 1162 | } |
1179 | } | 1163 | } |
1180 | 1164 | ||
1165 | public List<DirGroupsReplyData> FindGroups(IClientAPI remoteClient, string query) | ||
1166 | { | ||
1167 | return m_groupData.FindGroups(GetRequestingAgentID(remoteClient), query); | ||
1168 | } | ||
1169 | |||
1170 | |||
1181 | #endregion | 1171 | #endregion |
1182 | 1172 | ||
1183 | #region Client/Update Tools | 1173 | #region Client/Update Tools |