diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs | 408 |
1 files changed, 408 insertions, 0 deletions
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs new file mode 100644 index 0000000..d4739c6 --- /dev/null +++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRemoteConnectorModule.cs | |||
@@ -0,0 +1,408 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | |||
41 | using OpenMetaverse; | ||
42 | using Mono.Addins; | ||
43 | using log4net; | ||
44 | using Nini.Config; | ||
45 | |||
46 | namespace OpenSim.Groups | ||
47 | { | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsServiceRemoteConnectorModule")] | ||
49 | public class GroupsServiceRemoteConnectorModule : ISharedRegionModule, IGroupsServicesConnector | ||
50 | { | ||
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | private bool m_Enabled = false; | ||
54 | private GroupsServiceRemoteConnector m_GroupsService; | ||
55 | private IUserManagement m_UserManagement; | ||
56 | private List<Scene> m_Scenes; | ||
57 | |||
58 | private RemoteConnectorCacheWrapper m_CacheWrapper; | ||
59 | |||
60 | #region constructors | ||
61 | public GroupsServiceRemoteConnectorModule() | ||
62 | { | ||
63 | } | ||
64 | |||
65 | public GroupsServiceRemoteConnectorModule(IConfigSource config, IUserManagement uman) | ||
66 | { | ||
67 | Init(config); | ||
68 | m_UserManagement = uman; | ||
69 | m_CacheWrapper = new RemoteConnectorCacheWrapper(m_UserManagement); | ||
70 | |||
71 | } | ||
72 | #endregion | ||
73 | |||
74 | private void Init(IConfigSource config) | ||
75 | { | ||
76 | m_GroupsService = new GroupsServiceRemoteConnector(config); | ||
77 | m_Scenes = new List<Scene>(); | ||
78 | |||
79 | } | ||
80 | |||
81 | #region ISharedRegionModule | ||
82 | |||
83 | public void Initialise(IConfigSource config) | ||
84 | { | ||
85 | IConfig groupsConfig = config.Configs["Groups"]; | ||
86 | if (groupsConfig == null) | ||
87 | return; | ||
88 | |||
89 | if ((groupsConfig.GetBoolean("Enabled", false) == false) | ||
90 | || (groupsConfig.GetString("ServicesConnectorModule", string.Empty) != Name)) | ||
91 | { | ||
92 | return; | ||
93 | } | ||
94 | |||
95 | Init(config); | ||
96 | |||
97 | m_Enabled = true; | ||
98 | m_log.DebugFormat("[Groups.RemoteConnector]: Initializing {0}", this.Name); | ||
99 | } | ||
100 | |||
101 | public string Name | ||
102 | { | ||
103 | get { return "Groups Remote Service Connector"; } | ||
104 | } | ||
105 | |||
106 | public Type ReplaceableInterface | ||
107 | { | ||
108 | get { return null; } | ||
109 | } | ||
110 | |||
111 | public void AddRegion(Scene scene) | ||
112 | { | ||
113 | if (!m_Enabled) | ||
114 | return; | ||
115 | |||
116 | m_log.DebugFormat("[Groups.RemoteConnector]: Registering {0} with {1}", this.Name, scene.RegionInfo.RegionName); | ||
117 | scene.RegisterModuleInterface<IGroupsServicesConnector>(this); | ||
118 | m_Scenes.Add(scene); | ||
119 | } | ||
120 | |||
121 | public void RemoveRegion(Scene scene) | ||
122 | { | ||
123 | if (!m_Enabled) | ||
124 | return; | ||
125 | |||
126 | scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); | ||
127 | m_Scenes.Remove(scene); | ||
128 | } | ||
129 | |||
130 | public void RegionLoaded(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | |||
135 | if (m_UserManagement == null) | ||
136 | { | ||
137 | m_UserManagement = scene.RequestModuleInterface<IUserManagement>(); | ||
138 | m_CacheWrapper = new RemoteConnectorCacheWrapper(m_UserManagement); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | public void PostInitialise() | ||
143 | { | ||
144 | } | ||
145 | |||
146 | public void Close() | ||
147 | { | ||
148 | } | ||
149 | |||
150 | #endregion | ||
151 | |||
152 | #region IGroupsServicesConnector | ||
153 | |||
154 | public UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, | ||
155 | bool allowPublish, bool maturePublish, UUID founderID, out string reason) | ||
156 | { | ||
157 | m_log.DebugFormat("[Groups.RemoteConnector]: Creating group {0}", name); | ||
158 | string r = string.Empty; | ||
159 | |||
160 | UUID groupID = m_CacheWrapper.CreateGroup(RequestingAgentID, delegate | ||
161 | { | ||
162 | return m_GroupsService.CreateGroup(RequestingAgentID.ToString(), name, charter, showInList, insigniaID, | ||
163 | membershipFee, openEnrollment, allowPublish, maturePublish, founderID, out r); | ||
164 | }); | ||
165 | |||
166 | reason = r; | ||
167 | return groupID; | ||
168 | } | ||
169 | |||
170 | public bool UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, | ||
171 | bool openEnrollment, bool allowPublish, bool maturePublish, out string reason) | ||
172 | { | ||
173 | string r = string.Empty; | ||
174 | |||
175 | bool success = m_CacheWrapper.UpdateGroup(groupID, delegate | ||
176 | { | ||
177 | return m_GroupsService.UpdateGroup(RequestingAgentID, groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish); | ||
178 | }); | ||
179 | |||
180 | reason = r; | ||
181 | return success; | ||
182 | } | ||
183 | |||
184 | public ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID, string GroupName) | ||
185 | { | ||
186 | if (GroupID == UUID.Zero && (GroupName == null || GroupName != null && GroupName == string.Empty)) | ||
187 | return null; | ||
188 | |||
189 | return m_CacheWrapper.GetGroupRecord(RequestingAgentID,GroupID,GroupName, delegate | ||
190 | { | ||
191 | return m_GroupsService.GetGroupRecord(RequestingAgentID, GroupID, GroupName); | ||
192 | }); | ||
193 | } | ||
194 | |||
195 | public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string search) | ||
196 | { | ||
197 | // TODO! | ||
198 | return m_GroupsService.FindGroups(RequestingAgentID, search); | ||
199 | } | ||
200 | |||
201 | public bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason) | ||
202 | { | ||
203 | string agentFullID = AgentID; | ||
204 | m_log.DebugFormat("[Groups.RemoteConnector]: Add agent {0} to group {1}", agentFullID, GroupID); | ||
205 | string r = string.Empty; | ||
206 | |||
207 | bool success = m_CacheWrapper.AddAgentToGroup(RequestingAgentID, AgentID, GroupID, delegate | ||
208 | { | ||
209 | return m_GroupsService.AddAgentToGroup(RequestingAgentID, agentFullID, GroupID, RoleID, token, out r); | ||
210 | }); | ||
211 | |||
212 | reason = r; | ||
213 | return success; | ||
214 | } | ||
215 | |||
216 | public void RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID) | ||
217 | { | ||
218 | m_CacheWrapper.RemoveAgentFromGroup(RequestingAgentID, AgentID, GroupID, delegate | ||
219 | { | ||
220 | m_GroupsService.RemoveAgentFromGroup(RequestingAgentID, AgentID, GroupID); | ||
221 | }); | ||
222 | |||
223 | } | ||
224 | |||
225 | public void SetAgentActiveGroup(string RequestingAgentID, string AgentID, UUID GroupID) | ||
226 | { | ||
227 | m_CacheWrapper.SetAgentActiveGroup(AgentID, delegate | ||
228 | { | ||
229 | return m_GroupsService.SetAgentActiveGroup(RequestingAgentID, AgentID, GroupID); | ||
230 | }); | ||
231 | } | ||
232 | |||
233 | public ExtendedGroupMembershipData GetAgentActiveMembership(string RequestingAgentID, string AgentID) | ||
234 | { | ||
235 | return m_CacheWrapper.GetAgentActiveMembership(AgentID, delegate | ||
236 | { | ||
237 | return m_GroupsService.GetMembership(RequestingAgentID, AgentID, UUID.Zero); | ||
238 | }); | ||
239 | } | ||
240 | |||
241 | public ExtendedGroupMembershipData GetAgentGroupMembership(string RequestingAgentID, string AgentID, UUID GroupID) | ||
242 | { | ||
243 | return m_CacheWrapper.GetAgentGroupMembership(AgentID, GroupID, delegate | ||
244 | { | ||
245 | return m_GroupsService.GetMembership(RequestingAgentID, AgentID, GroupID); | ||
246 | }); | ||
247 | } | ||
248 | |||
249 | public List<GroupMembershipData> GetAgentGroupMemberships(string RequestingAgentID, string AgentID) | ||
250 | { | ||
251 | return m_CacheWrapper.GetAgentGroupMemberships(AgentID, delegate | ||
252 | { | ||
253 | return m_GroupsService.GetMemberships(RequestingAgentID, AgentID); | ||
254 | }); | ||
255 | } | ||
256 | |||
257 | |||
258 | public List<GroupMembersData> GetGroupMembers(string RequestingAgentID, UUID GroupID) | ||
259 | { | ||
260 | return m_CacheWrapper.GetGroupMembers(RequestingAgentID, GroupID, delegate | ||
261 | { | ||
262 | return m_GroupsService.GetGroupMembers(RequestingAgentID, GroupID); | ||
263 | }); | ||
264 | } | ||
265 | |||
266 | public bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason) | ||
267 | { | ||
268 | string r = string.Empty; | ||
269 | bool success = m_CacheWrapper.AddGroupRole(groupID, roleID, description, name, powers, title, delegate | ||
270 | { | ||
271 | return m_GroupsService.AddGroupRole(RequestingAgentID, groupID, roleID, name, description, title, powers, out r); | ||
272 | }); | ||
273 | |||
274 | reason = r; | ||
275 | return success; | ||
276 | } | ||
277 | |||
278 | public bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers) | ||
279 | { | ||
280 | return m_CacheWrapper.UpdateGroupRole(groupID, roleID, name, description, title, powers, delegate | ||
281 | { | ||
282 | return m_GroupsService.UpdateGroupRole(RequestingAgentID, groupID, roleID, name, description, title, powers); | ||
283 | }); | ||
284 | } | ||
285 | |||
286 | public void RemoveGroupRole(string RequestingAgentID, UUID groupID, UUID roleID) | ||
287 | { | ||
288 | m_CacheWrapper.RemoveGroupRole(RequestingAgentID, groupID, roleID, delegate | ||
289 | { | ||
290 | m_GroupsService.RemoveGroupRole(RequestingAgentID, groupID, roleID); | ||
291 | }); | ||
292 | } | ||
293 | |||
294 | public List<GroupRolesData> GetGroupRoles(string RequestingAgentID, UUID GroupID) | ||
295 | { | ||
296 | return m_CacheWrapper.GetGroupRoles(RequestingAgentID, GroupID, delegate | ||
297 | { | ||
298 | return m_GroupsService.GetGroupRoles(RequestingAgentID, GroupID); | ||
299 | }); | ||
300 | } | ||
301 | |||
302 | public List<GroupRoleMembersData> GetGroupRoleMembers(string RequestingAgentID, UUID GroupID) | ||
303 | { | ||
304 | return m_CacheWrapper.GetGroupRoleMembers(RequestingAgentID, GroupID, delegate | ||
305 | { | ||
306 | return m_GroupsService.GetGroupRoleMembers(RequestingAgentID, GroupID); | ||
307 | }); | ||
308 | } | ||
309 | |||
310 | public void AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID) | ||
311 | { | ||
312 | m_CacheWrapper.AddAgentToGroupRole(RequestingAgentID, AgentID, GroupID, RoleID, delegate | ||
313 | { | ||
314 | return m_GroupsService.AddAgentToGroupRole(RequestingAgentID, AgentID, GroupID, RoleID); | ||
315 | }); | ||
316 | } | ||
317 | |||
318 | public void RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID) | ||
319 | { | ||
320 | m_CacheWrapper.RemoveAgentFromGroupRole(RequestingAgentID, AgentID, GroupID, RoleID, delegate | ||
321 | { | ||
322 | return m_GroupsService.RemoveAgentFromGroupRole(RequestingAgentID, AgentID, GroupID, RoleID); | ||
323 | }); | ||
324 | } | ||
325 | |||
326 | public List<GroupRolesData> GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID) | ||
327 | { | ||
328 | return m_CacheWrapper.GetAgentGroupRoles(RequestingAgentID, AgentID, GroupID, delegate | ||
329 | { | ||
330 | return m_GroupsService.GetAgentGroupRoles(RequestingAgentID, AgentID, GroupID); ; | ||
331 | }); | ||
332 | } | ||
333 | |||
334 | public void SetAgentActiveGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID) | ||
335 | { | ||
336 | m_CacheWrapper.SetAgentActiveGroupRole(AgentID, GroupID, delegate | ||
337 | { | ||
338 | m_GroupsService.SetAgentActiveGroupRole(RequestingAgentID, AgentID, GroupID, RoleID); | ||
339 | }); | ||
340 | } | ||
341 | |||
342 | public void UpdateMembership(string RequestingAgentID, string AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) | ||
343 | { | ||
344 | m_CacheWrapper.UpdateMembership(AgentID, GroupID, AcceptNotices, ListInProfile, delegate | ||
345 | { | ||
346 | m_GroupsService.UpdateMembership(RequestingAgentID, AgentID, GroupID, AcceptNotices, ListInProfile); | ||
347 | }); | ||
348 | } | ||
349 | |||
350 | public bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID) | ||
351 | { | ||
352 | return m_GroupsService.AddAgentToGroupInvite(RequestingAgentID, inviteID, groupID, roleID, agentID); | ||
353 | } | ||
354 | |||
355 | public GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID) | ||
356 | { | ||
357 | return m_GroupsService.GetAgentToGroupInvite(RequestingAgentID, inviteID); | ||
358 | } | ||
359 | |||
360 | public void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID) | ||
361 | { | ||
362 | m_GroupsService.RemoveAgentToGroupInvite(RequestingAgentID, inviteID); | ||
363 | } | ||
364 | |||
365 | public bool AddGroupNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, | ||
366 | bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID) | ||
367 | { | ||
368 | GroupNoticeInfo notice = new GroupNoticeInfo(); | ||
369 | notice.GroupID = groupID; | ||
370 | notice.Message = message; | ||
371 | notice.noticeData = new ExtendedGroupNoticeData(); | ||
372 | notice.noticeData.AttachmentItemID = attItemID; | ||
373 | notice.noticeData.AttachmentName = attName; | ||
374 | notice.noticeData.AttachmentOwnerID = attOwnerID.ToString(); | ||
375 | notice.noticeData.AttachmentType = attType; | ||
376 | notice.noticeData.FromName = fromName; | ||
377 | notice.noticeData.HasAttachment = hasAttachment; | ||
378 | notice.noticeData.NoticeID = noticeID; | ||
379 | notice.noticeData.Subject = subject; | ||
380 | notice.noticeData.Timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
381 | |||
382 | return m_CacheWrapper.AddGroupNotice(groupID, noticeID, notice, delegate | ||
383 | { | ||
384 | return m_GroupsService.AddGroupNotice(RequestingAgentID, groupID, noticeID, fromName, subject, message, | ||
385 | hasAttachment, attType, attName, attItemID, attOwnerID); | ||
386 | }); | ||
387 | } | ||
388 | |||
389 | public GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID) | ||
390 | { | ||
391 | return m_CacheWrapper.GetGroupNotice(noticeID, delegate | ||
392 | { | ||
393 | return m_GroupsService.GetGroupNotice(RequestingAgentID, noticeID); | ||
394 | }); | ||
395 | } | ||
396 | |||
397 | public List<ExtendedGroupNoticeData> GetGroupNotices(string RequestingAgentID, UUID GroupID) | ||
398 | { | ||
399 | return m_CacheWrapper.GetGroupNotices(GroupID, delegate | ||
400 | { | ||
401 | return m_GroupsService.GetGroupNotices(RequestingAgentID, GroupID); | ||
402 | }); | ||
403 | } | ||
404 | |||
405 | #endregion | ||
406 | } | ||
407 | |||
408 | } | ||