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