opensim-development – Blame information for rev 1

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