MockGroupsServicesConnector.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Reflection;
  31. using log4net;
  32. using Mono.Addins;
  33. using Nini.Config;
  34. using OpenMetaverse;
  35. using OpenSim.Data;
  36. using OpenSim.Data.Null;
  37. using OpenSim.Framework;
  38. using OpenSim.Region.Framework.Interfaces;
  39. using OpenSim.Region.Framework.Scenes;
  40. using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups;
  41. namespace OpenSim.Tests.Common.Mock
  42. {
  43. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
  44. public class MockGroupsServicesConnector : ISharedRegionModule, IGroupsServicesConnector
  45. {
  46. private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  47. IXGroupData m_data = new NullXGroupData(null, null);
  48. public string Name
  49. {
  50. get { return "MockGroupsServicesConnector"; }
  51. }
  52. public Type ReplaceableInterface
  53. {
  54. get { return null; }
  55. }
  56. public void Initialise(IConfigSource config)
  57. {
  58. }
  59. public void Close()
  60. {
  61. }
  62. public void AddRegion(Scene scene)
  63. {
  64. m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Adding to region {0}", scene.RegionInfo.RegionName);
  65. scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
  66. }
  67. public void RemoveRegion(Scene scene)
  68. {
  69. }
  70. public void RegionLoaded(Scene scene)
  71. {
  72. }
  73. public void PostInitialise()
  74. {
  75. }
  76. public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
  77. int membershipFee, bool openEnrollment, bool allowPublish,
  78. bool maturePublish, UUID founderID)
  79. {
  80. XGroup group = new XGroup()
  81. {
  82. groupID = UUID.Random(),
  83. ownerRoleID = UUID.Random(),
  84. name = name,
  85. charter = charter,
  86. showInList = showInList,
  87. insigniaID = insigniaID,
  88. membershipFee = membershipFee,
  89. openEnrollment = openEnrollment,
  90. allowPublish = allowPublish,
  91. maturePublish = maturePublish,
  92. founderID = founderID,
  93. everyonePowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultEveryonePowers,
  94. ownersPowers = (ulong)XmlRpcGroupsServicesConnectorModule.DefaultOwnerPowers
  95. };
  96. if (m_data.StoreGroup(group))
  97. {
  98. m_log.DebugFormat("[MOCK GROUPS SERVICES CONNECTOR]: Created group {0} {1}", group.name, group.groupID);
  99. return group.groupID;
  100. }
  101. else
  102. {
  103. m_log.ErrorFormat("[MOCK GROUPS SERVICES CONNECTOR]: Failed to create group {0}", name);
  104. return UUID.Zero;
  105. }
  106. }
  107. public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
  108. UUID insigniaID, int membershipFee, bool openEnrollment,
  109. bool allowPublish, bool maturePublish)
  110. {
  111. }
  112. public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
  113. string title, ulong powers)
  114. {
  115. }
  116. public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
  117. {
  118. }
  119. public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
  120. string title, ulong powers)
  121. {
  122. }
  123. public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
  124. {
  125. m_log.DebugFormat(
  126. "[MOCK GROUPS SERVICES CONNECTOR]: Processing GetGroupRecord() for groupID {0}, name {1}",
  127. groupID, groupName);
  128. XGroup[] groups;
  129. string field, val;
  130. if (groupID != UUID.Zero)
  131. {
  132. field = "groupID";
  133. val = groupID.ToString();
  134. }
  135. else
  136. {
  137. field = "name";
  138. val = groupName;
  139. }
  140. groups = m_data.GetGroups(field, val);
  141. if (groups.Length == 0)
  142. return null;
  143. XGroup xg = groups[0];
  144. GroupRecord gr = new GroupRecord()
  145. {
  146. GroupID = xg.groupID,
  147. GroupName = xg.name,
  148. AllowPublish = xg.allowPublish,
  149. MaturePublish = xg.maturePublish,
  150. Charter = xg.charter,
  151. FounderID = xg.founderID,
  152. // FIXME: group picture storage location unknown
  153. MembershipFee = xg.membershipFee,
  154. OpenEnrollment = xg.openEnrollment,
  155. OwnerRoleID = xg.ownerRoleID,
  156. ShowInList = xg.showInList
  157. };
  158. return gr;
  159. }
  160. public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
  161. {
  162. return default(GroupProfileData);
  163. }
  164. public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  165. {
  166. }
  167. public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  168. {
  169. }
  170. public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
  171. {
  172. }
  173. public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
  174. {
  175. }
  176. public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
  177. {
  178. return null;
  179. }
  180. public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
  181. {
  182. }
  183. public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  184. {
  185. }
  186. public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  187. {
  188. }
  189. public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  190. {
  191. }
  192. public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
  193. {
  194. }
  195. public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
  196. {
  197. return null;
  198. }
  199. public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  200. {
  201. return null;
  202. }
  203. public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
  204. {
  205. return null;
  206. }
  207. public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
  208. {
  209. return new List<GroupMembershipData>();
  210. }
  211. public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
  212. {
  213. return null;
  214. }
  215. public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
  216. {
  217. return null;
  218. }
  219. public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
  220. {
  221. return null;
  222. }
  223. public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
  224. {
  225. return null;
  226. }
  227. public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
  228. {
  229. return null;
  230. }
  231. public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
  232. {
  233. return null;
  234. }
  235. public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
  236. {
  237. }
  238. public void ResetAgentGroupChatSessions(UUID agentID)
  239. {
  240. }
  241. public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
  242. {
  243. return false;
  244. }
  245. public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
  246. {
  247. return false;
  248. }
  249. public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
  250. {
  251. }
  252. public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
  253. {
  254. }
  255. }
  256. }