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