aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs35
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs25
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs6
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs73
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs326
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs302
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs67
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs1329
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs287
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs31
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs10
14 files changed, 2047 insertions, 502 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 850474d..41e41e4 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -513,6 +513,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
513 byte flags = buffer.Data[0]; 513 byte flags = buffer.Data[0];
514 bool isResend = (flags & Helpers.MSG_RESENT) != 0; 514 bool isResend = (flags & Helpers.MSG_RESENT) != 0;
515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0; 515 bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
516 bool isZerocoded = (flags & Helpers.MSG_ZEROCODED) != 0;
516 LLUDPClient udpClient = outgoingPacket.Client; 517 LLUDPClient udpClient = outgoingPacket.Client;
517 518
518 if (!udpClient.IsConnected) 519 if (!udpClient.IsConnected)
@@ -522,23 +523,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
522 523
523 int dataLength = buffer.DataLength; 524 int dataLength = buffer.DataLength;
524 525
525 // Keep appending ACKs until there is no room left in the buffer or there are 526 // NOTE: I'm seeing problems with some viewers when ACKs are appended to zerocoded packets so I've disabled that here
526 // no more ACKs to append 527 if (!isZerocoded)
527 uint ackCount = 0;
528 uint ack;
529 while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
530 { 528 {
531 Utils.UIntToBytesBig(ack, buffer.Data, dataLength); 529 // Keep appending ACKs until there is no room left in the buffer or there are
532 dataLength += 4; 530 // no more ACKs to append
533 ++ackCount; 531 uint ackCount = 0;
534 } 532 uint ack;
533 while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
534 {
535 Utils.UIntToBytesBig(ack, buffer.Data, dataLength);
536 dataLength += 4;
537 ++ackCount;
538 }
535 539
536 if (ackCount > 0) 540 if (ackCount > 0)
537 { 541 {
538 // Set the last byte of the packet equal to the number of appended ACKs 542 // Set the last byte of the packet equal to the number of appended ACKs
539 buffer.Data[dataLength++] = (byte)ackCount; 543 buffer.Data[dataLength++] = (byte)ackCount;
540 // Set the appended ACKs flag on this packet 544 // Set the appended ACKs flag on this packet
541 buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS); 545 buffer.Data[0] = (byte)(buffer.Data[0] | Helpers.MSG_APPENDED_ACKS);
546 }
542 } 547 }
543 548
544 buffer.DataLength = dataLength; 549 buffer.DataLength = dataLength;
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
index e37da9f..36dae6b 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
@@ -173,11 +173,11 @@ namespace OpenSim.Region.CoreModules.Framework.Library
173 m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); 173 m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName);
174 simpleName = GetInventoryPathFromName(simpleName); 174 simpleName = GetInventoryPathFromName(simpleName);
175 175
176 InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName);
176 try 177 try
177 { 178 {
178 InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName);
179 List<InventoryNodeBase> nodes = archread.Execute(); 179 List<InventoryNodeBase> nodes = archread.Execute();
180 if (nodes.Count == 0) 180 if (nodes != null && nodes.Count == 0)
181 { 181 {
182 // didn't find the subfolder with the given name; place it on the top 182 // didn't find the subfolder with the given name; place it on the top
183 m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); 183 m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName);
@@ -185,16 +185,33 @@ namespace OpenSim.Region.CoreModules.Framework.Library
185 archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName); 185 archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName);
186 archread.Execute(); 186 archread.Execute();
187 } 187 }
188 archread.Close(); 188 foreach (InventoryNodeBase node in nodes)
189 FixPerms(node);
189 } 190 }
190 catch (Exception e) 191 catch (Exception e)
191 { 192 {
192 m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.Message); 193 m_log.DebugFormat("[LIBRARY MODULE]: Exception when processing archive {0}: {1}", iarFileName, e.StackTrace);
194 }
195 finally
196 {
197 archread.Close();
193 } 198 }
194 } 199 }
195 200
196 } 201 }
197 202
203 private void FixPerms(InventoryNodeBase node)
204 {
205 if (node is InventoryItemBase)
206 {
207 InventoryItemBase item = (InventoryItemBase)node;
208 item.BasePermissions = 0x7FFFFFFF;
209 item.EveryOnePermissions = 0x7FFFFFFF;
210 item.CurrentPermissions = 0x7FFFFFFF;
211 item.NextPermissions = 0x7FFFFFFF;
212 }
213 }
214
198 private void DumpLibrary() 215 private void DumpLibrary()
199 { 216 {
200 InventoryFolderImpl lib = m_Library.LibraryRootFolder; 217 InventoryFolderImpl lib = m_Library.LibraryRootFolder;
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index 77d6e9a..e6cab1d 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -1,9 +1,28 @@
1/* 1/*
2 * Copyright (c) Thomas Grimshaw and Magne Metaverse Research 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * This module is not open source. All rights reserved.
5 * Unauthorised copying, distribution or public display is prohibited.
6 * 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.
7 */ 26 */
8 27
9using System; 28using System;
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
index 488dbd5..3321b38 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
@@ -144,6 +144,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
144 return account; 144 return account;
145 } 145 }
146 146
147 public override bool StoreUserAccount(UserAccount data)
148 {
149 // This remote connector refuses to serve this method
150 return false;
151 }
152
147 #endregion 153 #endregion
148 } 154 }
149} 155}
diff --git a/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs
new file mode 100644
index 0000000..f158236
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs
@@ -0,0 +1,73 @@
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 OpenMetaverse;
29using OpenSim.Framework;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 /// <summary>
34 /// Provide mechanisms for messaging groups.
35 /// </summary>
36 ///
37 /// TODO: Provide a mechanism for receiving group messages as well as sending them
38 ///
39 public interface IGroupsMessagingModule
40 {
41 /// <summary>
42 /// Start a group chat session.
43 /// </summary>
44 /// You must call this before calling SendMessageToGroup(). If a chat session for this group is already taking
45 /// place then the agent will added to that session.
46 /// <param name="agentID">
47 /// A UUID that represents the agent being added. If you are agentless (e.g. you are
48 /// a region module), then you can use any random ID.
49 /// </param>
50 /// <param name="groupID">
51 /// The ID for the group to join. Currently, the session ID used is identical to the
52 /// group ID.
53 /// </param>
54 /// <returns>
55 /// True if the chat session was started successfully, false otherwise.
56 /// </returns>
57 bool StartGroupChatSession(UUID agentID, UUID groupID);
58
59 /// <summary>
60 /// Send a message to an entire group.
61 /// </summary>
62 /// <param name="im">
63 /// The message itself. The fields that must be populated are
64 ///
65 /// imSessionID - Populate this with the group ID (session ID and group ID are currently identical)
66 /// fromAgentName - Populate this with whatever arbitrary name you want to show up in the chat dialog
67 /// message - The message itself
68 /// dialog - This must be (byte)InstantMessageDialog.SessionSend
69 /// </param>
70 /// <param name="groupID"></param>
71 void SendMessageToGroup(GridInstantMessage im, UUID groupID);
72 }
73} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 00fe5df..17a5349 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -28,41 +28,30 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31
32
33using log4net; 31using log4net;
34using Mono.Addins; 32using Mono.Addins;
35using Nini.Config; 33using Nini.Config;
36
37using OpenMetaverse; 34using OpenMetaverse;
38using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
39
40using OpenSim.Framework; 36using OpenSim.Framework;
41using OpenSim.Region.CoreModules.Framework.EventQueue; 37using OpenSim.Region.CoreModules.Framework.EventQueue;
42using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
44 40
45
46using Caps = OpenSim.Framework.Capabilities.Caps; 41using Caps = OpenSim.Framework.Capabilities.Caps;
47 42
48namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 43namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
49{ 44{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class GroupsMessagingModule : ISharedRegionModule 46 public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule
52 { 47 {
53
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 49
56 private List<Scene> m_sceneList = new List<Scene>(); 50 private List<Scene> m_sceneList = new List<Scene>();
57 51
58 private IMessageTransferModule m_msgTransferModule = null; 52 private IMessageTransferModule m_msgTransferModule = null;
59 53
60 private IGroupsModule m_groupsModule = null; 54 private IGroupsServicesConnector m_groupData = null;
61
62 // TODO: Move this off to the Groups Server
63 public Dictionary<Guid, List<Guid>> m_agentsInGroupSession = new Dictionary<Guid, List<Guid>>();
64 public Dictionary<Guid, List<Guid>> m_agentsDroppedSession = new Dictionary<Guid, List<Guid>>();
65
66 55
67 // Config Options 56 // Config Options
68 private bool m_groupMessagingEnabled = false; 57 private bool m_groupMessagingEnabled = false;
@@ -108,21 +97,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
108 97
109 public void AddRegion(Scene scene) 98 public void AddRegion(Scene scene)
110 { 99 {
111 // NoOp 100 if (!m_groupMessagingEnabled)
101 return;
102
103 scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
112 } 104 }
105
113 public void RegionLoaded(Scene scene) 106 public void RegionLoaded(Scene scene)
114 { 107 {
115 if (!m_groupMessagingEnabled) 108 if (!m_groupMessagingEnabled)
116 return; 109 return;
117 110
118 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 111 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
119 112
120 m_groupsModule = scene.RequestModuleInterface<IGroupsModule>(); 113 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
121 114
122 // No groups module, no groups messaging 115 // No groups module, no groups messaging
123 if (m_groupsModule == null) 116 if (m_groupData == null)
124 { 117 {
125 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsModule, GroupsMessagingModule is now disabled."); 118 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled.");
126 Close(); 119 Close();
127 m_groupMessagingEnabled = false; 120 m_groupMessagingEnabled = false;
128 return; 121 return;
@@ -144,7 +137,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
144 137
145 scene.EventManager.OnNewClient += OnNewClient; 138 scene.EventManager.OnNewClient += OnNewClient;
146 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 139 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
147 140 scene.EventManager.OnClientLogin += OnClientLogin;
148 } 141 }
149 142
150 public void RemoveRegion(Scene scene) 143 public void RemoveRegion(Scene scene)
@@ -172,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
172 165
173 m_sceneList.Clear(); 166 m_sceneList.Clear();
174 167
175 m_groupsModule = null; 168 m_groupData = null;
176 m_msgTransferModule = null; 169 m_msgTransferModule = null;
177 } 170 }
178 171
@@ -197,7 +190,83 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
197 190
198 #endregion 191 #endregion
199 192
200 #region SimGridEventHandlers 193 /// <summary>
194 /// Not really needed, but does confirm that the group exists.
195 /// </summary>
196 public bool StartGroupChatSession(UUID agentID, UUID groupID)
197 {
198 if (m_debugEnabled)
199 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
200
201 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
202
203 if (groupInfo != null)
204 {
205 return true;
206 }
207 else
208 {
209 return false;
210 }
211 }
212
213 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
214 {
215 if (m_debugEnabled)
216 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
217
218
219 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID))
220 {
221 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
222 {
223 // Don't deliver messages to people who have dropped this session
224 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
225 continue;
226 }
227
228 // Copy Message
229 GridInstantMessage msg = new GridInstantMessage();
230 msg.imSessionID = groupID.Guid;
231 msg.fromAgentName = im.fromAgentName;
232 msg.message = im.message;
233 msg.dialog = im.dialog;
234 msg.offline = im.offline;
235 msg.ParentEstateID = im.ParentEstateID;
236 msg.Position = im.Position;
237 msg.RegionID = im.RegionID;
238 msg.binaryBucket = im.binaryBucket;
239 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
240
241 msg.fromAgentID = im.fromAgentID;
242 msg.fromGroup = true;
243
244 msg.toAgentID = member.AgentID.Guid;
245
246 IClientAPI client = GetActiveClient(member.AgentID);
247 if (client == null)
248 {
249 // If they're not local, forward across the grid
250 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
251 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
252 }
253 else
254 {
255 // Deliver locally, directly
256 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
257 ProcessMessageFromGroupSession(msg);
258 }
259 }
260 }
261
262 #region SimGridEventHandlers
263
264 void OnClientLogin(IClientAPI client)
265 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
267
268
269 }
201 270
202 private void OnNewClient(IClientAPI client) 271 private void OnNewClient(IClientAPI client)
203 { 272 {
@@ -234,44 +303,48 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
234 303
235 private void ProcessMessageFromGroupSession(GridInstantMessage msg) 304 private void ProcessMessageFromGroupSession(GridInstantMessage msg)
236 { 305 {
237 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); 306 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
307
308 UUID AgentID = new UUID(msg.fromAgentID);
309 UUID GroupID = new UUID(msg.imSessionID);
238 310
239 switch (msg.dialog) 311 switch (msg.dialog)
240 { 312 {
241 case (byte)InstantMessageDialog.SessionAdd: 313 case (byte)InstantMessageDialog.SessionAdd:
242 AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID); 314 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
243 break; 315 break;
244 316
245 case (byte)InstantMessageDialog.SessionDrop: 317 case (byte)InstantMessageDialog.SessionDrop:
246 RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID); 318 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
247 break; 319 break;
248 320
249 case (byte)InstantMessageDialog.SessionSend: 321 case (byte)InstantMessageDialog.SessionSend:
250 if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) 322 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
251 && !m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 323 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
324 )
252 { 325 {
253 // Agent not in session and hasn't dropped from session 326 // Agent not in session and hasn't dropped from session
254 // Add them to the session for now, and Invite them 327 // Add them to the session for now, and Invite them
255 AddAgentToGroupSession(msg.toAgentID, msg.imSessionID); 328 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
256 329
257 UUID toAgentID = new UUID(msg.toAgentID); 330 UUID toAgentID = new UUID(msg.toAgentID);
258 IClientAPI activeClient = GetActiveClient(toAgentID); 331 IClientAPI activeClient = GetActiveClient(toAgentID);
259 if (activeClient != null) 332 if (activeClient != null)
260 { 333 {
261 UUID groupID = new UUID(msg.fromAgentID); 334 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
262
263 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
264 if (groupInfo != null) 335 if (groupInfo != null)
265 { 336 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); 337 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
267 338
268 // Force? open the group session dialog??? 339 // Force? open the group session dialog???
340 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
269 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); 341 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
270 eq.ChatterboxInvitation( 342 eq.ChatterboxInvitation(
271 groupID 343 GroupID
272 , groupInfo.GroupName 344 , groupInfo.GroupName
273 , new UUID(msg.fromAgentID) 345 , new UUID(msg.fromAgentID)
274 , msg.message, new UUID(msg.toAgentID) 346 , msg.message
347 , new UUID(msg.toAgentID)
275 , msg.fromAgentName 348 , msg.fromAgentName
276 , msg.dialog 349 , msg.dialog
277 , msg.timestamp 350 , msg.timestamp
@@ -284,8 +357,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
284 , Utils.StringToBytes(groupInfo.GroupName) 357 , Utils.StringToBytes(groupInfo.GroupName)
285 ); 358 );
286 359
287 eq.ChatterBoxSessionAgentListUpdates( 360 eq.ChatterBoxSessionAgentListUpdates(
288 new UUID(groupID) 361 new UUID(GroupID)
289 , new UUID(msg.fromAgentID) 362 , new UUID(msg.fromAgentID)
290 , new UUID(msg.toAgentID) 363 , new UUID(msg.toAgentID)
291 , false //canVoiceChat 364 , false //canVoiceChat
@@ -294,8 +367,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
294 ); 367 );
295 } 368 }
296 } 369 }
297 } 370 }
298 else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 371 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
299 { 372 {
300 // User hasn't dropped, so they're in the session, 373 // User hasn't dropped, so they're in the session,
301 // maybe we should deliver it. 374 // maybe we should deliver it.
@@ -321,56 +394,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
321 394
322 #endregion 395 #endregion
323 396
324 #region ClientEvents 397
325 398 #region ClientEvents
326 private void RemoveAgentFromGroupSession(Guid agentID, Guid sessionID)
327 {
328 if (m_agentsInGroupSession.ContainsKey(sessionID))
329 {
330 // If in session remove
331 if (m_agentsInGroupSession[sessionID].Contains(agentID))
332 {
333 m_agentsInGroupSession[sessionID].Remove(agentID);
334 }
335
336 // If not in dropped list, add
337 if (!m_agentsDroppedSession[sessionID].Contains(agentID))
338 {
339 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Dropped {1} from session {0}", sessionID, agentID);
340 m_agentsDroppedSession[sessionID].Add(agentID);
341 }
342 }
343 }
344
345 private void AddAgentToGroupSession(Guid agentID, Guid sessionID)
346 {
347 // Add Session Status if it doesn't exist for this session
348 CreateGroupSessionTracking(sessionID);
349
350 // If nessesary, remove from dropped list
351 if (m_agentsDroppedSession[sessionID].Contains(agentID))
352 {
353 m_agentsDroppedSession[sessionID].Remove(agentID);
354 }
355
356 // If nessesary, add to in session list
357 if (!m_agentsInGroupSession[sessionID].Contains(agentID))
358 {
359 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Added {1} to session {0}", sessionID, agentID);
360 m_agentsInGroupSession[sessionID].Add(agentID);
361 }
362 }
363
364 private void CreateGroupSessionTracking(Guid sessionID)
365 {
366 if (!m_agentsInGroupSession.ContainsKey(sessionID))
367 {
368 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Creating session tracking for : {0}", sessionID);
369 m_agentsInGroupSession.Add(sessionID, new List<Guid>());
370 m_agentsDroppedSession.Add(sessionID, new List<Guid>());
371 }
372 }
373
374 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 399 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
375 { 400 {
376 if (m_debugEnabled) 401 if (m_debugEnabled)
@@ -382,22 +407,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
382 407
383 // Start group IM session 408 // Start group IM session
384 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 409 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
385 { 410 {
386 UUID groupID = new UUID(im.toAgentID); 411 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
387 412
388 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); 413 UUID GroupID = new UUID(im.imSessionID);
414 UUID AgentID = new UUID(im.fromAgentID);
415
416 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
417
389 if (groupInfo != null) 418 if (groupInfo != null)
390 { 419 {
391 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); 420 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
392 421
393 AddAgentToGroupSession(im.fromAgentID, im.imSessionID); 422 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
394
395 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID);
396 423
397 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 424 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
398 queue.ChatterBoxSessionAgentListUpdates( 425 queue.ChatterBoxSessionAgentListUpdates(
399 new UUID(groupID) 426 GroupID
400 , new UUID(im.fromAgentID) 427 , AgentID
401 , new UUID(im.toAgentID) 428 , new UUID(im.toAgentID)
402 , false //canVoiceChat 429 , false //canVoiceChat
403 , false //isModerator 430 , false //isModerator
@@ -408,65 +435,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
408 435
409 // Send a message from locally connected client to a group 436 // Send a message from locally connected client to a group
410 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 437 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
411 { 438 {
412 UUID groupID = new UUID(im.toAgentID); 439 UUID GroupID = new UUID(im.imSessionID);
440 UUID AgentID = new UUID(im.fromAgentID);
413 441
414 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); 442 if (m_debugEnabled)
443 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
415 444
416 SendMessageToGroup(im, groupID); 445 //If this agent is sending a message, then they want to be in the session
446 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
447
448 SendMessageToGroup(im, GroupID);
417 } 449 }
418 } 450 }
419 451
420 #endregion 452 #endregion
421 453
422 private void SendMessageToGroup(GridInstantMessage im, UUID groupID)
423 {
424 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
425
426 foreach (GroupMembersData member in m_groupsModule.GroupMembersRequest(null, groupID))
427 {
428 if (!m_agentsDroppedSession.ContainsKey(im.imSessionID) || m_agentsDroppedSession[im.imSessionID].Contains(member.AgentID.Guid))
429 {
430 // Don't deliver messages to people who have dropped this session
431 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
432 continue;
433 }
434
435 // Copy Message
436 GridInstantMessage msg = new GridInstantMessage();
437 msg.imSessionID = im.imSessionID;
438 msg.fromAgentName = im.fromAgentName;
439 msg.message = im.message;
440 msg.dialog = im.dialog;
441 msg.offline = im.offline;
442 msg.ParentEstateID = im.ParentEstateID;
443 msg.Position = im.Position;
444 msg.RegionID = im.RegionID;
445 msg.binaryBucket = im.binaryBucket;
446 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
447
448 // Updat Pertinate fields to make it a "group message"
449 msg.fromAgentID = groupID.Guid;
450 msg.fromGroup = true;
451
452 msg.toAgentID = member.AgentID.Guid;
453
454 IClientAPI client = GetActiveClient(member.AgentID);
455 if (client == null)
456 {
457 // If they're not local, forward across the grid
458 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
459 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
460 }
461 else
462 {
463 // Deliver locally, directly
464 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
465 ProcessMessageFromGroupSession(msg);
466 }
467 }
468 }
469
470 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) 454 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
471 { 455 {
472 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 456 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -517,7 +501,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
517 /// Try to find an active IClientAPI reference for agentID giving preference to root connections 501 /// Try to find an active IClientAPI reference for agentID giving preference to root connections
518 /// </summary> 502 /// </summary>
519 private IClientAPI GetActiveClient(UUID agentID) 503 private IClientAPI GetActiveClient(UUID agentID)
520 { 504 {
505 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
506
521 IClientAPI child = null; 507 IClientAPI child = null;
522 508
523 // Try root avatar first 509 // Try root avatar first
@@ -528,17 +514,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
528 { 514 {
529 ScenePresence user = (ScenePresence)scene.Entities[agentID]; 515 ScenePresence user = (ScenePresence)scene.Entities[agentID];
530 if (!user.IsChildAgent) 516 if (!user.IsChildAgent)
531 { 517 {
518 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name);
532 return user.ControllingClient; 519 return user.ControllingClient;
533 } 520 }
534 else 521 else
535 { 522 {
523 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name);
536 child = user.ControllingClient; 524 child = user.ControllingClient;
537 } 525 }
538 } 526 }
539 } 527 }
540 528
541 // If we didn't find a root, then just return whichever child we found, or null if none 529 // If we didn't find a root, then just return whichever child we found, or null if none
530 if (child == null)
531 {
532 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
533 }
534 else
535 {
536 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
537 }
542 return child; 538 return child;
543 } 539 }
544 540
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 61c51e0..e5dab93 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -89,16 +89,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
89 89
90 private IGroupsServicesConnector m_groupData = null; 90 private IGroupsServicesConnector m_groupData = null;
91 91
92 class GroupRequestIDInfo
93 {
94 public GroupRequestID RequestID = new GroupRequestID();
95 public DateTime LastUsedTMStamp = DateTime.MinValue;
96 }
97 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
98 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
99 private Timer m_clientRequestIDFlushTimer;
100
101
102 // Configuration settings 92 // Configuration settings
103 private bool m_groupsEnabled = false; 93 private bool m_groupsEnabled = false;
104 private bool m_groupNoticesEnabled = true; 94 private bool m_groupNoticesEnabled = true;
@@ -135,30 +125,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
135 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 125 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
136 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 126 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
137 127
138 m_clientRequestIDFlushTimer = new Timer();
139 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
140 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
141 m_clientRequestIDFlushTimer.AutoReset = true;
142 m_clientRequestIDFlushTimer.Start();
143 }
144 }
145
146 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
147 {
148 lock (m_clientRequestIDInfo)
149 {
150 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
151 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
152 foreach (UUID key in CurrentKeys)
153 {
154 if (m_clientRequestIDInfo.ContainsKey(key))
155 {
156 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
157 {
158 m_clientRequestIDInfo.Remove(key);
159 }
160 }
161 }
162 } 128 }
163 } 129 }
164 130
@@ -209,14 +175,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
209 } 175 }
210 176
211 scene.EventManager.OnNewClient += OnNewClient; 177 scene.EventManager.OnNewClient += OnNewClient;
212 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
213
214 // The InstantMessageModule itself doesn't do this, 179 // The InstantMessageModule itself doesn't do this,
215 // so lets see if things explode if we don't do it 180 // so lets see if things explode if we don't do it
216 // scene.EventManager.OnClientClosed += OnClientClosed; 181 // scene.EventManager.OnClientClosed += OnClientClosed;
217 182
218 } 183 }
219 184
220 public void RemoveRegion(Scene scene) 185 public void RemoveRegion(Scene scene)
221 { 186 {
222 if (!m_groupsEnabled) 187 if (!m_groupsEnabled)
@@ -236,8 +201,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 return; 201 return;
237 202
238 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 203 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
239
240 m_clientRequestIDFlushTimer.Stop();
241 } 204 }
242 205
243 public Type ReplaceableInterface 206 public Type ReplaceableInterface
@@ -274,14 +237,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
274 // Used for Notices and Group Invites/Accept/Reject 237 // Used for Notices and Group Invites/Accept/Reject
275 client.OnInstantMessage += OnInstantMessage; 238 client.OnInstantMessage += OnInstantMessage;
276 239
277 lock (m_clientRequestIDInfo) 240 // Send client thier groups information.
278 {
279 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
280 {
281 // flush any old RequestID information
282 m_clientRequestIDInfo.Remove(client.AgentId);
283 }
284 }
285 SendAgentGroupDataUpdate(client, client.AgentId); 241 SendAgentGroupDataUpdate(client, client.AgentId);
286 } 242 }
287 243
@@ -289,7 +245,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
289 { 245 {
290 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 246 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
291 247
292 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); 248 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
293 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 249 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
294 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 250 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
295 } 251 }
@@ -338,9 +294,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
338 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); 294 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
339 295
340 // TODO: This currently ignores pretty much all the query flags including Mature and sort order 296 // TODO: This currently ignores pretty much all the query flags including Mature and sort order
341 remoteClient.SendDirGroupsReply( 297 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray());
342 queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); 298 }
343 } 299
344 } 300 }
345 301
346 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 302 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
@@ -352,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
352 string activeGroupName = string.Empty; 308 string activeGroupName = string.Empty;
353 ulong activeGroupPowers = (ulong)GroupPowers.None; 309 ulong activeGroupPowers = (ulong)GroupPowers.None;
354 310
355 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); 311 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
356 if (membership != null) 312 if (membership != null)
357 { 313 {
358 activeGroupID = membership.GroupID; 314 activeGroupID = membership.GroupID;
@@ -371,7 +327,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
371 327
372 string GroupName; 328 string GroupName;
373 329
374 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); 330 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
375 if (group != null) 331 if (group != null)
376 { 332 {
377 GroupName = group.GroupName; 333 GroupName = group.GroupName;
@@ -392,7 +348,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
392 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 348 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
393 { 349 {
394 UUID inviteID = new UUID(im.imSessionID); 350 UUID inviteID = new UUID(im.imSessionID);
395 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 351 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
396 352
397 if (inviteInfo == null) 353 if (inviteInfo == null)
398 { 354 {
@@ -411,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
411 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 367 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
412 368
413 // and the sessionid is the role 369 // and the sessionid is the role
414 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 370 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
415 371
416 GridInstantMessage msg = new GridInstantMessage(); 372 GridInstantMessage msg = new GridInstantMessage();
417 msg.imSessionID = UUID.Zero.Guid; 373 msg.imSessionID = UUID.Zero.Guid;
@@ -435,14 +391,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
435 // TODO: If the inviter is still online, they need an agent dataupdate 391 // TODO: If the inviter is still online, they need an agent dataupdate
436 // and maybe group membership updates for the invitee 392 // and maybe group membership updates for the invitee
437 393
438 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 394 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
439 } 395 }
440 396
441 // Reject 397 // Reject
442 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 398 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
443 { 399 {
444 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 400 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
445 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 401 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
446 } 402 }
447 } 403 }
448 } 404 }
@@ -456,7 +412,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
456 } 412 }
457 413
458 UUID GroupID = new UUID(im.toAgentID); 414 UUID GroupID = new UUID(im.toAgentID);
459 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) 415 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null)
460 { 416 {
461 UUID NoticeID = UUID.Random(); 417 UUID NoticeID = UUID.Random();
462 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 418 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -500,14 +456,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
500 } 456 }
501 457
502 458
503 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 459 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
504 if (OnNewGroupNotice != null) 460 if (OnNewGroupNotice != null)
505 { 461 {
506 OnNewGroupNotice(GroupID, NoticeID); 462 OnNewGroupNotice(GroupID, NoticeID);
507 } 463 }
508 464
509 // Send notice out to everyone that wants notices 465 // Send notice out to everyone that wants notices
510 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) 466 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
511 { 467 {
512 if (m_debugEnabled) 468 if (m_debugEnabled)
513 { 469 {
@@ -553,7 +509,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
553 IClientAPI ejectee = GetActiveClient(ejecteeID); 509 IClientAPI ejectee = GetActiveClient(ejecteeID);
554 if (ejectee != null) 510 if (ejectee != null)
555 { 511 {
556 UUID groupID = new UUID(im.fromAgentID); 512 UUID groupID = new UUID(im.imSessionID);
557 ejectee.SendAgentDropGroup(groupID); 513 ejectee.SendAgentDropGroup(groupID);
558 } 514 }
559 } 515 }
@@ -592,25 +548,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
592 548
593 public GroupRecord GetGroupRecord(UUID GroupID) 549 public GroupRecord GetGroupRecord(UUID GroupID)
594 { 550 {
595 return m_groupData.GetGroupRecord(null, GroupID, null); 551 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
596 } 552 }
597 553
598 public GroupRecord GetGroupRecord(string name) 554 public GroupRecord GetGroupRecord(string name)
599 { 555 {
600 return m_groupData.GetGroupRecord(null, UUID.Zero, name); 556 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
601 } 557 }
602 558
603 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 559 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
604 { 560 {
605 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 561 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
606 562
607 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 563 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
608 564
609 // Changing active group changes title, active powers, all kinds of things 565 // Changing active group changes title, active powers, all kinds of things
610 // anyone who is in any region that can see this client, should probably be 566 // anyone who is in any region that can see this client, should probably be
611 // updated with new group info. At a minimum, they should get ScenePresence 567 // updated with new group info. At a minimum, they should get ScenePresence
612 // updated with new title. 568 // updated with new title.
613 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 569 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
614 } 570 }
615 571
616 /// <summary> 572 /// <summary>
@@ -620,10 +576,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
620 { 576 {
621 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 577 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
622 578
623 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
624 579
625 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); 580 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
626 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 581 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
627 582
628 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 583 List<GroupTitlesData> titles = new List<GroupTitlesData>();
629 foreach (GroupRolesData role in agentRoles) 584 foreach (GroupRolesData role in agentRoles)
@@ -645,8 +600,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
645 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 600 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
646 { 601 {
647 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 602 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
603 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
648 604
649 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); 605 if (m_debugEnabled)
606 {
607 foreach (GroupMembersData member in data)
608 {
609 m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
610 }
611 }
650 612
651 return data; 613 return data;
652 614
@@ -656,7 +618,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
656 { 618 {
657 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 619 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
658 620
659 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); 621 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
660 622
661 return data; 623 return data;
662 } 624 }
@@ -665,8 +627,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
665 { 627 {
666 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 628 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
667 629
668 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); 630 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
669 631
632 if (m_debugEnabled)
633 {
634 foreach (GroupRoleMembersData member in data)
635 {
636 m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
637 }
638 }
670 return data; 639 return data;
671 } 640 }
672 641
@@ -676,17 +645,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
676 645
677 GroupProfileData profile = new GroupProfileData(); 646 GroupProfileData profile = new GroupProfileData();
678 647
679 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
680 648
681 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); 649 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
682 if (groupInfo != null) 650 if (groupInfo != null)
683 { 651 {
684 profile.AllowPublish = groupInfo.AllowPublish; 652 profile.AllowPublish = groupInfo.AllowPublish;
685 profile.Charter = groupInfo.Charter; 653 profile.Charter = groupInfo.Charter;
686 profile.FounderID = groupInfo.FounderID; 654 profile.FounderID = groupInfo.FounderID;
687 profile.GroupID = groupID; 655 profile.GroupID = groupID;
688 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; 656 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
689 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; 657 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
690 profile.InsigniaID = groupInfo.GroupPicture; 658 profile.InsigniaID = groupInfo.GroupPicture;
691 profile.MaturePublish = groupInfo.MaturePublish; 659 profile.MaturePublish = groupInfo.MaturePublish;
692 profile.MembershipFee = groupInfo.MembershipFee; 660 profile.MembershipFee = groupInfo.MembershipFee;
@@ -697,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
697 profile.ShowInList = groupInfo.ShowInList; 665 profile.ShowInList = groupInfo.ShowInList;
698 } 666 }
699 667
700 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 668 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
701 if (memberInfo != null) 669 if (memberInfo != null)
702 { 670 {
703 profile.MemberTitle = memberInfo.GroupTitle; 671 profile.MemberTitle = memberInfo.GroupTitle;
@@ -711,7 +679,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
711 { 679 {
712 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 680 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
713 681
714 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); 682 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
715 } 683 }
716 684
717 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 685 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
@@ -721,33 +689,30 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
721 "[GROUPS]: {0} called with groupID={1}, agentID={2}", 689 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
722 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); 690 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
723 691
724 return m_groupData.GetAgentGroupMembership(null, agentID, groupID); 692 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
725 } 693 }
726 694
727 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 695 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
728 { 696 {
729 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 697 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
730 698
731 // TODO: Security Check? 699 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
732 700 m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
733 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
734 } 701 }
735 702
736 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 703 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
737 { 704 {
738 // TODO: Security Check? 705 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
739 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 706 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
740 707
741 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); 708 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
742 } 709 }
743 710
744 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 711 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
745 { 712 {
746 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 713 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
747 714
748 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 715 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null)
749
750 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
751 { 716 {
752 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 717 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
753 return UUID.Zero; 718 return UUID.Zero;
@@ -761,14 +726,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
761 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group."); 726 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got issuficient funds to create a group.");
762 return UUID.Zero; 727 return UUID.Zero;
763 } 728 }
764 money.ApplyGroupCreationCharge(remoteClient.AgentId); 729 money.ApplyGroupCreationCharge(GetRequestingAgentID(remoteClient));
765 } 730 }
766 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 731 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
767 732
768 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 733 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
769 734
770 // Update the founder with new group information. 735 // Update the founder with new group information.
771 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 736 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
772 737
773 return groupID; 738 return groupID;
774 } 739 }
@@ -779,7 +744,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
779 744
780 // ToDo: check if agent is a member of group and is allowed to see notices? 745 // ToDo: check if agent is a member of group and is allowed to see notices?
781 746
782 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); 747 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
783 } 748 }
784 749
785 /// <summary> 750 /// <summary>
@@ -789,7 +754,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
789 { 754 {
790 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 755 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
791 756
792 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); 757 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
793 if (membership != null) 758 if (membership != null)
794 { 759 {
795 return membership.GroupTitle; 760 return membership.GroupTitle;
@@ -804,13 +769,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
804 { 769 {
805 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 770 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
806 771
807 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); 772 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
808 773
809 // TODO: Not sure what all is needed here, but if the active group role change is for the group 774 // TODO: Not sure what all is needed here, but if the active group role change is for the group
810 // the client currently has set active, then we need to do a scene presence update too 775 // the client currently has set active, then we need to do a scene presence update too
811 // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) 776 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
812 777
813 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 778 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
814 } 779 }
815 780
816 781
@@ -820,16 +785,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
820 785
821 // Security Checks are handled in the Groups Service. 786 // Security Checks are handled in the Groups Service.
822 787
823 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
824
825 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 788 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
826 { 789 {
827 case OpenMetaverse.GroupRoleUpdate.Create: 790 case OpenMetaverse.GroupRoleUpdate.Create:
828 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); 791 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
829 break; 792 break;
830 793
831 case OpenMetaverse.GroupRoleUpdate.Delete: 794 case OpenMetaverse.GroupRoleUpdate.Delete:
832 m_groupData.RemoveGroupRole(grID, groupID, roleID); 795 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
833 break; 796 break;
834 797
835 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 798 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -840,7 +803,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
840 GroupPowers gp = (GroupPowers)powers; 803 GroupPowers gp = (GroupPowers)powers;
841 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 804 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
842 } 805 }
843 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); 806 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
844 break; 807 break;
845 808
846 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 809 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -851,7 +814,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
851 } 814 }
852 815
853 // TODO: This update really should send out updates for everyone in the role that just got changed. 816 // TODO: This update really should send out updates for everyone in the role that just got changed.
854 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 817 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
855 } 818 }
856 819
857 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 820 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -859,18 +822,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
859 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 822 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
860 // Todo: Security check 823 // Todo: Security check
861 824
862 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
863
864 switch (changes) 825 switch (changes)
865 { 826 {
866 case 0: 827 case 0:
867 // Add 828 // Add
868 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); 829 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
869 830
870 break; 831 break;
871 case 1: 832 case 1:
872 // Remove 833 // Remove
873 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); 834 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
874 835
875 break; 836 break;
876 default: 837 default:
@@ -879,25 +840,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
879 } 840 }
880 841
881 // TODO: This update really should send out updates for everyone in the role that just got changed. 842 // TODO: This update really should send out updates for everyone in the role that just got changed.
882 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 843 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
883 } 844 }
884 845
885 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 846 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
886 { 847 {
887 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 848 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
888 849
889 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 850 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID);
890
891 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
892 851
893 if (data != null) 852 if (data != null)
894 { 853 {
895 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); 854 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
896 855
897 GridInstantMessage msg = new GridInstantMessage(); 856 GridInstantMessage msg = new GridInstantMessage();
898 msg.imSessionID = UUID.Zero.Guid; 857 msg.imSessionID = UUID.Zero.Guid;
899 msg.fromAgentID = data.GroupID.Guid; 858 msg.fromAgentID = data.GroupID.Guid;
900 msg.toAgentID = remoteClient.AgentId.Guid; 859 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
901 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 860 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
902 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 861 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
903 msg.message = data.noticeData.Subject + "|" + data.Message; 862 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -909,7 +868,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
909 msg.RegionID = UUID.Zero.Guid; 868 msg.RegionID = UUID.Zero.Guid;
910 msg.binaryBucket = data.BinaryBucket; 869 msg.binaryBucket = data.BinaryBucket;
911 870
912 OutgoingInstantMessage(msg, remoteClient.AgentId); 871 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
913 } 872 }
914 873
915 } 874 }
@@ -929,7 +888,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
929 msg.Position = Vector3.Zero; 888 msg.Position = Vector3.Zero;
930 msg.RegionID = UUID.Zero.Guid; 889 msg.RegionID = UUID.Zero.Guid;
931 890
932 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); 891 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
933 if (info != null) 892 if (info != null)
934 { 893 {
935 msg.fromAgentID = info.GroupID.Guid; 894 msg.fromAgentID = info.GroupID.Guid;
@@ -956,7 +915,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
956 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 915 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
957 916
958 // Send agent information about his groups 917 // Send agent information about his groups
959 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 918 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
960 } 919 }
961 920
962 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 921 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -964,19 +923,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
964 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 923 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
965 924
966 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 925 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
967 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); 926 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
968 927
969 remoteClient.SendJoinGroupReply(groupID, true); 928 remoteClient.SendJoinGroupReply(groupID, true);
970 929
971 // Should this send updates to everyone in the group? 930 // Should this send updates to everyone in the group?
972 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 931 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
973 } 932 }
974 933
975 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 934 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
976 { 935 {
977 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 936 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
978 937
979 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 938 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
980 939
981 remoteClient.SendLeaveGroupReply(groupID, true); 940 remoteClient.SendLeaveGroupReply(groupID, true);
982 941
@@ -984,33 +943,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
984 943
985 // SL sends out notifcations to the group messaging session that the person has left 944 // SL sends out notifcations to the group messaging session that the person has left
986 // Should this also update everyone who is in the group? 945 // Should this also update everyone who is in the group?
987 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 946 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
988 } 947 }
989 948
990 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 949 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
991 { 950 {
992 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 951 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
993 952
994 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
995 953
996 // Todo: Security check? 954 // Todo: Security check?
997 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); 955 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID);
956
957 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true);
998 958
999 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 959 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
1000 960
1001 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null);
1002 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); 961 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID);
1003 if ((groupInfo == null) || (account == null)) 962 if ((groupInfo == null) || (account == null))
1004 { 963 {
1005 return; 964 return;
1006 } 965 }
1007
1008 966
1009 // Send Message to Ejectee 967 // Send Message to Ejectee
1010 GridInstantMessage msg = new GridInstantMessage(); 968 GridInstantMessage msg = new GridInstantMessage();
1011 969
1012 msg.imSessionID = UUID.Zero.Guid; 970 msg.imSessionID = UUID.Zero.Guid;
1013 msg.fromAgentID = remoteClient.AgentId.Guid; 971 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1014 // msg.fromAgentID = info.GroupID; 972 // msg.fromAgentID = info.GroupID;
1015 msg.toAgentID = ejecteeID.Guid; 973 msg.toAgentID = ejecteeID.Guid;
1016 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 974 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1036,8 +994,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1036 994
1037 msg = new GridInstantMessage(); 995 msg = new GridInstantMessage();
1038 msg.imSessionID = UUID.Zero.Guid; 996 msg.imSessionID = UUID.Zero.Guid;
1039 msg.fromAgentID = remoteClient.AgentId.Guid; 997 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1040 msg.toAgentID = remoteClient.AgentId.Guid; 998 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
1041 msg.timestamp = 0; 999 msg.timestamp = 0;
1042 msg.fromAgentName = remoteClient.Name; 1000 msg.fromAgentName = remoteClient.Name;
1043 if (account != null) 1001 if (account != null)
@@ -1055,7 +1013,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1055 msg.Position = Vector3.Zero; 1013 msg.Position = Vector3.Zero;
1056 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1014 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1057 msg.binaryBucket = new byte[0]; 1015 msg.binaryBucket = new byte[0];
1058 OutgoingInstantMessage(msg, remoteClient.AgentId); 1016 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
1059 1017
1060 1018
1061 // SL sends out messages to everyone in the group 1019 // SL sends out messages to everyone in the group
@@ -1069,13 +1027,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1069 1027
1070 // Todo: Security check, probably also want to send some kind of notification 1028 // Todo: Security check, probably also want to send some kind of notification
1071 UUID InviteID = UUID.Random(); 1029 UUID InviteID = UUID.Random();
1072 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1073 1030
1074 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); 1031 m_groupData.AddAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID, groupID, roleID, invitedAgentID);
1075 1032
1076 // Check to see if the invite went through, if it did not then it's possible 1033 // Check to see if the invite went through, if it did not then it's possible
1077 // the remoteClient did not validate or did not have permission to invite. 1034 // the remoteClient did not validate or did not have permission to invite.
1078 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); 1035 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID);
1079 1036
1080 if (inviteInfo != null) 1037 if (inviteInfo != null)
1081 { 1038 {
@@ -1087,7 +1044,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1087 1044
1088 msg.imSessionID = inviteUUID; 1045 msg.imSessionID = inviteUUID;
1089 1046
1090 // msg.fromAgentID = remoteClient.AgentId.Guid; 1047 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1091 msg.fromAgentID = groupID.Guid; 1048 msg.fromAgentID = groupID.Guid;
1092 msg.toAgentID = invitedAgentID.Guid; 1049 msg.toAgentID = invitedAgentID.Guid;
1093 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1050 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1140,57 +1097,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1140 return child; 1097 return child;
1141 } 1098 }
1142 1099
1143 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1144 {
1145 if (client == null)
1146 {
1147 return new GroupRequestID();
1148 }
1149
1150 lock (m_clientRequestIDInfo)
1151 {
1152 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1153 {
1154 GroupRequestIDInfo info = new GroupRequestIDInfo();
1155 info.RequestID.AgentID = client.AgentId;
1156 info.RequestID.SessionID = client.SessionId;
1157
1158 //UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1159 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
1160 if (account == null)
1161 {
1162 // This should be impossible. If I've been passed a reference to a client
1163 // that client should be registered with the UserService. So something
1164 // is horribly wrong somewhere.
1165
1166 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
1167
1168 // Default to local user service and hope for the best?
1169 // REFACTORING PROBLEM
1170 //info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1171
1172 }
1173 else
1174 {
1175 string domain = string.Empty; //m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1176 object homeUriObj;
1177 if (account.ServiceURLs.TryGetValue("HomeURI", out homeUriObj) && homeUriObj != null)
1178 domain = homeUriObj.ToString();
1179 // They're a local user, use this:
1180 info.RequestID.UserServiceURL = domain;
1181 }
1182
1183 m_clientRequestIDInfo.Add(client.AgentId, info);
1184 }
1185
1186 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1187
1188 return m_clientRequestIDInfo[client.AgentId].RequestID;
1189 }
1190// Unreachable code!
1191// return new GroupRequestID();
1192 }
1193
1194 /// <summary> 1100 /// <summary>
1195 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1101 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1196 /// </summary> 1102 /// </summary>
@@ -1209,7 +1115,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1209 1115
1210 foreach (GroupMembershipData membership in data) 1116 foreach (GroupMembershipData membership in data)
1211 { 1117 {
1212 if (remoteClient.AgentId != dataForAgentID) 1118 if (GetRequestingAgentID(remoteClient) != dataForAgentID)
1213 { 1119 {
1214 if (!membership.ListInProfile) 1120 if (!membership.ListInProfile)
1215 { 1121 {
@@ -1239,11 +1145,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1239 llDataStruct.Add("GroupData", GroupData); 1145 llDataStruct.Add("GroupData", GroupData);
1240 llDataStruct.Add("NewGroupData", NewGroupData); 1146 llDataStruct.Add("NewGroupData", NewGroupData);
1241 1147
1148 if (m_debugEnabled)
1149 {
1150 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1151 }
1152
1242 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1153 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1243 1154
1244 if (queue != null) 1155 if (queue != null)
1245 { 1156 {
1246 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), remoteClient.AgentId); 1157 queue.Enqueue(EventQueueHelper.buildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
1247 } 1158 }
1248 1159
1249 } 1160 }
@@ -1316,7 +1227,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1316 /// <returns></returns> 1227 /// <returns></returns>
1317 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1228 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1318 { 1229 {
1319 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); 1230 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
1320 GroupMembershipData[] membershipArray; 1231 GroupMembershipData[] membershipArray;
1321 1232
1322 if (requestingClient.AgentId != dataForAgentID) 1233 if (requestingClient.AgentId != dataForAgentID)
@@ -1338,7 +1249,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1338 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1249 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1339 foreach (GroupMembershipData membership in membershipArray) 1250 foreach (GroupMembershipData membership in membershipArray)
1340 { 1251 {
1341 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); 1252 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
1342 } 1253 }
1343 } 1254 }
1344 1255
@@ -1397,6 +1308,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1397 } 1308 }
1398 1309
1399 #endregion 1310 #endregion
1311
1312 private UUID GetRequestingAgentID(IClientAPI client)
1313 {
1314 UUID requestingAgentID = UUID.Zero;
1315 if (client != null)
1316 {
1317 requestingAgentID = client.AgentId;
1318 }
1319 return requestingAgentID;
1320 }
1400 } 1321 }
1401 1322
1323 public class GroupNoticeInfo
1324 {
1325 public GroupNoticeData noticeData = new GroupNoticeData();
1326 public UUID GroupID = UUID.Zero;
1327 public string Message = string.Empty;
1328 public byte[] BinaryBucket = new byte[0];
1329 }
1402} 1330}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 621ab28..54ffc81 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -36,41 +36,47 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
36{ 36{
37 interface IGroupsServicesConnector 37 interface IGroupsServicesConnector
38 { 38 {
39 UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); 39 UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID);
40 void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); 40 void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
41 GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName); 41 GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName);
42 List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search); 42 List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search);
43 List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID); 43 List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID);
44 44
45 void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); 45 void AddGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
46 void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers); 46 void UpdateGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers);
47 void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID); 47 void RemoveGroupRole(UUID RequestingAgentID, UUID groupID, UUID roleID);
48 List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID); 48 List<GroupRolesData> GetGroupRoles(UUID RequestingAgentID, UUID GroupID);
49 List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID); 49 List<GroupRoleMembersData> GetGroupRoleMembers(UUID RequestingAgentID, UUID GroupID);
50 50
51 void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 51 void AddAgentToGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
52 void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); 52 void RemoveAgentFromGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
53 53
54 void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID); 54 void AddAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID);
55 GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); 55 GroupInviteInfo GetAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID);
56 void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID); 56 void RemoveAgentToGroupInvite(UUID RequestingAgentID, UUID inviteID);
57 57
58 void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 58 void AddAgentToGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
59 void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 59 void RemoveAgentFromGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
60 List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID); 60 List<GroupRolesData> GetAgentGroupRoles(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
61 61
62 void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); 62 void SetAgentActiveGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
63 GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID); 63 GroupMembershipData GetAgentActiveMembership(UUID RequestingAgentID, UUID AgentID);
64 64
65 void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 65 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
66 void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); 66 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
67 67
68 GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID); 68 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
69 List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID); 69 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID);
70 70
71 void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
72 GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID); 72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID);
73 List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID); 73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID);
74
75 void ResetAgentGroupChatSessions(UUID agentID);
76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID);
77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID);
78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID);
79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID);
74 } 80 }
75 81
76 public class GroupInviteInfo 82 public class GroupInviteInfo
@@ -80,11 +86,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
80 public UUID AgentID = UUID.Zero; 86 public UUID AgentID = UUID.Zero;
81 public UUID InviteID = UUID.Zero; 87 public UUID InviteID = UUID.Zero;
82 } 88 }
83
84 public class GroupRequestID
85 {
86 public UUID AgentID = UUID.Zero;
87 public string UserServiceURL = string.Empty;
88 public UUID SessionID = UUID.Zero;
89 }
90} 89}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
new file mode 100644
index 0000000..4867c01
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -0,0 +1,1329 @@
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;
30using System.Collections.Generic;
31using System.Collections.Specialized;
32using System.Reflection;
33
34using Nwc.XmlRpc;
35
36using log4net;
37using Mono.Addins;
38using Nini.Config;
39
40using OpenMetaverse;
41using OpenMetaverse.StructuredData;
42
43using OpenSim.Framework;
44using OpenSim.Framework.Communications;
45using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Services.Interfaces;
47
48/***************************************************************************
49 * Simian Data Map
50 * ===============
51 *
52 * OwnerID -> Type -> Key
53 * -----------------------
54 *
55 * UserID -> Group -> ActiveGroup
56 * + GroupID
57 *
58 * UserID -> GroupSessionDropped -> GroupID
59 * UserID -> GroupSessionInvited -> GroupID
60 *
61 * UserID -> GroupMember -> GroupID
62 * + SelectedRoleID [UUID]
63 * + AcceptNotices [bool]
64 * + ListInProfile [bool]
65 * + Contribution [int]
66 *
67 * UserID -> GroupRole[GroupID] -> RoleID
68 *
69 *
70 * GroupID -> Group -> GroupName
71 * + Charter
72 * + ShowInList
73 * + InsigniaID
74 * + MembershipFee
75 * + OpenEnrollment
76 * + AllowPublish
77 * + MaturePublish
78 * + FounderID
79 * + EveryonePowers
80 * + OwnerRoleID
81 * + OwnersPowers
82 *
83 * GroupID -> GroupRole -> RoleID
84 * + Name
85 * + Description
86 * + Title
87 * + Powers
88 *
89 * GroupID -> GroupMemberInvite -> InviteID
90 * + AgentID
91 * + RoleID
92 *
93 * GroupID -> GroupNotice -> NoticeID
94 * + TimeStamp [uint]
95 * + FromName [string]
96 * + Subject [string]
97 * + Message [string]
98 * + BinaryBucket [byte[]]
99 *
100 * */
101
102namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
103{
104 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
105 public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
106 {
107 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
108
109 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
110 GroupPowers.Accountable |
111 GroupPowers.JoinChat |
112 GroupPowers.AllowVoiceChat |
113 GroupPowers.ReceiveNotices |
114 GroupPowers.StartProposal |
115 GroupPowers.VoteOnProposal;
116
117 // Would this be cleaner as (GroupPowers)ulong.MaxValue;
118 public const GroupPowers m_DefaultOwnerPowers = GroupPowers.Accountable
119 | GroupPowers.AllowEditLand
120 | GroupPowers.AllowFly
121 | GroupPowers.AllowLandmark
122 | GroupPowers.AllowRez
123 | GroupPowers.AllowSetHome
124 | GroupPowers.AllowVoiceChat
125 | GroupPowers.AssignMember
126 | GroupPowers.AssignMemberLimited
127 | GroupPowers.ChangeActions
128 | GroupPowers.ChangeIdentity
129 | GroupPowers.ChangeMedia
130 | GroupPowers.ChangeOptions
131 | GroupPowers.CreateRole
132 | GroupPowers.DeedObject
133 | GroupPowers.DeleteRole
134 | GroupPowers.Eject
135 | GroupPowers.FindPlaces
136 | GroupPowers.Invite
137 | GroupPowers.JoinChat
138 | GroupPowers.LandChangeIdentity
139 | GroupPowers.LandDeed
140 | GroupPowers.LandDivideJoin
141 | GroupPowers.LandEdit
142 | GroupPowers.LandEjectAndFreeze
143 | GroupPowers.LandGardening
144 | GroupPowers.LandManageAllowed
145 | GroupPowers.LandManageBanned
146 | GroupPowers.LandManagePasses
147 | GroupPowers.LandOptions
148 | GroupPowers.LandRelease
149 | GroupPowers.LandSetSale
150 | GroupPowers.ModerateChat
151 | GroupPowers.ObjectManipulate
152 | GroupPowers.ObjectSetForSale
153 | GroupPowers.ReceiveNotices
154 | GroupPowers.RemoveMember
155 | GroupPowers.ReturnGroupOwned
156 | GroupPowers.ReturnGroupSet
157 | GroupPowers.ReturnNonGroup
158 | GroupPowers.RoleProperties
159 | GroupPowers.SendNotices
160 | GroupPowers.SetLandingPoint
161 | GroupPowers.StartProposal
162 | GroupPowers.VoteOnProposal;
163
164 private bool m_connectorEnabled = false;
165
166 private string m_groupsServerURI = string.Empty;
167
168 private bool m_debugEnabled = false;
169
170 // private IUserAccountService m_accountService = null;
171
172
173 #region IRegionModuleBase Members
174
175 public string Name
176 {
177 get { return "SimianGroupsServicesConnector"; }
178 }
179
180 // this module is not intended to be replaced, but there should only be 1 of them.
181 public Type ReplaceableInterface
182 {
183 get { return null; }
184 }
185
186 public void Initialise(IConfigSource config)
187 {
188 IConfig groupsConfig = config.Configs["Groups"];
189
190 if (groupsConfig == null)
191 {
192 // Do not run this module by default.
193 return;
194 }
195 else
196 {
197 // if groups aren't enabled, we're not needed.
198 // if we're not specified as the connector to use, then we're not wanted
199 if ((groupsConfig.GetBoolean("Enabled", false) == false)
200 || (groupsConfig.GetString("ServicesConnectorModule", "Default") != Name))
201 {
202 m_connectorEnabled = false;
203 return;
204 }
205
206 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
207
208 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
209 if ((m_groupsServerURI == null) ||
210 (m_groupsServerURI == string.Empty))
211 {
212 m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
213 m_connectorEnabled = false;
214 return;
215 }
216
217 // If we got all the config options we need, lets start'er'up
218 m_connectorEnabled = true;
219
220 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
221
222 }
223 }
224
225 public void Close()
226 {
227 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name);
228 }
229
230 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
231 {
232 if (m_connectorEnabled)
233 {
234 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
235 }
236 }
237
238 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
239 {
240 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
241 {
242 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
243 }
244 }
245
246 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
247 {
248 // TODO: May want to consider listenning for Agent Connections so we can pre-cache group info
249 // scene.EventManager.OnNewClient += OnNewClient;
250 }
251
252 #endregion
253
254 #region ISharedRegionModule Members
255
256 public void PostInitialise()
257 {
258 // NoOp
259 }
260
261 #endregion
262
263
264
265
266 #region IGroupsServicesConnector Members
267
268 /// <summary>
269 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role.
270 /// </summary>
271 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
272 int membershipFee, bool openEnrollment, bool allowPublish,
273 bool maturePublish, UUID founderID)
274 {
275 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
276
277 UUID GroupID = UUID.Random();
278 UUID OwnerRoleID = UUID.Random();
279
280 OSDMap GroupInfoMap = new OSDMap();
281 GroupInfoMap["Charter"] = OSD.FromString(charter);
282 GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
283 GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
284 GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
285 GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
286 GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
287 GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
288 GroupInfoMap["FounderID"] = OSD.FromUUID(founderID);
289 GroupInfoMap["EveryonePowers"] = OSD.FromULong((ulong)m_DefaultEveryonePowers);
290 GroupInfoMap["OwnerRoleID"] = OSD.FromUUID(OwnerRoleID);
291 GroupInfoMap["OwnersPowers"] = OSD.FromULong((ulong)m_DefaultOwnerPowers);
292
293 if(SimianAddGeneric(GroupID, "Group", name, GroupInfoMap))
294 {
295 AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
296 AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
297
298 AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
299
300 return GroupID;
301 }
302 else
303 {
304 return UUID.Zero;
305 }
306 }
307
308
309 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
310 UUID insigniaID, int membershipFee, bool openEnrollment,
311 bool allowPublish, bool maturePublish)
312 {
313 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
314 // TODO: Check to make sure requestingAgentID has permission to update group
315
316 string GroupName;
317 OSDMap GroupInfoMap;
318 if( SimianGetFirstGenericEntry(groupID, "GroupInfo", out GroupName, out GroupInfoMap) )
319 {
320 GroupInfoMap["Charter"] = OSD.FromString(charter);
321 GroupInfoMap["ShowInList"] = OSD.FromBoolean(showInList);
322 GroupInfoMap["InsigniaID"] = OSD.FromUUID(insigniaID);
323 GroupInfoMap["MembershipFee"] = OSD.FromInteger(0);
324 GroupInfoMap["OpenEnrollment"] = OSD.FromBoolean(openEnrollment);
325 GroupInfoMap["AllowPublish"] = OSD.FromBoolean(allowPublish);
326 GroupInfoMap["MaturePublish"] = OSD.FromBoolean(maturePublish);
327
328 SimianAddGeneric(groupID, "Group", GroupName, GroupInfoMap);
329 }
330
331 }
332
333
334 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
335 string title, ulong powers)
336 {
337 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
338
339 OSDMap GroupRoleInfo = new OSDMap();
340 GroupRoleInfo["Name"] = OSD.FromString(name);
341 GroupRoleInfo["Description"] = OSD.FromString(description);
342 GroupRoleInfo["Title"] = OSD.FromString(title);
343 GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
344
345 // TODO: Add security, make sure that requestingAgentID has permision to add roles
346 SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
347 }
348
349 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
350 {
351 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
352
353 // TODO: Add security
354
355 // Can't delete the Everyone Role
356 if (roleID != UUID.Zero)
357 {
358 // Remove all GroupRole Members from Role
359 Dictionary<UUID, OSDMap> GroupRoleMembers;
360 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
361 if (SimianGetGenericEntries(GroupRoleMemberType, roleID.ToString(), out GroupRoleMembers))
362 {
363 foreach(UUID UserID in GroupRoleMembers.Keys)
364 {
365 EnsureRoleNotSelectedByMember(groupID, roleID, UserID);
366
367 SimianRemoveGenericEntry(UserID, GroupRoleMemberType, roleID.ToString());
368 }
369 }
370
371 // Remove role
372 SimianRemoveGenericEntry(groupID, "GroupRole", roleID.ToString());
373 }
374 }
375
376
377 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
378 string title, ulong powers)
379 {
380 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
381
382 // TODO: Security, check that requestingAgentID is allowed to update group roles
383
384 OSDMap GroupRoleInfo;
385 if (SimianGetGenericEntry(groupID, "GroupRole", roleID.ToString(), out GroupRoleInfo))
386 {
387 if (name != null)
388 {
389 GroupRoleInfo["Name"] = OSD.FromString(name);
390 }
391 if (description != null)
392 {
393 GroupRoleInfo["Description"] = OSD.FromString(description);
394 }
395 if (title != null)
396 {
397 GroupRoleInfo["Title"] = OSD.FromString(title);
398 }
399 GroupRoleInfo["Powers"] = OSD.FromULong((ulong)powers);
400
401 }
402
403
404 SimianAddGeneric(groupID, "GroupRole", roleID.ToString(), GroupRoleInfo);
405 }
406
407 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID groupID, string groupName)
408 {
409 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
410
411 OSDMap GroupInfoMap = null;
412 if (groupID != UUID.Zero)
413 {
414 if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out GroupInfoMap))
415 {
416 return null;
417 }
418 }
419 else if ((groupName != null) && (groupName != string.Empty))
420 {
421 if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
422 {
423 return null;
424 }
425 }
426
427 GroupRecord GroupInfo = new GroupRecord();
428
429 GroupInfo.GroupID = groupID;
430 GroupInfo.GroupName = groupName;
431 GroupInfo.Charter = GroupInfoMap["Charter"].AsString();
432 GroupInfo.ShowInList = GroupInfoMap["ShowInList"].AsBoolean();
433 GroupInfo.GroupPicture = GroupInfoMap["InsigniaID"].AsUUID();
434 GroupInfo.MembershipFee = GroupInfoMap["MembershipFee"].AsInteger();
435 GroupInfo.OpenEnrollment = GroupInfoMap["OpenEnrollment"].AsBoolean();
436 GroupInfo.AllowPublish = GroupInfoMap["AllowPublish"].AsBoolean();
437 GroupInfo.MaturePublish = GroupInfoMap["MaturePublish"].AsBoolean();
438 GroupInfo.FounderID = GroupInfoMap["FounderID"].AsUUID();
439 GroupInfo.OwnerRoleID = GroupInfoMap["OwnerRoleID"].AsUUID();
440
441 return GroupInfo;
442
443 }
444
445 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID groupID, UUID memberID)
446 {
447 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
448
449 OSDMap groupProfile;
450 string groupName;
451 if (!SimianGetFirstGenericEntry(groupID, "Group", out groupName, out groupProfile))
452 {
453 // GroupProfileData is not nullable
454 return new GroupProfileData();
455 }
456
457 GroupProfileData MemberGroupProfile = new GroupProfileData();
458 MemberGroupProfile.GroupID = groupID;
459 MemberGroupProfile.Name = groupName;
460
461 if (groupProfile["Charter"] != null)
462 {
463 MemberGroupProfile.Charter = groupProfile["Charter"].AsString();
464 }
465
466 MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1";
467 MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID();
468 MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger();
469 MemberGroupProfile.OpenEnrollment = groupProfile["OpenEnrollment"].AsBoolean();
470 MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean();
471 MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean();
472 MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();;
473 MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID();
474
475 Dictionary<UUID, OSDMap> Members;
476 if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members))
477 {
478 MemberGroupProfile.GroupMembershipCount = Members.Count;
479 }
480
481 Dictionary<string, OSDMap> Roles;
482 if (SimianGetGenericEntries(groupID, "GroupRole", out Roles))
483 {
484 MemberGroupProfile.GroupRolesCount = Roles.Count;
485 }
486
487 // TODO: Get Group Money balance from somewhere
488 // group.Money = 0;
489
490 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, memberID, groupID);
491
492 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
493 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
494
495 return MemberGroupProfile;
496 }
497
498 public void SetAgentActiveGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
499 {
500 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
501
502 OSDMap ActiveGroup = new OSDMap();
503 ActiveGroup.Add("GroupID", OSD.FromUUID(groupID));
504 SimianAddGeneric(agentID, "Group", "ActiveGroup", ActiveGroup);
505 }
506
507 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
508 {
509 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
510
511 OSDMap GroupMemberInfo;
512 if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
513 {
514 GroupMemberInfo = new OSDMap();
515 }
516
517 GroupMemberInfo["SelectedRoleID"] = OSD.FromUUID(roleID);
518 SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
519 }
520
521 public void SetAgentGroupInfo(UUID requestingAgentID, UUID agentID, UUID groupID, bool acceptNotices, bool listInProfile)
522 {
523 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
524
525 OSDMap GroupMemberInfo;
526 if (!SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out GroupMemberInfo))
527 {
528 GroupMemberInfo = new OSDMap();
529 }
530
531 GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices);
532 GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile);
533 GroupMemberInfo["Contribution"] = OSD.FromInteger(0);
534 GroupMemberInfo["SelectedRole"] = OSD.FromUUID(UUID.Zero);
535 SimianAddGeneric(agentID, "GroupMember", groupID.ToString(), GroupMemberInfo);
536 }
537
538 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
539 {
540 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
541
542 OSDMap Invite = new OSDMap();
543 Invite["AgentID"] = OSD.FromUUID(agentID);
544 Invite["RoleID"] = OSD.FromUUID(roleID);
545
546 SimianAddGeneric(groupID, "GroupMemberInvite", inviteID.ToString(), Invite);
547 }
548
549 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
550 {
551 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
552
553 OSDMap GroupMemberInvite;
554 UUID GroupID;
555 if (!SimianGetFirstGenericEntry("GroupMemberInvite", inviteID.ToString(), out GroupID, out GroupMemberInvite))
556 {
557 return null;
558 }
559
560 GroupInviteInfo inviteInfo = new GroupInviteInfo();
561 inviteInfo.InviteID = inviteID;
562 inviteInfo.GroupID = GroupID;
563 inviteInfo.AgentID = GroupMemberInvite["AgentID"].AsUUID();
564 inviteInfo.RoleID = GroupMemberInvite["RoleID"].AsUUID();
565
566 return inviteInfo;
567 }
568
569 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
570 {
571 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
572
573 GroupInviteInfo invite = GetAgentToGroupInvite(requestingAgentID, inviteID);
574 SimianRemoveGenericEntry(invite.GroupID, "GroupMemberInvite", inviteID.ToString());
575 }
576
577 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
578 {
579 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
580
581 // Setup Agent/Group information
582 SetAgentGroupInfo(requestingAgentID, AgentID, GroupID, true, true);
583
584 // Add agent to Everyone Group
585 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, UUID.Zero);
586
587 // Add agent to Specified Role
588 AddAgentToGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
589
590 // Set selected role in this group to specified role
591 SetAgentActiveGroupRole(requestingAgentID, AgentID, GroupID, RoleID);
592 }
593
594 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID agentID, UUID groupID)
595 {
596 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
597
598 // If current active group is the group the agent is being removed from, change their group to UUID.Zero
599 GroupMembershipData memberActiveMembership = GetAgentActiveMembership(requestingAgentID, agentID);
600 if (memberActiveMembership.GroupID == groupID)
601 {
602 SetAgentActiveGroup(agentID, agentID, UUID.Zero);
603 }
604
605 // Remove Group Member information for this group
606 SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString());
607
608 // By using a Simian Generics Type consisting of a prefix and a groupID,
609 // combined with RoleID as key allows us to get a list of roles a particular member
610 // of a group is assigned to.
611 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
612
613 // Take Agent out of all other group roles
614 Dictionary<string, OSDMap> GroupRoles;
615 if (SimianGetGenericEntries(agentID, GroupRoleMemberType, out GroupRoles))
616 {
617 foreach (string roleID in GroupRoles.Keys)
618 {
619 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID);
620 }
621 }
622 }
623
624 public void AddAgentToGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
625 {
626 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
627
628 SimianAddGeneric(agentID, "GroupRole" + groupID.ToString(), roleID.ToString(), new OSDMap());
629 }
630
631 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID agentID, UUID groupID, UUID roleID)
632 {
633 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
634
635 // Cannot remove members from the Everyone Role
636 if (roleID != UUID.Zero)
637 {
638 EnsureRoleNotSelectedByMember(groupID, roleID, agentID);
639
640 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
641 SimianRemoveGenericEntry(agentID, GroupRoleMemberType, roleID.ToString());
642 }
643 }
644
645 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
646 {
647 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
648
649 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
650
651 NameValueCollection requestArgs = new NameValueCollection
652 {
653 { "RequestMethod", "GetGenerics" },
654 { "Type", "Group" },
655 { "Key", search },
656 { "Fuzzy", "1" }
657 };
658
659
660 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
661 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
662 {
663 OSDArray entryArray = (OSDArray)response["Entries"];
664 foreach (OSDMap entryMap in entryArray)
665 {
666 DirGroupsReplyData data = new DirGroupsReplyData();
667 data.groupID = entryMap["OwnerID"].AsUUID();
668 data.groupName = entryMap["Key"].AsString();
669
670 // TODO: is there a better way to do this?
671 Dictionary<UUID, OSDMap> Members;
672 if (SimianGetGenericEntries("GroupMember", data.groupID.ToString(), out Members))
673 {
674 data.members = Members.Count;
675 }
676 else
677 {
678 data.members = 0;
679 }
680
681 // TODO: sort results?
682 // data.searchOrder = order;
683
684 findings.Add(data);
685 }
686 }
687
688
689 return findings;
690 }
691
692 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID agentID, UUID groupID)
693 {
694 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
695
696 GroupMembershipData data = new GroupMembershipData();
697
698 ///////////////////////////////
699 // Agent Specific Information:
700 //
701 OSDMap UserActiveGroup;
702 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
703 {
704 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
705 }
706
707 OSDMap UserGroupMemberInfo;
708 if( SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo) )
709 {
710 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
711 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
712 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
713 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
714
715 ///////////////////////////////
716 // Role Specific Information:
717 //
718
719 OSDMap GroupRoleInfo;
720 if( SimianGetGenericEntry(groupID, "GroupRole", data.ActiveRole.ToString(), out GroupRoleInfo) )
721 {
722 data.GroupTitle = GroupRoleInfo["Title"].AsString();
723 data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
724 }
725 }
726
727 ///////////////////////////////
728 // Group Specific Information:
729 //
730 OSDMap GroupInfo;
731 string GroupName;
732 if( SimianGetFirstGenericEntry(groupID, "Group", out GroupName, out GroupInfo) )
733 {
734 data.GroupID = groupID;
735 data.AllowPublish = GroupInfo["AllowPublish"].AsBoolean();
736 data.Charter = GroupInfo["Charter"].AsString();
737 data.FounderID = GroupInfo["FounderID"].AsUUID();
738 data.GroupName = GroupName;
739 data.GroupPicture = GroupInfo["InsigniaID"].AsUUID();
740 data.MaturePublish = GroupInfo["MaturePublish"].AsBoolean();
741 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
742 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
743 data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
744 }
745
746 return data;
747 }
748
749 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID agentID)
750 {
751 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
752
753 UUID GroupID = UUID.Zero;
754 OSDMap UserActiveGroup;
755 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
756 {
757 GroupID = UserActiveGroup["GroupID"].AsUUID();
758 }
759
760 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Active GroupID : {0}", GroupID.ToString());
761 return GetAgentGroupMembership(requestingAgentID, agentID, GroupID);
762 }
763
764 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID agentID)
765 {
766 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
767
768 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
769
770 Dictionary<string,OSDMap> GroupMemberShips;
771 if (SimianGetGenericEntries(agentID, "GroupMember", out GroupMemberShips))
772 {
773 foreach (string key in GroupMemberShips.Keys)
774 {
775 memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key)));
776 }
777 }
778
779 return memberships;
780 }
781
782 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID agentID, UUID groupID)
783 {
784 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
785
786 List<GroupRolesData> Roles = new List<GroupRolesData>();
787
788 Dictionary<string, OSDMap> GroupRoles;
789 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
790 {
791 Dictionary<string, OSDMap> MemberRoles;
792 if (SimianGetGenericEntries(agentID, "GroupRole" + groupID.ToString(), out MemberRoles))
793 {
794 foreach (KeyValuePair<string, OSDMap> kvp in MemberRoles)
795 {
796 GroupRolesData data = new GroupRolesData();
797 data.RoleID = UUID.Parse(kvp.Key);
798 data.Name = GroupRoles[kvp.Key]["Name"].AsString();
799 data.Description = GroupRoles[kvp.Key]["Description"].AsString();
800 data.Title = GroupRoles[kvp.Key]["Title"].AsString();
801 data.Powers = GroupRoles[kvp.Key]["Powers"].AsULong();
802
803 Roles.Add(data);
804 }
805 }
806 }
807 return Roles;
808 }
809
810 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID groupID)
811 {
812 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
813
814 List<GroupRolesData> Roles = new List<GroupRolesData>();
815
816 Dictionary<string, OSDMap> GroupRoles;
817 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
818 {
819 foreach (KeyValuePair<string, OSDMap> role in GroupRoles)
820 {
821 GroupRolesData data = new GroupRolesData();
822
823 data.RoleID = UUID.Parse(role.Key);
824
825 data.Name = role.Value["Name"].AsString();
826 data.Description = role.Value["Description"].AsString();
827 data.Title = role.Value["Title"].AsString();
828 data.Powers = role.Value["Powers"].AsULong();
829
830 Dictionary<UUID, OSDMap> GroupRoleMembers;
831 if (SimianGetGenericEntries("GroupRole" + groupID.ToString(), role.Key, out GroupRoleMembers))
832 {
833 data.Members = GroupRoleMembers.Count;
834 }
835 else
836 {
837 data.Members = 0;
838 }
839
840 Roles.Add(data);
841 }
842 }
843
844 return Roles;
845
846 }
847
848
849
850 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
851 {
852 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
853
854 List<GroupMembersData> members = new List<GroupMembersData>();
855
856 OSDMap GroupInfo;
857 string GroupName;
858 UUID GroupOwnerRoleID = UUID.Zero;
859 if (!SimianGetFirstGenericEntry(GroupID, "Group", out GroupName, out GroupInfo))
860 {
861 return members;
862 }
863 GroupOwnerRoleID = GroupInfo["OwnerRoleID"].AsUUID();
864
865 // Locally cache group roles, since we'll be needing this data for each member
866 Dictionary<string,OSDMap> GroupRoles;
867 SimianGetGenericEntries(GroupID, "GroupRole", out GroupRoles);
868
869 // Locally cache list of group owners
870 Dictionary<UUID, OSDMap> GroupOwners;
871 SimianGetGenericEntries("GroupRole" + GroupID.ToString(), GroupOwnerRoleID.ToString(), out GroupOwners);
872
873
874 Dictionary<UUID, OSDMap> GroupMembers;
875 if (SimianGetGenericEntries("GroupMember", GroupID.ToString(), out GroupMembers))
876 {
877 foreach (KeyValuePair<UUID, OSDMap> member in GroupMembers)
878 {
879 GroupMembersData data = new GroupMembersData();
880
881 data.AgentID = member.Key;
882
883 UUID SelectedRoleID = member.Value["SelectedRoleID"].AsUUID();
884
885 data.AcceptNotices = member.Value["AcceptNotices"].AsBoolean();
886 data.ListInProfile = member.Value["ListInProfile"].AsBoolean();
887 data.Contribution = member.Value["Contribution"].AsInteger();
888
889 data.IsOwner = GroupOwners.ContainsKey(member.Key);
890
891 OSDMap GroupRoleInfo = GroupRoles[SelectedRoleID.ToString()];
892 data.Title = GroupRoleInfo["Title"].AsString();
893 data.AgentPowers = GroupRoleInfo["Powers"].AsULong();
894
895 members.Add(data);
896 }
897 }
898
899 return members;
900
901 }
902
903 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID groupID)
904 {
905 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
906
907 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
908
909 Dictionary<string, OSDMap> GroupRoles;
910 if (SimianGetGenericEntries(groupID, "GroupRole", out GroupRoles))
911 {
912 foreach( KeyValuePair<string, OSDMap> Role in GroupRoles )
913 {
914 Dictionary<UUID, OSDMap> GroupRoleMembers;
915 if( SimianGetGenericEntries("GroupRole"+groupID.ToString(), Role.Key, out GroupRoleMembers) )
916 {
917 foreach( KeyValuePair<UUID, OSDMap> GroupRoleMember in GroupRoleMembers )
918 {
919 GroupRoleMembersData data = new GroupRoleMembersData();
920
921 data.MemberID = GroupRoleMember.Key;
922 data.RoleID = UUID.Parse(Role.Key);
923
924 members.Add(data);
925 }
926 }
927 }
928 }
929
930 return members;
931 }
932
933 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
934 {
935 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
936
937 List<GroupNoticeData> values = new List<GroupNoticeData>();
938
939 Dictionary<string, OSDMap> Notices;
940 if (SimianGetGenericEntries(GroupID, "GroupNotice", out Notices))
941 {
942 foreach (KeyValuePair<string, OSDMap> Notice in Notices)
943 {
944 GroupNoticeData data = new GroupNoticeData();
945 data.NoticeID = UUID.Parse(Notice.Key);
946 data.Timestamp = Notice.Value["TimeStamp"].AsUInteger();
947 data.FromName = Notice.Value["FromName"].AsString();
948 data.Subject = Notice.Value["Subject"].AsString();
949 data.HasAttachment = Notice.Value["BinaryBucket"].AsBinary().Length > 0;
950
951 //TODO: Figure out how to get this
952 data.AssetType = 0;
953
954 values.Add(data);
955 }
956 }
957
958 return values;
959
960 }
961 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
962 {
963 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
964
965 OSDMap GroupNotice;
966 UUID GroupID;
967 if (SimianGetFirstGenericEntry("GroupNotice", noticeID.ToString(), out GroupID, out GroupNotice))
968 {
969 GroupNoticeInfo data = new GroupNoticeInfo();
970 data.GroupID = GroupID;
971 data.Message = GroupNotice["Message"].AsString();
972 data.BinaryBucket = GroupNotice["BinaryBucket"].AsBinary();
973 data.noticeData.NoticeID = noticeID;
974 data.noticeData.Timestamp = GroupNotice["TimeStamp"].AsUInteger();
975 data.noticeData.FromName = GroupNotice["FromName"].AsString();
976 data.noticeData.Subject = GroupNotice["Subject"].AsString();
977 data.noticeData.HasAttachment = data.BinaryBucket.Length > 0;
978 data.noticeData.AssetType = 0;
979
980 if (data.Message == null)
981 {
982 data.Message = string.Empty;
983 }
984
985 return data;
986 }
987 return null;
988 }
989 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
990 {
991 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
992
993 OSDMap Notice = new OSDMap();
994 Notice["TimeStamp"] = OSD.FromUInteger((uint)Util.UnixTimeSinceEpoch());
995 Notice["FromName"] = OSD.FromString(fromName);
996 Notice["Subject"] = OSD.FromString(subject);
997 Notice["Message"] = OSD.FromString(message);
998 Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket);
999
1000 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
1001
1002 }
1003 #endregion
1004
1005 #region GroupSessionTracking
1006
1007 public void ResetAgentGroupChatSessions(UUID agentID)
1008 {
1009 Dictionary<string, OSDMap> agentSessions;
1010
1011 if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions))
1012 {
1013 foreach (string GroupID in agentSessions.Keys)
1014 {
1015 SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID);
1016 }
1017 }
1018
1019 if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions))
1020 {
1021 foreach (string GroupID in agentSessions.Keys)
1022 {
1023 SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID);
1024 }
1025 }
1026 }
1027
1028 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
1029 {
1030 OSDMap session;
1031 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1032 }
1033
1034 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
1035 {
1036 SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap());
1037 }
1038
1039 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
1040 {
1041 SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap());
1042 }
1043
1044 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
1045 {
1046 OSDMap session;
1047 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1048 }
1049
1050 #endregion
1051
1052 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
1053 {
1054 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1055
1056 // If member's SelectedRole is roleID, change their selected role to Everyone
1057 // before removing them from the role
1058 OSDMap UserGroupInfo;
1059 if (SimianGetGenericEntry(userID, "GroupMember", groupID.ToString(), out UserGroupInfo))
1060 {
1061 if (UserGroupInfo["SelectedRoleID"].AsUUID() == roleID)
1062 {
1063 UserGroupInfo["SelectedRoleID"] = OSD.FromUUID(UUID.Zero);
1064 }
1065 SimianAddGeneric(userID, "GroupMember", groupID.ToString(), UserGroupInfo);
1066 }
1067 }
1068
1069
1070 #region Simian Util Methods
1071 private bool SimianAddGeneric(UUID ownerID, string type, string key, OSDMap map)
1072 {
1073 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1074
1075 string value = OSDParser.SerializeJsonString(map);
1076
1077 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] value: {0}", value);
1078
1079 NameValueCollection RequestArgs = new NameValueCollection
1080 {
1081 { "RequestMethod", "AddGeneric" },
1082 { "OwnerID", ownerID.ToString() },
1083 { "Type", type },
1084 { "Key", key },
1085 { "Value", value}
1086 };
1087
1088
1089 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs);
1090 if (Response["Success"].AsBoolean())
1091 {
1092 return true;
1093 }
1094 else
1095 {
1096 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, Response["Message"]);
1097 return false;
1098 }
1099 }
1100
1101 /// <summary>
1102 /// Returns the first of possibly many entries for Owner/Type pair
1103 /// </summary>
1104 private bool SimianGetFirstGenericEntry(UUID ownerID, string type, out string key, out OSDMap map)
1105 {
1106 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type);
1107
1108 NameValueCollection RequestArgs = new NameValueCollection
1109 {
1110 { "RequestMethod", "GetGenerics" },
1111 { "OwnerID", ownerID.ToString() },
1112 { "Type", type }
1113 };
1114
1115
1116 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs);
1117 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1118 {
1119 OSDArray entryArray = (OSDArray)Response["Entries"];
1120 if (entryArray.Count >= 1)
1121 {
1122 OSDMap entryMap = entryArray[0] as OSDMap;
1123 key = entryMap["Key"].AsString();
1124 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1125
1126 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1127
1128 return true;
1129 }
1130 else
1131 {
1132 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1133 }
1134 }
1135 else
1136 {
1137 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1138 }
1139 key = null;
1140 map = null;
1141 return false;
1142 }
1143 private bool SimianGetFirstGenericEntry(string type, string key, out UUID ownerID, out OSDMap map)
1144 {
1145 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1146
1147
1148 NameValueCollection RequestArgs = new NameValueCollection
1149 {
1150 { "RequestMethod", "GetGenerics" },
1151 { "Type", type },
1152 { "Key", key}
1153 };
1154
1155
1156 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs);
1157 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1158 {
1159 OSDArray entryArray = (OSDArray)Response["Entries"];
1160 if (entryArray.Count >= 1)
1161 {
1162 OSDMap entryMap = entryArray[0] as OSDMap;
1163 ownerID = entryMap["OwnerID"].AsUUID();
1164 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1165
1166 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1167
1168 return true;
1169 }
1170 else
1171 {
1172 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1173 }
1174 }
1175 else
1176 {
1177 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1178 }
1179 ownerID = UUID.Zero;
1180 map = null;
1181 return false;
1182 }
1183
1184 private bool SimianGetGenericEntry(UUID ownerID, string type, string key, out OSDMap map)
1185 {
1186 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1187
1188 NameValueCollection RequestArgs = new NameValueCollection
1189 {
1190 { "RequestMethod", "GetGenerics" },
1191 { "OwnerID", ownerID.ToString() },
1192 { "Type", type },
1193 { "Key", key}
1194 };
1195
1196
1197 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs);
1198 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1199 {
1200 OSDArray entryArray = (OSDArray)Response["Entries"];
1201 if (entryArray.Count == 1)
1202 {
1203 OSDMap entryMap = entryArray[0] as OSDMap;
1204 key = entryMap["Key"].AsString();
1205 map = (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString());
1206
1207 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1208
1209 return true;
1210 }
1211 else
1212 {
1213 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1214 }
1215 }
1216 else
1217 {
1218 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", Response["Message"]);
1219 }
1220 map = null;
1221 return false;
1222 }
1223
1224 private bool SimianGetGenericEntries(UUID ownerID, string type, out Dictionary<string, OSDMap> maps)
1225 {
1226 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name,ownerID, type);
1227
1228 NameValueCollection requestArgs = new NameValueCollection
1229 {
1230 { "RequestMethod", "GetGenerics" },
1231 { "OwnerID", ownerID.ToString() },
1232 { "Type", type }
1233 };
1234
1235
1236
1237 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1238 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1239 {
1240 maps = new Dictionary<string, OSDMap>();
1241
1242 OSDArray entryArray = (OSDArray)response["Entries"];
1243 foreach (OSDMap entryMap in entryArray)
1244 {
1245 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1246 maps.Add(entryMap["Key"].AsString(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1247 }
1248 if(maps.Count == 0)
1249 {
1250 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1251 }
1252
1253 return true;
1254 }
1255 else
1256 {
1257 maps = null;
1258 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
1259 }
1260 return false;
1261 }
1262 private bool SimianGetGenericEntries(string type, string key, out Dictionary<UUID, OSDMap> maps)
1263 {
1264 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2})", System.Reflection.MethodBase.GetCurrentMethod().Name, type, key);
1265
1266 NameValueCollection requestArgs = new NameValueCollection
1267 {
1268 { "RequestMethod", "GetGenerics" },
1269 { "Type", type },
1270 { "Key", key }
1271 };
1272
1273
1274
1275 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1276 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1277 {
1278 maps = new Dictionary<UUID, OSDMap>();
1279
1280 OSDArray entryArray = (OSDArray)response["Entries"];
1281 foreach (OSDMap entryMap in entryArray)
1282 {
1283 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Generics Result {0}", entryMap["Value"].AsString());
1284 maps.Add(entryMap["OwnerID"].AsUUID(), (OSDMap)OSDParser.DeserializeJson(entryMap["Value"].AsString()));
1285 }
1286 if (maps.Count == 0)
1287 {
1288 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] No Generics Results");
1289 }
1290 return true;
1291 }
1292 else
1293 {
1294 maps = null;
1295 m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR]: Error retrieving group info ({0})", response["Message"]);
1296 }
1297 return false;
1298 }
1299
1300 private bool SimianRemoveGenericEntry(UUID ownerID, string type, string key)
1301 {
1302 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called ({1},{2},{3})", System.Reflection.MethodBase.GetCurrentMethod().Name, ownerID, type, key);
1303
1304 NameValueCollection requestArgs = new NameValueCollection
1305 {
1306 { "RequestMethod", "RemoveGeneric" },
1307 { "OwnerID", ownerID.ToString() },
1308 { "Type", type },
1309 { "Key", key }
1310 };
1311
1312
1313 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1314 if (response["Success"].AsBoolean())
1315 {
1316 return true;
1317 }
1318 else
1319 {
1320 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: Error {0}, {1}, {2}, {3}", ownerID, type, key, response["Message"]);
1321 return false;
1322 }
1323 }
1324 #endregion
1325
1326 }
1327
1328}
1329
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 24ae4f7..8e7aa68 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -40,7 +40,9 @@ using OpenMetaverse;
40using OpenMetaverse.StructuredData; 40using OpenMetaverse.StructuredData;
41 41
42using OpenSim.Framework; 42using OpenSim.Framework;
43using OpenSim.Framework.Communications;
43using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces;
44 46
45namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 47namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
46{ 48{
@@ -59,13 +61,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
59 61
60 private bool m_connectorEnabled = false; 62 private bool m_connectorEnabled = false;
61 63
62 private string m_serviceURL = string.Empty; 64 private string m_groupsServerURI = string.Empty;
63 65
64 private bool m_disableKeepAlive = false; 66 private bool m_disableKeepAlive = false;
65 67
66 private string m_groupReadKey = string.Empty; 68 private string m_groupReadKey = string.Empty;
67 private string m_groupWriteKey = string.Empty; 69 private string m_groupWriteKey = string.Empty;
68 70
71 private IUserAccountService m_accountService = null;
72
73 // Used to track which agents are have dropped from a group chat session
74 // Should be reset per agent, on logon
75 // TODO: move this to Flotsam XmlRpc Service
76 // SessionID, List<AgentID>
77 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
78 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
79
69 80
70 #region IRegionModuleBase Members 81 #region IRegionModuleBase Members
71 82
@@ -100,13 +111,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
100 return; 111 return;
101 } 112 }
102 113
103 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 114 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
104 115
105 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); 116 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
106 if ((m_serviceURL == null) || 117 if ((m_groupsServerURI == null) ||
107 (m_serviceURL == string.Empty)) 118 (m_groupsServerURI == string.Empty))
108 { 119 {
109 m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); 120 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
110 m_connectorEnabled = false; 121 m_connectorEnabled = false;
111 return; 122 return;
112 } 123 }
@@ -116,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
116 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 127 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
117 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 128 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
118 129
130
131
132
119 // If we got all the config options we need, lets start'er'up 133 // If we got all the config options we need, lets start'er'up
120 m_connectorEnabled = true; 134 m_connectorEnabled = true;
121 } 135 }
@@ -129,13 +143,24 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
129 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 143 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
130 { 144 {
131 if (m_connectorEnabled) 145 if (m_connectorEnabled)
146 {
147
148 if (m_accountService == null)
149 {
150 m_accountService = scene.UserAccountService;
151 }
152
153
132 scene.RegisterModuleInterface<IGroupsServicesConnector>(this); 154 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
155 }
133 } 156 }
134 157
135 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) 158 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
136 { 159 {
137 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) 160 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
161 {
138 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); 162 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
163 }
139 } 164 }
140 165
141 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) 166 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -155,14 +180,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
155 180
156 #endregion 181 #endregion
157 182
158
159
160 #region IGroupsServicesConnector Members 183 #region IGroupsServicesConnector Members
161 184
162 /// <summary> 185 /// <summary>
163 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. 186 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role.
164 /// </summary> 187 /// </summary>
165 public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, 188 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
166 int membershipFee, bool openEnrollment, bool allowPublish, 189 int membershipFee, bool openEnrollment, bool allowPublish,
167 bool maturePublish, UUID founderID) 190 bool maturePublish, UUID founderID)
168 { 191 {
@@ -234,7 +257,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
234 257
235 258
236 259
237 Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param); 260 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param);
238 261
239 if (respData.Contains("error")) 262 if (respData.Contains("error"))
240 { 263 {
@@ -246,7 +269,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
246 return UUID.Parse((string)respData["GroupID"]); 269 return UUID.Parse((string)respData["GroupID"]);
247 } 270 }
248 271
249 public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, 272 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
250 UUID insigniaID, int membershipFee, bool openEnrollment, 273 UUID insigniaID, int membershipFee, bool openEnrollment,
251 bool allowPublish, bool maturePublish) 274 bool allowPublish, bool maturePublish)
252 { 275 {
@@ -260,10 +283,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
260 param["AllowPublish"] = allowPublish == true ? 1 : 0; 283 param["AllowPublish"] = allowPublish == true ? 1 : 0;
261 param["MaturePublish"] = maturePublish == true ? 1 : 0; 284 param["MaturePublish"] = maturePublish == true ? 1 : 0;
262 285
263 XmlRpcCall(requestID, "groups.updateGroup", param); 286 XmlRpcCall(requestingAgentID, "groups.updateGroup", param);
264 } 287 }
265 288
266 public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 289 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
267 string title, ulong powers) 290 string title, ulong powers)
268 { 291 {
269 Hashtable param = new Hashtable(); 292 Hashtable param = new Hashtable();
@@ -274,19 +297,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
274 param["Title"] = title; 297 param["Title"] = title;
275 param["Powers"] = powers.ToString(); 298 param["Powers"] = powers.ToString();
276 299
277 XmlRpcCall(requestID, "groups.addRoleToGroup", param); 300 XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param);
278 } 301 }
279 302
280 public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID) 303 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
281 { 304 {
282 Hashtable param = new Hashtable(); 305 Hashtable param = new Hashtable();
283 param["GroupID"] = groupID.ToString(); 306 param["GroupID"] = groupID.ToString();
284 param["RoleID"] = roleID.ToString(); 307 param["RoleID"] = roleID.ToString();
285 308
286 XmlRpcCall(requestID, "groups.removeRoleFromGroup", param); 309 XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param);
287 } 310 }
288 311
289 public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 312 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
290 string title, ulong powers) 313 string title, ulong powers)
291 { 314 {
292 Hashtable param = new Hashtable(); 315 Hashtable param = new Hashtable();
@@ -306,10 +329,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
306 } 329 }
307 param["Powers"] = powers.ToString(); 330 param["Powers"] = powers.ToString();
308 331
309 XmlRpcCall(requestID, "groups.updateGroupRole", param); 332 XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param);
310 } 333 }
311 334
312 public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName) 335 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
313 { 336 {
314 Hashtable param = new Hashtable(); 337 Hashtable param = new Hashtable();
315 if (GroupID != UUID.Zero) 338 if (GroupID != UUID.Zero)
@@ -321,7 +344,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
321 param["Name"] = GroupName.ToString(); 344 param["Name"] = GroupName.ToString();
322 } 345 }
323 346
324 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); 347 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
325 348
326 if (respData.Contains("error")) 349 if (respData.Contains("error"))
327 { 350 {
@@ -332,12 +355,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
332 355
333 } 356 }
334 357
335 public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID) 358 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
336 { 359 {
337 Hashtable param = new Hashtable(); 360 Hashtable param = new Hashtable();
338 param["GroupID"] = GroupID.ToString(); 361 param["GroupID"] = GroupID.ToString();
339 362
340 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); 363 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
341 364
342 if (respData.Contains("error")) 365 if (respData.Contains("error"))
343 { 366 {
@@ -345,7 +368,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
345 return new GroupProfileData(); 368 return new GroupProfileData();
346 } 369 }
347 370
348 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID); 371 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
349 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); 372 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
350 373
351 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; 374 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
@@ -354,26 +377,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
354 return MemberGroupProfile; 377 return MemberGroupProfile;
355 } 378 }
356 379
357 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) 380 public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
358 { 381 {
359 Hashtable param = new Hashtable(); 382 Hashtable param = new Hashtable();
360 param["AgentID"] = AgentID.ToString(); 383 param["AgentID"] = AgentID.ToString();
361 param["GroupID"] = GroupID.ToString(); 384 param["GroupID"] = GroupID.ToString();
362 385
363 XmlRpcCall(requestID, "groups.setAgentActiveGroup", param); 386 XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param);
364 } 387 }
365 388
366 public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 389 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
367 { 390 {
368 Hashtable param = new Hashtable(); 391 Hashtable param = new Hashtable();
369 param["AgentID"] = AgentID.ToString(); 392 param["AgentID"] = AgentID.ToString();
370 param["GroupID"] = GroupID.ToString(); 393 param["GroupID"] = GroupID.ToString();
371 param["SelectedRoleID"] = RoleID.ToString(); 394 param["SelectedRoleID"] = RoleID.ToString();
372 395
373 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); 396 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
374 } 397 }
375 398
376 public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 399 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
377 { 400 {
378 Hashtable param = new Hashtable(); 401 Hashtable param = new Hashtable();
379 param["AgentID"] = AgentID.ToString(); 402 param["AgentID"] = AgentID.ToString();
@@ -381,11 +404,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
381 param["AcceptNotices"] = AcceptNotices ? "1" : "0"; 404 param["AcceptNotices"] = AcceptNotices ? "1" : "0";
382 param["ListInProfile"] = ListInProfile ? "1" : "0"; 405 param["ListInProfile"] = ListInProfile ? "1" : "0";
383 406
384 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); 407 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
385 408
386 } 409 }
387 410
388 public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 411 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
389 { 412 {
390 Hashtable param = new Hashtable(); 413 Hashtable param = new Hashtable();
391 param["InviteID"] = inviteID.ToString(); 414 param["InviteID"] = inviteID.ToString();
@@ -393,16 +416,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
393 param["RoleID"] = roleID.ToString(); 416 param["RoleID"] = roleID.ToString();
394 param["GroupID"] = groupID.ToString(); 417 param["GroupID"] = groupID.ToString();
395 418
396 XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param); 419 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param);
397 420
398 } 421 }
399 422
400 public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) 423 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
401 { 424 {
402 Hashtable param = new Hashtable(); 425 Hashtable param = new Hashtable();
403 param["InviteID"] = inviteID.ToString(); 426 param["InviteID"] = inviteID.ToString();
404 427
405 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param); 428 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param);
406 429
407 if (respData.Contains("error")) 430 if (respData.Contains("error"))
408 { 431 {
@@ -418,59 +441,59 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
418 return inviteInfo; 441 return inviteInfo;
419 } 442 }
420 443
421 public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) 444 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
422 { 445 {
423 Hashtable param = new Hashtable(); 446 Hashtable param = new Hashtable();
424 param["InviteID"] = inviteID.ToString(); 447 param["InviteID"] = inviteID.ToString();
425 448
426 XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param); 449 XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param);
427 } 450 }
428 451
429 public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 452 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
430 { 453 {
431 Hashtable param = new Hashtable(); 454 Hashtable param = new Hashtable();
432 param["AgentID"] = AgentID.ToString(); 455 param["AgentID"] = AgentID.ToString();
433 param["GroupID"] = GroupID.ToString(); 456 param["GroupID"] = GroupID.ToString();
434 param["RoleID"] = RoleID.ToString(); 457 param["RoleID"] = RoleID.ToString();
435 458
436 XmlRpcCall(requestID, "groups.addAgentToGroup", param); 459 XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param);
437 } 460 }
438 461
439 public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) 462 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
440 { 463 {
441 Hashtable param = new Hashtable(); 464 Hashtable param = new Hashtable();
442 param["AgentID"] = AgentID.ToString(); 465 param["AgentID"] = AgentID.ToString();
443 param["GroupID"] = GroupID.ToString(); 466 param["GroupID"] = GroupID.ToString();
444 467
445 XmlRpcCall(requestID, "groups.removeAgentFromGroup", param); 468 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param);
446 } 469 }
447 470
448 public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 471 public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
449 { 472 {
450 Hashtable param = new Hashtable(); 473 Hashtable param = new Hashtable();
451 param["AgentID"] = AgentID.ToString(); 474 param["AgentID"] = AgentID.ToString();
452 param["GroupID"] = GroupID.ToString(); 475 param["GroupID"] = GroupID.ToString();
453 param["RoleID"] = RoleID.ToString(); 476 param["RoleID"] = RoleID.ToString();
454 477
455 XmlRpcCall(requestID, "groups.addAgentToGroupRole", param); 478 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param);
456 } 479 }
457 480
458 public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 481 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
459 { 482 {
460 Hashtable param = new Hashtable(); 483 Hashtable param = new Hashtable();
461 param["AgentID"] = AgentID.ToString(); 484 param["AgentID"] = AgentID.ToString();
462 param["GroupID"] = GroupID.ToString(); 485 param["GroupID"] = GroupID.ToString();
463 param["RoleID"] = RoleID.ToString(); 486 param["RoleID"] = RoleID.ToString();
464 487
465 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); 488 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param);
466 } 489 }
467 490
468 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search) 491 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
469 { 492 {
470 Hashtable param = new Hashtable(); 493 Hashtable param = new Hashtable();
471 param["Search"] = search; 494 param["Search"] = search;
472 495
473 Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param); 496 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);
474 497
475 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); 498 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
476 499
@@ -492,13 +515,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
492 return findings; 515 return findings;
493 } 516 }
494 517
495 public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID) 518 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
496 { 519 {
497 Hashtable param = new Hashtable(); 520 Hashtable param = new Hashtable();
498 param["AgentID"] = AgentID.ToString(); 521 param["AgentID"] = AgentID.ToString();
499 param["GroupID"] = GroupID.ToString(); 522 param["GroupID"] = GroupID.ToString();
500 523
501 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param); 524 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param);
502 525
503 if (respData.Contains("error")) 526 if (respData.Contains("error"))
504 { 527 {
@@ -510,12 +533,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
510 return data; 533 return data;
511 } 534 }
512 535
513 public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID) 536 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
514 { 537 {
515 Hashtable param = new Hashtable(); 538 Hashtable param = new Hashtable();
516 param["AgentID"] = AgentID.ToString(); 539 param["AgentID"] = AgentID.ToString();
517 540
518 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param); 541 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param);
519 542
520 if (respData.Contains("error")) 543 if (respData.Contains("error"))
521 { 544 {
@@ -525,12 +548,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
525 return HashTableToGroupMembershipData(respData); 548 return HashTableToGroupMembershipData(respData);
526 } 549 }
527 550
528 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID) 551 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
529 { 552 {
530 Hashtable param = new Hashtable(); 553 Hashtable param = new Hashtable();
531 param["AgentID"] = AgentID.ToString(); 554 param["AgentID"] = AgentID.ToString();
532 555
533 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param); 556 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param);
534 557
535 List<GroupMembershipData> memberships = new List<GroupMembershipData>(); 558 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
536 559
@@ -545,13 +568,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
545 return memberships; 568 return memberships;
546 } 569 }
547 570
548 public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID) 571 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
549 { 572 {
550 Hashtable param = new Hashtable(); 573 Hashtable param = new Hashtable();
551 param["AgentID"] = AgentID.ToString(); 574 param["AgentID"] = AgentID.ToString();
552 param["GroupID"] = GroupID.ToString(); 575 param["GroupID"] = GroupID.ToString();
553 576
554 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param); 577 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param);
555 578
556 List<GroupRolesData> Roles = new List<GroupRolesData>(); 579 List<GroupRolesData> Roles = new List<GroupRolesData>();
557 580
@@ -577,12 +600,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
577 600
578 } 601 }
579 602
580 public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID) 603 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
581 { 604 {
582 Hashtable param = new Hashtable(); 605 Hashtable param = new Hashtable();
583 param["GroupID"] = GroupID.ToString(); 606 param["GroupID"] = GroupID.ToString();
584 607
585 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param); 608 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param);
586 609
587 List<GroupRolesData> Roles = new List<GroupRolesData>(); 610 List<GroupRolesData> Roles = new List<GroupRolesData>();
588 611
@@ -610,12 +633,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
610 633
611 634
612 635
613 public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) 636 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
614 { 637 {
615 Hashtable param = new Hashtable(); 638 Hashtable param = new Hashtable();
616 param["GroupID"] = GroupID.ToString(); 639 param["GroupID"] = GroupID.ToString();
617 640
618 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param); 641 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param);
619 642
620 List<GroupMembersData> members = new List<GroupMembersData>(); 643 List<GroupMembersData> members = new List<GroupMembersData>();
621 644
@@ -643,12 +666,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
643 666
644 } 667 }
645 668
646 public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID) 669 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
647 { 670 {
648 Hashtable param = new Hashtable(); 671 Hashtable param = new Hashtable();
649 param["GroupID"] = GroupID.ToString(); 672 param["GroupID"] = GroupID.ToString();
650 673
651 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param); 674 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
652 675
653 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); 676 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
654 677
@@ -667,12 +690,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
667 return members; 690 return members;
668 } 691 }
669 692
670 public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID) 693 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
671 { 694 {
672 Hashtable param = new Hashtable(); 695 Hashtable param = new Hashtable();
673 param["GroupID"] = GroupID.ToString(); 696 param["GroupID"] = GroupID.ToString();
674 697
675 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param); 698 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
676 699
677 List<GroupNoticeData> values = new List<GroupNoticeData>(); 700 List<GroupNoticeData> values = new List<GroupNoticeData>();
678 701
@@ -694,12 +717,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
694 return values; 717 return values;
695 718
696 } 719 }
697 public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID) 720 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
698 { 721 {
699 Hashtable param = new Hashtable(); 722 Hashtable param = new Hashtable();
700 param["NoticeID"] = noticeID.ToString(); 723 param["NoticeID"] = noticeID.ToString();
701 724
702 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param); 725 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
703 726
704 727
705 if (respData.Contains("error")) 728 if (respData.Contains("error"))
@@ -725,7 +748,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
725 748
726 return data; 749 return data;
727 } 750 }
728 public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 751 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
729 { 752 {
730 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); 753 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
731 754
@@ -738,9 +761,72 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
738 param["BinaryBucket"] = binBucket; 761 param["BinaryBucket"] = binBucket;
739 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); 762 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
740 763
741 XmlRpcCall(requestID, "groups.addGroupNotice", param); 764 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
742 } 765 }
743 #endregion 766
767
768
769 #endregion
770
771 #region GroupSessionTracking
772
773 public void ResetAgentGroupChatSessions(UUID agentID)
774 {
775 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
776 {
777 agentList.Remove(agentID);
778 }
779 }
780
781 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
782 {
783 // If we're tracking this group, and we can find them in the tracking, then they've been invited
784 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
785 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
786 }
787
788 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
789 {
790 // If we're tracking drops for this group,
791 // and we find them, well... then they've dropped
792 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
793 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
794 }
795
796 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
797 {
798 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
799 {
800 // If not in dropped list, add
801 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
802 {
803 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
804 }
805 }
806 }
807
808 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
809 {
810 // Add Session Status if it doesn't exist for this session
811 CreateGroupChatSessionTracking(groupID);
812
813 // If nessesary, remove from dropped list
814 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
815 {
816 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
817 }
818 }
819
820 private void CreateGroupChatSessionTracking(UUID groupID)
821 {
822 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
823 {
824 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
825 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
826 }
827
828 }
829 #endregion
744 830
745 #region XmlRpcHashtableMarshalling 831 #region XmlRpcHashtableMarshalling
746 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) 832 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
@@ -831,15 +917,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
831 /// <summary> 917 /// <summary>
832 /// Encapsulate the XmlRpc call to standardize security and error handling. 918 /// Encapsulate the XmlRpc call to standardize security and error handling.
833 /// </summary> 919 /// </summary>
834 private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) 920 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
835 { 921 {
836 if (requestID == null) 922 string UserService;
837 { 923 UUID SessionID;
838 requestID = new GroupRequestID(); 924 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
839 } 925 param.Add("requestingAgentID", requestingAgentID.ToString());
840 param.Add("RequestingAgentID", requestID.AgentID.ToString()); 926 param.Add("RequestingAgentUserService", UserService);
841 param.Add("RequestingAgentUserService", requestID.UserServiceURL); 927 param.Add("RequestingSessionID", SessionID.ToString());
842 param.Add("RequestingSessionID", requestID.SessionID.ToString());
843 928
844 929
845 param.Add("ReadKey", m_groupReadKey); 930 param.Add("ReadKey", m_groupReadKey);
@@ -856,7 +941,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
856 941
857 try 942 try
858 { 943 {
859 resp = req.Send(m_serviceURL, 10000); 944 resp = req.Send(m_groupsServerURI, 10000);
860 } 945 }
861 catch (Exception e) 946 catch (Exception e)
862 { 947 {
@@ -930,15 +1015,49 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
930 } 1015 }
931 } 1016 }
932 1017
1018
1019 /// <summary>
1020 /// Group Request Tokens are an attempt to allow the groups service to authenticate
1021 /// requests.
1022 /// TODO: This broke after the big grid refactor, either find a better way, or discard this
1023 /// </summary>
1024 /// <param name="client"></param>
1025 /// <returns></returns>
1026 private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
1027 {
1028 UserServiceURL = "";
1029 SessionID = UUID.Zero;
1030
933 1031
934 } 1032 // Need to rework this based on changes to User Services
1033 /*
1034 UserAccount userAccount = m_accountService.GetUserAccount(UUID.Zero,AgentID);
1035 if (userAccount == null)
1036 {
1037 // This should be impossible. If I've been passed a reference to a client
1038 // that client should be registered with the UserService. So something
1039 // is horribly wrong somewhere.
935 1040
936 public class GroupNoticeInfo 1041 m_log.WarnFormat("[GROUPS]: Could not find a UserServiceURL for {0}", AgentID);
937 { 1042
938 public GroupNoticeData noticeData = new GroupNoticeData(); 1043 }
939 public UUID GroupID = UUID.Zero; 1044 else if (userProfile is ForeignUserProfileData)
940 public string Message = string.Empty; 1045 {
941 public byte[] BinaryBucket = new byte[0]; 1046 // They aren't from around here
1047 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1048 UserServiceURL = fupd.UserServerURI;
1049 SessionID = fupd.CurrentAgent.SessionID;
1050
1051 }
1052 else
1053 {
1054 // They're a local user, use this:
1055 UserServiceURL = m_commManager.NetworkServersInfo.UserURL;
1056 SessionID = userProfile.CurrentAgent.SessionID;
1057 }
1058 */
1059 }
1060
942 } 1061 }
943} 1062}
944 1063
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 4e8a3c4..880ca1b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -1,4 +1,31 @@
1using System; 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;
2using System.Reflection; 29using System.Reflection;
3using System.Collections; 30using System.Collections;
4using System.Collections.Generic; 31using System.Collections.Generic;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
index ef990a1..f13b6e5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -1,4 +1,31 @@
1using System.Collections; 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.Collections;
2using OpenSim.Region.ScriptEngine.Interfaces; 29using OpenSim.Region.ScriptEngine.Interfaces;
3 30
4using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; 31using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
@@ -15,7 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
15 { 42 {
16 // Windlight Functions 43 // Windlight Functions
17 LSL_List cmGetWindlightScene(LSL_List rules); 44 LSL_List cmGetWindlightScene(LSL_List rules);
18 int cmSetWindlightScene(LSL_List rules); 45 int cmSetWindlightScene(LSL_List rules);
19 int cmSetWindlightSceneTargeted(LSL_List rules, key target); 46 int cmSetWindlightSceneTargeted(LSL_List rules, key target);
20 } 47 }
21} 48}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
index 522c020..f94ef4a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
70 public const int WL_CLOUD_SCROLL_Y = 32; 70 public const int WL_CLOUD_SCROLL_Y = 32;
71 public const int WL_CLOUD_SCROLL_Y_LOCK = 33; 71 public const int WL_CLOUD_SCROLL_Y_LOCK = 33;
72 public const int WL_CLOUD_SCROLL_X_LOCK = 34; 72 public const int WL_CLOUD_SCROLL_X_LOCK = 34;
73 public const int WL_DRAW_CLASSIC_CLOUDS = 35; 73 public const int WL_DRAW_CLASSIC_CLOUDS = 35;
74 public const int WL_SUN_MOON_POSITION = 36; 74 public const int WL_SUN_MOON_POSITION = 36;
75 75
76 } 76 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
index 5bc3a88..c0edaae 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -66,11 +66,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
66 public int cmSetWindlightScene(LSL_List rules) 66 public int cmSetWindlightScene(LSL_List rules)
67 { 67 {
68 return m_CM_Functions.cmSetWindlightScene(rules); 68 return m_CM_Functions.cmSetWindlightScene(rules);
69 } 69 }
70 70
71 public int cmSetWindlightSceneTargeted(LSL_List rules, key target) 71 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
72 { 72 {
73 return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); 73 return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
74 } 74 }
75 } 75 }
76} 76}