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