clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
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;
30 using System.Collections.Generic;
31 using System.Reflection;
32 using log4net;
33 using Mono.Addins;
34 using Nini.Config;
35 using OpenMetaverse;
36 using OpenSim.Data;
37 using OpenSim.Data.Null;
38 using OpenSim.Framework;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
41 using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
42  
43 namespace OpenSim.Tests.Common.Mock
44 {
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
46 public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49  
50 IXGroupData m_data = new NullXGroupData(null, null);
51  
52 public string Name
53 {
54 get { return "MockGroupsServicesConnector"; }
55 }
56  
57 public Type ReplaceableInterface
58 {
59 get { return null; }
60 }
61  
62 public void Initialise(IConfigSource config)
63 {
64 }
65  
66 public void Close()
67 {
68 }
69  
70 public void AddRegion(Scene scene)
71 {
72 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Adding to region {0}", scene.RegionInfo.RegionName);
73 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
74 }
75  
76 public void RemoveRegion(Scene scene)
77 {
78 }
79  
80 public void RegionLoaded(Scene scene)
81 {
82 }
83  
84 public void PostInitialise()
85 {
86 }
87  
88 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
89 int membershipFee, bool openEnrollment, bool allowPublish,
90 bool maturePublish, UUID founderID)
91 {
92 XGroup group = new XGroup()
93 {
94 groupID = UUID.Random(),
95 ownerRoleID = UUID.Random(),
96 name = name,
97 charter = charter,
98 showInList = showInList,
99 insigniaID = insigniaID,
100 membershipFee = membershipFee,
101 openEnrollment = openEnrollment,
102 allowPublish = allowPublish,
103 maturePublish = maturePublish,
104 founderID = founderID,
105 everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers,
106 ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers
107 };
108  
109 if (m_data.StoreGroup(group))
110 {
111 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID);
112 return group.groupID;
113 }
114 else
115 {
116 m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name);
117 return UUID.Zero;
118 }
119 }
120  
121 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
122 UUID insigniaID, int membershipFee, bool openEnrollment,
123 bool allowPublish, bool maturePublish)
124 {
125 }
126  
127 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
128 string title, ulong powers)
129 {
130 }
131  
132 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
133 {
134 }
135  
136 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
137 string title, ulong powers)
138 {
139 }
140  
141 private XGroup GetXGroup(UUID groupID, string name)
142 {
143 XGroup group = m_data.GetGroup(groupID);
144  
145  
146 if (group == null)
147 m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: No group found with ID {0}", groupID);
148  
149 return group;
150 }
151  
152 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
153 {
154 m_log.DebugFormat(
155 "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
156 groupID, groupName);
157  
158 XGroup xg = GetXGroup(groupID, groupName);
159  
160 if (xg == null)
161 return null;
162  
163 GroupRecord gr = new GroupRecord()
164 {
165 GroupID = xg.groupID,
166 GroupName = xg.name,
167 AllowPublish = xg.allowPublish,
168 MaturePublish = xg.maturePublish,
169 Charter = xg.charter,
170 FounderID = xg.founderID,
171 // FIXME: group picture storage location unknown
172 MembershipFee = xg.membershipFee,
173 OpenEnrollment = xg.openEnrollment,
174 OwnerRoleID = xg.ownerRoleID,
175 ShowInList = xg.showInList
176 };
177  
178 return gr;
179 }
180  
181 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
182 {
183 return default(GroupProfileData);
184 }
185  
186 public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
187 {
188 }
189  
190 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
191 {
192 }
193  
194 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
195 {
196 m_log.DebugFormat(
197 "[MOCK GROUPS SERVICES CONNECTOR]: SetAgentGroupInfo, requestingAgentID {0}, agentID {1}, groupID {2}, acceptNotices {3}, listInProfile {4}",
198 requestingAgentID, agentID, groupID, acceptNotices, listInProfile);
199  
200 XGroup group = GetXGroup(groupID, null);
201  
202 if (group == null)
203 return;
204  
205 XGroupMember xgm = null;
206 if (!group.members.TryGetValue(agentID, out xgm))
207 return;
208  
209 xgm.acceptNotices = acceptNotices;
210 xgm.listInProfile = listInProfile;
211  
212 m_data.StoreGroup(group);
213 }
214  
215 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
216 {
217 }
218  
219 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
220 {
221 return null;
222 }
223  
224 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
225 {
226 }
227  
228 public void AddAgentToGroup(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
229 {
230 m_log.DebugFormat(
231 "[MOCK GROUPS SERVICES CONNECTOR]: AddAgentToGroup, requestingAgentID {0}, agentID {1}, groupID {2}, roleID {3}",
232 requestingAgentID, agentID, groupID, roleID);
233  
234 XGroup group = GetXGroup(groupID, null);
235  
236 if (group == null)
237 return;
238  
239 XGroupMember groupMember = new XGroupMember()
240 {
241 agentID = agentID,
242 groupID = groupID,
243 roleID = roleID
244 };
245  
246 group.members[agentID] = groupMember;
247  
248 m_data.StoreGroup(group);
249 }
250  
251 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
252 {
253 }
254  
255 public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
256 {
257 }
258  
259 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
260 {
261 }
262  
263 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
264 {
265 return null;
266 }
267  
268 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
269 {
270 return null;
271 }
272  
273 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
274 {
275 return null;
276 }
277  
278 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
279 {
280 return new List<GroupMembershipData>();
281 }
282  
283 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
284 {
285 return null;
286 }
287  
288 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
289 {
290 return null;
291 }
292  
293 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID groupID)
294 {
295 m_log.DebugFormat(
296 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupMembers, requestingAgentID {0}, groupID {1}",
297 requestingAgentID, groupID);
298  
299 List<GroupMembersData> groupMembers = new List<GroupMembersData>();
300  
301 XGroup group = GetXGroup(groupID, null);
302  
303 if (group == null)
304 return groupMembers;
305  
306 foreach (XGroupMember xgm in group.members.Values)
307 {
308 GroupMembersData gmd = new GroupMembersData();
309 gmd.AgentID = xgm.agentID;
310 gmd.IsOwner = group.founderID == gmd.AgentID;
311 gmd.AcceptNotices = xgm.acceptNotices;
312 gmd.ListInProfile = xgm.listInProfile;
313  
314 groupMembers.Add(gmd);
315 }
316  
317 return groupMembers;
318 }
319  
320 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
321 {
322 return null;
323 }
324  
325 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID groupID)
326 {
327 XGroup group = GetXGroup(groupID, null);
328  
329 if (group == null)
330 return null;
331  
332 List<GroupNoticeData> notices = new List<GroupNoticeData>();
333  
334 foreach (XGroupNotice notice in group.notices.Values)
335 {
336 GroupNoticeData gnd = new GroupNoticeData()
337 {
338 NoticeID = notice.noticeID,
339 Timestamp = notice.timestamp,
340 FromName = notice.fromName,
341 Subject = notice.subject,
342 HasAttachment = notice.hasAttachment,
343 AssetType = (byte)notice.assetType
344 };
345  
346 notices.Add(gnd);
347 }
348  
349 return notices;
350 }
351  
352 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
353 {
354 m_log.DebugFormat(
355 "[MOCK GROUPS SERVICES CONNECTOR]: GetGroupNotices, requestingAgentID {0}, noticeID {1}",
356 requestingAgentID, noticeID);
357  
358 // Yes, not an efficient way to do it.
359 Dictionary<UUID, XGroup> groups = m_data.GetGroups();
360  
361 foreach (XGroup group in groups.Values)
362 {
363 if (group.notices.ContainsKey(noticeID))
364 {
365 XGroupNotice n = group.notices[noticeID];
366  
367 GroupNoticeInfo gni = new GroupNoticeInfo();
368 gni.GroupID = n.groupID;
369 gni.Message = n.message;
370 gni.BinaryBucket = n.binaryBucket;
371 gni.noticeData.NoticeID = n.noticeID;
372 gni.noticeData.Timestamp = n.timestamp;
373 gni.noticeData.FromName = n.fromName;
374 gni.noticeData.Subject = n.subject;
375 gni.noticeData.HasAttachment = n.hasAttachment;
376 gni.noticeData.AssetType = (byte)n.assetType;
377  
378 return gni;
379 }
380 }
381  
382 return null;
383 }
384  
385 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
386 {
387 m_log.DebugFormat(
388 "[MOCK GROUPS SERVICES CONNECTOR]: AddGroupNotice, requestingAgentID {0}, groupID {1}, noticeID {2}, fromName {3}, subject {4}, message {5}, binaryBucket.Length {6}",
389 requestingAgentID, groupID, noticeID, fromName, subject, message, binaryBucket.Length);
390  
391 XGroup group = GetXGroup(groupID, null);
392  
393 if (group == null)
394 return;
395  
396 XGroupNotice groupNotice = new XGroupNotice()
397 {
398 groupID = groupID,
399 noticeID = noticeID,
400 fromName = fromName,
401 subject = subject,
402 message = message,
403 timestamp = (uint)Util.UnixTimeSinceEpoch(),
404 hasAttachment = false,
405 assetType = 0,
406 binaryBucket = binaryBucket
407 };
408  
409 group.notices[noticeID] = groupNotice;
410  
411 m_data.StoreGroup(group);
412 }
413  
414 public void ResetAgentGroupChatSessions(UUID agentID)
415 {
416 }
417  
418 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
419 {
420 return false;
421 }
422  
423 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
424 {
425 return false;
426 }
427  
428 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
429 {
430 }
431  
432 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
433 {
434 }
435 }
436 }