aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Application/ConfigurationLoader.cs19
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs47
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs35
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs2
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsMessagingModule.cs73
-rw-r--r--OpenSim/Region/Framework/Interfaces/IGroupsModule.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs57
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs51
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs35
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs266
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs321
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs66
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs326
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs83
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs38
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs7
29 files changed, 918 insertions, 668 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs
index 21edcc5..da77a2b 100644
--- a/OpenSim/Region/Application/ConfigurationLoader.cs
+++ b/OpenSim/Region/Application/ConfigurationLoader.cs
@@ -164,12 +164,12 @@ namespace OpenSim
164 m_config.Source = new IniConfigSource(); 164 m_config.Source = new IniConfigSource();
165 m_config.Source.Merge(DefaultConfig()); 165 m_config.Source.Merge(DefaultConfig());
166 166
167 m_log.Info("[CONFIG] Reading configuration settings"); 167 m_log.Info("[CONFIG]: Reading configuration settings");
168 168
169 if (sources.Count == 0) 169 if (sources.Count == 0)
170 { 170 {
171 m_log.FatalFormat("[CONFIG] Could not load any configuration"); 171 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
172 m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.ini.example file to OpenSim.ini?"); 172 m_log.FatalFormat("[CONFIG]: Did you copy the OpenSim.ini.example file to OpenSim.ini?");
173 Environment.Exit(1); 173 Environment.Exit(1);
174 } 174 }
175 175
@@ -182,8 +182,8 @@ namespace OpenSim
182 182
183 if (!iniFileExists) 183 if (!iniFileExists)
184 { 184 {
185 m_log.FatalFormat("[CONFIG] Could not load any configuration"); 185 m_log.FatalFormat("[CONFIG]: Could not load any configuration");
186 m_log.FatalFormat("[CONFIG] Configuration exists, but there was an error loading it!"); 186 m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!");
187 Environment.Exit(1); 187 Environment.Exit(1);
188 } 188 }
189 189
@@ -257,20 +257,17 @@ namespace OpenSim
257 257
258 if (!IsUri(iniPath)) 258 if (!IsUri(iniPath))
259 { 259 {
260 m_log.InfoFormat("[CONFIG] Reading configuration file {0}", 260 m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath));
261 Path.GetFullPath(iniPath));
262 261
263 m_config.Source.Merge(new IniConfigSource(iniPath)); 262 m_config.Source.Merge(new IniConfigSource(iniPath));
264 success = true; 263 success = true;
265 } 264 }
266 else 265 else
267 { 266 {
268 m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...", 267 m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", iniPath);
269 iniPath);
270 268
271 // The ini file path is a http URI 269 // The ini file path is a http URI
272 // Try to read it 270 // Try to read it
273 //
274 try 271 try
275 { 272 {
276 XmlReader r = XmlReader.Create(iniPath); 273 XmlReader r = XmlReader.Create(iniPath);
@@ -281,7 +278,7 @@ namespace OpenSim
281 } 278 }
282 catch (Exception e) 279 catch (Exception e)
283 { 280 {
284 m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath); 281 m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), iniPath);
285 Environment.Exit(1); 282 Environment.Exit(1);
286 } 283 }
287 } 284 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 2ab713d..724c8bc 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -348,6 +348,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
348 protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates; 348 protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates;
349 private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates; 349 private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates;
350 private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates; 350 private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates;
351
352 /// <value>
353 /// List used in construction of data blocks for an object update packet. This is to stop us having to
354 /// continually recreate it.
355 /// </value>
356 protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
357
358 /// <value>
359 /// Maintain a record of all the objects killed. This allows us to stop an update being sent from the
360 /// thread servicing the m_primFullUpdates queue after a kill. If this happens the object persists as an
361 /// ownerless phantom.
362 ///
363 /// All manipulation of this set has to occur under a m_primFullUpdate.SyncRoot lock
364 ///
365 /// </value>
366 protected HashSet<uint> m_killRecord;
367
351 private int m_moneyBalance; 368 private int m_moneyBalance;
352 private int m_animationSequenceNumber = 1; 369 private int m_animationSequenceNumber = 1;
353 private bool m_SendLogoutPacketWhenClosing = true; 370 private bool m_SendLogoutPacketWhenClosing = true;
@@ -437,6 +454,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
437 m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); 454 m_avatarTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
438 m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); 455 m_primTerseUpdates = new PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
439 m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count); 456 m_primFullUpdates = new PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock>(m_scene.Entities.Count);
457 m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
458 m_killRecord = new HashSet<uint>();
440 459
441 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 460 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
442 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>(); 461 m_hyperAssets = m_scene.RequestModuleInterface<IHyperAssetService>();
@@ -1476,7 +1495,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1476 kill.ObjectData[0].ID = localID; 1495 kill.ObjectData[0].ID = localID;
1477 kill.Header.Reliable = true; 1496 kill.Header.Reliable = true;
1478 kill.Header.Zerocoded = true; 1497 kill.Header.Zerocoded = true;
1479 OutPacket(kill, ThrottleOutPacketType.State); 1498
1499 lock (m_primFullUpdates.SyncRoot)
1500 {
1501 m_killRecord.Add(localID);
1502 OutPacket(kill, ThrottleOutPacketType.State);
1503 }
1480 } 1504 }
1481 1505
1482 /// <summary> 1506 /// <summary>
@@ -3518,21 +3542,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3518 if (count == 0) 3542 if (count == 0)
3519 return; 3543 return;
3520 3544
3521 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[count]; 3545 m_fullUpdateDataBlocksBuilder.Clear();
3546
3522 for (int i = 0; i < count; i++) 3547 for (int i = 0; i < count; i++)
3523 { 3548 {
3524 outPacket.ObjectData[i] = m_primFullUpdates.Dequeue(); 3549 ObjectUpdatePacket.ObjectDataBlock block = m_primFullUpdates.Dequeue();
3525 3550
3551 if (!m_killRecord.Contains(block.ID))
3552 {
3553 m_fullUpdateDataBlocksBuilder.Add(block);
3554
3526// string text = Util.FieldToString(outPacket.ObjectData[i].Text); 3555// string text = Util.FieldToString(outPacket.ObjectData[i].Text);
3527// if (text.IndexOf("\n") >= 0) 3556// if (text.IndexOf("\n") >= 0)
3528// text = text.Remove(text.IndexOf("\n")); 3557// text = text.Remove(text.IndexOf("\n"));
3529// m_log.DebugFormat( 3558// m_log.DebugFormat(
3530// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}", 3559// "[CLIENT]: Sending full info about prim {0} text {1} to client {2}",
3531// outPacket.ObjectData[i].ID, text, Name); 3560// outPacket.ObjectData[i].ID, text, Name);
3561 }
3562// else
3563// {
3564// m_log.WarnFormat(
3565// "[CLIENT]: Preventing full update for {0} after kill to {1}", block.ID, Name);
3566// }
3532 } 3567 }
3533 }
3534 3568
3535 OutPacket(outPacket, ThrottleOutPacketType.State); 3569 outPacket.ObjectData = m_fullUpdateDataBlocksBuilder.ToArray();
3570
3571 OutPacket(outPacket, ThrottleOutPacketType.State);
3572 }
3536 } 3573 }
3537 3574
3538 public void SendPrimTerseUpdate(SendPrimitiveTerseData data) 3575 public void SendPrimTerseUpdate(SendPrimitiveTerseData data)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 3c4fa72..5ed4cd7 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/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index c7aeca14..e57e298 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -105,10 +105,10 @@ namespace OpenSim.Region.ClientStack
105 105
106 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort)) 106 if (m_networkServersInfo.HttpUsesSSL && (m_networkServersInfo.HttpListenerPort == m_networkServersInfo.httpSSLPort))
107 { 107 {
108 m_log.Error("[HTTP]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports"); 108 m_log.Error("[REGION SERVER]: HTTP Server config failed. HTTP Server and HTTPS server must be on different ports");
109 } 109 }
110 110
111 m_log.Info("[REGION]: Starting HTTP server"); 111 m_log.InfoFormat("[REGION SERVER]: Starting HTTP server on port {0}", m_httpServerPort);
112 m_httpServer.Start(); 112 m_httpServer.Start();
113 113
114 base.StartupSpecific(); 114 base.StartupSpecific();
@@ -134,4 +134,4 @@ namespace OpenSim.Region.ClientStack
134 return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier); 134 return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier);
135 } 135 }
136 } 136 }
137} 137} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index 72ec869..6a9a962 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
79 { 79 {
80 ScenePresence sp = m_scene.GetScenePresence(agentID); 80 ScenePresence sp = m_scene.GetScenePresence(agentID);
81 81
82 if (sp != null) 82 if (sp != null && !sp.IsChildAgent)
83 sp.ControllingClient.SendAgentAlertMessage(message, modal); 83 sp.ControllingClient.SendAgentAlertMessage(message, modal);
84 } 84 }
85 85
@@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
91 { 91 {
92 ScenePresence presence = presenceList[i]; 92 ScenePresence presence = presenceList[i];
93 93
94 if (presence.Firstname == firstName && presence.Lastname == lastName) 94 if (!presence.IsChildAgent && presence.Firstname == firstName && presence.Lastname == lastName)
95 { 95 {
96 presence.ControllingClient.SendAgentAlertMessage(message, modal); 96 presence.ControllingClient.SendAgentAlertMessage(message, modal);
97 break; 97 break;
@@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
130 } 130 }
131 131
132 ScenePresence sp = m_scene.GetScenePresence(avatarID); 132 ScenePresence sp = m_scene.GetScenePresence(avatarID);
133 if (sp != null) 133 if (sp != null && !sp.IsChildAgent)
134 sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); 134 sp.ControllingClient.SendDialog(objectName, objectID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels);
135 } 135 }
136 136
@@ -139,7 +139,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
139 { 139 {
140 ScenePresence sp = m_scene.GetScenePresence(avatarID); 140 ScenePresence sp = m_scene.GetScenePresence(avatarID);
141 141
142 if (sp != null) 142 if (sp != null && !sp.IsChildAgent)
143 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); 143 sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url);
144 } 144 }
145 145
@@ -206,4 +206,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
206 return result; 206 return result;
207 } 207 }
208 } 208 }
209} 209} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
index 27b64bf..40ffcb4 100644
--- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -131,8 +131,8 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
131 { 131 {
132 // Start http server 132 // Start http server
133 // Attach xmlrpc handlers 133 // Attach xmlrpc handlers
134 m_log.Info("[REMOTE_DATA]: " + 134 m_log.Info("[XML RPC MODULE]: " +
135 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); 135 "Starting up XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
136 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort); 136 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
137 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 137 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
138 httpServer.Start(); 138 httpServer.Start();
@@ -192,7 +192,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
192 // This should no longer happen, but the check is reasonable anyway 192 // This should no longer happen, but the check is reasonable anyway
193 if (null == m_openChannels) 193 if (null == m_openChannels)
194 { 194 {
195 m_log.Warn("[RemoteDataReply] Attempt to open channel before initialization is complete"); 195 m_log.Warn("[XML RPC MODULE]: Attempt to open channel before initialization is complete");
196 return newChannel; 196 return newChannel;
197 } 197 }
198 198
@@ -279,7 +279,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
279 } 279 }
280 else 280 else
281 { 281 {
282 m_log.Warn("[RemoteDataReply]: Channel or message_id not found"); 282 m_log.Warn("[XML RPC MODULE]: Channel or message_id not found");
283 } 283 }
284 } 284 }
285 285
@@ -340,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
340 } 340 }
341 else 341 else
342 { 342 {
343 m_log.Error("UNABLE TO REMOVE COMPLETED REQUEST"); 343 m_log.Error("[XML RPC MODULE]: UNABLE TO REMOVE COMPLETED REQUEST");
344 } 344 }
345 } 345 }
346 } 346 }
@@ -728,4 +728,4 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC
728 return ReqID; 728 return ReqID;
729 } 729 }
730 } 730 }
731} 731} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
index d68c683..4abc215 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Interregion/LocalInterregionComms.cs
@@ -260,7 +260,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
260 { 260 {
261 if (s.RegionInfo.RegionHandle == regionHandle) 261 if (s.RegionInfo.RegionHandle == regionHandle)
262 { 262 {
263 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject"); 263 m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
264 if (isLocalCall) 264 if (isLocalCall)
265 { 265 {
266 // We need to make a local copy of the object 266 // We need to make a local copy of the object
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index 191e859..cabd51c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -314,10 +314,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
314 { 314 {
315// m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); 315// m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID);
316 316
317 UUID requestedItemId = item.ID;
318
317 item = m_InventoryService.GetItem(item); 319 item = m_InventoryService.GetItem(item);
318 320
319 if (null == item) 321 if (null == item)
320 m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID); 322 m_log.ErrorFormat(
323 "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", requestedItemId);
321 324
322 return item; 325 return item;
323 } 326 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 381c8f7..2e30e09 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -276,7 +276,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
276 } 276 }
277 } 277 }
278 278
279 if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) 279 if (!m_scene.AddRestoredSceneObject(sceneObject, true, false))
280 { 280 {
281 sceneObjectsLoadedCount++; 281 sceneObjectsLoadedCount++;
282 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); 282 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
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/Framework/Interfaces/IGroupsModule.cs b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
index 8980b2d..9683da0 100644
--- a/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IGroupsModule.cs
@@ -37,6 +37,37 @@ namespace OpenSim.Region.Framework.Interfaces
37 { 37 {
38 event NewGroupNotice OnNewGroupNotice; 38 event NewGroupNotice OnNewGroupNotice;
39 39
40 /// <summary>
41 /// Create a group
42 /// </summary>
43 /// <param name="remoteClient"></param>
44 /// <param name="name"></param>
45 /// <param name="charter"></param>
46 /// <param name="showInList"></param>
47 /// <param name="insigniaID"></param>
48 /// <param name="membershipFee"></param>
49 /// <param name="openEnrollment"></param>
50 /// <param name="allowPublish"></param>
51 /// <param name="maturePublish"></param>
52 /// <returns>The UUID of the created group</returns>
53 UUID CreateGroup(
54 IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee,
55 bool openEnrollment, bool allowPublish, bool maturePublish);
56
57 /// <summary>
58 /// Get a group
59 /// </summary>
60 /// <param name="name">Name of the group</param>
61 /// <returns>The group's data. Null if there is no such group.</returns>
62 GroupRecord GetGroupRecord(string name);
63
64 /// <summary>
65 /// Get a group
66 /// </summary>
67 /// <param name="GroupID">ID of the group</param>
68 /// <returns>The group's data. Null if there is no such group.</returns>
69 GroupRecord GetGroupRecord(UUID GroupID);
70
40 void ActivateGroup(IClientAPI remoteClient, UUID groupID); 71 void ActivateGroup(IClientAPI remoteClient, UUID groupID);
41 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID); 72 List<GroupTitlesData> GroupTitlesRequest(IClientAPI remoteClient, UUID groupID);
42 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID); 73 List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID);
@@ -51,7 +82,6 @@ namespace OpenSim.Region.Framework.Interfaces
51 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile); 82 void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile);
52 83
53 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID); 84 void GroupTitleUpdate(IClientAPI remoteClient, UUID GroupID, UUID TitleRoleID);
54 UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish);
55 85
56 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID); 86 GroupNoticeData[] GroupNoticesListRequest(IClientAPI remoteClient, UUID GroupID);
57 string GetGroupTitle(UUID avatarID); 87 string GetGroupTitle(UUID avatarID);
@@ -64,7 +94,6 @@ namespace OpenSim.Region.Framework.Interfaces
64 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID); 94 void LeaveGroupRequest(IClientAPI remoteClient, UUID GroupID);
65 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID); 95 void EjectGroupMemberRequest(IClientAPI remoteClient, UUID GroupID, UUID EjecteeID);
66 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID); 96 void InviteGroupRequest(IClientAPI remoteClient, UUID GroupID, UUID InviteeID, UUID RoleID);
67 GroupRecord GetGroupRecord(UUID GroupID);
68 void NotifyChange(UUID GroupID); 97 void NotifyChange(UUID GroupID);
69 } 98 }
70} 99}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 57e1c37..4365ece 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -107,21 +107,24 @@ namespace OpenSim.Region.Framework.Scenes
107 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; 107 public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
108 108
109 /// <summary> 109 /// <summary>
110 /// Called when an object is touched/grabbed. 110 /// Fired when an object is touched/grabbed.
111 /// </summary> 111 /// </summary>
112 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of 112 /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
113 /// the root part. 113 /// the root part.
114 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
115 public event ObjectGrabDelegate OnObjectGrab; 114 public event ObjectGrabDelegate OnObjectGrab;
115 public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
116 116
117 public event ObjectGrabDelegate OnObjectGrabbing; 117 public event ObjectGrabDelegate OnObjectGrabbing;
118 public event ObjectDeGrabDelegate OnObjectDeGrab; 118 public event ObjectDeGrabDelegate OnObjectDeGrab;
119 public event ScriptResetDelegate OnScriptReset; 119 public event ScriptResetDelegate OnScriptReset;
120 120
121 public event OnPermissionErrorDelegate OnPermissionError; 121 public event OnPermissionErrorDelegate OnPermissionError;
122 122
123 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); 123 /// <summary>
124 /// Fired when a new script is created.
125 /// </summary>
124 public event NewRezScript OnRezScript; 126 public event NewRezScript OnRezScript;
127 public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
125 128
126 public delegate void RemoveScript(uint localID, UUID itemID); 129 public delegate void RemoveScript(uint localID, UUID itemID);
127 public event RemoveScript OnRemoveScript; 130 public event RemoveScript OnRemoveScript;
@@ -163,38 +166,35 @@ namespace OpenSim.Region.Framework.Scenes
163 166
164 public delegate void ClientClosed(UUID clientID, Scene scene); 167 public delegate void ClientClosed(UUID clientID, Scene scene);
165 168
166 public event ClientClosed OnClientClosed; 169 public event ClientClosed OnClientClosed;
167
168 public delegate void ScriptChangedEvent(uint localID, uint change);
169 170
171 /// <summary>
172 /// This is fired when a scene object property that a script might be interested in (such as color, scale or
173 /// inventory) changes. Only enough information is sent for the LSL changed event
174 /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed)
175 /// </summary>
170 public event ScriptChangedEvent OnScriptChangedEvent; 176 public event ScriptChangedEvent OnScriptChangedEvent;
177 public delegate void ScriptChangedEvent(uint localID, uint change);
171 178
172 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); 179 public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed);
173
174 public event ScriptControlEvent OnScriptControlEvent; 180 public event ScriptControlEvent OnScriptControlEvent;
175 181
176 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); 182 public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
177
178 public event ScriptAtTargetEvent OnScriptAtTargetEvent; 183 public event ScriptAtTargetEvent OnScriptAtTargetEvent;
179 184
180 public delegate void ScriptNotAtTargetEvent(uint localID); 185 public delegate void ScriptNotAtTargetEvent(uint localID);
181
182 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 186 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
183 187
184 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); 188 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
185
186 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; 189 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
187 190
188 public delegate void ScriptNotAtRotTargetEvent(uint localID); 191 public delegate void ScriptNotAtRotTargetEvent(uint localID);
189
190 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; 192 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
191 193
192 public delegate void ScriptColliding(uint localID, ColliderArgs colliders); 194 public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
193
194 public event ScriptColliding OnScriptColliderStart; 195 public event ScriptColliding OnScriptColliderStart;
195 public event ScriptColliding OnScriptColliding; 196 public event ScriptColliding OnScriptColliding;
196 public event ScriptColliding OnScriptCollidingEnd; 197 public event ScriptColliding OnScriptCollidingEnd;
197
198 public event ScriptColliding OnScriptLandColliderStart; 198 public event ScriptColliding OnScriptLandColliderStart;
199 public event ScriptColliding OnScriptLandColliding; 199 public event ScriptColliding OnScriptLandColliding;
200 public event ScriptColliding OnScriptLandColliderEnd; 200 public event ScriptColliding OnScriptLandColliderEnd;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 4f2b446..f556b35 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -438,29 +438,31 @@ namespace OpenSim.Region.Framework.Scenes
438 itemCopy.InvType = item.InvType; 438 itemCopy.InvType = item.InvType;
439 itemCopy.Folder = recipientFolderId; 439 itemCopy.Folder = recipientFolderId;
440 440
441 if (Permissions.PropagatePermissions()) 441 if (Permissions.PropagatePermissions() && recipient != senderId)
442 { 442 {
443 // First, make sore base is limited to the next perms
444 itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions;
445 // By default, current equals base
446 itemCopy.CurrentPermissions = itemCopy.BasePermissions;
447
448 // If this is an object, replace current perms
449 // with folded perms
443 if (item.InvType == (int)InventoryType.Object) 450 if (item.InvType == (int)InventoryType.Object)
444 { 451 {
445 itemCopy.BasePermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); 452 itemCopy.CurrentPermissions &= ~(uint)(PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
446 itemCopy.BasePermissions |= (item.CurrentPermissions & 7) << 13; 453 itemCopy.CurrentPermissions |= (item.CurrentPermissions & 7) << 13;
447 }
448 else
449 {
450 itemCopy.BasePermissions = item.BasePermissions & item.NextPermissions;
451 } 454 }
452 455
453 itemCopy.CurrentPermissions = itemCopy.BasePermissions; 456 // Ensure there is no escalation
454 if ((item.CurrentPermissions & 8) != 0) // Propagate slam bit 457 itemCopy.CurrentPermissions &= item.NextPermissions;
455 { 458
456 itemCopy.BasePermissions &= item.NextPermissions; 459 // Need slam bit on xfer
457 itemCopy.CurrentPermissions = itemCopy.BasePermissions; 460 itemCopy.CurrentPermissions |= 8;
458 itemCopy.CurrentPermissions |= 8;
459 }
460 461
461 itemCopy.NextPermissions = item.NextPermissions; 462 itemCopy.NextPermissions = item.NextPermissions;
462 itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; 463
463 itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; 464 itemCopy.EveryOnePermissions = 0;
465 itemCopy.GroupPermissions = 0;
464 } 466 }
465 else 467 else
466 { 468 {
@@ -531,7 +533,6 @@ namespace OpenSim.Region.Framework.Scenes
531 return null; 533 return null;
532 } 534 }
533 535
534
535 if (recipientParentFolderId == UUID.Zero) 536 if (recipientParentFolderId == UUID.Zero)
536 { 537 {
537 InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); 538 InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId);
@@ -910,12 +911,12 @@ namespace OpenSim.Region.Framework.Scenes
910 911
911 if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions()) 912 if ((part.OwnerID != destAgent) && Permissions.PropagatePermissions())
912 { 913 {
914 agentItem.BasePermissions = taskItem.BasePermissions & taskItem.NextPermissions;
913 if (taskItem.InvType == (int)InventoryType.Object) 915 if (taskItem.InvType == (int)InventoryType.Object)
914 agentItem.BasePermissions = taskItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13); 916 agentItem.CurrentPermissions = agentItem.BasePermissions & ((taskItem.CurrentPermissions & 7) << 13);
915 else 917 agentItem.CurrentPermissions = agentItem.BasePermissions ;
916 agentItem.BasePermissions = taskItem.BasePermissions; 918
917 agentItem.BasePermissions &= taskItem.NextPermissions; 919 agentItem.CurrentPermissions |= 8;
918 agentItem.CurrentPermissions = agentItem.BasePermissions | 8;
919 agentItem.NextPermissions = taskItem.NextPermissions; 920 agentItem.NextPermissions = taskItem.NextPermissions;
920 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions; 921 agentItem.EveryOnePermissions = taskItem.EveryonePermissions & taskItem.NextPermissions;
921 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; 922 agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions;
@@ -2075,7 +2076,10 @@ namespace OpenSim.Region.Framework.Scenes
2075 group.RootPart.IsAttachment = true; 2076 group.RootPart.IsAttachment = true;
2076 } 2077 }
2077 2078
2078 AddNewSceneObject(group, true); 2079 // If we're rezzing an attachment then don't ask AddNewSceneObject() to update the client since
2080 // we'll be doing that later on. Scheduling more than one full update during the attachment
2081 // process causes some clients to fail to display the attachment properly.
2082 AddNewSceneObject(group, true, !attachment);
2079 2083
2080 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 2084 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2081 // if attachment we set it's asset id so object updates can reflect that 2085 // if attachment we set it's asset id so object updates can reflect that
@@ -2445,6 +2449,8 @@ namespace OpenSim.Region.Framework.Scenes
2445 return; 2449 return;
2446 } 2450 }
2447 2451
2452 m_log.DebugFormat("[SCENE INVENTORY]: {0} {1} IsAttachment={2}", att.Name, att.LocalId, att.IsAttachment);
2453 Console.WriteLine("HERE X");
2448 ScenePresence presence; 2454 ScenePresence presence;
2449 if (TryGetAvatar(remoteClient.AgentId, out presence)) 2455 if (TryGetAvatar(remoteClient.AgentId, out presence))
2450 { 2456 {
@@ -2452,9 +2458,12 @@ namespace OpenSim.Region.Framework.Scenes
2452 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 2458 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2453 item = InventoryService.GetItem(item); 2459 item = InventoryService.GetItem(item);
2454 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 2460 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
2461 Console.WriteLine("HERE Y");
2455 2462
2456 if (m_AvatarFactory != null) 2463 if (m_AvatarFactory != null)
2457 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 2464 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
2465
2466 Console.WriteLine("HERE Z");
2458 } 2467 }
2459 } 2468 }
2460 2469
@@ -2637,4 +2646,4 @@ namespace OpenSim.Region.Framework.Scenes
2637 m_sceneGraph.LinkObjects(root, children); 2646 m_sceneGraph.LinkObjects(root, children);
2638 } 2647 }
2639 } 2648 }
2640} 2649} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index ac04dc7..d8e604f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes
124 { 124 {
125 if (((SceneObjectGroup)ent).LocalId == primLocalID) 125 if (((SceneObjectGroup)ent).LocalId == primLocalID)
126 { 126 {
127 m_log.DebugFormat("[SCENE]: Received full update request for {0} from {1}", primLocalID, remoteClient.Name);
127 ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient); 128 ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient);
128 return; 129 return;
129 } 130 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 637ebff..f8ca047 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1850,9 +1850,31 @@ namespace OpenSim.Region.Framework.Scenes
1850 /// true if the object was added, false if an object with the same uuid was already in the scene 1850 /// true if the object was added, false if an object with the same uuid was already in the scene
1851 /// </returns> 1851 /// </returns>
1852 public bool AddRestoredSceneObject( 1852 public bool AddRestoredSceneObject(
1853 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1854 {
1855 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1856 }
1857
1858 /// <summary>
1859 /// Add an object into the scene that has come from storage
1860 /// </summary>
1861 ///
1862 /// <param name="sceneObject"></param>
1863 /// <param name="attachToBackup">
1864 /// If true, changes to the object will be reflected in its persisted data
1865 /// If false, the persisted data will not be changed even if the object in the scene is changed
1866 /// </param>
1867 /// <param name="alreadyPersisted">
1868 /// If true, we won't persist this object until it changes
1869 /// If false, we'll persist this object immediately
1870 /// </param>
1871 /// <returns>
1872 /// true if the object was added, false if an object with the same uuid was already in the scene
1873 /// </returns>
1874 public bool AddRestoredSceneObject(
1853 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) 1875 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
1854 { 1876 {
1855 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted); 1877 return AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, true);
1856 } 1878 }
1857 1879
1858 /// <summary> 1880 /// <summary>
@@ -1886,7 +1908,7 @@ namespace OpenSim.Region.Framework.Scenes
1886 } 1908 }
1887 1909
1888 /// <summary> 1910 /// <summary>
1889 /// Delete every object from the scene 1911 /// Delete every object from the scene. This does not include attachments worn by avatars.
1890 /// </summary> 1912 /// </summary>
1891 public void DeleteAllSceneObjects() 1913 public void DeleteAllSceneObjects()
1892 { 1914 {
@@ -1897,7 +1919,11 @@ namespace OpenSim.Region.Framework.Scenes
1897 foreach (EntityBase e in entities) 1919 foreach (EntityBase e in entities)
1898 { 1920 {
1899 if (e is SceneObjectGroup) 1921 if (e is SceneObjectGroup)
1900 DeleteSceneObject((SceneObjectGroup)e, false); 1922 {
1923 SceneObjectGroup sog = (SceneObjectGroup)e;
1924 if (!sog.IsAttachment)
1925 DeleteSceneObject((SceneObjectGroup)e, false);
1926 }
1901 } 1927 }
1902 } 1928 }
1903 } 1929 }
@@ -2461,7 +2487,7 @@ namespace OpenSim.Region.Framework.Scenes
2461 /// <returns></returns> 2487 /// <returns></returns>
2462 public bool IncomingCreateObject(ISceneObject sog) 2488 public bool IncomingCreateObject(ISceneObject sog)
2463 { 2489 {
2464 //m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); 2490 m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
2465 SceneObjectGroup newObject; 2491 SceneObjectGroup newObject;
2466 try 2492 try
2467 { 2493 {
@@ -2533,10 +2559,12 @@ namespace OpenSim.Region.Framework.Scenes
2533 2559
2534 if (sceneObject.IsAttachmentCheckFull()) // Attachment 2560 if (sceneObject.IsAttachmentCheckFull()) // Attachment
2535 { 2561 {
2562 m_log.DebugFormat("[SCENE]: Adding attachment {0} {1}", sceneObject.Name, sceneObject.LocalId);
2563
2536 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); 2564 sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
2537 sceneObject.RootPart.AddFlag(PrimFlags.Phantom); 2565 sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
2538 2566
2539 AddRestoredSceneObject(sceneObject, false, false); 2567 AddRestoredSceneObject(sceneObject, false, false, false);
2540 2568
2541 // Handle attachment special case 2569 // Handle attachment special case
2542 SceneObjectPart RootPrim = sceneObject.RootPart; 2570 SceneObjectPart RootPrim = sceneObject.RootPart;
@@ -2544,6 +2572,8 @@ namespace OpenSim.Region.Framework.Scenes
2544 // Fix up attachment Parent Local ID 2572 // Fix up attachment Parent Local ID
2545 ScenePresence sp = GetScenePresence(sceneObject.OwnerID); 2573 ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
2546 2574
2575 Console.WriteLine("AAAA");
2576
2547 //uint parentLocalID = 0; 2577 //uint parentLocalID = 0;
2548 if (sp != null) 2578 if (sp != null)
2549 { 2579 {
@@ -2562,20 +2592,25 @@ namespace OpenSim.Region.Framework.Scenes
2562 //grp.SetFromAssetID(grp.RootPart.LastOwnerID); 2592 //grp.SetFromAssetID(grp.RootPart.LastOwnerID);
2563 m_log.DebugFormat( 2593 m_log.DebugFormat(
2564 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); 2594 "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition);
2565 2595
2596 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2566 AttachObject( 2597 AttachObject(
2567 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); 2598 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2568 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2599
2569 grp.SendGroupFullUpdate(); 2600 //grp.SendGroupFullUpdate();
2570 } 2601 }
2571 else 2602 else
2572 { 2603 {
2573 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2604 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2574 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2605 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2575 } 2606 }
2607
2608 Console.WriteLine("BBBB");
2576 } 2609 }
2577 else 2610 else
2578 { 2611 {
2612 m_log.DebugFormat("[SCENE]: Adding ordinary object {0} {1}", sceneObject.Name, sceneObject.LocalId);
2613
2579 AddRestoredSceneObject(sceneObject, true, false); 2614 AddRestoredSceneObject(sceneObject, true, false);
2580 2615
2581 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2616 if (!Permissions.CanObjectEntry(sceneObject.UUID,
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 2f6a0db..50feb17 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -1383,7 +1383,9 @@ namespace OpenSim.Region.Framework.Scenes
1383 // now we have a child agent in this region. Request all interesting data about other (root) agents 1383 // now we have a child agent in this region. Request all interesting data about other (root) agents
1384 agent.SendInitialFullUpdateToAllClients(); 1384 agent.SendInitialFullUpdateToAllClients();
1385 1385
1386 Console.WriteLine("SCS 1");
1386 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true); 1387 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1388 Console.WriteLine("SCS 2");
1387 1389
1388 // m_scene.SendKillObject(m_localId); 1390 // m_scene.SendKillObject(m_localId);
1389 1391
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index ad24160..fa3c5eb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -216,11 +216,15 @@ namespace OpenSim.Region.Framework.Scenes
216 /// If true, we won't persist this object until it changes 216 /// If true, we won't persist this object until it changes
217 /// If false, we'll persist this object immediately 217 /// If false, we'll persist this object immediately
218 /// </param> 218 /// </param>
219 /// <param name="sendClientUpdate">
220 /// If true, we send updates to the client to tell it about this object
221 /// If false, we leave it up to the caller to do this
222 /// </param>
219 /// <returns> 223 /// <returns>
220 /// true if the object was added, false if an object with the same uuid was already in the scene 224 /// true if the object was added, false if an object with the same uuid was already in the scene
221 /// </returns> 225 /// </returns>
222 protected internal bool AddRestoredSceneObject( 226 protected internal bool AddRestoredSceneObject(
223 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) 227 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
224 { 228 {
225 if (!alreadyPersisted) 229 if (!alreadyPersisted)
226 { 230 {
@@ -228,8 +232,29 @@ namespace OpenSim.Region.Framework.Scenes
228 sceneObject.HasGroupChanged = true; 232 sceneObject.HasGroupChanged = true;
229 } 233 }
230 234
231 return AddSceneObject(sceneObject, attachToBackup, true); 235 return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
232 } 236 }
237
238// /// <summary>
239// /// Add an object into the scene that has come from storage
240// /// </summary>
241// /// <param name="sceneObject"></param>
242// /// <param name="attachToBackup">
243// /// If true, changes to the object will be reflected in its persisted data
244// /// If false, the persisted data will not be changed even if the object in the scene is changed
245// /// </param>
246// /// <param name="alreadyPersisted">
247// /// If true, we won't persist this object until it changes
248// /// If false, we'll persist this object immediately
249// /// </param>
250// /// <returns>
251// /// true if the object was added, false if an object with the same uuid was already in the scene
252// /// </returns>
253// protected internal bool AddRestoredSceneObject(
254// SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
255// {
256// AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, true);
257// }
233 258
234 /// <summary> 259 /// <summary>
235 /// Add a newly created object to the scene. This will both update the scene, and send information about the 260 /// Add a newly created object to the scene. This will both update the scene, and send information about the
@@ -536,7 +561,6 @@ namespace OpenSim.Region.Framework.Scenes
536// m_log.DebugFormat( 561// m_log.DebugFormat(
537// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}", 562// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}",
538// objatt.Name, remoteClient.Name, AttachmentPt); 563// objatt.Name, remoteClient.Name, AttachmentPt);
539
540 if (objatt != null) 564 if (objatt != null)
541 { 565 {
542 bool tainted = false; 566 bool tainted = false;
@@ -612,11 +636,13 @@ namespace OpenSim.Region.Framework.Scenes
612 protected internal bool AttachObject( 636 protected internal bool AttachObject(
613 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) 637 IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent)
614 { 638 {
639 Console.WriteLine("HERE A");
615 SceneObjectGroup group = GetGroupByPrim(objectLocalID); 640 SceneObjectGroup group = GetGroupByPrim(objectLocalID);
616 if (group != null) 641 if (group != null)
617 { 642 {
618 if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) 643 if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
619 { 644 {
645 Console.WriteLine("HERE -1");
620 // If the attachment point isn't the same as the one previously used 646 // If the attachment point isn't the same as the one previously used
621 // set it's offset position = 0 so that it appears on the attachment point 647 // set it's offset position = 0 so that it appears on the attachment point
622 // and not in a weird location somewhere unknown. 648 // and not in a weird location somewhere unknown.
@@ -655,9 +681,12 @@ namespace OpenSim.Region.Framework.Scenes
655 itemId = group.GetFromItemID(); 681 itemId = group.GetFromItemID();
656 } 682 }
657 683
684 Console.WriteLine("HERE 0");
658 m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group); 685 m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group);
659 686
687 Console.WriteLine("HERE 1");
660 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); 688 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
689 Console.WriteLine("HERE 2");
661 // In case it is later dropped again, don't let 690 // In case it is later dropped again, don't let
662 // it get cleaned up 691 // it get cleaned up
663 // 692 //
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index c14b39a..ba3fde7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1494,6 +1494,10 @@ namespace OpenSim.Region.Framework.Scenes
1494 1494
1495 public void SendFullUpdateToClient(IClientAPI remoteClient) 1495 public void SendFullUpdateToClient(IClientAPI remoteClient)
1496 { 1496 {
1497 if (IsAttachment)
1498 m_log.DebugFormat(
1499 "[SOG]: Sending full update to client {0} for {1} {2}", remoteClient.Name, Name, LocalId);
1500
1497 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); 1501 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID));
1498 1502
1499 lock (m_parts) 1503 lock (m_parts)
@@ -1513,8 +1517,9 @@ namespace OpenSim.Region.Framework.Scenes
1513 /// <param name="part"></param> 1517 /// <param name="part"></param>
1514 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) 1518 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1515 { 1519 {
1516// m_log.DebugFormat( 1520 if (IsAttachment)
1517// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); 1521 m_log.DebugFormat(
1522 "[SOG]: Sending part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
1518 1523
1519 if (m_rootPart.UUID == part.UUID) 1524 if (m_rootPart.UUID == part.UUID)
1520 { 1525 {
@@ -1994,7 +1999,8 @@ namespace OpenSim.Region.Framework.Scenes
1994 1999
1995 public void ScheduleFullUpdateToAvatar(ScenePresence presence) 2000 public void ScheduleFullUpdateToAvatar(ScenePresence presence)
1996 { 2001 {
1997// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); 2002 if (IsAttachment)
2003 m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
1998 2004
1999 RootPart.AddFullUpdateToAvatar(presence); 2005 RootPart.AddFullUpdateToAvatar(presence);
2000 2006
@@ -2026,7 +2032,8 @@ namespace OpenSim.Region.Framework.Scenes
2026 /// </summary> 2032 /// </summary>
2027 public void ScheduleGroupForFullUpdate() 2033 public void ScheduleGroupForFullUpdate()
2028 { 2034 {
2029// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); 2035 if (IsAttachment)
2036 m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID);
2030 2037
2031 checkAtTargets(); 2038 checkAtTargets();
2032 RootPart.ScheduleFullUpdate(); 2039 RootPart.ScheduleFullUpdate();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a85a4b3..ffbb427 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1259,16 +1259,17 @@ namespace OpenSim.Region.Framework.Scenes
1259 /// Tell all scene presences that they should send updates for this part to their clients 1259 /// Tell all scene presences that they should send updates for this part to their clients
1260 /// </summary> 1260 /// </summary>
1261 public void AddFullUpdateToAllAvatars() 1261 public void AddFullUpdateToAllAvatars()
1262 { 1262 {
1263 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1263 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1264 for (int i = 0; i < avatars.Length; i++) 1264 for (int i = 0; i < avatars.Length; i++)
1265 { 1265 AddFullUpdateToAvatar(avatars[i]);
1266 avatars[i].SceneViewer.QueuePartForUpdate(this);
1267 }
1268 } 1266 }
1269 1267
1270 public void AddFullUpdateToAvatar(ScenePresence presence) 1268 public void AddFullUpdateToAvatar(ScenePresence presence)
1271 { 1269 {
1270 if (IsAttachment)
1271 m_log.DebugFormat("AddFullUpdateToAllAvatar() {0} for {1} {2}", presence.Name, Name, LocalId);
1272
1272 presence.SceneViewer.QueuePartForUpdate(this); 1273 presence.SceneViewer.QueuePartForUpdate(this);
1273 } 1274 }
1274 1275
@@ -1287,13 +1288,14 @@ namespace OpenSim.Region.Framework.Scenes
1287 { 1288 {
1288 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 1289 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1289 for (int i = 0; i < avatars.Length; i++) 1290 for (int i = 0; i < avatars.Length; i++)
1290 { 1291 AddTerseUpdateToAvatar(avatars[i]);
1291 avatars[i].SceneViewer.QueuePartForUpdate(this);
1292 }
1293 } 1292 }
1294 1293
1295 public void AddTerseUpdateToAvatar(ScenePresence presence) 1294 public void AddTerseUpdateToAvatar(ScenePresence presence)
1296 { 1295 {
1296 if (IsAttachment)
1297 m_log.DebugFormat("AddTerseUpdateToAvatar() {0} for {1} {2}", presence.Name, Name, LocalId);
1298
1297 presence.SceneViewer.QueuePartForUpdate(this); 1299 presence.SceneViewer.QueuePartForUpdate(this);
1298 } 1300 }
1299 1301
@@ -2727,7 +2729,8 @@ namespace OpenSim.Region.Framework.Scenes
2727 /// </summary> 2729 /// </summary>
2728 public void ScheduleFullUpdate() 2730 public void ScheduleFullUpdate()
2729 { 2731 {
2730// m_log.DebugFormat("[SCENE OBJECT PART]: Scheduling full update for {0} {1}", Name, LocalId); 2732 if (IsAttachment)
2733 m_log.DebugFormat("[SOP]: Scheduling full update for {0} {1}", Name, LocalId);
2731 2734
2732 if (m_parentGroup != null) 2735 if (m_parentGroup != null)
2733 { 2736 {
@@ -2840,6 +2843,10 @@ namespace OpenSim.Region.Framework.Scenes
2840 /// <param name="remoteClient"></param> 2843 /// <param name="remoteClient"></param>
2841 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) 2844 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2842 { 2845 {
2846 if (IsAttachment)
2847 m_log.DebugFormat(
2848 "[SCENE OBJECT PART]: Sending part full update to {0} for {1} {2}", remoteClient.Name, Name, LocalId);
2849
2843 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); 2850 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
2844 } 2851 }
2845 2852
@@ -2848,6 +2855,10 @@ namespace OpenSim.Region.Framework.Scenes
2848 /// </summary> 2855 /// </summary>
2849 public void SendFullUpdateToAllClients() 2856 public void SendFullUpdateToAllClients()
2850 { 2857 {
2858 if (IsAttachment)
2859 m_log.DebugFormat(
2860 "[SCENE OBJECT PART]: Sending full update for {0} {1} for all clients", Name, LocalId);
2861
2851 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2862 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2852 for (int i = 0; i < avatars.Length; i++) 2863 for (int i = 0; i < avatars.Length; i++)
2853 { 2864 {
@@ -2859,6 +2870,10 @@ namespace OpenSim.Region.Framework.Scenes
2859 2870
2860 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2871 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2861 { 2872 {
2873 if (IsAttachment)
2874 m_log.DebugFormat(
2875 "[SCENE OBJECT PART]: Sending full update for {0} {1} to all clients except {2}", Name, LocalId, agentID);
2876
2862 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2877 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2863 for (int i = 0; i < avatars.Length; i++) 2878 for (int i = 0; i < avatars.Length; i++)
2864 { 2879 {
@@ -2965,6 +2980,9 @@ namespace OpenSim.Region.Framework.Scenes
2965 { 2980 {
2966 if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes 2981 if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
2967 { 2982 {
2983 if (IsAttachment)
2984 m_log.DebugFormat("[SOP]: Sending scheduled full update for {0} {1}", Name, LocalId);
2985
2968 AddFullUpdateToAllAvatars(); 2986 AddFullUpdateToAllAvatars();
2969 ClearUpdateSchedule(); 2987 ClearUpdateSchedule();
2970 } 2988 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a555eae..21ca1de 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -638,7 +638,6 @@ namespace OpenSim.Region.Framework.Scenes
638 m_items[item.ItemID] = item; 638 m_items[item.ItemID] = item;
639 m_inventorySerial++; 639 m_inventorySerial++;
640 m_part.TriggerScriptChangedEvent(Changed.INVENTORY); 640 m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
641
642 HasInventoryChanged = true; 641 HasInventoryChanged = true;
643 m_part.ParentGroup.HasGroupChanged = true; 642 m_part.ParentGroup.HasGroupChanged = true;
644 643
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index e4296ef..6f2bef9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection;
30using OpenMetaverse; 31using OpenMetaverse;
31using log4net; 32using log4net;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -39,6 +40,8 @@ namespace OpenSim.Region.Framework.Scenes
39{ 40{
40 public class SceneViewer : ISceneViewer 41 public class SceneViewer : ISceneViewer
41 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44
42 protected ScenePresence m_presence; 45 protected ScenePresence m_presence;
43 protected UpdateQueue m_partsUpdateQueue = new UpdateQueue(); 46 protected UpdateQueue m_partsUpdateQueue = new UpdateQueue();
44 protected Queue<SceneObjectGroup> m_pendingObjects; 47 protected Queue<SceneObjectGroup> m_pendingObjects;
@@ -60,6 +63,9 @@ namespace OpenSim.Region.Framework.Scenes
60 /// <param name="part"></param> 63 /// <param name="part"></param>
61 public void QueuePartForUpdate(SceneObjectPart part) 64 public void QueuePartForUpdate(SceneObjectPart part)
62 { 65 {
66 if (part.IsAttachment)
67 m_log.DebugFormat("[SCENE VIEWER]: Queueing part {0} {1} for update", part.Name, part.LocalId);
68
63 lock (m_partsUpdateQueue) 69 lock (m_partsUpdateQueue)
64 { 70 {
65 m_partsUpdateQueue.Enqueue(part); 71 m_partsUpdateQueue.Enqueue(part);
@@ -134,7 +140,7 @@ namespace OpenSim.Region.Framework.Scenes
134 } 140 }
135 else if (update.LastTerseUpdateTime <= part.TimeStampTerse) 141 else if (update.LastTerseUpdateTime <= part.TimeStampTerse)
136 { 142 {
137// m_log.DebugFormat( 143// m_log.DebugFormat(AddFullUpdateToAvatar
138// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}", 144// "[SCENE PRESENCE]: Tersely updating prim {0}, {1} - part timestamp {2}",
139// part.Name, part.UUID, part.TimeStampTerse); 145// part.Name, part.UUID, part.TimeStampTerse);
140 146
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 00fe5df..06aad91 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,8 +97,12 @@ 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)
@@ -117,12 +110,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
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,6 @@ 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
148 } 140 }
149 141
150 public void RemoveRegion(Scene scene) 142 public void RemoveRegion(Scene scene)
@@ -172,7 +164,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
172 164
173 m_sceneList.Clear(); 165 m_sceneList.Clear();
174 166
175 m_groupsModule = null; 167 m_groupData = null;
176 m_msgTransferModule = null; 168 m_msgTransferModule = null;
177 } 169 }
178 170
@@ -197,6 +189,75 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
197 189
198 #endregion 190 #endregion
199 191
192 /// <summary>
193 /// Not really needed, but does confirm that the group exists.
194 /// </summary>
195 public bool StartGroupChatSession(UUID agentID, UUID groupID)
196 {
197 if (m_debugEnabled)
198 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
199
200 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
201
202 if (groupInfo != null)
203 {
204 return true;
205 }
206 else
207 {
208 return false;
209 }
210 }
211
212 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
213 {
214 if (m_debugEnabled)
215 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
216
217
218 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID))
219 {
220 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
221 {
222 // Don't deliver messages to people who have dropped this session
223 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
224 continue;
225 }
226
227 // Copy Message
228 GridInstantMessage msg = new GridInstantMessage();
229 msg.imSessionID = groupID.Guid;
230 msg.fromAgentName = im.fromAgentName;
231 msg.message = im.message;
232 msg.dialog = im.dialog;
233 msg.offline = im.offline;
234 msg.ParentEstateID = im.ParentEstateID;
235 msg.Position = im.Position;
236 msg.RegionID = im.RegionID;
237 msg.binaryBucket = im.binaryBucket;
238 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
239
240 msg.fromAgentID = im.fromAgentID;
241 msg.fromGroup = true;
242
243 msg.toAgentID = member.AgentID.Guid;
244
245 IClientAPI client = GetActiveClient(member.AgentID);
246 if (client == null)
247 {
248 // If they're not local, forward across the grid
249 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} via Grid", member.AgentID);
250 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
251 }
252 else
253 {
254 // Deliver locally, directly
255 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Passing to ProcessMessageFromGroupSession to deliver to {0} locally", client.Name);
256 ProcessMessageFromGroupSession(msg);
257 }
258 }
259 }
260
200 #region SimGridEventHandlers 261 #region SimGridEventHandlers
201 262
202 private void OnNewClient(IClientAPI client) 263 private void OnNewClient(IClientAPI client)
@@ -236,42 +297,46 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 { 297 {
237 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); 298 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
238 299
300 UUID AgentID = new UUID(msg.fromAgentID);
301 UUID GroupID = new UUID(msg.imSessionID);
302
239 switch (msg.dialog) 303 switch (msg.dialog)
240 { 304 {
241 case (byte)InstantMessageDialog.SessionAdd: 305 case (byte)InstantMessageDialog.SessionAdd:
242 AddAgentToGroupSession(msg.fromAgentID, msg.imSessionID); 306 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
243 break; 307 break;
244 308
245 case (byte)InstantMessageDialog.SessionDrop: 309 case (byte)InstantMessageDialog.SessionDrop:
246 RemoveAgentFromGroupSession(msg.fromAgentID, msg.imSessionID); 310 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
247 break; 311 break;
248 312
249 case (byte)InstantMessageDialog.SessionSend: 313 case (byte)InstantMessageDialog.SessionSend:
250 if (!m_agentsInGroupSession.ContainsKey(msg.toAgentID) 314 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
251 && !m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 315 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
316 )
252 { 317 {
253 // Agent not in session and hasn't dropped from session 318 // Agent not in session and hasn't dropped from session
254 // Add them to the session for now, and Invite them 319 // Add them to the session for now, and Invite them
255 AddAgentToGroupSession(msg.toAgentID, msg.imSessionID); 320 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
256 321
257 UUID toAgentID = new UUID(msg.toAgentID); 322 UUID toAgentID = new UUID(msg.toAgentID);
258 IClientAPI activeClient = GetActiveClient(toAgentID); 323 IClientAPI activeClient = GetActiveClient(toAgentID);
259 if (activeClient != null) 324 if (activeClient != null)
260 { 325 {
261 UUID groupID = new UUID(msg.fromAgentID); 326 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
262
263 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID);
264 if (groupInfo != null) 327 if (groupInfo != null)
265 { 328 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); 329 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
267 330
268 // Force? open the group session dialog??? 331 // Force? open the group session dialog???
332 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
269 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); 333 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
270 eq.ChatterboxInvitation( 334 eq.ChatterboxInvitation(
271 groupID 335 GroupID
272 , groupInfo.GroupName 336 , groupInfo.GroupName
273 , new UUID(msg.fromAgentID) 337 , new UUID(msg.fromAgentID)
274 , msg.message, new UUID(msg.toAgentID) 338 , msg.message
339 , new UUID(msg.toAgentID)
275 , msg.fromAgentName 340 , msg.fromAgentName
276 , msg.dialog 341 , msg.dialog
277 , msg.timestamp 342 , msg.timestamp
@@ -285,7 +350,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
285 ); 350 );
286 351
287 eq.ChatterBoxSessionAgentListUpdates( 352 eq.ChatterBoxSessionAgentListUpdates(
288 new UUID(groupID) 353 new UUID(GroupID)
289 , new UUID(msg.fromAgentID) 354 , new UUID(msg.fromAgentID)
290 , new UUID(msg.toAgentID) 355 , new UUID(msg.toAgentID)
291 , false //canVoiceChat 356 , false //canVoiceChat
@@ -295,7 +360,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
295 } 360 }
296 } 361 }
297 } 362 }
298 else if (!m_agentsDroppedSession.ContainsKey(msg.toAgentID)) 363 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
299 { 364 {
300 // User hasn't dropped, so they're in the session, 365 // User hasn't dropped, so they're in the session,
301 // maybe we should deliver it. 366 // maybe we should deliver it.
@@ -321,56 +386,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
321 386
322 #endregion 387 #endregion
323 388
324 #region ClientEvents
325
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 389
390 #region ClientEvents
374 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 391 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
375 { 392 {
376 if (m_debugEnabled) 393 if (m_debugEnabled)
@@ -383,21 +400,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
383 // Start group IM session 400 // Start group IM session
384 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 401 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
385 { 402 {
386 UUID groupID = new UUID(im.toAgentID); 403 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
387 404
388 GroupRecord groupInfo = m_groupsModule.GetGroupRecord(groupID); 405 UUID GroupID = new UUID(im.imSessionID);
406 UUID AgentID = new UUID(im.fromAgentID);
407
408 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
409
389 if (groupInfo != null) 410 if (groupInfo != null)
390 { 411 {
391 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Start Group Session for {0}", groupInfo.GroupName); 412 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
392
393 AddAgentToGroupSession(im.fromAgentID, im.imSessionID);
394 413
395 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, groupID); 414 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
396 415
397 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 416 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
398 queue.ChatterBoxSessionAgentListUpdates( 417 queue.ChatterBoxSessionAgentListUpdates(
399 new UUID(groupID) 418 GroupID
400 , new UUID(im.fromAgentID) 419 , AgentID
401 , new UUID(im.toAgentID) 420 , new UUID(im.toAgentID)
402 , false //canVoiceChat 421 , false //canVoiceChat
403 , false //isModerator 422 , false //isModerator
@@ -409,64 +428,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
409 // Send a message from locally connected client to a group 428 // Send a message from locally connected client to a group
410 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 429 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
411 { 430 {
412 UUID groupID = new UUID(im.toAgentID); 431 UUID GroupID = new UUID(im.imSessionID);
432 UUID AgentID = new UUID(im.fromAgentID);
413 433
414 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", groupID, im.imSessionID.ToString()); 434 if (m_debugEnabled)
435 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
415 436
416 SendMessageToGroup(im, groupID); 437 //If this agent is sending a message, then they want to be in the session
438 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
439
440 SendMessageToGroup(im, GroupID);
417 } 441 }
418 } 442 }
419 443
420 #endregion 444 #endregion
421 445
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) 446 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
471 { 447 {
472 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 448 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -518,6 +494,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
518 /// </summary> 494 /// </summary>
519 private IClientAPI GetActiveClient(UUID agentID) 495 private IClientAPI GetActiveClient(UUID agentID)
520 { 496 {
497 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
498
521 IClientAPI child = null; 499 IClientAPI child = null;
522 500
523 // Try root avatar first 501 // Try root avatar first
@@ -529,16 +507,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
529 ScenePresence user = (ScenePresence)scene.Entities[agentID]; 507 ScenePresence user = (ScenePresence)scene.Entities[agentID];
530 if (!user.IsChildAgent) 508 if (!user.IsChildAgent)
531 { 509 {
510 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name);
532 return user.ControllingClient; 511 return user.ControllingClient;
533 } 512 }
534 else 513 else
535 { 514 {
515 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name);
536 child = user.ControllingClient; 516 child = user.ControllingClient;
537 } 517 }
538 } 518 }
539 } 519 }
540 520
541 // If we didn't find a root, then just return whichever child we found, or null if none 521 // If we didn't find a root, then just return whichever child we found, or null if none
522 if (child == null)
523 {
524 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
525 }
526 else
527 {
528 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
529 }
542 return child; 530 return child;
543 } 531 }
544 532
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 8d32e66..3e05732 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -87,16 +87,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
87 87
88 private IGroupsServicesConnector m_groupData = null; 88 private IGroupsServicesConnector m_groupData = null;
89 89
90 class GroupRequestIDInfo
91 {
92 public GroupRequestID RequestID = new GroupRequestID();
93 public DateTime LastUsedTMStamp = DateTime.MinValue;
94 }
95 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
96 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
97 private Timer m_clientRequestIDFlushTimer;
98
99
100 // Configuration settings 90 // Configuration settings
101 private bool m_groupsEnabled = false; 91 private bool m_groupsEnabled = false;
102 private bool m_groupNoticesEnabled = true; 92 private bool m_groupNoticesEnabled = true;
@@ -133,30 +123,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
133 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 123 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
134 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 124 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
135 125
136 m_clientRequestIDFlushTimer = new Timer();
137 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
138 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
139 m_clientRequestIDFlushTimer.AutoReset = true;
140 m_clientRequestIDFlushTimer.Start();
141 }
142 }
143
144 void FlushClientRequestIDInfoCache(object sender, ElapsedEventArgs e)
145 {
146 lock (m_clientRequestIDInfo)
147 {
148 TimeSpan cacheTimeout = new TimeSpan(0,0, m_clientRequestIDFlushTimeOut / 1000);
149 UUID[] CurrentKeys = new UUID[m_clientRequestIDInfo.Count];
150 foreach (UUID key in CurrentKeys)
151 {
152 if (m_clientRequestIDInfo.ContainsKey(key))
153 {
154 if (DateTime.Now - m_clientRequestIDInfo[key].LastUsedTMStamp > cacheTimeout)
155 {
156 m_clientRequestIDInfo.Remove(key);
157 }
158 }
159 }
160 } 126 }
161 } 127 }
162 128
@@ -234,8 +200,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
234 return; 200 return;
235 201
236 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 202 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
237
238 m_clientRequestIDFlushTimer.Stop();
239 } 203 }
240 204
241 public Type ReplaceableInterface 205 public Type ReplaceableInterface
@@ -272,14 +236,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
272 // Used for Notices and Group Invites/Accept/Reject 236 // Used for Notices and Group Invites/Accept/Reject
273 client.OnInstantMessage += OnInstantMessage; 237 client.OnInstantMessage += OnInstantMessage;
274 238
275 lock (m_clientRequestIDInfo) 239 // Send client thier groups information.
276 {
277 if (m_clientRequestIDInfo.ContainsKey(client.AgentId))
278 {
279 // flush any old RequestID information
280 m_clientRequestIDInfo.Remove(client.AgentId);
281 }
282 }
283 SendAgentGroupDataUpdate(client, client.AgentId); 240 SendAgentGroupDataUpdate(client, client.AgentId);
284 } 241 }
285 242
@@ -287,7 +244,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
287 { 244 {
288 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 245 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
289 246
290 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(remoteClient), avatarID).ToArray(); 247 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
291 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 248 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
292 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 249 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
293 } 250 }
@@ -331,10 +288,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
331 { 288 {
332 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups) 289 if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
333 { 290 {
334 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart); 291 if (m_debugEnabled)
292 m_log.DebugFormat(
293 "[GROUPS]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
294 System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
335 295
336 // 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
337 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetClientGroupRequestID(remoteClient), queryText).ToArray()); 297 remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentID(remoteClient), queryText).ToArray());
338 } 298 }
339 299
340 } 300 }
@@ -348,7 +308,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
348 string activeGroupName = string.Empty; 308 string activeGroupName = string.Empty;
349 ulong activeGroupPowers = (ulong)GroupPowers.None; 309 ulong activeGroupPowers = (ulong)GroupPowers.None;
350 310
351 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetClientGroupRequestID(remoteClient), dataForAgentID); 311 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
352 if (membership != null) 312 if (membership != null)
353 { 313 {
354 activeGroupID = membership.GroupID; 314 activeGroupID = membership.GroupID;
@@ -361,13 +321,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
361 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 321 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle);
362 } 322 }
363 323
364 private void HandleUUIDGroupNameRequest(UUID GroupID,IClientAPI remoteClient) 324 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
365 { 325 {
366 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 326 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
367 327
368 string GroupName; 328 string GroupName;
369 329
370 GroupRecord group = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null); 330 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
371 if (group != null) 331 if (group != null)
372 { 332 {
373 GroupName = group.GroupName; 333 GroupName = group.GroupName;
@@ -382,13 +342,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
382 342
383 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 343 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
384 { 344 {
385 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 345 if (m_debugEnabled)
346 {
347 m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
348 m_log.DebugFormat("[GROUPS]: remoteClient ({0}) im ({1})", remoteClient, im);
349
350 }
351
386 352
387 // Group invitations 353 // Group invitations
388 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)) 354 if ((im.dialog == (byte)InstantMessageDialog.GroupInvitationAccept) || (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline))
389 { 355 {
390 UUID inviteID = new UUID(im.imSessionID); 356 UUID inviteID = new UUID(im.imSessionID);
391 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 357 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
392 358
393 if (inviteInfo == null) 359 if (inviteInfo == null)
394 { 360 {
@@ -407,7 +373,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
407 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice."); 373 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received an accept invite notice.");
408 374
409 // and the sessionid is the role 375 // and the sessionid is the role
410 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID); 376 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), inviteInfo.AgentID, inviteInfo.GroupID, inviteInfo.RoleID);
411 377
412 GridInstantMessage msg = new GridInstantMessage(); 378 GridInstantMessage msg = new GridInstantMessage();
413 msg.imSessionID = UUID.Zero.Guid; 379 msg.imSessionID = UUID.Zero.Guid;
@@ -431,14 +397,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
431 // TODO: If the inviter is still online, they need an agent dataupdate 397 // TODO: If the inviter is still online, they need an agent dataupdate
432 // and maybe group membership updates for the invitee 398 // and maybe group membership updates for the invitee
433 399
434 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 400 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
435 } 401 }
436 402
437 // Reject 403 // Reject
438 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline) 404 if (im.dialog == (byte)InstantMessageDialog.GroupInvitationDecline)
439 { 405 {
440 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice."); 406 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Received a reject invite notice.");
441 m_groupData.RemoveAgentToGroupInvite(GetClientGroupRequestID(remoteClient), inviteID); 407 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
442 } 408 }
443 } 409 }
444 } 410 }
@@ -452,7 +418,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
452 } 418 }
453 419
454 UUID GroupID = new UUID(im.toAgentID); 420 UUID GroupID = new UUID(im.toAgentID);
455 if (m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), GroupID, null) != null) 421 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null) != null)
456 { 422 {
457 UUID NoticeID = UUID.Random(); 423 UUID NoticeID = UUID.Random();
458 string Subject = im.message.Substring(0, im.message.IndexOf('|')); 424 string Subject = im.message.Substring(0, im.message.IndexOf('|'));
@@ -496,14 +462,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
496 } 462 }
497 463
498 464
499 m_groupData.AddGroupNotice(GetClientGroupRequestID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket); 465 m_groupData.AddGroupNotice(GetRequestingAgentID(remoteClient), GroupID, NoticeID, im.fromAgentName, Subject, Message, bucket);
500 if (OnNewGroupNotice != null) 466 if (OnNewGroupNotice != null)
501 { 467 {
502 OnNewGroupNotice(GroupID, NoticeID); 468 OnNewGroupNotice(GroupID, NoticeID);
503 } 469 }
504 470
505 // Send notice out to everyone that wants notices 471 // Send notice out to everyone that wants notices
506 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), GroupID)) 472 foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), GroupID))
507 { 473 {
508 if (m_debugEnabled) 474 if (m_debugEnabled)
509 { 475 {
@@ -521,7 +487,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
521 if (member.AcceptNotices) 487 if (member.AcceptNotices)
522 { 488 {
523 // Build notice IIM 489 // Build notice IIM
524 GridInstantMessage msg = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); 490 GridInstantMessage msg = CreateGroupNoticeIM(GetRequestingAgentID(remoteClient), NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice);
525 491
526 msg.toAgentID = member.AgentID.Guid; 492 msg.toAgentID = member.AgentID.Guid;
527 OutgoingInstantMessage(msg, member.AgentID); 493 OutgoingInstantMessage(msg, member.AgentID);
@@ -549,7 +515,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
549 IClientAPI ejectee = GetActiveClient(ejecteeID); 515 IClientAPI ejectee = GetActiveClient(ejecteeID);
550 if (ejectee != null) 516 if (ejectee != null)
551 { 517 {
552 UUID groupID = new UUID(im.fromAgentID); 518 UUID groupID = new UUID(im.imSessionID);
553 ejectee.SendAgentDropGroup(groupID); 519 ejectee.SendAgentDropGroup(groupID);
554 } 520 }
555 } 521 }
@@ -588,20 +554,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
588 554
589 public GroupRecord GetGroupRecord(UUID GroupID) 555 public GroupRecord GetGroupRecord(UUID GroupID)
590 { 556 {
591 return m_groupData.GetGroupRecord(null, GroupID, null); 557 return m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
592 } 558 }
593 559
560 public GroupRecord GetGroupRecord(string name)
561 {
562 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
563 }
564
594 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 565 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
595 { 566 {
596 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 567 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
597 568
598 m_groupData.SetAgentActiveGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 569 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
599 570
600 // Changing active group changes title, active powers, all kinds of things 571 // Changing active group changes title, active powers, all kinds of things
601 // anyone who is in any region that can see this client, should probably be 572 // anyone who is in any region that can see this client, should probably be
602 // updated with new group info. At a minimum, they should get ScenePresence 573 // updated with new group info. At a minimum, they should get ScenePresence
603 // updated with new title. 574 // updated with new title.
604 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 575 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
605 } 576 }
606 577
607 /// <summary> 578 /// <summary>
@@ -611,10 +582,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
611 { 582 {
612 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 583 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
613 584
614 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
615 585
616 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(grID, remoteClient.AgentId, groupID); 586 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
617 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 587 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
618 588
619 List<GroupTitlesData> titles = new List<GroupTitlesData>(); 589 List<GroupTitlesData> titles = new List<GroupTitlesData>();
620 foreach (GroupRolesData role in agentRoles) 590 foreach (GroupRolesData role in agentRoles)
@@ -636,8 +606,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
636 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 606 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
637 { 607 {
638 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 608 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
609 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
639 610
640 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetClientGroupRequestID(remoteClient), groupID); 611 if (m_debugEnabled)
612 {
613 foreach (GroupMembersData member in data)
614 {
615 m_log.DebugFormat("[GROUPS]: Member({0}) - IsOwner({1})", member.AgentID, member.IsOwner);
616 }
617 }
641 618
642 return data; 619 return data;
643 620
@@ -647,21 +624,25 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
647 { 624 {
648 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 625 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
649 626
650 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetClientGroupRequestID(remoteClient), groupID); 627 List<GroupRolesData> data = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID);
651 628
652 return data; 629 return data;
653
654 } 630 }
655 631
656 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID) 632 public List<GroupRoleMembersData> GroupRoleMembersRequest(IClientAPI remoteClient, UUID groupID)
657 { 633 {
658 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 634 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
659 635
660 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetClientGroupRequestID(remoteClient), groupID); 636 List<GroupRoleMembersData> data = m_groupData.GetGroupRoleMembers(GetRequestingAgentID(remoteClient), groupID);
661 637
638 if (m_debugEnabled)
639 {
640 foreach (GroupRoleMembersData member in data)
641 {
642 m_log.DebugFormat("[GROUPS]: Member({0}) - Role({1})", member.MemberID, member.RoleID);
643 }
644 }
662 return data; 645 return data;
663
664
665 } 646 }
666 647
667 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID) 648 public GroupProfileData GroupProfileRequest(IClientAPI remoteClient, UUID groupID)
@@ -670,17 +651,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
670 651
671 GroupProfileData profile = new GroupProfileData(); 652 GroupProfileData profile = new GroupProfileData();
672 653
673 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
674 654
675 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetClientGroupRequestID(remoteClient), groupID, null); 655 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
676 if (groupInfo != null) 656 if (groupInfo != null)
677 { 657 {
678 profile.AllowPublish = groupInfo.AllowPublish; 658 profile.AllowPublish = groupInfo.AllowPublish;
679 profile.Charter = groupInfo.Charter; 659 profile.Charter = groupInfo.Charter;
680 profile.FounderID = groupInfo.FounderID; 660 profile.FounderID = groupInfo.FounderID;
681 profile.GroupID = groupID; 661 profile.GroupID = groupID;
682 profile.GroupMembershipCount = m_groupData.GetGroupMembers(grID, groupID).Count; 662 profile.GroupMembershipCount = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID).Count;
683 profile.GroupRolesCount = m_groupData.GetGroupRoles(grID, groupID).Count; 663 profile.GroupRolesCount = m_groupData.GetGroupRoles(GetRequestingAgentID(remoteClient), groupID).Count;
684 profile.InsigniaID = groupInfo.GroupPicture; 664 profile.InsigniaID = groupInfo.GroupPicture;
685 profile.MaturePublish = groupInfo.MaturePublish; 665 profile.MaturePublish = groupInfo.MaturePublish;
686 profile.MembershipFee = groupInfo.MembershipFee; 666 profile.MembershipFee = groupInfo.MembershipFee;
@@ -691,7 +671,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
691 profile.ShowInList = groupInfo.ShowInList; 671 profile.ShowInList = groupInfo.ShowInList;
692 } 672 }
693 673
694 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(grID, remoteClient.AgentId, groupID); 674 GroupMembershipData memberInfo = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
695 if (memberInfo != null) 675 if (memberInfo != null)
696 { 676 {
697 profile.MemberTitle = memberInfo.GroupTitle; 677 profile.MemberTitle = memberInfo.GroupTitle;
@@ -705,40 +685,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
705 { 685 {
706 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 686 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
707 687
708 return m_groupData.GetAgentGroupMemberships(null, agentID).ToArray(); 688 return m_groupData.GetAgentGroupMemberships(UUID.Zero, agentID).ToArray();
709 } 689 }
710 690
711 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 691 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
712 { 692 {
713 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 693 if (m_debugEnabled)
694 m_log.DebugFormat(
695 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
696 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
714 697
715 return m_groupData.GetAgentGroupMembership(null, agentID, groupID); 698 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
716 } 699 }
717 700
718 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 701 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
719 { 702 {
720 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 703 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
721 704
722 // TODO: Security Check? 705 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
723 706 m_groupData.UpdateGroup(GetRequestingAgentID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
724 m_groupData.UpdateGroup(GetClientGroupRequestID(remoteClient), groupID, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish);
725 } 707 }
726 708
727 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile) 709 public void SetGroupAcceptNotices(IClientAPI remoteClient, UUID groupID, bool acceptNotices, bool listInProfile)
728 { 710 {
729 // TODO: Security Check? 711 // Note: Permissions checking for modification rights is handled by the Groups Server/Service
730 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 712 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
731 713
732 m_groupData.SetAgentGroupInfo(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, acceptNotices, listInProfile); 714 m_groupData.SetAgentGroupInfo(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, acceptNotices, listInProfile);
733 } 715 }
734 716
735 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 717 public UUID CreateGroup(IClientAPI remoteClient, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
736 { 718 {
737 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 719 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
738 720
739 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 721 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null)
740
741 if (m_groupData.GetGroupRecord(grID, UUID.Zero, name) != null)
742 { 722 {
743 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 723 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
744 return UUID.Zero; 724 return UUID.Zero;
@@ -754,12 +734,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
754 } 734 }
755 money.ApplyGroupCreationCharge(remoteClient.AgentId); 735 money.ApplyGroupCreationCharge(remoteClient.AgentId);
756 } 736 }
757 UUID groupID = m_groupData.CreateGroup(grID, name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, remoteClient.AgentId); 737 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
758 738
759 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 739 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
760 740
761 // Update the founder with new group information. 741 // Update the founder with new group information.
762 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 742 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
763 743
764 return groupID; 744 return groupID;
765 } 745 }
@@ -770,7 +750,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
770 750
771 // ToDo: check if agent is a member of group and is allowed to see notices? 751 // ToDo: check if agent is a member of group and is allowed to see notices?
772 752
773 return m_groupData.GetGroupNotices(GetClientGroupRequestID(remoteClient), groupID).ToArray(); 753 return m_groupData.GetGroupNotices(GetRequestingAgentID(remoteClient), groupID).ToArray();
774 } 754 }
775 755
776 /// <summary> 756 /// <summary>
@@ -780,7 +760,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
780 { 760 {
781 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 761 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
782 762
783 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(null, avatarID); 763 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(UUID.Zero, avatarID);
784 if (membership != null) 764 if (membership != null)
785 { 765 {
786 return membership.GroupTitle; 766 return membership.GroupTitle;
@@ -795,13 +775,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
795 { 775 {
796 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 776 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
797 777
798 m_groupData.SetAgentActiveGroupRole(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, titleRoleID); 778 m_groupData.SetAgentActiveGroupRole(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, titleRoleID);
799 779
800 // TODO: Not sure what all is needed here, but if the active group role change is for the group 780 // TODO: Not sure what all is needed here, but if the active group role change is for the group
801 // the client currently has set active, then we need to do a scene presence update too 781 // the client currently has set active, then we need to do a scene presence update too
802 // if (m_groupData.GetAgentActiveMembership(remoteClient.AgentId).GroupID == GroupID) 782 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
803 783
804 UpdateAllClientsWithGroupInfo(remoteClient.AgentId); 784 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
805 } 785 }
806 786
807 787
@@ -811,16 +791,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
811 791
812 // Security Checks are handled in the Groups Service. 792 // Security Checks are handled in the Groups Service.
813 793
814 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
815
816 switch ((OpenMetaverse.GroupRoleUpdate)updateType) 794 switch ((OpenMetaverse.GroupRoleUpdate)updateType)
817 { 795 {
818 case OpenMetaverse.GroupRoleUpdate.Create: 796 case OpenMetaverse.GroupRoleUpdate.Create:
819 m_groupData.AddGroupRole(grID, groupID, UUID.Random(), name, description, title, powers); 797 m_groupData.AddGroupRole(GetRequestingAgentID(remoteClient), groupID, UUID.Random(), name, description, title, powers);
820 break; 798 break;
821 799
822 case OpenMetaverse.GroupRoleUpdate.Delete: 800 case OpenMetaverse.GroupRoleUpdate.Delete:
823 m_groupData.RemoveGroupRole(grID, groupID, roleID); 801 m_groupData.RemoveGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID);
824 break; 802 break;
825 803
826 case OpenMetaverse.GroupRoleUpdate.UpdateAll: 804 case OpenMetaverse.GroupRoleUpdate.UpdateAll:
@@ -831,7 +809,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
831 GroupPowers gp = (GroupPowers)powers; 809 GroupPowers gp = (GroupPowers)powers;
832 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString()); 810 m_log.DebugFormat("[GROUPS]: Role ({0}) updated with Powers ({1}) ({2})", name, powers.ToString(), gp.ToString());
833 } 811 }
834 m_groupData.UpdateGroupRole(grID, groupID, roleID, name, description, title, powers); 812 m_groupData.UpdateGroupRole(GetRequestingAgentID(remoteClient), groupID, roleID, name, description, title, powers);
835 break; 813 break;
836 814
837 case OpenMetaverse.GroupRoleUpdate.NoUpdate: 815 case OpenMetaverse.GroupRoleUpdate.NoUpdate:
@@ -842,7 +820,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
842 } 820 }
843 821
844 // TODO: This update really should send out updates for everyone in the role that just got changed. 822 // TODO: This update really should send out updates for everyone in the role that just got changed.
845 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 823 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
846 } 824 }
847 825
848 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 826 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -850,18 +828,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
850 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 828 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
851 // Todo: Security check 829 // Todo: Security check
852 830
853 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
854
855 switch (changes) 831 switch (changes)
856 { 832 {
857 case 0: 833 case 0:
858 // Add 834 // Add
859 m_groupData.AddAgentToGroupRole(grID, memberID, groupID, roleID); 835 m_groupData.AddAgentToGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
860 836
861 break; 837 break;
862 case 1: 838 case 1:
863 // Remove 839 // Remove
864 m_groupData.RemoveAgentFromGroupRole(grID, memberID, groupID, roleID); 840 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
865 841
866 break; 842 break;
867 default: 843 default:
@@ -870,25 +846,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
870 } 846 }
871 847
872 // TODO: This update really should send out updates for everyone in the role that just got changed. 848 // TODO: This update really should send out updates for everyone in the role that just got changed.
873 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 849 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
874 } 850 }
875 851
876 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 852 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
877 { 853 {
878 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 854 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
879 855
880 GroupRequestID grID = GetClientGroupRequestID(remoteClient); 856 GroupNoticeInfo data = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), groupNoticeID);
881
882 GroupNoticeInfo data = m_groupData.GetGroupNotice(grID, groupNoticeID);
883 857
884 if (data != null) 858 if (data != null)
885 { 859 {
886 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, data.GroupID, null); 860 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), data.GroupID, null);
887 861
888 GridInstantMessage msg = new GridInstantMessage(); 862 GridInstantMessage msg = new GridInstantMessage();
889 msg.imSessionID = UUID.Zero.Guid; 863 msg.imSessionID = UUID.Zero.Guid;
890 msg.fromAgentID = data.GroupID.Guid; 864 msg.fromAgentID = data.GroupID.Guid;
891 msg.toAgentID = remoteClient.AgentId.Guid; 865 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
892 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 866 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
893 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName; 867 msg.fromAgentName = "Group Notice : " + groupInfo == null ? "Unknown" : groupInfo.GroupName;
894 msg.message = data.noticeData.Subject + "|" + data.Message; 868 msg.message = data.noticeData.Subject + "|" + data.Message;
@@ -900,7 +874,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
900 msg.RegionID = UUID.Zero.Guid; 874 msg.RegionID = UUID.Zero.Guid;
901 msg.binaryBucket = data.BinaryBucket; 875 msg.binaryBucket = data.BinaryBucket;
902 876
903 OutgoingInstantMessage(msg, remoteClient.AgentId); 877 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
904 } 878 }
905 879
906 } 880 }
@@ -920,7 +894,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
920 msg.Position = Vector3.Zero; 894 msg.Position = Vector3.Zero;
921 msg.RegionID = UUID.Zero.Guid; 895 msg.RegionID = UUID.Zero.Guid;
922 896
923 GroupNoticeInfo info = m_groupData.GetGroupNotice(null, groupNoticeID); 897 GroupNoticeInfo info = m_groupData.GetGroupNotice(agentID, groupNoticeID);
924 if (info != null) 898 if (info != null)
925 { 899 {
926 msg.fromAgentID = info.GroupID.Guid; 900 msg.fromAgentID = info.GroupID.Guid;
@@ -947,7 +921,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
947 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 921 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
948 922
949 // Send agent information about his groups 923 // Send agent information about his groups
950 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 924 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
951 } 925 }
952 926
953 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 927 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -955,19 +929,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
955 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 929 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
956 930
957 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 931 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
958 m_groupData.AddAgentToGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID, UUID.Zero); 932 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
959 933
960 remoteClient.SendJoinGroupReply(groupID, true); 934 remoteClient.SendJoinGroupReply(groupID, true);
961 935
962 // Should this send updates to everyone in the group? 936 // Should this send updates to everyone in the group?
963 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 937 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
964 } 938 }
965 939
966 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 940 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
967 { 941 {
968 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 942 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
969 943
970 m_groupData.RemoveAgentFromGroup(GetClientGroupRequestID(remoteClient), remoteClient.AgentId, groupID); 944 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
971 945
972 remoteClient.SendLeaveGroupReply(groupID, true); 946 remoteClient.SendLeaveGroupReply(groupID, true);
973 947
@@ -975,21 +949,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
975 949
976 // SL sends out notifcations to the group messaging session that the person has left 950 // SL sends out notifcations to the group messaging session that the person has left
977 // Should this also update everyone who is in the group? 951 // Should this also update everyone who is in the group?
978 SendAgentGroupDataUpdate(remoteClient, remoteClient.AgentId); 952 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
979 } 953 }
980 954
981 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 955 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
982 { 956 {
983 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 957 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
984 958
985 GroupRequestID grID = GetClientGroupRequestID(remoteClient);
986 959
987 // Todo: Security check? 960 // Todo: Security check?
988 m_groupData.RemoveAgentFromGroup(grID, ejecteeID, groupID); 961 m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID);
989 962
990 remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); 963 remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true);
991 964
992 GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); 965 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
993 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); 966 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID);
994 967
995 if ((groupInfo == null) || (userProfile == null)) 968 if ((groupInfo == null) || (userProfile == null))
@@ -1002,7 +975,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1002 GridInstantMessage msg = new GridInstantMessage(); 975 GridInstantMessage msg = new GridInstantMessage();
1003 976
1004 msg.imSessionID = UUID.Zero.Guid; 977 msg.imSessionID = UUID.Zero.Guid;
1005 msg.fromAgentID = remoteClient.AgentId.Guid; 978 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1006 // msg.fromAgentID = info.GroupID; 979 // msg.fromAgentID = info.GroupID;
1007 msg.toAgentID = ejecteeID.Guid; 980 msg.toAgentID = ejecteeID.Guid;
1008 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 981 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1028,8 +1001,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1028 1001
1029 msg = new GridInstantMessage(); 1002 msg = new GridInstantMessage();
1030 msg.imSessionID = UUID.Zero.Guid; 1003 msg.imSessionID = UUID.Zero.Guid;
1031 msg.fromAgentID = remoteClient.AgentId.Guid; 1004 msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1032 msg.toAgentID = remoteClient.AgentId.Guid; 1005 msg.toAgentID = GetRequestingAgentID(remoteClient).Guid;
1033 msg.timestamp = 0; 1006 msg.timestamp = 0;
1034 msg.fromAgentName = remoteClient.Name; 1007 msg.fromAgentName = remoteClient.Name;
1035 if (userProfile != null) 1008 if (userProfile != null)
@@ -1047,7 +1020,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1047 msg.Position = Vector3.Zero; 1020 msg.Position = Vector3.Zero;
1048 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; 1021 msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid;
1049 msg.binaryBucket = new byte[0]; 1022 msg.binaryBucket = new byte[0];
1050 OutgoingInstantMessage(msg, remoteClient.AgentId); 1023 OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient));
1051 1024
1052 1025
1053 // SL sends out messages to everyone in the group 1026 // SL sends out messages to everyone in the group
@@ -1057,17 +1030,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1057 1030
1058 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) 1031 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
1059 { 1032 {
1060 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1033 if (m_debugEnabled)
1034 {
1035 m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1036 m_log.DebugFormat("[GROUPS]: remoteClient({0}) groupID({0}) invitedAgentID({0}) roleID({0})", remoteClient, groupID, invitedAgentID, roleID);
1037 }
1038
1061 1039
1062 // Todo: Security check, probably also want to send some kind of notification 1040 // Todo: Security check, probably also want to send some kind of notification
1063 UUID InviteID = UUID.Random(); 1041 UUID InviteID = UUID.Random();
1064 GroupRequestID grid = GetClientGroupRequestID(remoteClient);
1065 1042
1066 m_groupData.AddAgentToGroupInvite(grid, InviteID, groupID, roleID, invitedAgentID); 1043 UUID requestingAgentID = GetRequestingAgentID(remoteClient);
1044 if (requestingAgentID == UUID.Zero)
1045 {
1046 m_log.Error("[GROUPS] Group Invite Requires a valid requesting agent to be specified");
1047 }
1048 m_groupData.AddAgentToGroupInvite(requestingAgentID, InviteID, groupID, roleID, invitedAgentID);
1067 1049
1068 // Check to see if the invite went through, if it did not then it's possible 1050 // Check to see if the invite went through, if it did not then it's possible
1069 // the remoteClient did not validate or did not have permission to invite. 1051 // the remoteClient did not validate or did not have permission to invite.
1070 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(grid, InviteID); 1052 GroupInviteInfo inviteInfo = m_groupData.GetAgentToGroupInvite(GetRequestingAgentID(remoteClient), InviteID);
1071 1053
1072 if (inviteInfo != null) 1054 if (inviteInfo != null)
1073 { 1055 {
@@ -1079,7 +1061,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1079 1061
1080 msg.imSessionID = inviteUUID; 1062 msg.imSessionID = inviteUUID;
1081 1063
1082 // msg.fromAgentID = remoteClient.AgentId.Guid; 1064 // msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid;
1083 msg.fromAgentID = groupID.Guid; 1065 msg.fromAgentID = groupID.Guid;
1084 msg.toAgentID = invitedAgentID.Guid; 1066 msg.toAgentID = invitedAgentID.Guid;
1085 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 1067 //msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
@@ -1132,57 +1114,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1132 return child; 1114 return child;
1133 } 1115 }
1134 1116
1135 private GroupRequestID GetClientGroupRequestID(IClientAPI client)
1136 {
1137 if (client == null)
1138 {
1139 return new GroupRequestID();
1140 }
1141
1142 lock (m_clientRequestIDInfo)
1143 {
1144 if (!m_clientRequestIDInfo.ContainsKey(client.AgentId))
1145 {
1146 GroupRequestIDInfo info = new GroupRequestIDInfo();
1147 info.RequestID.AgentID = client.AgentId;
1148 info.RequestID.SessionID = client.SessionId;
1149
1150 UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(client.AgentId);
1151 if (userProfile == null)
1152 {
1153 // This should be impossible. If I've been passed a reference to a client
1154 // that client should be registered with the UserService. So something
1155 // is horribly wrong somewhere.
1156
1157 m_log.WarnFormat("[GROUPS]: Could not find a user profile for {0} / {1}", client.Name, client.AgentId);
1158
1159 // Default to local user service and hope for the best?
1160 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1161
1162 }
1163 else if (userProfile is ForeignUserProfileData)
1164 {
1165 // They aren't from around here
1166 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1167 info.RequestID.UserServiceURL = fupd.UserServerURI;
1168 }
1169 else
1170 {
1171 // They're a local user, use this:
1172 info.RequestID.UserServiceURL = m_sceneList[0].CommsManager.NetworkServersInfo.UserURL;
1173 }
1174
1175 m_clientRequestIDInfo.Add(client.AgentId, info);
1176 }
1177
1178 m_clientRequestIDInfo[client.AgentId].LastUsedTMStamp = DateTime.Now;
1179
1180 return m_clientRequestIDInfo[client.AgentId].RequestID;
1181 }
1182// Unreachable code!
1183// return new GroupRequestID();
1184 }
1185
1186 /// <summary> 1117 /// <summary>
1187 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'. 1118 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1188 /// </summary> 1119 /// </summary>
@@ -1231,6 +1162,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1231 llDataStruct.Add("GroupData", GroupData); 1162 llDataStruct.Add("GroupData", GroupData);
1232 llDataStruct.Add("NewGroupData", NewGroupData); 1163 llDataStruct.Add("NewGroupData", NewGroupData);
1233 1164
1165 if (m_debugEnabled)
1166 {
1167 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1168 }
1169
1234 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 1170 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1235 1171
1236 if (queue != null) 1172 if (queue != null)
@@ -1308,7 +1244,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1308 /// <returns></returns> 1244 /// <returns></returns>
1309 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID) 1245 private GroupMembershipData[] GetProfileListedGroupMemberships(IClientAPI requestingClient, UUID dataForAgentID)
1310 { 1246 {
1311 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(GetClientGroupRequestID(requestingClient), dataForAgentID); 1247 List<GroupMembershipData> membershipData = m_groupData.GetAgentGroupMemberships(requestingClient.AgentId, dataForAgentID);
1312 GroupMembershipData[] membershipArray; 1248 GroupMembershipData[] membershipArray;
1313 1249
1314 if (requestingClient.AgentId != dataForAgentID) 1250 if (requestingClient.AgentId != dataForAgentID)
@@ -1330,7 +1266,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1330 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1266 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
1331 foreach (GroupMembershipData membership in membershipArray) 1267 foreach (GroupMembershipData membership in membershipArray)
1332 { 1268 {
1333 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2}", dataForAgentID, membership.GroupName, membership.GroupTitle); 1269 m_log.InfoFormat("[GROUPS]: {0} :: {1} - {2} - {3}", dataForAgentID, membership.GroupName, membership.GroupTitle, membership.GroupPowers);
1334 } 1270 }
1335 } 1271 }
1336 1272
@@ -1389,6 +1325,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1389 } 1325 }
1390 1326
1391 #endregion 1327 #endregion
1328
1329 private UUID GetRequestingAgentID(IClientAPI client)
1330 {
1331 UUID requestingAgentID = UUID.Zero;
1332 if (client != null)
1333 {
1334 requestingAgentID = client.AgentId;
1335 }
1336 return requestingAgentID;
1337 }
1392 } 1338 }
1393 1339
1340 public class GroupNoticeInfo
1341 {
1342 public GroupNoticeData noticeData = new GroupNoticeData();
1343 public UUID GroupID = UUID.Zero;
1344 public string Message = string.Empty;
1345 public byte[] BinaryBucket = new byte[0];
1346 }
1394} 1347}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 9e0fa2d..a046e09 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -36,42 +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(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
59 void RemoveAgentFromGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
60 List<GroupRolesData> GetAgentGroupRoles(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
58 61
59 void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 62 void SetAgentActiveGroup(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
60 void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 63 GroupMembershipData GetAgentActiveMembership(UUID RequestingAgentID, UUID AgentID);
61 List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID);
62 64
63 void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID); 65 void SetAgentActiveGroupRole(UUID RequestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID);
64 GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID); 66 void SetAgentGroupInfo(UUID RequestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile);
65 67
66 void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID); 68 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
67 void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile); 69 List<GroupMembershipData> GetAgentGroupMemberships(UUID RequestingAgentID, UUID AgentID);
68 70
69 GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID); 71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
70 List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID); 72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID);
73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID);
71 74
72 void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 75 void ResetAgentGroupChatSessions(UUID agentID);
73 GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID); 76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID);
74 List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID); 77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID);
78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID);
79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID);
75 } 80 }
76 81
77 public class GroupInviteInfo 82 public class GroupInviteInfo
@@ -81,11 +86,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
81 public UUID AgentID = UUID.Zero; 86 public UUID AgentID = UUID.Zero;
82 public UUID InviteID = UUID.Zero; 87 public UUID InviteID = UUID.Zero;
83 } 88 }
84
85 public class GroupRequestID
86 {
87 public UUID AgentID = UUID.Zero;
88 public string UserServiceURL = string.Empty;
89 public UUID SessionID = UUID.Zero;
90 }
91} 89}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 964d0bb..861731c 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -40,6 +40,7 @@ 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;
44 45
45namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 46namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
@@ -47,9 +48,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 48 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
48 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector 49 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
49 { 50 {
50 private static readonly ILog m_log = 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 52
54 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | 53 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
55 GroupPowers.Accountable | 54 GroupPowers.Accountable |
@@ -61,13 +60,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
61 60
62 private bool m_connectorEnabled = false; 61 private bool m_connectorEnabled = false;
63 62
64 private string m_serviceURL = string.Empty; 63 private string m_groupsServerURI = string.Empty;
65 64
66 private bool m_disableKeepAlive = false; 65 private bool m_disableKeepAlive = false;
67 66
68 private string m_groupReadKey = string.Empty; 67 private string m_groupReadKey = string.Empty;
69 private string m_groupWriteKey = string.Empty; 68 private string m_groupWriteKey = string.Empty;
70 69
70 private IUserService m_userService = null;
71 private CommunicationsManager m_commManager = null;
72
73 private bool m_debugEnabled = false;
74
75
76 // Used to track which agents are have dropped from a group chat session
77 // Should be reset per agent, on logon
78 // TODO: move this to Flotsam XmlRpc Service
79 // SessionID, List<AgentID>
80 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
81 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
82
71 83
72 #region IRegionModuleBase Members 84 #region IRegionModuleBase Members
73 85
@@ -104,11 +116,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
104 116
105 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 117 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
106 118
107 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty); 119 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", groupsConfig.GetString("XmlRpcServiceURL", string.Empty));
108 if ((m_serviceURL == null) || 120 if ((m_groupsServerURI == null) ||
109 (m_serviceURL == string.Empty)) 121 (m_groupsServerURI == string.Empty))
110 { 122 {
111 m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]"); 123 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
112 m_connectorEnabled = false; 124 m_connectorEnabled = false;
113 return; 125 return;
114 } 126 }
@@ -118,6 +130,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
118 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 130 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
119 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 131 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
120 132
133 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
134
135
121 // If we got all the config options we need, lets start'er'up 136 // If we got all the config options we need, lets start'er'up
122 m_connectorEnabled = true; 137 m_connectorEnabled = true;
123 } 138 }
@@ -131,13 +146,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
131 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 146 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
132 { 147 {
133 if (m_connectorEnabled) 148 if (m_connectorEnabled)
149 {
134 scene.RegisterModuleInterface<IGroupsServicesConnector>(this); 150 scene.RegisterModuleInterface<IGroupsServicesConnector>(this);
151
152 if (m_userService == null)
153 {
154 m_userService = scene.CommsManager.UserService;
155 m_commManager = scene.CommsManager;
156 }
157 }
135 } 158 }
136 159
137 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene) 160 public void RemoveRegion(OpenSim.Region.Framework.Scenes.Scene scene)
138 { 161 {
139 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this) 162 if (scene.RequestModuleInterface<IGroupsServicesConnector>() == this)
163 {
140 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this); 164 scene.UnregisterModuleInterface<IGroupsServicesConnector>(this);
165 }
141 } 166 }
142 167
143 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene) 168 public void RegionLoaded(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -157,14 +182,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
157 182
158 #endregion 183 #endregion
159 184
160
161
162 #region IGroupsServicesConnector Members 185 #region IGroupsServicesConnector Members
163 186
164 /// <summary> 187 /// <summary>
165 /// 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. 188 /// 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.
166 /// </summary> 189 /// </summary>
167 public UUID CreateGroup(GroupRequestID requestID, string name, string charter, bool showInList, UUID insigniaID, 190 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
168 int membershipFee, bool openEnrollment, bool allowPublish, 191 int membershipFee, bool openEnrollment, bool allowPublish,
169 bool maturePublish, UUID founderID) 192 bool maturePublish, UUID founderID)
170 { 193 {
@@ -236,7 +259,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
236 259
237 260
238 261
239 Hashtable respData = XmlRpcCall(requestID, "groups.createGroup", param); 262 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param);
240 263
241 if (respData.Contains("error")) 264 if (respData.Contains("error"))
242 { 265 {
@@ -248,7 +271,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
248 return UUID.Parse((string)respData["GroupID"]); 271 return UUID.Parse((string)respData["GroupID"]);
249 } 272 }
250 273
251 public void UpdateGroup(GroupRequestID requestID, UUID groupID, string charter, bool showInList, 274 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
252 UUID insigniaID, int membershipFee, bool openEnrollment, 275 UUID insigniaID, int membershipFee, bool openEnrollment,
253 bool allowPublish, bool maturePublish) 276 bool allowPublish, bool maturePublish)
254 { 277 {
@@ -262,10 +285,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
262 param["AllowPublish"] = allowPublish == true ? 1 : 0; 285 param["AllowPublish"] = allowPublish == true ? 1 : 0;
263 param["MaturePublish"] = maturePublish == true ? 1 : 0; 286 param["MaturePublish"] = maturePublish == true ? 1 : 0;
264 287
265 XmlRpcCall(requestID, "groups.updateGroup", param); 288 XmlRpcCall(requestingAgentID, "groups.updateGroup", param);
266 } 289 }
267 290
268 public void AddGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 291 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
269 string title, ulong powers) 292 string title, ulong powers)
270 { 293 {
271 Hashtable param = new Hashtable(); 294 Hashtable param = new Hashtable();
@@ -276,19 +299,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
276 param["Title"] = title; 299 param["Title"] = title;
277 param["Powers"] = powers.ToString(); 300 param["Powers"] = powers.ToString();
278 301
279 XmlRpcCall(requestID, "groups.addRoleToGroup", param); 302 XmlRpcCall(requestingAgentID, "groups.addRoleToGroup", param);
280 } 303 }
281 304
282 public void RemoveGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID) 305 public void RemoveGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID)
283 { 306 {
284 Hashtable param = new Hashtable(); 307 Hashtable param = new Hashtable();
285 param["GroupID"] = groupID.ToString(); 308 param["GroupID"] = groupID.ToString();
286 param["RoleID"] = roleID.ToString(); 309 param["RoleID"] = roleID.ToString();
287 310
288 XmlRpcCall(requestID, "groups.removeRoleFromGroup", param); 311 XmlRpcCall(requestingAgentID, "groups.removeRoleFromGroup", param);
289 } 312 }
290 313
291 public void UpdateGroupRole(GroupRequestID requestID, UUID groupID, UUID roleID, string name, string description, 314 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
292 string title, ulong powers) 315 string title, ulong powers)
293 { 316 {
294 Hashtable param = new Hashtable(); 317 Hashtable param = new Hashtable();
@@ -308,10 +331,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
308 } 331 }
309 param["Powers"] = powers.ToString(); 332 param["Powers"] = powers.ToString();
310 333
311 XmlRpcCall(requestID, "groups.updateGroupRole", param); 334 XmlRpcCall(requestingAgentID, "groups.updateGroupRole", param);
312 } 335 }
313 336
314 public GroupRecord GetGroupRecord(GroupRequestID requestID, UUID GroupID, string GroupName) 337 public GroupRecord GetGroupRecord(UUID requestingAgentID, UUID GroupID, string GroupName)
315 { 338 {
316 Hashtable param = new Hashtable(); 339 Hashtable param = new Hashtable();
317 if (GroupID != UUID.Zero) 340 if (GroupID != UUID.Zero)
@@ -323,7 +346,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
323 param["Name"] = GroupName.ToString(); 346 param["Name"] = GroupName.ToString();
324 } 347 }
325 348
326 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); 349 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
327 350
328 if (respData.Contains("error")) 351 if (respData.Contains("error"))
329 { 352 {
@@ -334,12 +357,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
334 357
335 } 358 }
336 359
337 public GroupProfileData GetMemberGroupProfile(GroupRequestID requestID, UUID GroupID, UUID AgentID) 360 public GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID)
338 { 361 {
339 Hashtable param = new Hashtable(); 362 Hashtable param = new Hashtable();
340 param["GroupID"] = GroupID.ToString(); 363 param["GroupID"] = GroupID.ToString();
341 364
342 Hashtable respData = XmlRpcCall(requestID, "groups.getGroup", param); 365 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroup", param);
343 366
344 if (respData.Contains("error")) 367 if (respData.Contains("error"))
345 { 368 {
@@ -347,38 +370,35 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
347 return new GroupProfileData(); 370 return new GroupProfileData();
348 } 371 }
349 372
350 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestID, AgentID, GroupID); 373 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
351 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); 374 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
352 375
353 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; 376 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
354 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; 377 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
355 378
356 return MemberGroupProfile; 379 return MemberGroupProfile;
357
358 } 380 }
359 381
360 382 public void SetAgentActiveGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
361
362 public void SetAgentActiveGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID)
363 { 383 {
364 Hashtable param = new Hashtable(); 384 Hashtable param = new Hashtable();
365 param["AgentID"] = AgentID.ToString(); 385 param["AgentID"] = AgentID.ToString();
366 param["GroupID"] = GroupID.ToString(); 386 param["GroupID"] = GroupID.ToString();
367 387
368 XmlRpcCall(requestID, "groups.setAgentActiveGroup", param); 388 XmlRpcCall(requestingAgentID, "groups.setAgentActiveGroup", param);
369 } 389 }
370 390
371 public void SetAgentActiveGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 391 public void SetAgentActiveGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
372 { 392 {
373 Hashtable param = new Hashtable(); 393 Hashtable param = new Hashtable();
374 param["AgentID"] = AgentID.ToString(); 394 param["AgentID"] = AgentID.ToString();
375 param["GroupID"] = GroupID.ToString(); 395 param["GroupID"] = GroupID.ToString();
376 param["SelectedRoleID"] = RoleID.ToString(); 396 param["SelectedRoleID"] = RoleID.ToString();
377 397
378 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); 398 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
379 } 399 }
380 400
381 public void SetAgentGroupInfo(GroupRequestID requestID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile) 401 public void SetAgentGroupInfo(UUID requestingAgentID, UUID AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
382 { 402 {
383 Hashtable param = new Hashtable(); 403 Hashtable param = new Hashtable();
384 param["AgentID"] = AgentID.ToString(); 404 param["AgentID"] = AgentID.ToString();
@@ -386,11 +406,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
386 param["AcceptNotices"] = AcceptNotices ? "1" : "0"; 406 param["AcceptNotices"] = AcceptNotices ? "1" : "0";
387 param["ListInProfile"] = ListInProfile ? "1" : "0"; 407 param["ListInProfile"] = ListInProfile ? "1" : "0";
388 408
389 XmlRpcCall(requestID, "groups.setAgentGroupInfo", param); 409 XmlRpcCall(requestingAgentID, "groups.setAgentGroupInfo", param);
390 410
391 } 411 }
392 412
393 public void AddAgentToGroupInvite(GroupRequestID requestID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID) 413 public void AddAgentToGroupInvite(UUID requestingAgentID, UUID inviteID, UUID groupID, UUID roleID, UUID agentID)
394 { 414 {
395 Hashtable param = new Hashtable(); 415 Hashtable param = new Hashtable();
396 param["InviteID"] = inviteID.ToString(); 416 param["InviteID"] = inviteID.ToString();
@@ -398,16 +418,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
398 param["RoleID"] = roleID.ToString(); 418 param["RoleID"] = roleID.ToString();
399 param["GroupID"] = groupID.ToString(); 419 param["GroupID"] = groupID.ToString();
400 420
401 XmlRpcCall(requestID, "groups.addAgentToGroupInvite", param); 421 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupInvite", param);
402 422
403 } 423 }
404 424
405 public GroupInviteInfo GetAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) 425 public GroupInviteInfo GetAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
406 { 426 {
407 Hashtable param = new Hashtable(); 427 Hashtable param = new Hashtable();
408 param["InviteID"] = inviteID.ToString(); 428 param["InviteID"] = inviteID.ToString();
409 429
410 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentToGroupInvite", param); 430 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentToGroupInvite", param);
411 431
412 if (respData.Contains("error")) 432 if (respData.Contains("error"))
413 { 433 {
@@ -423,60 +443,59 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
423 return inviteInfo; 443 return inviteInfo;
424 } 444 }
425 445
426 public void RemoveAgentToGroupInvite(GroupRequestID requestID, UUID inviteID) 446 public void RemoveAgentToGroupInvite(UUID requestingAgentID, UUID inviteID)
427 { 447 {
428 Hashtable param = new Hashtable(); 448 Hashtable param = new Hashtable();
429 param["InviteID"] = inviteID.ToString(); 449 param["InviteID"] = inviteID.ToString();
430 450
431 XmlRpcCall(requestID, "groups.removeAgentToGroupInvite", param); 451 XmlRpcCall(requestingAgentID, "groups.removeAgentToGroupInvite", param);
432 } 452 }
433 453
434 public void AddAgentToGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 454 public void AddAgentToGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
435 { 455 {
436 Hashtable param = new Hashtable(); 456 Hashtable param = new Hashtable();
437 param["AgentID"] = AgentID.ToString(); 457 param["AgentID"] = AgentID.ToString();
438 param["GroupID"] = GroupID.ToString(); 458 param["GroupID"] = GroupID.ToString();
439 param["RoleID"] = RoleID.ToString(); 459 param["RoleID"] = RoleID.ToString();
440 460
441 XmlRpcCall(requestID, "groups.addAgentToGroup", param); 461 XmlRpcCall(requestingAgentID, "groups.addAgentToGroup", param);
442 } 462 }
443 463
444 public void RemoveAgentFromGroup(GroupRequestID requestID, UUID AgentID, UUID GroupID) 464 public void RemoveAgentFromGroup(UUID requestingAgentID, UUID AgentID, UUID GroupID)
445 { 465 {
446 Hashtable param = new Hashtable(); 466 Hashtable param = new Hashtable();
447 param["AgentID"] = AgentID.ToString(); 467 param["AgentID"] = AgentID.ToString();
448 param["GroupID"] = GroupID.ToString(); 468 param["GroupID"] = GroupID.ToString();
449 469
450 XmlRpcCall(requestID, "groups.removeAgentFromGroup", param); 470 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroup", param);
451 } 471 }
452 472
453 public void AddAgentToGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 473 public void AddAgentToGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
454 { 474 {
455 Hashtable param = new Hashtable(); 475 Hashtable param = new Hashtable();
456 param["AgentID"] = AgentID.ToString(); 476 param["AgentID"] = AgentID.ToString();
457 param["GroupID"] = GroupID.ToString(); 477 param["GroupID"] = GroupID.ToString();
458 param["RoleID"] = RoleID.ToString(); 478 param["RoleID"] = RoleID.ToString();
459 479
460 XmlRpcCall(requestID, "groups.addAgentToGroupRole", param); 480 XmlRpcCall(requestingAgentID, "groups.addAgentToGroupRole", param);
461 } 481 }
462 482
463 public void RemoveAgentFromGroupRole(GroupRequestID requestID, UUID AgentID, UUID GroupID, UUID RoleID) 483 public void RemoveAgentFromGroupRole(UUID requestingAgentID, UUID AgentID, UUID GroupID, UUID RoleID)
464 { 484 {
465 Hashtable param = new Hashtable(); 485 Hashtable param = new Hashtable();
466 param["AgentID"] = AgentID.ToString(); 486 param["AgentID"] = AgentID.ToString();
467 param["GroupID"] = GroupID.ToString(); 487 param["GroupID"] = GroupID.ToString();
468 param["RoleID"] = RoleID.ToString(); 488 param["RoleID"] = RoleID.ToString();
469 489
470 XmlRpcCall(requestID, "groups.removeAgentFromGroupRole", param); 490 XmlRpcCall(requestingAgentID, "groups.removeAgentFromGroupRole", param);
471 } 491 }
472 492
473 493 public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
474 public List<DirGroupsReplyData> FindGroups(GroupRequestID requestID, string search)
475 { 494 {
476 Hashtable param = new Hashtable(); 495 Hashtable param = new Hashtable();
477 param["Search"] = search; 496 param["Search"] = search;
478 497
479 Hashtable respData = XmlRpcCall(requestID, "groups.findGroups", param); 498 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);
480 499
481 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>(); 500 List<DirGroupsReplyData> findings = new List<DirGroupsReplyData>();
482 501
@@ -498,13 +517,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
498 return findings; 517 return findings;
499 } 518 }
500 519
501 public GroupMembershipData GetAgentGroupMembership(GroupRequestID requestID, UUID AgentID, UUID GroupID) 520 public GroupMembershipData GetAgentGroupMembership(UUID requestingAgentID, UUID AgentID, UUID GroupID)
502 { 521 {
503 Hashtable param = new Hashtable(); 522 Hashtable param = new Hashtable();
504 param["AgentID"] = AgentID.ToString(); 523 param["AgentID"] = AgentID.ToString();
505 param["GroupID"] = GroupID.ToString(); 524 param["GroupID"] = GroupID.ToString();
506 525
507 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMembership", param); 526 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMembership", param);
508 527
509 if (respData.Contains("error")) 528 if (respData.Contains("error"))
510 { 529 {
@@ -516,12 +535,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
516 return data; 535 return data;
517 } 536 }
518 537
519 public GroupMembershipData GetAgentActiveMembership(GroupRequestID requestID, UUID AgentID) 538 public GroupMembershipData GetAgentActiveMembership(UUID requestingAgentID, UUID AgentID)
520 { 539 {
521 Hashtable param = new Hashtable(); 540 Hashtable param = new Hashtable();
522 param["AgentID"] = AgentID.ToString(); 541 param["AgentID"] = AgentID.ToString();
523 542
524 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentActiveMembership", param); 543 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentActiveMembership", param);
525 544
526 if (respData.Contains("error")) 545 if (respData.Contains("error"))
527 { 546 {
@@ -531,13 +550,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
531 return HashTableToGroupMembershipData(respData); 550 return HashTableToGroupMembershipData(respData);
532 } 551 }
533 552
534 553 public List<GroupMembershipData> GetAgentGroupMemberships(UUID requestingAgentID, UUID AgentID)
535 public List<GroupMembershipData> GetAgentGroupMemberships(GroupRequestID requestID, UUID AgentID)
536 { 554 {
537 Hashtable param = new Hashtable(); 555 Hashtable param = new Hashtable();
538 param["AgentID"] = AgentID.ToString(); 556 param["AgentID"] = AgentID.ToString();
539 557
540 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentGroupMemberships", param); 558 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentGroupMemberships", param);
541 559
542 List<GroupMembershipData> memberships = new List<GroupMembershipData>(); 560 List<GroupMembershipData> memberships = new List<GroupMembershipData>();
543 561
@@ -552,13 +570,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
552 return memberships; 570 return memberships;
553 } 571 }
554 572
555 public List<GroupRolesData> GetAgentGroupRoles(GroupRequestID requestID, UUID AgentID, UUID GroupID) 573 public List<GroupRolesData> GetAgentGroupRoles(UUID requestingAgentID, UUID AgentID, UUID GroupID)
556 { 574 {
557 Hashtable param = new Hashtable(); 575 Hashtable param = new Hashtable();
558 param["AgentID"] = AgentID.ToString(); 576 param["AgentID"] = AgentID.ToString();
559 param["GroupID"] = GroupID.ToString(); 577 param["GroupID"] = GroupID.ToString();
560 578
561 Hashtable respData = XmlRpcCall(requestID, "groups.getAgentRoles", param); 579 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getAgentRoles", param);
562 580
563 List<GroupRolesData> Roles = new List<GroupRolesData>(); 581 List<GroupRolesData> Roles = new List<GroupRolesData>();
564 582
@@ -584,12 +602,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
584 602
585 } 603 }
586 604
587 public List<GroupRolesData> GetGroupRoles(GroupRequestID requestID, UUID GroupID) 605 public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID)
588 { 606 {
589 Hashtable param = new Hashtable(); 607 Hashtable param = new Hashtable();
590 param["GroupID"] = GroupID.ToString(); 608 param["GroupID"] = GroupID.ToString();
591 609
592 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoles", param); 610 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoles", param);
593 611
594 List<GroupRolesData> Roles = new List<GroupRolesData>(); 612 List<GroupRolesData> Roles = new List<GroupRolesData>();
595 613
@@ -617,12 +635,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
617 635
618 636
619 637
620 public List<GroupMembersData> GetGroupMembers(GroupRequestID requestID, UUID GroupID) 638 public List<GroupMembersData> GetGroupMembers(UUID requestingAgentID, UUID GroupID)
621 { 639 {
622 Hashtable param = new Hashtable(); 640 Hashtable param = new Hashtable();
623 param["GroupID"] = GroupID.ToString(); 641 param["GroupID"] = GroupID.ToString();
624 642
625 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupMembers", param); 643 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupMembers", param);
626 644
627 List<GroupMembersData> members = new List<GroupMembersData>(); 645 List<GroupMembersData> members = new List<GroupMembersData>();
628 646
@@ -650,12 +668,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
650 668
651 } 669 }
652 670
653 public List<GroupRoleMembersData> GetGroupRoleMembers(GroupRequestID requestID, UUID GroupID) 671 public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID)
654 { 672 {
655 Hashtable param = new Hashtable(); 673 Hashtable param = new Hashtable();
656 param["GroupID"] = GroupID.ToString(); 674 param["GroupID"] = GroupID.ToString();
657 675
658 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupRoleMembers", param); 676 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupRoleMembers", param);
659 677
660 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>(); 678 List<GroupRoleMembersData> members = new List<GroupRoleMembersData>();
661 679
@@ -674,12 +692,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
674 return members; 692 return members;
675 } 693 }
676 694
677 public List<GroupNoticeData> GetGroupNotices(GroupRequestID requestID, UUID GroupID) 695 public List<GroupNoticeData> GetGroupNotices(UUID requestingAgentID, UUID GroupID)
678 { 696 {
679 Hashtable param = new Hashtable(); 697 Hashtable param = new Hashtable();
680 param["GroupID"] = GroupID.ToString(); 698 param["GroupID"] = GroupID.ToString();
681 699
682 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotices", param); 700 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotices", param);
683 701
684 List<GroupNoticeData> values = new List<GroupNoticeData>(); 702 List<GroupNoticeData> values = new List<GroupNoticeData>();
685 703
@@ -701,12 +719,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
701 return values; 719 return values;
702 720
703 } 721 }
704 public GroupNoticeInfo GetGroupNotice(GroupRequestID requestID, UUID noticeID) 722 public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID)
705 { 723 {
706 Hashtable param = new Hashtable(); 724 Hashtable param = new Hashtable();
707 param["NoticeID"] = noticeID.ToString(); 725 param["NoticeID"] = noticeID.ToString();
708 726
709 Hashtable respData = XmlRpcCall(requestID, "groups.getGroupNotice", param); 727 Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param);
710 728
711 729
712 if (respData.Contains("error")) 730 if (respData.Contains("error"))
@@ -732,7 +750,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
732 750
733 return data; 751 return data;
734 } 752 }
735 public void AddGroupNotice(GroupRequestID requestID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) 753 public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket)
736 { 754 {
737 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); 755 string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, "");
738 756
@@ -745,7 +763,70 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
745 param["BinaryBucket"] = binBucket; 763 param["BinaryBucket"] = binBucket;
746 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString(); 764 param["TimeStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
747 765
748 XmlRpcCall(requestID, "groups.addGroupNotice", param); 766 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
767 }
768
769
770
771 #endregion
772
773 #region GroupSessionTracking
774
775 public void ResetAgentGroupChatSessions(UUID agentID)
776 {
777 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
778 {
779 agentList.Remove(agentID);
780 }
781 }
782
783 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
784 {
785 // If we're tracking this group, and we can find them in the tracking, then they've been invited
786 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
787 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
788 }
789
790 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
791 {
792 // If we're tracking drops for this group,
793 // and we find them, well... then they've dropped
794 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
795 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
796 }
797
798 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
799 {
800 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
801 {
802 // If not in dropped list, add
803 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
804 {
805 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
806 }
807 }
808 }
809
810 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
811 {
812 // Add Session Status if it doesn't exist for this session
813 CreateGroupChatSessionTracking(groupID);
814
815 // If nessesary, remove from dropped list
816 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
817 {
818 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
819 }
820 }
821
822 private void CreateGroupChatSessionTracking(UUID groupID)
823 {
824 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
825 {
826 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
827 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
828 }
829
749 } 830 }
750 #endregion 831 #endregion
751 832
@@ -778,7 +859,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
778 859
779 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile) 860 private GroupRecord GroupProfileHashtableToGroupRecord(Hashtable groupProfile)
780 { 861 {
781
782 GroupRecord group = new GroupRecord(); 862 GroupRecord group = new GroupRecord();
783 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]); 863 group.GroupID = UUID.Parse((string)groupProfile["GroupID"]);
784 group.GroupName = groupProfile["Name"].ToString(); 864 group.GroupName = groupProfile["Name"].ToString();
@@ -797,6 +877,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
797 877
798 return group; 878 return group;
799 } 879 }
880
800 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData) 881 private static GroupMembershipData HashTableToGroupMembershipData(Hashtable respData)
801 { 882 {
802 GroupMembershipData data = new GroupMembershipData(); 883 GroupMembershipData data = new GroupMembershipData();
@@ -829,6 +910,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
829 data.MembershipFee = int.Parse((string)respData["MembershipFee"]); 910 data.MembershipFee = int.Parse((string)respData["MembershipFee"]);
830 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1"); 911 data.OpenEnrollment = ((string)respData["OpenEnrollment"] == "1");
831 data.ShowInList = ((string)respData["ShowInList"] == "1"); 912 data.ShowInList = ((string)respData["ShowInList"] == "1");
913
832 return data; 914 return data;
833 } 915 }
834 916
@@ -837,20 +919,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
837 /// <summary> 919 /// <summary>
838 /// Encapsulate the XmlRpc call to standardize security and error handling. 920 /// Encapsulate the XmlRpc call to standardize security and error handling.
839 /// </summary> 921 /// </summary>
840 private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) 922 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
841 { 923 {
842 if (requestID == null) 924 string UserService;
843 { 925 UUID SessionID;
844 requestID = new GroupRequestID(); 926 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
845 } 927 param.Add("RequestingAgentID", requestingAgentID.ToString());
846 param.Add("RequestingAgentID", requestID.AgentID.ToString()); 928 param.Add("RequestingAgentUserService", UserService);
847 param.Add("RequestingAgentUserService", requestID.UserServiceURL); 929 param.Add("RequestingSessionID", SessionID.ToString());
848 param.Add("RequestingSessionID", requestID.SessionID.ToString());
849 930
850 931
851 param.Add("ReadKey", m_groupReadKey); 932 param.Add("ReadKey", m_groupReadKey);
852 param.Add("WriteKey", m_groupWriteKey); 933 param.Add("WriteKey", m_groupWriteKey);
853 934
935 if (m_debugEnabled)
936 {
937 m_log.Debug("[XMLRPCGROUPDATA] XmlRpcCall Params:");
938 foreach (string key in param.Keys)
939 {
940 m_log.DebugFormat("[XMLRPCGROUPDATA] {0} : {1}", key, param[key]);
941 }
942 }
854 943
855 IList parameters = new ArrayList(); 944 IList parameters = new ArrayList();
856 parameters.Add(param); 945 parameters.Add(param);
@@ -862,7 +951,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
862 951
863 try 952 try
864 { 953 {
865 resp = req.Send(m_serviceURL, 10000); 954 resp = req.Send(m_groupsServerURI, 10000);
866 } 955 }
867 catch (Exception e) 956 catch (Exception e)
868 { 957 {
@@ -871,10 +960,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
871 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); 960 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
872 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); 961 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
873 962
874 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) 963 if ((req != null) && (req.RequestResponse != null))
964 {
965 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
875 { 966 {
876 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); 967 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
877 } 968 }
969 }
878 970
879 foreach (string key in param.Keys) 971 foreach (string key in param.Keys)
880 { 972 {
@@ -886,12 +978,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
886 return respData; 978 return respData;
887 } 979 }
888 980
981
889 if (resp.Value is Hashtable) 982 if (resp.Value is Hashtable)
890 { 983 {
891 Hashtable respData = (Hashtable)resp.Value; 984 Hashtable respData = (Hashtable)resp.Value;
892 if (respData.Contains("error") && !respData.Contains("succeed")) 985 if (respData.Contains("error") && !respData.Contains("succeed"))
893 { 986 {
894 LogRespDataToConsoleError(respData); 987 LogRespDataToConsoleError(function, respData);
895 } 988 }
896 989
897 return respData; 990 return respData;
@@ -919,32 +1012,75 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
919 return error; 1012 return error;
920 } 1013 }
921 1014
922 private void LogRespDataToConsoleError(Hashtable respData) 1015 private void LogRespDataToConsoleError(string function, Hashtable respData)
923 { 1016 {
1017 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Error data from XmlRpcGroups server method: {0}", function);
924 m_log.Error("[XMLRPCGROUPDATA]: Error:"); 1018 m_log.Error("[XMLRPCGROUPDATA]: Error:");
925 1019
926 foreach (string key in respData.Keys) 1020 foreach (string key in respData.Keys)
927 { 1021 {
928 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); 1022 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key);
929 1023
930 string[] lines = respData[key].ToString().Split(new char[] { '\n' }); 1024 if ((respData != null) && (respData.ContainsKey(key)) && (respData[key]!=null))
931 foreach (string line in lines)
932 { 1025 {
933 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); 1026 string[] lines = respData[key].ToString().Split(new char[] { '\n' });
1027 foreach (string line in lines)
1028 {
1029 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line);
1030 }
1031 }
1032 else
1033 {
1034 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} : Empty/NULL", key);
934 } 1035 }
935 1036
936 } 1037 }
937 } 1038 }
938 1039
1040
1041 /// <summary>
1042 /// Group Request Tokens are an attempt to allow the groups service to authenticate
1043 /// requests.
1044 /// TODO: This broke after the big grid refactor, either find a better way, or discard this
1045 /// </summary>
1046 /// <param name="client"></param>
1047 /// <returns></returns>
1048 private void GetClientGroupRequestID(UUID AgentID, out string UserServiceURL, out UUID SessionID)
1049 {
1050 // Default to local grid user service
1051 UserServiceURL = m_commManager.NetworkServersInfo.UserURL; ;
939 1052
940 } 1053 // if AgentID == UUID, there will be no SessionID. This will be true when
1054 // the region is requesting information for region use (object permissions for example)
1055 SessionID = UUID.Zero;
941 1056
942 public class GroupNoticeInfo 1057 // Attempt to get User Profile, for SessionID
943 { 1058 UserProfileData userProfile = m_userService.GetUserProfile(AgentID);
944 public GroupNoticeData noticeData = new GroupNoticeData(); 1059
945 public UUID GroupID = UUID.Zero; 1060 if ((userProfile != null) && (userProfile is ForeignUserProfileData))
946 public string Message = string.Empty; 1061 {
947 public byte[] BinaryBucket = new byte[0]; 1062 // They aren't from around here
1063 ForeignUserProfileData fupd = (ForeignUserProfileData)userProfile;
1064 UserServiceURL = fupd.UserServerURI;
1065 SessionID = fupd.CurrentAgent.SessionID;
1066
1067 }
1068 else if (userProfile != null)
1069 {
1070 // Local, just use the local SessionID
1071 SessionID = userProfile.CurrentAgent.SessionID;
1072 }
1073 else if (AgentID != UUID.Zero)
1074 {
1075 // This should be impossible. If I've been passed a reference to a client
1076 // that client should be registered with the UserService. So something
1077 // is horribly wrong somewhere.
1078
1079 // m_log.WarnFormat("[XMLRPCGROUPDATA]: Could not find a UserServiceURL for {0}", AgentID);
1080
1081 }
1082 }
1083
948 } 1084 }
949} 1085}
950 1086
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index c653e98..672109b 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -146,6 +146,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
146 c.Position = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30); 146 c.Position = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30);
147 c.Sender = null; 147 c.Sender = null;
148 c.SenderUUID = UUID.Zero; 148 c.SenderUUID = UUID.Zero;
149 c.Scene = m_scene;
149 150
150 m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}", 151 m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}",
151 m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); 152 m_scene.RegionInfo.RegionName, c.Message, m_channelNotify);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3b2c9b1..e4e087f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -9784,90 +9784,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9784 9784
9785 Notecard nc = new Notecard(); 9785 Notecard nc = new Notecard();
9786 nc.lastRef = DateTime.Now; 9786 nc.lastRef = DateTime.Now;
9787 nc.text = ParseText(text.Replace("\r", "").Split('\n')); 9787 nc.text = SLUtil.ParseNotecardToList(text).ToArray();
9788 m_Notecards[assetID] = nc; 9788 m_Notecards[assetID] = nc;
9789 } 9789 }
9790 } 9790 }
9791 9791
9792 protected static string[] ParseText(string[] input)
9793 {
9794 int idx = 0;
9795 int level = 0;
9796 List<string> output = new List<string>();
9797 string[] words;
9798
9799 while (idx < input.Length)
9800 {
9801 if (input[idx] == "{")
9802 {
9803 level++;
9804 idx++;
9805 continue;
9806 }
9807
9808 if (input[idx]== "}")
9809 {
9810 level--;
9811 idx++;
9812 continue;
9813 }
9814
9815 switch (level)
9816 {
9817 case 0:
9818 words = input[idx].Split(' '); // Linden text ver
9819 // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard)
9820 if (words.Length < 3)
9821 return new String[0];
9822
9823 int version = int.Parse(words[3]);
9824 if (version != 2)
9825 return new String[0];
9826 break;
9827 case 1:
9828 words = input[idx].Split(' ');
9829 if (words[0] == "LLEmbeddedItems")
9830 break;
9831 if (words[0] == "Text")
9832 {
9833 int len = int.Parse(words[2]);
9834 idx++;
9835
9836 int count = -1;
9837
9838 while (count < len)
9839 {
9840 // int l = input[idx].Length;
9841 string ln = input[idx];
9842
9843 int need = len-count-1;
9844 if (ln.Length > need)
9845 ln = ln.Substring(0, need);
9846
9847 output.Add(ln);
9848 count += ln.Length + 1;
9849 idx++;
9850 }
9851
9852 return output.ToArray();
9853 }
9854 break;
9855 case 2:
9856 words = input[idx].Split(' '); // count
9857 if (words[0] == "count")
9858 {
9859 int c = int.Parse(words[1]);
9860 if (c > 0)
9861 return new String[0];
9862 break;
9863 }
9864 break;
9865 }
9866 idx++;
9867 }
9868 return output.ToArray();
9869 }
9870
9871 public static bool IsCached(UUID assetID) 9792 public static bool IsCached(UUID assetID)
9872 { 9793 {
9873 lock (m_Notecards) 9794 lock (m_Notecards)
@@ -9923,4 +9844,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9923 } 9844 }
9924 } 9845 }
9925 } 9846 }
9926} 9847} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index d8c0ba5..959164b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -32,7 +32,7 @@ using System.Globalization;
32using System.Reflection; 32using System.Reflection;
33using System.IO; 33using System.IO;
34using Microsoft.CSharp; 34using Microsoft.CSharp;
35using Microsoft.JScript; 35//using Microsoft.JScript;
36using Microsoft.VisualBasic; 36using Microsoft.VisualBasic;
37using log4net; 37using log4net;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
@@ -82,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
82 82
83 private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); 83 private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
84 private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); 84 private static VBCodeProvider VBcodeProvider = new VBCodeProvider();
85 private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider(); 85// private static JScriptCodeProvider JScodeProvider = new JScriptCodeProvider();
86 private static CSharpCodeProvider YPcodeProvider = new CSharpCodeProvider(); // YP is translated into CSharp 86 private static CSharpCodeProvider YPcodeProvider = new CSharpCodeProvider(); // YP is translated into CSharp
87 private static YP2CSConverter YP_Converter = new YP2CSConverter(); 87 private static YP2CSConverter YP_Converter = new YP2CSConverter();
88 88
@@ -395,9 +395,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
395 case enumCompileType.vb: 395 case enumCompileType.vb:
396 compileScript = CreateVBCompilerScript(compileScript); 396 compileScript = CreateVBCompilerScript(compileScript);
397 break; 397 break;
398 case enumCompileType.js: 398// case enumCompileType.js:
399 compileScript = CreateJSCompilerScript(compileScript); 399// compileScript = CreateJSCompilerScript(compileScript);
400 break; 400// break;
401 case enumCompileType.yp: 401 case enumCompileType.yp:
402 compileScript = CreateYPCompilerScript(compileScript); 402 compileScript = CreateYPCompilerScript(compileScript);
403 break; 403 break;
@@ -420,16 +420,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
420 } 420 }
421 } 421 }
422 422
423 private static string CreateJSCompilerScript(string compileScript) 423// private static string CreateJSCompilerScript(string compileScript)
424 { 424// {
425 compileScript = String.Empty + 425// compileScript = String.Empty +
426 "import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" + 426// "import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" +
427 "package SecondLife {\r\n" + 427// "package SecondLife {\r\n" +
428 "class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" + 428// "class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
429 compileScript + 429// compileScript +
430 "} }\r\n"; 430// "} }\r\n";
431 return compileScript; 431// return compileScript;
432 } 432// }
433 433
434 private static string CreateCSCompilerScript(string compileScript) 434 private static string CreateCSCompilerScript(string compileScript)
435 { 435 {
@@ -580,10 +580,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
580 } 580 }
581 } while (!complete); 581 } while (!complete);
582 break; 582 break;
583 case enumCompileType.js: 583// case enumCompileType.js:
584 results = JScodeProvider.CompileAssemblyFromSource( 584// results = JScodeProvider.CompileAssemblyFromSource(
585 parameters, Script); 585// parameters, Script);
586 break; 586// break;
587 case enumCompileType.yp: 587 case enumCompileType.yp:
588 results = YPcodeProvider.CompileAssemblyFromSource( 588 results = YPcodeProvider.CompileAssemblyFromSource(
589 parameters, Script); 589 parameters, Script);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index d30d2dc..18351ad 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -541,7 +541,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
541 m_CurrentResult = null; 541 m_CurrentResult = null;
542 } 542 }
543 543
544 return true; 544 return false;
545 } 545 }
546 546
547 public void SetState(string state) 547 public void SetState(string state)
@@ -991,7 +991,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
991 public string GetXMLState() 991 public string GetXMLState()
992 { 992 {
993 bool run = Running; 993 bool run = Running;
994 Stop(100); 994 bool stopped = Stop(100);
995 Running = run; 995 Running = run;
996 996
997 // We should not be doing this, but since we are about to 997 // We should not be doing this, but since we are about to
@@ -1002,6 +1002,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1002 1002
1003 // Force an update of the in-memory plugin data 1003 // Force an update of the in-memory plugin data
1004 // 1004 //
1005 if (!stopped)
1006 return String.Empty;
1007
1005 PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID); 1008 PluginData = AsyncCommandManager.GetSerializationData(m_Engine, m_ItemID);
1006 1009
1007 return ScriptSerializer.Serialize(this); 1010 return ScriptSerializer.Serialize(this);