aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--[-rwxr-xr-x]OpenSim/Region/Application/OpenSim.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs110
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs57
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs1
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs39
-rw-r--r--OpenSim/Region/DataSnapshot/DataSnapshotManager.cs6
-rw-r--r--OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs1
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs29
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs12
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScriptModule.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs80
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs36
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs1
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs128
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs12
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs183
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs273
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs249
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs18
35 files changed, 880 insertions, 517 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 38b2084..1395030 100755..100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -251,8 +251,9 @@ namespace OpenSim
251 "Save named prim to XML2", SavePrimsXml2); 251 "Save named prim to XML2", SavePrimsXml2);
252 252
253 m_console.Commands.AddCommand("region", false, "load oar", 253 m_console.Commands.AddCommand("region", false, "load oar",
254 "load oar [--merge] <oar name>", 254 "load oar [--merge] [--skip-assets] <oar name>",
255 "Load a region's data from OAR archive", LoadOar); 255 "Load a region's data from OAR archive. --merge will merge the oar with the existing scene. --skip-assets will load the oar but ignore the assets it contains",
256 LoadOar);
256 257
257 m_console.Commands.AddCommand("region", false, "save oar", 258 m_console.Commands.AddCommand("region", false, "save oar",
258 "save oar <oar name>", 259 "save oar <oar name>",
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 552f64c..d41deb0 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -182,6 +182,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
182 public event TeleportLocationRequest OnSetStartLocationRequest; 182 public event TeleportLocationRequest OnSetStartLocationRequest;
183 public event UpdateAvatarProperties OnUpdateAvatarProperties; 183 public event UpdateAvatarProperties OnUpdateAvatarProperties;
184 public event CreateNewInventoryItem OnCreateNewInventoryItem; 184 public event CreateNewInventoryItem OnCreateNewInventoryItem;
185 public event LinkInventoryItem OnLinkInventoryItem;
185 public event CreateInventoryFolder OnCreateNewInventoryFolder; 186 public event CreateInventoryFolder OnCreateNewInventoryFolder;
186 public event UpdateInventoryFolder OnUpdateInventoryFolder; 187 public event UpdateInventoryFolder OnUpdateInventoryFolder;
187 public event MoveInventoryFolder OnMoveInventoryFolder; 188 public event MoveInventoryFolder OnMoveInventoryFolder;
@@ -641,7 +642,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
641 if (pprocessor.Async) 642 if (pprocessor.Async)
642 { 643 {
643 object obj = new AsyncPacketProcess(this, pprocessor.method, packet); 644 object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
644 Util.FireAndForget(ProcessSpecificPacketAsync,obj); 645 Util.FireAndForget(ProcessSpecificPacketAsync, obj);
645 result = true; 646 result = true;
646 } 647 }
647 else 648 else
@@ -669,8 +670,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
669 public void ProcessSpecificPacketAsync(object state) 670 public void ProcessSpecificPacketAsync(object state)
670 { 671 {
671 AsyncPacketProcess packetObject = (AsyncPacketProcess)state; 672 AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
672 packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack); 673
673 674 try
675 {
676 packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
677 }
678 catch (Exception e)
679 {
680 // Make sure that we see any exception caused by the asynchronous operation.
681 m_log.Error(
682 string.Format("[LLCLIENTVIEW]: Caught exception while processing {0}", packetObject.Pack), e);
683 }
674 } 684 }
675 685
676 #endregion Packet Handling 686 #endregion Packet Handling
@@ -4726,6 +4736,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4726 AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder); 4736 AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
4727 AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder); 4737 AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
4728 AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem); 4738 AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
4739 AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
4729 AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory); 4740 AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
4730 AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents); 4741 AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
4731 AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents); 4742 AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
@@ -7045,6 +7056,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7045 return true; 7056 return true;
7046 } 7057 }
7047 7058
7059 /// <summary>
7060 /// This is the entry point for the UDP route by which the client can retrieve asset data. If the request
7061 /// is successful then a TransferInfo packet will be sent back, followed by one or more TransferPackets
7062 /// </summary>
7063 /// <param name="sender"></param>
7064 /// <param name="Pack"></param>
7065 /// <returns>This parameter may be ignored since we appear to return true whatever happens</returns>
7048 private bool HandleTransferRequest(IClientAPI sender, Packet Pack) 7066 private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
7049 { 7067 {
7050 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); 7068 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
@@ -7055,7 +7073,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7055 // Has to be done here, because AssetCache can't do it 7073 // Has to be done here, because AssetCache can't do it
7056 // 7074 //
7057 UUID taskID = UUID.Zero; 7075 UUID taskID = UUID.Zero;
7058 if (transfer.TransferInfo.SourceType == 3) 7076 if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
7059 { 7077 {
7060 taskID = new UUID(transfer.TransferInfo.Params, 48); 7078 taskID = new UUID(transfer.TransferInfo.Params, 48);
7061 UUID itemID = new UUID(transfer.TransferInfo.Params, 64); 7079 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
@@ -7326,6 +7344,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7326 return true; 7344 return true;
7327 } 7345 }
7328 7346
7347 private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
7348 {
7349 LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
7350
7351 #region Packet Session and User Check
7352 if (m_checkPackets)
7353 {
7354 if (createLink.AgentData.SessionID != SessionId ||
7355 createLink.AgentData.AgentID != AgentId)
7356 return true;
7357 }
7358 #endregion
7359
7360 LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
7361
7362 if (linkInventoryItem != null)
7363 {
7364 linkInventoryItem(
7365 this,
7366 createLink.InventoryBlock.TransactionID,
7367 createLink.InventoryBlock.FolderID,
7368 createLink.InventoryBlock.CallbackID,
7369 Util.FieldToString(createLink.InventoryBlock.Description),
7370 Util.FieldToString(createLink.InventoryBlock.Name),
7371 createLink.InventoryBlock.InvType,
7372 createLink.InventoryBlock.Type,
7373 createLink.InventoryBlock.OldItemID);
7374 }
7375
7376 return true;
7377 }
7378
7329 private bool HandleFetchInventory(IClientAPI sender, Packet Pack) 7379 private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
7330 { 7380 {
7331 if (OnFetchInventory != null) 7381 if (OnFetchInventory != null)
@@ -7670,12 +7720,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7670 newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask; 7720 newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
7671 newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask; 7721 newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
7672 newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask; 7722 newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
7723
7724 // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
7725 // different
7673 //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned; 7726 //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
7674 newTaskItem.Type = updatetask.InventoryData.Type; 7727 newTaskItem.Type = updatetask.InventoryData.Type;
7675 newTaskItem.InvType = updatetask.InventoryData.InvType; 7728 newTaskItem.InvType = updatetask.InventoryData.InvType;
7676 newTaskItem.Flags = updatetask.InventoryData.Flags; 7729 newTaskItem.Flags = updatetask.InventoryData.Flags;
7677 //newTaskItem.SaleType=updatetask.InventoryData.SaleType; 7730 //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
7678 //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;; 7731 //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
7679 newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name); 7732 newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
7680 newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description); 7733 newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
7681 newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate; 7734 newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
@@ -7683,7 +7736,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7683 newTaskItem, updatetask.UpdateData.LocalID); 7736 newTaskItem, updatetask.UpdateData.LocalID);
7684 } 7737 }
7685 } 7738 }
7686 } 7739 }
7687 7740
7688 return true; 7741 return true;
7689 } 7742 }
@@ -11075,7 +11128,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11075 { 11128 {
11076 if (m_debugPacketLevel >= 255) 11129 if (m_debugPacketLevel >= 255)
11077 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type); 11130 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type);
11078 11131
11079 if (!ProcessPacketMethod(Pack)) 11132 if (!ProcessPacketMethod(Pack))
11080 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type); 11133 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type);
11081 11134
@@ -11297,17 +11350,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11297 return String.Empty; 11350 return String.Empty;
11298 } 11351 }
11299 11352
11300 public void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID) 11353 /// <summary>
11354 /// Make an asset request to the asset service in response to a client request.
11355 /// </summary>
11356 /// <param name="transferRequest"></param>
11357 /// <param name="taskID"></param>
11358 protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
11301 { 11359 {
11302 UUID requestID = UUID.Zero; 11360 UUID requestID = UUID.Zero;
11303 if (transferRequest.TransferInfo.SourceType == 2) 11361 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11304 { 11362 {
11305 //direct asset request
11306 requestID = new UUID(transferRequest.TransferInfo.Params, 0); 11363 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
11307 } 11364 }
11308 else if (transferRequest.TransferInfo.SourceType == 3) 11365 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11309 { 11366 {
11310 //inventory asset request
11311 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 11367 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
11312 //m_log.Debug("[XXX] inventory asset request " + requestID); 11368 //m_log.Debug("[XXX] inventory asset request " + requestID);
11313 //if (taskID == UUID.Zero) // Agent 11369 //if (taskID == UUID.Zero) // Agent
@@ -11320,29 +11376,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11320 // } 11376 // }
11321 } 11377 }
11322 11378
11323 //check to see if asset is in local cache, if not we need to request it from asset server. 11379 //m_log.DebugFormat("[LLCLIENTVIEW]: {0} requesting asset {1}", Name, requestID);
11324 //m_log.Debug("asset request " + requestID);
11325 11380
11326 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11381 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11327
11328 } 11382 }
11329 11383
11384 /// <summary>
11385 /// When we get a reply back from the asset service in response to a client request, send back the data.
11386 /// </summary>
11387 /// <param name="id"></param>
11388 /// <param name="sender"></param>
11389 /// <param name="asset"></param>
11330 protected void AssetReceived(string id, Object sender, AssetBase asset) 11390 protected void AssetReceived(string id, Object sender, AssetBase asset)
11331 { 11391 {
11332 TransferRequestPacket transferRequest = (TransferRequestPacket)sender; 11392 TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
11333 11393
11334 UUID requestID = UUID.Zero; 11394 UUID requestID = UUID.Zero;
11335 byte source = 2; 11395 byte source = (byte)SourceType.Asset;
11336 if ((transferRequest.TransferInfo.SourceType == 2) || (transferRequest.TransferInfo.SourceType == 2222)) 11396
11397 if ((transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11398 || (transferRequest.TransferInfo.SourceType == 2222))
11337 { 11399 {
11338 //direct asset request
11339 requestID = new UUID(transferRequest.TransferInfo.Params, 0); 11400 requestID = new UUID(transferRequest.TransferInfo.Params, 0);
11340 } 11401 }
11341 else if ((transferRequest.TransferInfo.SourceType == 3) || (transferRequest.TransferInfo.SourceType == 3333)) 11402 else if ((transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11403 || (transferRequest.TransferInfo.SourceType == 3333))
11342 { 11404 {
11343 //inventory asset request
11344 requestID = new UUID(transferRequest.TransferInfo.Params, 80); 11405 requestID = new UUID(transferRequest.TransferInfo.Params, 80);
11345 source = 3; 11406 source = (byte)SourceType.SimInventoryItem;
11346 //m_log.Debug("asset request " + requestID); 11407 //m_log.Debug("asset request " + requestID);
11347 } 11408 }
11348 11409
@@ -11355,9 +11416,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11355 if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer())) 11416 if ((userAssets != string.Empty) && (userAssets != m_hyperAssets.GetSimAssetServer()))
11356 { 11417 {
11357 m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id); 11418 m_log.DebugFormat("[CLIENT]: asset {0} not found in local asset storage. Trying user's storage.", id);
11358 if (transferRequest.TransferInfo.SourceType == 2) 11419 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
11359 transferRequest.TransferInfo.SourceType = 2222; // marker 11420 transferRequest.TransferInfo.SourceType = 2222; // marker
11360 else if (transferRequest.TransferInfo.SourceType == 3) 11421 else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
11361 transferRequest.TransferInfo.SourceType = 3333; // marker 11422 transferRequest.TransferInfo.SourceType = 3333; // marker
11362 11423
11363 m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived); 11424 m_assetService.Get(userAssets + "/" + id, transferRequest, AssetReceived);
@@ -11372,7 +11433,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11372 } 11433 }
11373 11434
11374 // Scripts cannot be retrieved by direct request 11435 // Scripts cannot be retrieved by direct request
11375 if (transferRequest.TransferInfo.SourceType == 2 && asset.Type == 10) 11436 if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
11376 return; 11437 return;
11377 11438
11378 // The asset is known to exist and is in our cache, so add it to the AssetRequests list 11439 // The asset is known to exist and is in our cache, so add it to the AssetRequests list
@@ -11605,6 +11666,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11605 public PacketMethod method; 11666 public PacketMethod method;
11606 public bool Async; 11667 public bool Async;
11607 } 11668 }
11669
11608 public class AsyncPacketProcess 11670 public class AsyncPacketProcess
11609 { 11671 {
11610 public bool result = false; 11672 public bool result = false;
diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
index 3b66859..53d2cef 100644
--- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
109 109
110 // Try to parse the texture ID from the request URL 110 // Try to parse the texture ID from the request URL
111 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); 111 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
112 string textureStr = GetOne(query, "texture_id"); 112 string textureStr = query.GetOne("texture_id");
113 113
114 if (m_assetService == null) 114 if (m_assetService == null)
115 { 115 {
@@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
166 166
167 private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture) 167 private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture)
168 { 168 {
169 string range = GetOne(request.Headers, "Range"); 169 string range = request.Headers.GetOne("Range");
170 if (!String.IsNullOrEmpty(range)) 170 if (!String.IsNullOrEmpty(range))
171 { 171 {
172 // Range request 172 // Range request
@@ -216,14 +216,5 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps
216 start = end = 0; 216 start = end = 0;
217 return false; 217 return false;
218 } 218 }
219
220 private static string GetOne(NameValueCollection collection, string key)
221 {
222 string[] values = collection.GetValues(key);
223 if (values != null && values.Length > 0)
224 return values[0];
225
226 return null;
227 }
228 } 219 }
229} 220}
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 23828ef..77e73fb 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -30,6 +30,7 @@ using System.Reflection;
30using log4net; 30using log4net;
31using Nini.Config; 31using Nini.Config;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenMetaverse.Packets;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Region.Framework; 35using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
@@ -169,6 +170,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
169 return true; 170 return true;
170 } 171 }
171 172
173 public void RezMultipleAttachmentsFromInventory(
174 IClientAPI remoteClient,
175 RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
176 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
177 {
178 foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
179 {
180 RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
181 }
182 }
183
172 public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 184 public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
173 { 185 {
174 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name); 186 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
@@ -238,6 +250,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
238 itemID, remoteClient.Name, AttachmentPt); 250 itemID, remoteClient.Name, AttachmentPt);
239 } 251 }
240 252
253 objatt.ResumeScripts();
241 return objatt; 254 return objatt;
242 } 255 }
243 256
@@ -311,6 +324,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
311 } 324 }
312 } 325 }
313 326
327 public void DetachObject(uint objectLocalID, IClientAPI remoteClient)
328 {
329 SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID);
330 if (group != null)
331 {
332 //group.DetachToGround();
333 ShowDetachInUserInventory(group.GetFromItemID(), remoteClient);
334 }
335 }
336
314 public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) 337 public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient)
315 { 338 {
316 ScenePresence presence; 339 ScenePresence presence;
@@ -329,6 +352,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
329 DetachSingleAttachmentToInv(itemID, remoteClient); 352 DetachSingleAttachmentToInv(itemID, remoteClient);
330 } 353 }
331 354
355 public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
356 {
357 SceneObjectPart part = m_scene.GetSceneObjectPart(itemID);
358 if (part == null || part.ParentGroup == null)
359 return;
360
361 UUID inventoryID = part.ParentGroup.GetFromItemID();
362
363 ScenePresence presence;
364 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
365 {
366 if (!m_scene.Permissions.CanRezObject(
367 part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
368 return;
369
370 presence.Appearance.DetachAttachment(itemID);
371
372 if (m_scene.AvatarFactory != null)
373 {
374 m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
375 }
376 part.ParentGroup.DetachToGround();
377
378 List<UUID> uuids = new List<UUID>();
379 uuids.Add(inventoryID);
380 m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids);
381 remoteClient.SendRemoveInventoryItem(inventoryID);
382 }
383
384 m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero);
385 }
386
332 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 387 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
333 // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? 388 // To LocalId or UUID, *THAT* is the question. How now Brown UUID??
334 protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) 389 protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)
@@ -359,4 +414,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
359 } 414 }
360 } 415 }
361 } 416 }
362} \ No newline at end of file 417}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 16e05b7..32a0df9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -621,6 +621,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
621 } 621 }
622 } 622 }
623 623
624 rootPart.ParentGroup.ResumeScripts();
624 return rootPart.ParentGroup; 625 return rootPart.ParentGroup;
625 } 626 }
626 } 627 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index e97d21f..a2f26d5 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -311,10 +311,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
311 { 311 {
312// m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); 312// m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID);
313 313
314 UUID requestedItemId = item.ID;
315
314 item = m_InventoryService.GetItem(item); 316 item = m_InventoryService.GetItem(item);
315 317
316 if (null == item) 318 if (null == item)
317 m_log.ErrorFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", item.ID); 319 m_log.ErrorFormat(
320 "[LOCAL INVENTORY SERVICES CONNECTOR]: Could not find item with id {0}", requestedItemId);
318 321
319 return item; 322 return item;
320 } 323 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 14bab6e..b37beab 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -53,25 +53,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 56 protected Scene m_scene;
57 private static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 57 protected Stream m_loadStream;
58 58 protected Guid m_requestId;
59 private Scene m_scene; 59 protected string m_errorMessage;
60 private Stream m_loadStream;
61 private Guid m_requestId;
62 private string m_errorMessage;
63 60
64 /// <value> 61 /// <value>
65 /// Should the archive being loaded be merged with what is already on the region? 62 /// Should the archive being loaded be merged with what is already on the region?
66 /// </value> 63 /// </value>
67 private bool m_merge; 64 protected bool m_merge;
65
66 /// <value>
67 /// Should we ignore any assets when reloading the archive?
68 /// </value>
69 protected bool m_skipAssets;
68 70
69 /// <summary> 71 /// <summary>
70 /// Used to cache lookups for valid uuids. 72 /// Used to cache lookups for valid uuids.
71 /// </summary> 73 /// </summary>
72 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); 74 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
73 75
74 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) 76 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
75 { 77 {
76 m_scene = scene; 78 m_scene = scene;
77 79
@@ -89,14 +91,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
89 91
90 m_errorMessage = String.Empty; 92 m_errorMessage = String.Empty;
91 m_merge = merge; 93 m_merge = merge;
94 m_skipAssets = skipAssets;
92 m_requestId = requestId; 95 m_requestId = requestId;
93 } 96 }
94 97
95 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId) 98 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
96 { 99 {
97 m_scene = scene; 100 m_scene = scene;
98 m_loadStream = loadStream; 101 m_loadStream = loadStream;
99 m_merge = merge; 102 m_merge = merge;
103 m_skipAssets = skipAssets;
100 m_requestId = requestId; 104 m_requestId = requestId;
101 } 105 }
102 106
@@ -133,9 +137,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
133 137
134 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 138 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
135 { 139 {
136 serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); 140 serialisedSceneObjects.Add(Encoding.UTF8.GetString(data));
137 } 141 }
138 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 142 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets)
139 { 143 {
140 if (LoadAsset(filePath, data)) 144 if (LoadAsset(filePath, data))
141 successfulAssetRestores++; 145 successfulAssetRestores++;
@@ -155,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
155 } 159 }
156 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) 160 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
157 { 161 {
158 serialisedParcels.Add(m_utf8Encoding.GetString(data)); 162 serialisedParcels.Add(Encoding.UTF8.GetString(data));
159 } 163 }
160 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 164 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
161 { 165 {
@@ -178,12 +182,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
178 archive.Close(); 182 archive.Close();
179 } 183 }
180 184
181 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 185 if (!m_skipAssets)
182
183 if (failedAssetRestores > 0)
184 { 186 {
185 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 187 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
186 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); 188
189 if (failedAssetRestores > 0)
190 {
191 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
192 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
193 }
187 } 194 }
188 195
189 if (!m_merge) 196 if (!m_merge)
@@ -279,6 +286,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
279 { 286 {
280 sceneObjectsLoadedCount++; 287 sceneObjectsLoadedCount++;
281 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); 288 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
289 sceneObject.ResumeScripts();
282 } 290 }
283 } 291 }
284 292
@@ -543,7 +551,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
543 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); 551 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
544 552
545 XmlTextReader xtr 553 XmlTextReader xtr
546 = new XmlTextReader(m_asciiEncoding.GetString(data), XmlNodeType.Document, context); 554 = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
547 555
548 RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; 556 RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;
549 557
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index fc8d4e1..82ede01 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -94,8 +94,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) 94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
95 { 95 {
96 bool mergeOar = false; 96 bool mergeOar = false;
97 bool skipAssets = false;
97 98
98 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); 99 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
100 options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
101
99 List<string> mainParams = options.Parse(cmdparams); 102 List<string> mainParams = options.Parse(cmdparams);
100 103
101// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); 104// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
@@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
105 108
106 if (mainParams.Count > 2) 109 if (mainParams.Count > 2)
107 { 110 {
108 DearchiveRegion(mainParams[2], mergeOar, Guid.Empty); 111 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
109 } 112 }
110 else 113 else
111 { 114 {
112 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty); 115 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty);
113 } 116 }
114 } 117 }
115 118
@@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
154 157
155 public void DearchiveRegion(string loadPath) 158 public void DearchiveRegion(string loadPath)
156 { 159 {
157 DearchiveRegion(loadPath, false, Guid.Empty); 160 DearchiveRegion(loadPath, false, false, Guid.Empty);
158 } 161 }
159 162
160 public void DearchiveRegion(string loadPath, bool merge, Guid requestId) 163 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
161 { 164 {
162 m_log.InfoFormat( 165 m_log.InfoFormat(
163 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 166 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
164 167
165 new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion(); 168 new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
166 } 169 }
167 170
168 public void DearchiveRegion(Stream loadStream) 171 public void DearchiveRegion(Stream loadStream)
169 { 172 {
170 DearchiveRegion(loadStream, false, Guid.Empty); 173 DearchiveRegion(loadStream, false, false, Guid.Empty);
171 } 174 }
172 175
173 public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId) 176 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
174 { 177 {
175 new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion(); 178 new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
176 } 179 }
177 } 180 }
178} 181}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index de16d89..624dc22 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -442,7 +442,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
442 byte[] archive = archiveWriteStream.ToArray(); 442 byte[] archive = archiveWriteStream.ToArray();
443 MemoryStream archiveReadStream = new MemoryStream(archive); 443 MemoryStream archiveReadStream = new MemoryStream(archive);
444 444
445 m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); 445 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty);
446 446
447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index 0f830e1..d940564 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -162,7 +162,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions
162 private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); 162 private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>();
163 private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); 163 private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>();
164 private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); 164 private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>();
165 private IFriendsModule m_friendsModule = null; 165 private IFriendsModule m_friendsModule;
166 private IGroupsModule m_groupsModule;
166 167
167 #endregion 168 #endregion
168 169
@@ -386,9 +387,12 @@ namespace OpenSim.Region.CoreModules.World.Permissions
386 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 387 m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
387 388
388 if (m_friendsModule == null) 389 if (m_friendsModule == null)
389 m_log.Error("[PERMISSIONS]: Friends module not found, friend permissions will not work"); 390 m_log.Warn("[PERMISSIONS]: Friends module not found, friend permissions will not work");
390 else 391
391 m_log.Info("[PERMISSIONS]: Friends module found, friend permissions enabled"); 392 m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
393
394 if (m_groupsModule == null)
395 m_log.Warn("[PERMISSIONS]: Groups module not found, group permissions will not work");
392 } 396 }
393 397
394 public void Close() 398 public void Close()
@@ -423,14 +427,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
423 // with the powers requested (powers = 0 for no powers check) 427 // with the powers requested (powers = 0 for no powers check)
424 protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) 428 protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers)
425 { 429 {
426 ScenePresence sp = m_scene.GetScenePresence(userID); 430 if (null == m_groupsModule)
427 if (sp != null) 431 return false;
428 { 432
429 IClientAPI client = sp.ControllingClient; 433 GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID);
430 434
431 return ((groupID == client.ActiveGroupId) && (client.ActiveGroupPowers != 0) && 435 if (gmd != null)
432 ((powers == 0) || ((client.ActiveGroupPowers & powers) == powers))); 436 {
437 if (((gmd.GroupPowers != 0) && powers == 0) || (gmd.GroupPowers & powers) == powers)
438 return true;
433 } 439 }
440
434 return false; 441 return false;
435 } 442 }
436 443
@@ -721,8 +728,17 @@ namespace OpenSim.Region.CoreModules.World.Permissions
721 permission = false; 728 permission = false;
722 } 729 }
723 730
731// m_log.DebugFormat(
732// "[PERMISSIONS]: group.GroupID = {0}, part.GroupMask = {1}, isGroupMember = {2} for {3}",
733// group.GroupID,
734// m_scene.GetSceneObjectPart(objId).GroupMask,
735// IsGroupMember(group.GroupID, currentUser, 0),
736// currentUser);
737
724 // Group members should be able to edit group objects 738 // Group members should be able to edit group objects
725 if ((group.GroupID != UUID.Zero) && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0) && IsGroupMember(group.GroupID, currentUser, 0)) 739 if ((group.GroupID != UUID.Zero)
740 && ((m_scene.GetSceneObjectPart(objId).GroupMask & (uint)PermissionMask.Modify) != 0)
741 && IsGroupMember(group.GroupID, currentUser, 0))
726 { 742 {
727 // Return immediately, so that the administrator can shares group objects 743 // Return immediately, so that the administrator can shares group objects
728 return true; 744 return true;
@@ -957,7 +973,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions
957 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name); 973 DebugPermissionInformation(MethodInfo.GetCurrentMethod().Name);
958 if (m_bypassPermissions) return m_bypassPermissionsValue; 974 if (m_bypassPermissions) return m_bypassPermissionsValue;
959 975
960
961 return GenericObjectPermission(editorID, objectID, false); 976 return GenericObjectPermission(editorID, objectID, false);
962 } 977 }
963 978
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
index 6949d7c..9fc002b 100644
--- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Region.DataSnapshot
94 if (!m_configLoaded) 94 if (!m_configLoaded)
95 { 95 {
96 m_configLoaded = true; 96 m_configLoaded = true;
97 m_log.Info("[DATASNAPSHOT]: Loading configuration"); 97 //m_log.Debug("[DATASNAPSHOT]: Loading configuration");
98 //Read from the config for options 98 //Read from the config for options
99 lock (m_syncInit) 99 lock (m_syncInit)
100 { 100 {
@@ -123,7 +123,7 @@ namespace OpenSim.Region.DataSnapshot
123 } 123 }
124 catch (Exception) 124 catch (Exception)
125 { 125 {
126 m_log.Info("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled."); 126 m_log.Warn("[DATASNAPSHOT]: Could not load configuration. DataSnapshot will be disabled.");
127 m_enabled = false; 127 m_enabled = false;
128 return; 128 return;
129 } 129 }
@@ -179,7 +179,7 @@ namespace OpenSim.Region.DataSnapshot
179 } 179 }
180 else 180 else
181 { 181 {
182 m_log.Warn("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); 182 //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else).");
183 } 183 }
184 } 184 }
185 185
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index 8d27f9c..09611af 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -129,6 +129,7 @@ namespace OpenSim.Region.Examples.SimpleModule
129 public event Action<UUID> OnRemoveAvatar; 129 public event Action<UUID> OnRemoveAvatar;
130 130
131 public event CreateNewInventoryItem OnCreateNewInventoryItem; 131 public event CreateNewInventoryItem OnCreateNewInventoryItem;
132 public event LinkInventoryItem OnLinkInventoryItem;
132 public event CreateInventoryFolder OnCreateNewInventoryFolder; 133 public event CreateInventoryFolder OnCreateNewInventoryFolder;
133 public event UpdateInventoryFolder OnUpdateInventoryFolder; 134 public event UpdateInventoryFolder OnUpdateInventoryFolder;
134 public event MoveInventoryFolder OnMoveInventoryFolder; 135 public event MoveInventoryFolder OnMoveInventoryFolder;
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 0222b02..f8af367 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using OpenMetaverse; 29using OpenMetaverse;
30using OpenMetaverse.Packets;
30using OpenSim.Framework; 31using OpenSim.Framework;
31using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
32 33
@@ -82,6 +83,34 @@ namespace OpenSim.Region.Framework.Interfaces
82 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); 83 IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
83 84
84 /// <summary> 85 /// <summary>
86 /// Rez multiple attachments from a user's inventory
87 /// </summary>
88 /// <param name="remoteClient"></param>
89 /// <param name="header"></param>
90 /// <param name="objects"></param>
91 void RezMultipleAttachmentsFromInventory(
92 IClientAPI remoteClient,
93 RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
94 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects);
95
96 /// <summary>
97 /// Detach an object from the avatar.
98 /// </summary>
99 ///
100 /// This method is called in response to a client's detach request, so we only update the information in
101 /// inventory
102 /// <param name="objectLocalID"></param>
103 /// <param name="remoteClient"></param>
104 void DetachObject(uint objectLocalID, IClientAPI remoteClient);
105
106 /// <summary>
107 /// Detach the given item to the ground.
108 /// </summary>
109 /// <param name="itemID"></param>
110 /// <param name="remoteClient"></param>
111 void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient);
112
113 /// <summary>
85 /// Update the user inventory to the attachment of an item 114 /// Update the user inventory to the attachment of an item
86 /// </summary> 115 /// </summary>
87 /// <param name="att"></param> 116 /// <param name="att"></param>
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 16ca3f9..4dd50d6 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -73,6 +73,9 @@ namespace OpenSim.Region.Framework.Interfaces
73 /// </summary> 73 /// </summary>
74 void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); 74 void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
75 75
76 ArrayList GetScriptErrors(UUID itemID);
77 void ResumeScripts();
78
76 /// <summary> 79 /// <summary>
77 /// Stop all the scripts in this entity. 80 /// Stop all the scripts in this entity.
78 /// </summary> 81 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
index 991d60c..89e59d0 100644
--- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs
@@ -90,8 +90,12 @@ namespace OpenSim.Region.Framework.Interfaces
90 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region 90 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
91 /// settings in the archive will be ignored. 91 /// settings in the archive will be ignored.
92 /// </param> 92 /// </param>
93 /// <param name="skipAssets">
94 /// If true, the archive is loaded without loading any assets contained within it. This is useful if the
95 /// assets are already known to be present in the grid's asset service.
96 /// </param>
93 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 97 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
94 void DearchiveRegion(string loadPath, bool merge, Guid requestId); 98 void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId);
95 99
96 /// <summary> 100 /// <summary>
97 /// Dearchive a region from a stream. This replaces the existing scene. 101 /// Dearchive a region from a stream. This replaces the existing scene.
@@ -113,7 +117,11 @@ namespace OpenSim.Region.Framework.Interfaces
113 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region 117 /// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
114 /// settings in the archive will be ignored. 118 /// settings in the archive will be ignored.
115 /// </param> 119 /// </param>
120 /// <param name="skipAssets">
121 /// If true, the archive is loaded without loading any assets contained within it. This is useful if the
122 /// assets are already known to be present in the grid's asset service.
123 /// </param
116 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> 124 /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
117 void DearchiveRegion(Stream loadStream, bool merge, Guid requestId); 125 void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId);
118 } 126 }
119} 127}
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
index e90b300..fecdd1b 100644
--- a/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScriptModule.cs
@@ -41,6 +41,14 @@ namespace OpenSim.Region.Framework.Interfaces
41 bool PostScriptEvent(UUID itemID, string name, Object[] args); 41 bool PostScriptEvent(UUID itemID, string name, Object[] args);
42 bool PostObjectEvent(UUID itemID, string name, Object[] args); 42 bool PostObjectEvent(UUID itemID, string name, Object[] args);
43 43
44 // Suspend ALL scripts in a given scene object. The item ID
45 // is the UUID of a SOG, and the method acts on all contained
46 // scripts. This is different from the suspend/resume that
47 // can be issued by a client.
48 //
49 void SuspendScript(UUID itemID);
50 void ResumeScript(UUID itemID);
51
44 ArrayList GetScriptErrors(UUID itemID); 52 ArrayList GetScriptErrors(UUID itemID);
45 } 53 }
46} 54}
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index fd7d44f..31ca2ab 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -420,11 +420,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
420 if (m_scenePresence.IsChildAgent) 420 if (m_scenePresence.IsChildAgent)
421 return; 421 return;
422 422
423 m_scenePresence.Scene.ForEachScenePresence( 423 UUID[] animIDs;
424 delegate(ScenePresence SP) 424 int[] sequenceNums;
425 { 425 UUID[] objectIDs;
426 SP.Animator.SendAnimPack(); 426
427 }); 427 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs);
428 client.SendAnimations(animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs);
428 } 429 }
429 430
430 /// <summary> 431 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 357cdc4..bf4c91f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,6 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38
39using OpenSim.Region.Framework; 38using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 40using OpenSim.Region.Framework.Scenes.Serialization;
@@ -64,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes
64 if (group is SceneObjectGroup) 63 if (group is SceneObjectGroup)
65 { 64 {
66 ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); 65 ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
66 ((SceneObjectGroup) group).ResumeScripts();
67 } 67 }
68 } 68 }
69 } 69 }
@@ -218,6 +218,7 @@ namespace OpenSim.Region.Framework.Scenes
218 { 218 {
219 remoteClient.SendAgentAlertMessage("Script saved", false); 219 remoteClient.SendAgentAlertMessage("Script saved", false);
220 } 220 }
221 part.ParentGroup.ResumeScripts();
221 return errors; 222 return errors;
222 } 223 }
223 224
@@ -471,7 +472,6 @@ namespace OpenSim.Region.Framework.Scenes
471 return null; 472 return null;
472 } 473 }
473 474
474
475 if (recipientParentFolderId == UUID.Zero) 475 if (recipientParentFolderId == UUID.Zero)
476 { 476 {
477 InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId); 477 InventoryFolderBase recipientRootFolder = InventoryService.GetRootFolder(recipientId);
@@ -721,6 +721,37 @@ namespace OpenSim.Region.Framework.Scenes
721 } 721 }
722 } 722 }
723 723
724 private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID,
725 uint callbackID, string description, string name,
726 sbyte invType, sbyte type, UUID olditemID)
727 {
728 m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID);
729
730 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
731 return;
732
733 ScenePresence presence;
734 if (TryGetScenePresence(remoteClient.AgentId, out presence))
735 {
736 byte[] data = null;
737
738 AssetBase asset = new AssetBase();
739 asset.FullID = olditemID;
740 asset.Type = type;
741 asset.Name = name;
742 asset.Description = description;
743
744 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, name, 0, callbackID, asset, invType, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch());
745
746 }
747 else
748 {
749 m_log.ErrorFormat(
750 "ScenePresence for agent uuid {0} unexpectedly not found in HandleLinkInventoryItem",
751 remoteClient.AgentId);
752 }
753 }
754
724 /// <summary> 755 /// <summary>
725 /// Remove an inventory item for the client's inventory 756 /// Remove an inventory item for the client's inventory
726 /// </summary> 757 /// </summary>
@@ -1163,6 +1194,7 @@ namespace OpenSim.Region.Framework.Scenes
1163 item = LibraryService.LibraryRootFolder.FindItem(itemID); 1194 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1164 } 1195 }
1165 1196
1197 // If we've found the item in the user's inventory or in the library
1166 if (item != null) 1198 if (item != null)
1167 { 1199 {
1168 part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID); 1200 part.ParentGroup.AddInventoryItem(remoteClient, primLocalID, item, copyID);
@@ -1841,50 +1873,6 @@ namespace OpenSim.Region.Framework.Scenes
1841 EventManager.TriggerStopScript(part.LocalId, itemID); 1873 EventManager.TriggerStopScript(part.LocalId, itemID);
1842 } 1874 }
1843 1875
1844 internal void SendAttachEvent(uint localID, UUID itemID, UUID avatarID)
1845 {
1846 EventManager.TriggerOnAttach(localID, itemID, avatarID);
1847 }
1848
1849 public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
1850 RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects)
1851 {
1852 foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects)
1853 {
1854 AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt);
1855 }
1856 }
1857
1858 public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
1859 {
1860 SceneObjectPart part = GetSceneObjectPart(itemID);
1861 if (part == null || part.ParentGroup == null)
1862 return;
1863
1864 UUID inventoryID = part.ParentGroup.GetFromItemID();
1865
1866 ScenePresence presence;
1867 if (TryGetScenePresence(remoteClient.AgentId, out presence))
1868 {
1869 if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
1870 return;
1871
1872 presence.Appearance.DetachAttachment(itemID);
1873 IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
1874 if (ava != null)
1875 {
1876 ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
1877 }
1878 part.ParentGroup.DetachToGround();
1879
1880 List<UUID> uuids = new List<UUID>();
1881 uuids.Add(inventoryID);
1882 InventoryService.DeleteItems(remoteClient.AgentId, uuids);
1883 remoteClient.SendRemoveInventoryItem(inventoryID);
1884 }
1885 SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
1886 }
1887
1888 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 1876 public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
1889 { 1877 {
1890 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); 1878 EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 671f8fc..58f890f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1159,7 +1159,6 @@ namespace OpenSim.Region.Framework.Scenes
1159 { 1159 {
1160 if (m_scripts_enabled != !ScriptEngine) 1160 if (m_scripts_enabled != !ScriptEngine)
1161 { 1161 {
1162 // Tedd! Here's the method to disable the scripting engine!
1163 if (ScriptEngine) 1162 if (ScriptEngine)
1164 { 1163 {
1165 m_log.Info("Stopping all Scripts in Scene"); 1164 m_log.Info("Stopping all Scripts in Scene");
@@ -1181,6 +1180,7 @@ namespace OpenSim.Region.Framework.Scenes
1181 if (ent is SceneObjectGroup) 1180 if (ent is SceneObjectGroup)
1182 { 1181 {
1183 ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0); 1182 ((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
1183 ((SceneObjectGroup)ent).ResumeScripts();
1184 } 1184 }
1185 } 1185 }
1186 } 1186 }
@@ -2777,6 +2777,7 @@ namespace OpenSim.Region.Framework.Scenes
2777 public virtual void SubscribeToClientInventoryEvents(IClientAPI client) 2777 public virtual void SubscribeToClientInventoryEvents(IClientAPI client)
2778 { 2778 {
2779 client.OnCreateNewInventoryItem += CreateNewInventoryItem; 2779 client.OnCreateNewInventoryItem += CreateNewInventoryItem;
2780 client.OnLinkInventoryItem += HandleLinkInventoryItem;
2780 client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; 2781 client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder;
2781 client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; 2782 client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder;
2782 client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!! 2783 client.OnMoveInventoryFolder += HandleMoveInventoryFolder; // 2; //!!
@@ -2796,14 +2797,13 @@ namespace OpenSim.Region.Framework.Scenes
2796 } 2797 }
2797 2798
2798 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) 2799 public virtual void SubscribeToClientAttachmentEvents(IClientAPI client)
2799 { 2800 {
2800 client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments;
2801 client.OnObjectDetach += m_sceneGraph.DetachObject;
2802
2803 if (AttachmentsModule != null) 2801 if (AttachmentsModule != null)
2804 { 2802 {
2805 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; 2803 client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory;
2804 client.OnRezMultipleAttachmentsFromInv += AttachmentsModule.RezMultipleAttachmentsFromInventory;
2806 client.OnObjectAttach += AttachmentsModule.AttachObject; 2805 client.OnObjectAttach += AttachmentsModule.AttachObject;
2806 client.OnObjectDetach += AttachmentsModule.DetachObject;
2807 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; 2807 client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory;
2808 } 2808 }
2809 } 2809 }
@@ -2952,14 +2952,13 @@ namespace OpenSim.Region.Framework.Scenes
2952 } 2952 }
2953 2953
2954 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) 2954 public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client)
2955 { 2955 {
2956 client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments;
2957 client.OnObjectDetach -= m_sceneGraph.DetachObject;
2958
2959 if (AttachmentsModule != null) 2956 if (AttachmentsModule != null)
2960 { 2957 {
2961 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; 2958 client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory;
2959 client.OnRezMultipleAttachmentsFromInv -= AttachmentsModule.RezMultipleAttachmentsFromInventory;
2962 client.OnObjectAttach -= AttachmentsModule.AttachObject; 2960 client.OnObjectAttach -= AttachmentsModule.AttachObject;
2961 client.OnObjectDetach -= AttachmentsModule.DetachObject;
2963 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; 2962 client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory;
2964 } 2963 }
2965 } 2964 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 3a1962c..3ac34d3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -467,9 +467,7 @@ namespace OpenSim.Region.Framework.Scenes
467 { 467 {
468 SceneObjectGroup group = GetGroupByPrim(objectLocalID); 468 SceneObjectGroup group = GetGroupByPrim(objectLocalID);
469 if (group != null) 469 if (group != null)
470 { 470 m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient);
471 m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient);
472 }
473 } 471 }
474 472
475 protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) 473 protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient)
@@ -1781,6 +1779,7 @@ namespace OpenSim.Region.Framework.Scenes
1781 copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0); 1779 copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0);
1782 copy.HasGroupChanged = true; 1780 copy.HasGroupChanged = true;
1783 copy.ScheduleGroupForFullUpdate(); 1781 copy.ScheduleGroupForFullUpdate();
1782 copy.ResumeScripts();
1784 1783
1785 // required for physics to update it's position 1784 // required for physics to update it's position
1786 copy.AbsolutePosition = copy.AbsolutePosition; 1785 copy.AbsolutePosition = copy.AbsolutePosition;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 8b58b3e..1149a20 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -171,7 +171,9 @@ namespace OpenSim.Region.Framework.Scenes
171 item.NextPermissions; 171 item.NextPermissions;
172 taskItem.NextPermissions = item.NextPermissions; 172 taskItem.NextPermissions = item.NextPermissions;
173 taskItem.CurrentPermissions |= 8; 173 taskItem.CurrentPermissions |= 8;
174 } else { 174 }
175 else
176 {
175 taskItem.BasePermissions = item.BasePermissions; 177 taskItem.BasePermissions = item.BasePermissions;
176 taskItem.CurrentPermissions = item.CurrentPermissions; 178 taskItem.CurrentPermissions = item.CurrentPermissions;
177 taskItem.CurrentPermissions |= 8; 179 taskItem.CurrentPermissions |= 8;
@@ -412,5 +414,13 @@ namespace OpenSim.Region.Framework.Scenes
412 scriptModule.SetXMLState(itemID, n.OuterXml); 414 scriptModule.SetXMLState(itemID, n.OuterXml);
413 } 415 }
414 } 416 }
417
418 public void ResumeScripts()
419 {
420 foreach (SceneObjectPart part in m_parts.Values)
421 {
422 part.Inventory.ResumeScripts();
423 }
424 }
415 } 425 }
416} 426}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index a1991c5..0404422 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -212,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes
212 } 212 }
213 } 213 }
214 214
215 private ArrayList GetScriptErrors(UUID itemID) 215 public ArrayList GetScriptErrors(UUID itemID)
216 { 216 {
217 ArrayList ret = new ArrayList(); 217 ArrayList ret = new ArrayList();
218 218
@@ -653,6 +653,7 @@ namespace OpenSim.Region.Framework.Scenes
653 item.ParentID = m_part.UUID; 653 item.ParentID = m_part.UUID;
654 item.ParentPartID = m_part.UUID; 654 item.ParentPartID = m_part.UUID;
655 item.Name = name; 655 item.Name = name;
656 item.GroupID = m_part.GroupID;
656 657
657 m_items.LockItemsForWrite(true); 658 m_items.LockItemsForWrite(true);
658 m_items.Add(item.ItemID, item); 659 m_items.Add(item.ItemID, item);
@@ -742,6 +743,12 @@ namespace OpenSim.Region.Framework.Scenes
742 item.ParentID = m_part.UUID; 743 item.ParentID = m_part.UUID;
743 item.ParentPartID = m_part.UUID; 744 item.ParentPartID = m_part.UUID;
744 item.Flags = m_items[item.ItemID].Flags; 745 item.Flags = m_items[item.ItemID].Flags;
746
747 // If group permissions have been set on, check that the groupID is up to date in case it has
748 // changed since permissions were last set.
749 if (item.GroupPermissions != (uint)PermissionMask.None)
750 item.GroupID = m_part.GroupID;
751
745 if (item.AssetID == UUID.Zero) 752 if (item.AssetID == UUID.Zero)
746 { 753 {
747 item.AssetID = m_items[item.ItemID].AssetID; 754 item.AssetID = m_items[item.ItemID].AssetID;
@@ -894,6 +901,7 @@ namespace OpenSim.Region.Framework.Scenes
894 uint everyoneMask = 0; 901 uint everyoneMask = 0;
895 uint baseMask = item.BasePermissions; 902 uint baseMask = item.BasePermissions;
896 uint ownerMask = item.CurrentPermissions; 903 uint ownerMask = item.CurrentPermissions;
904 uint groupMask = item.GroupPermissions;
897 905
898 invString.AddItemStart(); 906 invString.AddItemStart();
899 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 907 invString.AddNameValueLine("item_id", item.ItemID.ToString());
@@ -903,7 +911,7 @@ namespace OpenSim.Region.Framework.Scenes
903 911
904 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); 912 invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
905 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); 913 invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
906 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); 914 invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
907 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); 915 invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
908 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); 916 invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
909 917
@@ -1137,5 +1145,29 @@ namespace OpenSim.Region.Framework.Scenes
1137 } 1145 }
1138 return ret; 1146 return ret;
1139 } 1147 }
1148
1149 public void ResumeScripts()
1150 {
1151 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1152 if (engines == null)
1153 return;
1154
1155
1156 Items.LockItemsForRead(true);
1157
1158 foreach (TaskInventoryItem item in m_items.Values)
1159 {
1160 if (item.InvType == (int)InventoryType.LSL)
1161 {
1162 foreach (IScriptModule engine in engines)
1163 {
1164 if (engine != null)
1165 engine.ResumeScript(item.ItemID);
1166 }
1167 }
1168 }
1169
1170 Items.LockItemsForRead(false);
1171 }
1140 } 1172 }
1141} 1173}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 5c54616..c220bf0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -959,6 +959,7 @@ namespace OpenSim.Region.Framework.Scenes
959 959
960 m_isChildAgent = false; 960 m_isChildAgent = false;
961 961
962 // send the animations of the other presences to me
962 m_scene.ForEachScenePresence(delegate(ScenePresence presence) 963 m_scene.ForEachScenePresence(delegate(ScenePresence presence)
963 { 964 {
964 if (presence != this) 965 if (presence != this)
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
index cf0f345..b6677f0 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneXmlLoader.cs
@@ -182,6 +182,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
182 foreach (SceneObjectGroup sceneObject in sceneObjects) 182 foreach (SceneObjectGroup sceneObject in sceneObjects)
183 { 183 {
184 sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0); 184 sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0);
185 sceneObject.ResumeScripts();
185 } 186 }
186 } 187 }
187 188
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index f5b148f..69e78b3 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -724,6 +724,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
724 public event Action<UUID> OnRemoveAvatar; 724 public event Action<UUID> OnRemoveAvatar;
725 public event ObjectPermissions OnObjectPermissions; 725 public event ObjectPermissions OnObjectPermissions;
726 public event CreateNewInventoryItem OnCreateNewInventoryItem; 726 public event CreateNewInventoryItem OnCreateNewInventoryItem;
727 public event LinkInventoryItem OnLinkInventoryItem;
727 public event CreateInventoryFolder OnCreateNewInventoryFolder; 728 public event CreateInventoryFolder OnCreateNewInventoryFolder;
728 public event UpdateInventoryFolder OnUpdateInventoryFolder; 729 public event UpdateInventoryFolder OnUpdateInventoryFolder;
729 public event MoveInventoryFolder OnMoveInventoryFolder; 730 public event MoveInventoryFolder OnMoveInventoryFolder;
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
index e664b44..d49a489 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
109 } 109 }
110 else 110 else
111 { 111 {
112 m_log.WarnFormat("[IRC-Bridge] Not enabled. Connect for region {0} ignored", scene.RegionInfo.RegionName); 112 //m_log.DebugFormat("[IRC-Bridge] Not enabled. Connect for region {0} ignored", scene.RegionInfo.RegionName);
113 } 113 }
114 } 114 }
115 115
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 17a5349..185d44d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -49,9 +49,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
49 49
50 private List<Scene> m_sceneList = new List<Scene>(); 50 private List<Scene> m_sceneList = new List<Scene>();
51 51
52 private IMessageTransferModule m_msgTransferModule = null; 52 private IMessageTransferModule m_msgTransferModule = null;
53 53
54 private IGroupsServicesConnector m_groupData = null; 54 private IGroupsServicesConnector m_groupData = null;
55 55
56 // Config Options 56 // Config Options
57 private bool m_groupMessagingEnabled = false; 57 private bool m_groupMessagingEnabled = false;
@@ -108,13 +108,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
108 if (!m_groupMessagingEnabled) 108 if (!m_groupMessagingEnabled)
109 return; 109 return;
110 110
111 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);
112 112
113 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>(); 113 m_groupData = scene.RequestModuleInterface<IGroupsServicesConnector>();
114 114
115 // No groups module, no groups messaging 115 // No groups module, no groups messaging
116 if (m_groupData == null) 116 if (m_groupData == null)
117 { 117 {
118 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled."); 118 m_log.Error("[GROUPS-MESSAGING]: Could not get IGroupsServicesConnector, GroupsMessagingModule is now disabled.");
119 Close(); 119 Close();
120 m_groupMessagingEnabled = false; 120 m_groupMessagingEnabled = false;
@@ -190,9 +190,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
190 190
191 #endregion 191 #endregion
192 192
193 /// <summary> 193 /// <summary>
194 /// Not really needed, but does confirm that the group exists. 194 /// Not really needed, but does confirm that the group exists.
195 /// </summary> 195 /// </summary>
196 public bool StartGroupChatSession(UUID agentID, UUID groupID) 196 public bool StartGroupChatSession(UUID agentID, UUID groupID)
197 { 197 {
198 if (m_debugEnabled) 198 if (m_debugEnabled)
@@ -201,7 +201,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
201 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); 201 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
202 202
203 if (groupInfo != null) 203 if (groupInfo != null)
204 { 204 {
205 return true; 205 return true;
206 } 206 }
207 else 207 else
@@ -213,11 +213,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
213 public void SendMessageToGroup(GridInstantMessage im, UUID groupID) 213 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
214 { 214 {
215 if (m_debugEnabled) 215 if (m_debugEnabled)
216 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 216 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
217 217
218 218
219 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID)) 219 foreach (GroupMembersData member in m_groupData.GetGroupMembers(UUID.Zero, groupID))
220 { 220 {
221 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) 221 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
222 { 222 {
223 // Don't deliver messages to people who have dropped this session 223 // Don't deliver messages to people who have dropped this session
@@ -226,7 +226,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
226 } 226 }
227 227
228 // Copy Message 228 // Copy Message
229 GridInstantMessage msg = new GridInstantMessage(); 229 GridInstantMessage msg = new GridInstantMessage();
230 msg.imSessionID = groupID.Guid; 230 msg.imSessionID = groupID.Guid;
231 msg.fromAgentName = im.fromAgentName; 231 msg.fromAgentName = im.fromAgentName;
232 msg.message = im.message; 232 msg.message = im.message;
@@ -259,13 +259,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
259 } 259 }
260 } 260 }
261 261
262 #region SimGridEventHandlers 262 #region SimGridEventHandlers
263 263
264 void OnClientLogin(IClientAPI client) 264 void OnClientLogin(IClientAPI client)
265 { 265 {
266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name); 266 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
267 267
268 268
269 } 269 }
270 270
271 private void OnNewClient(IClientAPI client) 271 private void OnNewClient(IClientAPI client)
@@ -303,28 +303,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
303 303
304 private void ProcessMessageFromGroupSession(GridInstantMessage msg) 304 private void ProcessMessageFromGroupSession(GridInstantMessage msg)
305 { 305 {
306 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID); 306 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Session message from {0} going to agent {1}", msg.fromAgentName, msg.toAgentID);
307 307
308 UUID AgentID = new UUID(msg.fromAgentID); 308 UUID AgentID = new UUID(msg.fromAgentID);
309 UUID GroupID = new UUID(msg.imSessionID); 309 UUID GroupID = new UUID(msg.imSessionID);
310 310
311 switch (msg.dialog) 311 switch (msg.dialog)
312 { 312 {
313 case (byte)InstantMessageDialog.SessionAdd: 313 case (byte)InstantMessageDialog.SessionAdd:
314 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 314 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
315 break; 315 break;
316 316
317 case (byte)InstantMessageDialog.SessionDrop: 317 case (byte)InstantMessageDialog.SessionDrop:
318 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID); 318 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
319 break; 319 break;
320 320
321 case (byte)InstantMessageDialog.SessionSend: 321 case (byte)InstantMessageDialog.SessionSend:
322 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) 322 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)
323 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID) 323 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
324 ) 324 )
325 { 325 {
326 // Agent not in session and hasn't dropped from session 326 // Agent not in session and hasn't dropped from session
327 // Add them to the session for now, and Invite them 327 // Add them to the session for now, and Invite them
328 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 328 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
329 329
330 UUID toAgentID = new UUID(msg.toAgentID); 330 UUID toAgentID = new UUID(msg.toAgentID);
@@ -336,10 +336,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
336 { 336 {
337 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message"); 337 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
338 338
339 // Force? open the group session dialog??? 339 // Force? open the group session dialog???
340 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg); 340 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg);
341 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>(); 341 IEventQueue eq = activeClient.Scene.RequestModuleInterface<IEventQueue>();
342 eq.ChatterboxInvitation( 342 eq.ChatterboxInvitation(
343 GroupID 343 GroupID
344 , groupInfo.GroupName 344 , groupInfo.GroupName
345 , new UUID(msg.fromAgentID) 345 , new UUID(msg.fromAgentID)
@@ -357,7 +357,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
357 , Utils.StringToBytes(groupInfo.GroupName) 357 , Utils.StringToBytes(groupInfo.GroupName)
358 ); 358 );
359 359
360 eq.ChatterBoxSessionAgentListUpdates( 360 eq.ChatterBoxSessionAgentListUpdates(
361 new UUID(GroupID) 361 new UUID(GroupID)
362 , new UUID(msg.fromAgentID) 362 , new UUID(msg.fromAgentID)
363 , new UUID(msg.toAgentID) 363 , new UUID(msg.toAgentID)
@@ -367,7 +367,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
367 ); 367 );
368 } 368 }
369 } 369 }
370 } 370 }
371 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) 371 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID))
372 { 372 {
373 // User hasn't dropped, so they're in the session, 373 // User hasn't dropped, so they're in the session,
@@ -394,8 +394,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
394 394
395 #endregion 395 #endregion
396 396
397 397
398 #region ClientEvents 398 #region ClientEvents
399 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 399 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
400 { 400 {
401 if (m_debugEnabled) 401 if (m_debugEnabled)
@@ -407,23 +407,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
407 407
408 // Start group IM session 408 // Start group IM session
409 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 409 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
410 { 410 {
411 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID); 411 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
412 412
413 UUID GroupID = new UUID(im.imSessionID); 413 UUID GroupID = new UUID(im.imSessionID);
414 UUID AgentID = new UUID(im.fromAgentID); 414 UUID AgentID = new UUID(im.fromAgentID);
415 415
416 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); 416 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
417 417
418 if (groupInfo != null) 418 if (groupInfo != null)
419 { 419 {
420 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 420 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
421 421
422 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID); 422 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
423 423
424 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 424 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
425 queue.ChatterBoxSessionAgentListUpdates( 425 queue.ChatterBoxSessionAgentListUpdates(
426 GroupID 426 GroupID
427 , AgentID 427 , AgentID
428 , new UUID(im.toAgentID) 428 , new UUID(im.toAgentID)
429 , false //canVoiceChat 429 , false //canVoiceChat
@@ -435,16 +435,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
435 435
436 // Send a message from locally connected client to a group 436 // Send a message from locally connected client to a group
437 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 437 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
438 { 438 {
439 UUID GroupID = new UUID(im.imSessionID); 439 UUID GroupID = new UUID(im.imSessionID);
440 UUID AgentID = new UUID(im.fromAgentID); 440 UUID AgentID = new UUID(im.fromAgentID);
441 441
442 if (m_debugEnabled) 442 if (m_debugEnabled)
443 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString()); 443 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
444 444
445 //If this agent is sending a message, then they want to be in the session 445 //If this agent is sending a message, then they want to be in the session
446 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 446 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
447 447
448 SendMessageToGroup(im, GroupID); 448 SendMessageToGroup(im, GroupID);
449 } 449 }
450 } 450 }
@@ -501,7 +501,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
501 /// Try to find an active IClientAPI reference for agentID giving preference to root connections 501 /// Try to find an active IClientAPI reference for agentID giving preference to root connections
502 /// </summary> 502 /// </summary>
503 private IClientAPI GetActiveClient(UUID agentID) 503 private IClientAPI GetActiveClient(UUID agentID)
504 { 504 {
505 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); 505 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
506 506
507 IClientAPI child = null; 507 IClientAPI child = null;
@@ -514,26 +514,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
514 { 514 {
515 ScenePresence user = (ScenePresence)scene.Entities[agentID]; 515 ScenePresence user = (ScenePresence)scene.Entities[agentID];
516 if (!user.IsChildAgent) 516 if (!user.IsChildAgent)
517 { 517 {
518 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name); 518 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", user.ControllingClient.Name);
519 return user.ControllingClient; 519 return user.ControllingClient;
520 } 520 }
521 else 521 else
522 { 522 {
523 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name); 523 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", user.ControllingClient.Name);
524 child = user.ControllingClient; 524 child = user.ControllingClient;
525 } 525 }
526 } 526 }
527 } 527 }
528 528
529 // If we didn't find a root, then just return whichever child we found, or null if none 529 // If we didn't find a root, then just return whichever child we found, or null if none
530 if (child == null) 530 if (child == null)
531 { 531 {
532 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); 532 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
533 } 533 }
534 else 534 else
535 { 535 {
536 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); 536 if (m_debugEnabled) m_log.WarnFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
537 } 537 }
538 return child; 538 return child;
539 } 539 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index e5dab93..56c0d98 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -175,13 +175,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
175 } 175 }
176 176
177 scene.EventManager.OnNewClient += OnNewClient; 177 scene.EventManager.OnNewClient += OnNewClient;
178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 178 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
179 // The InstantMessageModule itself doesn't do this, 179 // The InstantMessageModule itself doesn't do this,
180 // so lets see if things explode if we don't do it 180 // so lets see if things explode if we don't do it
181 // scene.EventManager.OnClientClosed += OnClientClosed; 181 // scene.EventManager.OnClientClosed += OnClientClosed;
182 182
183 } 183 }
184 184
185 public void RemoveRegion(Scene scene) 185 public void RemoveRegion(Scene scene)
186 { 186 {
187 if (!m_groupsEnabled) 187 if (!m_groupsEnabled)
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 54ffc81..a046e09 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -70,12 +70,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
70 70
71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket); 71 void AddGroupNotice(UUID RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket);
72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID); 72 GroupNoticeInfo GetGroupNotice(UUID RequestingAgentID, UUID noticeID);
73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID); 73 List<GroupNoticeData> GetGroupNotices(UUID RequestingAgentID, UUID GroupID);
74 74
75 void ResetAgentGroupChatSessions(UUID agentID); 75 void ResetAgentGroupChatSessions(UUID agentID);
76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID); 76 bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID);
77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID); 77 bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID);
78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID); 78 void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID);
79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID); 79 void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID);
80 } 80 }
81 81
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 4867c01..9363205 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -167,6 +167,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
167 167
168 private bool m_debugEnabled = false; 168 private bool m_debugEnabled = false;
169 169
170 private ExpiringCache<string, OSDMap> m_memoryCache;
171 private int m_cacheTimeout = 30;
172
170 // private IUserAccountService m_accountService = null; 173 // private IUserAccountService m_accountService = null;
171 174
172 175
@@ -203,17 +206,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
203 return; 206 return;
204 } 207 }
205 208
206 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 209 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
207 210
208 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); 211 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
209 if ((m_groupsServerURI == null) || 212 if ((m_groupsServerURI == null) ||
210 (m_groupsServerURI == string.Empty)) 213 (m_groupsServerURI == string.Empty))
211 { 214 {
212 m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]"); 215 m_log.ErrorFormat("Please specify a valid Simian Server for GroupsServerURI in OpenSim.ini, [Groups]");
213 m_connectorEnabled = false; 216 m_connectorEnabled = false;
214 return; 217 return;
215 } 218 }
216 219
220
221 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
222 if (m_cacheTimeout == 0)
223 {
224 m_log.WarnFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Disabled.");
225 }
226 else
227 {
228 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout);
229 }
230
231
232
233 m_memoryCache = new ExpiringCache<string,OSDMap>();
234
235
217 // If we got all the config options we need, lets start'er'up 236 // If we got all the config options we need, lets start'er'up
218 m_connectorEnabled = true; 237 m_connectorEnabled = true;
219 238
@@ -224,7 +243,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
224 243
225 public void Close() 244 public void Close()
226 { 245 {
227 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); 246 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name);
228 } 247 }
229 248
230 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 249 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -657,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
657 }; 676 };
658 677
659 678
660 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 679 OSDMap response = CachedPostRequest(requestArgs);
661 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 680 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
662 { 681 {
663 OSDArray entryArray = (OSDArray)response["Entries"]; 682 OSDArray entryArray = (OSDArray)response["Entries"];
@@ -1000,53 +1019,53 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1000 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice); 1019 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
1001 1020
1002 } 1021 }
1003 #endregion 1022 #endregion
1004 1023
1005 #region GroupSessionTracking 1024 #region GroupSessionTracking
1006 1025
1007 public void ResetAgentGroupChatSessions(UUID agentID) 1026 public void ResetAgentGroupChatSessions(UUID agentID)
1008 { 1027 {
1009 Dictionary<string, OSDMap> agentSessions; 1028 Dictionary<string, OSDMap> agentSessions;
1010 1029
1011 if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions)) 1030 if (SimianGetGenericEntries(agentID, "GroupSessionDropped", out agentSessions))
1012 { 1031 {
1013 foreach (string GroupID in agentSessions.Keys) 1032 foreach (string GroupID in agentSessions.Keys)
1014 { 1033 {
1015 SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID); 1034 SimianRemoveGenericEntry(agentID, "GroupSessionDropped", GroupID);
1016 } 1035 }
1017 } 1036 }
1018 1037
1019 if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions)) 1038 if (SimianGetGenericEntries(agentID, "GroupSessionInvited", out agentSessions))
1020 { 1039 {
1021 foreach (string GroupID in agentSessions.Keys) 1040 foreach (string GroupID in agentSessions.Keys)
1022 { 1041 {
1023 SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID); 1042 SimianRemoveGenericEntry(agentID, "GroupSessionInvited", GroupID);
1024 } 1043 }
1025 } 1044 }
1026 } 1045 }
1027 1046
1028 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) 1047 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
1029 { 1048 {
1030 OSDMap session; 1049 OSDMap session;
1031 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); 1050 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1032 } 1051 }
1033 1052
1034 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) 1053 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
1035 { 1054 {
1036 SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap()); 1055 SimianAddGeneric(agentID, "GroupSessionDropped", groupID.ToString(), new OSDMap());
1037 } 1056 }
1038 1057
1039 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) 1058 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
1040 { 1059 {
1041 SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap()); 1060 SimianAddGeneric(agentID, "GroupSessionInvited", groupID.ToString(), new OSDMap());
1042 } 1061 }
1043 1062
1044 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) 1063 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
1045 { 1064 {
1046 OSDMap session; 1065 OSDMap session;
1047 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session); 1066 return SimianGetGenericEntry(agentID, "GroupSessionDropped", groupID.ToString(), out session);
1048 } 1067 }
1049 1068
1050 #endregion 1069 #endregion
1051 1070
1052 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID) 1071 private void EnsureRoleNotSelectedByMember(UUID groupID, UUID roleID, UUID userID)
@@ -1086,7 +1105,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1086 }; 1105 };
1087 1106
1088 1107
1089 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1108 OSDMap Response = CachedPostRequest(RequestArgs);
1090 if (Response["Success"].AsBoolean()) 1109 if (Response["Success"].AsBoolean())
1091 { 1110 {
1092 return true; 1111 return true;
@@ -1113,7 +1132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1113 }; 1132 };
1114 1133
1115 1134
1116 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1135 OSDMap Response = CachedPostRequest(RequestArgs);
1117 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1136 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1118 { 1137 {
1119 OSDArray entryArray = (OSDArray)Response["Entries"]; 1138 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1153,7 +1172,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1153 }; 1172 };
1154 1173
1155 1174
1156 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1175 OSDMap Response = CachedPostRequest(RequestArgs);
1157 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1176 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1158 { 1177 {
1159 OSDArray entryArray = (OSDArray)Response["Entries"]; 1178 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1194,7 +1213,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1194 }; 1213 };
1195 1214
1196 1215
1197 OSDMap Response = WebUtil.PostToService(m_groupsServerURI, RequestArgs); 1216 OSDMap Response = CachedPostRequest(RequestArgs);
1198 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray) 1217 if (Response["Success"].AsBoolean() && Response["Entries"] is OSDArray)
1199 { 1218 {
1200 OSDArray entryArray = (OSDArray)Response["Entries"]; 1219 OSDArray entryArray = (OSDArray)Response["Entries"];
@@ -1234,7 +1253,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1234 1253
1235 1254
1236 1255
1237 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1256 OSDMap response = CachedPostRequest(requestArgs);
1238 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 1257 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1239 { 1258 {
1240 maps = new Dictionary<string, OSDMap>(); 1259 maps = new Dictionary<string, OSDMap>();
@@ -1272,7 +1291,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1272 1291
1273 1292
1274 1293
1275 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1294 OSDMap response = CachedPostRequest(requestArgs);
1276 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) 1295 if (response["Success"].AsBoolean() && response["Entries"] is OSDArray)
1277 { 1296 {
1278 maps = new Dictionary<UUID, OSDMap>(); 1297 maps = new Dictionary<UUID, OSDMap>();
@@ -1310,7 +1329,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1310 }; 1329 };
1311 1330
1312 1331
1313 OSDMap response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1332 OSDMap response = CachedPostRequest(requestArgs);
1314 if (response["Success"].AsBoolean()) 1333 if (response["Success"].AsBoolean())
1315 { 1334 {
1316 return true; 1335 return true;
@@ -1321,8 +1340,50 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1321 return false; 1340 return false;
1322 } 1341 }
1323 } 1342 }
1324 #endregion 1343 #endregion
1325 1344
1345 #region CheesyCache
1346 OSDMap CachedPostRequest(NameValueCollection requestArgs)
1347 {
1348 // Immediately forward the request if the cache is disabled.
1349 if (m_cacheTimeout == 0)
1350 {
1351 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1352 }
1353
1354 // Check if this is an update or a request
1355 if ( requestArgs["RequestMethod"] == "RemoveGeneric"
1356 || requestArgs["RequestMethod"] == "AddGeneric"
1357 )
1358
1359 {
1360 // Any and all updates cause the cache to clear
1361 m_memoryCache.Clear();
1362
1363 // Send update to server, return the response without caching it
1364 return WebUtil.PostToService(m_groupsServerURI, requestArgs);
1365
1366 }
1367
1368 // If we're not doing an update, we must be requesting data
1369
1370 // Create the cache key for the request and see if we have it cached
1371 string CacheKey = WebUtil.BuildQueryString(requestArgs);
1372 OSDMap response = null;
1373 if (!m_memoryCache.TryGetValue(CacheKey, out response))
1374 {
1375 // if it wasn't in the cache, pass the request to the Simian Grid Services
1376 response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1377
1378 // and cache the response
1379 m_memoryCache.AddOrUpdate(CacheKey, response, TimeSpan.FromSeconds(m_cacheTimeout));
1380 }
1381
1382 // return cached response
1383 return response;
1384 }
1385 #endregion
1386
1326 } 1387 }
1327 1388
1328} 1389}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 8e7aa68..79b9a16 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Text;
32 33
33using Nwc.XmlRpc; 34using Nwc.XmlRpc;
34 35
@@ -68,14 +69,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
68 private string m_groupReadKey = string.Empty; 69 private string m_groupReadKey = string.Empty;
69 private string m_groupWriteKey = string.Empty; 70 private string m_groupWriteKey = string.Empty;
70 71
71 private IUserAccountService m_accountService = null; 72 private IUserAccountService m_accountService = null;
72 73
73 // Used to track which agents are have dropped from a group chat session 74 private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
74 // Should be reset per agent, on logon 75 private int m_cacheTimeout = 30;
75 // TODO: move this to Flotsam XmlRpc Service 76
76 // SessionID, List<AgentID> 77 // Used to track which agents are have dropped from a group chat session
77 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>(); 78 // Should be reset per agent, on logon
78 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>(); 79 // TODO: move this to Flotsam XmlRpc Service
80 // SessionID, List<AgentID>
81 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
82 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
79 83
80 84
81 #region IRegionModuleBase Members 85 #region IRegionModuleBase Members
@@ -111,12 +115,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
111 return; 115 return;
112 } 116 }
113 117
114 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name); 118 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name);
115 119
116 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); 120 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty);
117 if ((m_groupsServerURI == null) || 121 if ((m_groupsServerURI == null) ||
118 (m_groupsServerURI == string.Empty)) 122 (m_groupsServerURI == string.Empty))
119 { 123 {
120 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); 124 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]");
121 m_connectorEnabled = false; 125 m_connectorEnabled = false;
122 return; 126 return;
@@ -127,17 +131,26 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
127 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 131 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
128 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 132 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
129 133
130
131 134
135 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
136 if (m_cacheTimeout == 0)
137 {
138 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
139 }
140 else
141 {
142 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
143 }
132 144
133 // If we got all the config options we need, lets start'er'up 145 // If we got all the config options we need, lets start'er'up
146 m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
134 m_connectorEnabled = true; 147 m_connectorEnabled = true;
135 } 148 }
136 } 149 }
137 150
138 public void Close() 151 public void Close()
139 { 152 {
140 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name); 153 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
141 } 154 }
142 155
143 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 156 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -766,67 +779,67 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
766 779
767 780
768 781
769 #endregion 782 #endregion
770 783
771 #region GroupSessionTracking 784 #region GroupSessionTracking
772 785
773 public void ResetAgentGroupChatSessions(UUID agentID) 786 public void ResetAgentGroupChatSessions(UUID agentID)
774 { 787 {
775 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values) 788 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
776 { 789 {
777 agentList.Remove(agentID); 790 agentList.Remove(agentID);
778 } 791 }
779 } 792 }
780 793
781 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID) 794 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
782 { 795 {
783 // If we're tracking this group, and we can find them in the tracking, then they've been invited 796 // If we're tracking this group, and we can find them in the tracking, then they've been invited
784 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID) 797 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
785 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID); 798 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
786 } 799 }
787 800
788 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID) 801 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
789 { 802 {
790 // If we're tracking drops for this group, 803 // If we're tracking drops for this group,
791 // and we find them, well... then they've dropped 804 // and we find them, well... then they've dropped
792 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID) 805 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
793 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID); 806 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
794 } 807 }
795 808
796 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID) 809 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
797 { 810 {
798 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) 811 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
799 { 812 {
800 // If not in dropped list, add 813 // If not in dropped list, add
801 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) 814 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
802 { 815 {
803 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID); 816 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
804 } 817 }
805 } 818 }
806 } 819 }
807 820
808 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID) 821 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
809 { 822 {
810 // Add Session Status if it doesn't exist for this session 823 // Add Session Status if it doesn't exist for this session
811 CreateGroupChatSessionTracking(groupID); 824 CreateGroupChatSessionTracking(groupID);
812 825
813 // If nessesary, remove from dropped list 826 // If nessesary, remove from dropped list
814 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) 827 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
815 { 828 {
816 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID); 829 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
817 } 830 }
818 } 831 }
819 832
820 private void CreateGroupChatSessionTracking(UUID groupID) 833 private void CreateGroupChatSessionTracking(UUID groupID)
821 { 834 {
822 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) 835 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
823 { 836 {
824 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>()); 837 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
825 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>()); 838 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
826 } 839 }
827 840
828 } 841 }
829 #endregion 842 #endregion
830 843
831 #region XmlRpcHashtableMarshalling 844 #region XmlRpcHashtableMarshalling
832 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile) 845 private GroupProfileData GroupProfileHashtableToGroupProfileData(Hashtable groupProfile)
@@ -919,50 +932,84 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
919 /// </summary> 932 /// </summary>
920 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) 933 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
921 { 934 {
922 string UserService; 935 XmlRpcResponse resp = null;
923 UUID SessionID; 936 string CacheKey = null;
924 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
925 param.Add("requestingAgentID", requestingAgentID.ToString());
926 param.Add("RequestingAgentUserService", UserService);
927 param.Add("RequestingSessionID", SessionID.ToString());
928
929 937
930 param.Add("ReadKey", m_groupReadKey); 938 // Only bother with the cache if it isn't disabled.
931 param.Add("WriteKey", m_groupWriteKey); 939 if (m_cacheTimeout > 0)
940 {
941 if (!function.StartsWith("groups.get"))
942 {
943 // Any and all updates cause the cache to clear
944 m_memoryCache.Clear();
945 }
946 else
947 {
948 StringBuilder sb = new StringBuilder(requestingAgentID + function);
949 foreach (object key in param.Keys)
950 {
951 if (param[key] != null)
952 {
953 sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
954 }
955 }
956
957 CacheKey = sb.ToString();
958 m_memoryCache.TryGetValue(CacheKey, out resp);
959 }
932 960
961 }
962
963 if( resp == null )
964 {
965 string UserService;
966 UUID SessionID;
967 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
968 param.Add("requestingAgentID", requestingAgentID.ToString());
969 param.Add("RequestingAgentUserService", UserService);
970 param.Add("RequestingSessionID", SessionID.ToString());
933 971
934 IList parameters = new ArrayList();
935 parameters.Add(param);
936 972
937 ConfigurableKeepAliveXmlRpcRequest req; 973 param.Add("ReadKey", m_groupReadKey);
938 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); 974 param.Add("WriteKey", m_groupWriteKey);
939 975
940 XmlRpcResponse resp = null;
941 976
942 try 977 IList parameters = new ArrayList();
943 { 978 parameters.Add(param);
944 resp = req.Send(m_groupsServerURI, 10000); 979
945 } 980 ConfigurableKeepAliveXmlRpcRequest req;
946 catch (Exception e) 981 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
947 {
948
949 982
950 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
951 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
952 983
953 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None)) 984 try
954 { 985 {
955 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine); 986 resp = req.Send(m_groupsServerURI, 10000);
956 } 987
988 if ((m_cacheTimeout > 0) && (CacheKey != null))
989 {
990 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
991 }
957 992
958 foreach (string key in param.Keys) 993 }
994 catch (Exception e)
959 { 995 {
960 m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString()); 996 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
997 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", e.ToString());
998
999 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
1000 {
1001 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
1002 }
1003
1004 foreach (string key in param.Keys)
1005 {
1006 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
1007 }
1008
1009 Hashtable respData = new Hashtable();
1010 respData.Add("error", e.ToString());
1011 return respData;
961 } 1012 }
962
963 Hashtable respData = new Hashtable();
964 respData.Add("error", e.ToString());
965 return respData;
966 } 1013 }
967 1014
968 if (resp.Value is Hashtable) 1015 if (resp.Value is Hashtable)
@@ -976,21 +1023,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
976 return respData; 1023 return respData;
977 } 1024 }
978 1025
979 m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); 1026 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());
980 1027
981 if (resp.Value is ArrayList) 1028 if (resp.Value is ArrayList)
982 { 1029 {
983 ArrayList al = (ArrayList)resp.Value; 1030 ArrayList al = (ArrayList)resp.Value;
984 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count); 1031 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count);
985 1032
986 foreach (object o in al) 1033 foreach (object o in al)
987 { 1034 {
988 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString()); 1035 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString());
989 } 1036 }
990 } 1037 }
991 else 1038 else
992 { 1039 {
993 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString()); 1040 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString());
994 } 1041 }
995 1042
996 Hashtable error = new Hashtable(); 1043 Hashtable error = new Hashtable();
@@ -1000,16 +1047,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1000 1047
1001 private void LogRespDataToConsoleError(Hashtable respData) 1048 private void LogRespDataToConsoleError(Hashtable respData)
1002 { 1049 {
1003 m_log.Error("[XMLRPCGROUPDATA]: Error:"); 1050 m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:");
1004 1051
1005 foreach (string key in respData.Keys) 1052 foreach (string key in respData.Keys)
1006 { 1053 {
1007 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key); 1054 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key);
1008 1055
1009 string[] lines = respData[key].ToString().Split(new char[] { '\n' }); 1056 string[] lines = respData[key].ToString().Split(new char[] { '\n' });
1010 foreach (string line in lines) 1057 foreach (string line in lines)
1011 { 1058 {
1012 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line); 1059 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line);
1013 } 1060 }
1014 1061
1015 } 1062 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 338c04b..6360c99 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -235,6 +235,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
235 public event Action<UUID> OnRemoveAvatar; 235 public event Action<UUID> OnRemoveAvatar;
236 236
237 public event CreateNewInventoryItem OnCreateNewInventoryItem; 237 public event CreateNewInventoryItem OnCreateNewInventoryItem;
238 public event LinkInventoryItem OnLinkInventoryItem;
238 public event CreateInventoryFolder OnCreateNewInventoryFolder; 239 public event CreateInventoryFolder OnCreateNewInventoryFolder;
239 public event UpdateInventoryFolder OnUpdateInventoryFolder; 240 public event UpdateInventoryFolder OnUpdateInventoryFolder;
240 public event MoveInventoryFolder OnMoveInventoryFolder; 241 public event MoveInventoryFolder OnMoveInventoryFolder;
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index ae148a9..9f6ea35 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -81,6 +81,9 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
81 81
82 void PostEvent(EventParams data); 82 void PostEvent(EventParams data);
83 83
84 void Suspend();
85 void Resume();
86
84 /// <summary> 87 /// <summary>
85 /// Process the next event queued for this script 88 /// Process the next event queued for this script
86 /// </summary> 89 /// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 6ecafd4..9ccc199 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -96,6 +96,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
96 private bool m_startedFromSavedState; 96 private bool m_startedFromSavedState;
97 private UUID m_CurrentStateHash; 97 private UUID m_CurrentStateHash;
98 private UUID m_RegionID; 98 private UUID m_RegionID;
99 private bool m_Suspended = true;
99 100
100 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> 101 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
101 m_LineMap; 102 m_LineMap;
@@ -640,158 +641,160 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
640 /// <returns></returns> 641 /// <returns></returns>
641 public object EventProcessor() 642 public object EventProcessor()
642 { 643 {
644 EventParams data = null;
643 645
644 EventParams data = null; 646 lock (m_EventQueue)
645
646 lock (m_EventQueue)
647 {
648 lock (m_Script)
649 { 647 {
650 data = (EventParams) m_EventQueue.Dequeue(); 648 if (m_Suspended)
651 if (data == null) // Shouldn't happen 649 return 0;
650
651 lock (m_Script)
652 { 652 {
653 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown)) 653 data = (EventParams) m_EventQueue.Dequeue();
654 if (data == null) // Shouldn't happen
654 { 655 {
655 m_CurrentResult = m_Engine.QueueEventHandler(this); 656 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
657 {
658 m_CurrentResult = m_Engine.QueueEventHandler(this);
659 }
660 else
661 {
662 m_CurrentResult = null;
663 }
664 return 0;
656 } 665 }
657 else 666
667 if (data.EventName == "timer")
668 m_TimerQueued = false;
669 if (data.EventName == "control")
658 { 670 {
659 m_CurrentResult = null; 671 if (m_ControlEventsInQueue > 0)
672 m_ControlEventsInQueue--;
660 } 673 }
661 return 0; 674 if (data.EventName == "collision")
662 } 675 m_CollisionInQueue = false;
663
664 if (data.EventName == "timer")
665 m_TimerQueued = false;
666 if (data.EventName == "control")
667 {
668 if (m_ControlEventsInQueue > 0)
669 m_ControlEventsInQueue--;
670 } 676 }
671 if (data.EventName == "collision")
672 m_CollisionInQueue = false;
673 } 677 }
674 } 678 lock(m_Script)
675 lock(m_Script) 679 {
676 { 680
677 681 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
678 //m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
679 682
680 m_DetectParams = data.DetectParams; 683 m_DetectParams = data.DetectParams;
681 684
682 if (data.EventName == "state") // Hardcoded state change 685 if (data.EventName == "state") // Hardcoded state change
683 {
684// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
685// m_PrimName, m_ScriptName, data.Params[0].ToString());
686 m_State=data.Params[0].ToString();
687 AsyncCommandManager.RemoveScript(m_Engine,
688 m_LocalID, m_ItemID);
689
690 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
691 m_LocalID);
692 if (part != null)
693 {
694 part.SetScriptEvents(m_ItemID,
695 (int)m_Script.GetStateEventFlags(State));
696 }
697 }
698 else
699 {
700 if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
701 data.EventName == "control") // Don't freeze avies!
702 { 686 {
687 // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
688 // m_PrimName, m_ScriptName, data.Params[0].ToString());
689 m_State=data.Params[0].ToString();
690 AsyncCommandManager.RemoveScript(m_Engine,
691 m_LocalID, m_ItemID);
692
703 SceneObjectPart part = m_Engine.World.GetSceneObjectPart( 693 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
704 m_LocalID); 694 m_LocalID);
705 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", 695 if (part != null)
706 // m_PrimName, m_ScriptName, data.EventName, m_State); 696 {
707 697 part.SetScriptEvents(m_ItemID,
708 try 698 (int)m_Script.GetStateEventFlags(State));
699 }
700 }
701 else
702 {
703 if (m_Engine.World.PipeEventsForScript(m_LocalID) ||
704 data.EventName == "control") // Don't freeze avies!
709 { 705 {
710 m_CurrentEvent = data.EventName; 706 SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
711 m_EventStart = DateTime.Now; 707 m_LocalID);
712 m_InEvent = true; 708 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
709 // m_PrimName, m_ScriptName, data.EventName, m_State);
713 710
714 m_Script.ExecuteEvent(State, data.EventName, data.Params); 711 try
712 {
713 m_CurrentEvent = data.EventName;
714 m_EventStart = DateTime.Now;
715 m_InEvent = true;
715 716
716 m_InEvent = false; 717 m_Script.ExecuteEvent(State, data.EventName, data.Params);
717 m_CurrentEvent = String.Empty;
718 718
719 if (m_SaveState) 719 m_InEvent = false;
720 { 720 m_CurrentEvent = String.Empty;
721 // This will be the very first event we deliver
722 // (state_entry) in default state
723 //
724 721
725 SaveState(m_Assembly); 722 if (m_SaveState)
723 {
724 // This will be the very first event we deliver
725 // (state_entry) in default state
726 //
726 727
727 m_SaveState = false; 728 SaveState(m_Assembly);
728 }
729 }
730 catch (Exception e)
731 {
732 // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
733 m_InEvent = false;
734 m_CurrentEvent = String.Empty;
735 729
736 if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException)) 730 m_SaveState = false;
731 }
732 }
733 catch (Exception e)
737 { 734 {
738 try 735 // m_log.DebugFormat("[SCRIPT] Exception: {0}", e.Message);
736 m_InEvent = false;
737 m_CurrentEvent = String.Empty;
738
739 if ((!(e is TargetInvocationException) || (!(e.InnerException is SelfDeleteException) && !(e.InnerException is ScriptDeleteException))) && !(e is ThreadAbortException))
739 { 740 {
740 // DISPLAY ERROR INWORLD 741 try
741 string text = FormatException(e); 742 {
742 743 // DISPLAY ERROR INWORLD
743 if (text.Length > 1000) 744 string text = FormatException(e);
744 text = text.Substring(0, 1000); 745
745 m_Engine.World.SimChat(Utils.StringToBytes(text), 746 if (text.Length > 1000)
746 ChatTypeEnum.DebugChannel, 2147483647, 747 text = text.Substring(0, 1000);
747 part.AbsolutePosition, 748 m_Engine.World.SimChat(Utils.StringToBytes(text),
748 part.Name, part.UUID, false); 749 ChatTypeEnum.DebugChannel, 2147483647,
750 part.AbsolutePosition,
751 part.Name, part.UUID, false);
752 }
753 catch (Exception)
754 {
755 }
756 // catch (Exception e2) // LEGIT: User Scripting
757 // {
758 // m_log.Error("[SCRIPT]: "+
759 // "Error displaying error in-world: " +
760 // e2.ToString());
761 // m_log.Error("[SCRIPT]: " +
762 // "Errormessage: Error compiling script:\r\n" +
763 // e.ToString());
764 // }
749 } 765 }
750 catch (Exception) 766 else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
751 { 767 {
768 m_InSelfDelete = true;
769 if (part != null && part.ParentGroup != null)
770 m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
771 }
772 else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
773 {
774 m_InSelfDelete = true;
775 if (part != null && part.ParentGroup != null)
776 part.Inventory.RemoveInventoryItem(m_ItemID);
752 } 777 }
753 // catch (Exception e2) // LEGIT: User Scripting
754 // {
755 // m_log.Error("[SCRIPT]: "+
756 // "Error displaying error in-world: " +
757 // e2.ToString());
758 // m_log.Error("[SCRIPT]: " +
759 // "Errormessage: Error compiling script:\r\n" +
760 // e.ToString());
761 // }
762 }
763 else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
764 {
765 m_InSelfDelete = true;
766 if (part != null && part.ParentGroup != null)
767 m_Engine.World.DeleteSceneObject(part.ParentGroup, false);
768 }
769 else if ((e is TargetInvocationException) && (e.InnerException is ScriptDeleteException))
770 {
771 m_InSelfDelete = true;
772 if (part != null && part.ParentGroup != null)
773 part.Inventory.RemoveInventoryItem(m_ItemID);
774 } 778 }
775 } 779 }
776 } 780 }
777 }
778 781
779 lock (m_EventQueue) 782 lock (m_EventQueue)
780 {
781 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
782 {
783 m_CurrentResult = m_Engine.QueueEventHandler(this);
784 }
785 else
786 { 783 {
787 m_CurrentResult = null; 784 if ((m_EventQueue.Count > 0) && m_RunEvents && (!m_ShuttingDown))
785 {
786 m_CurrentResult = m_Engine.QueueEventHandler(this);
787 }
788 else
789 {
790 m_CurrentResult = null;
791 }
788 } 792 }
789 }
790 793
791 m_DetectParams = null; 794 m_DetectParams = null;
792 795
793 return 0; 796 return 0;
794 } 797 }
795 } 798 }
796 799
797 public int EventTime() 800 public int EventTime()
@@ -1018,5 +1021,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1018 { 1021 {
1019 get { return m_RegionID; } 1022 get { return m_RegionID; }
1020 } 1023 }
1024
1025 public void Suspend()
1026 {
1027 m_Suspended = true;
1028 }
1029
1030 public void Resume()
1031 {
1032 m_Suspended = false;
1033 }
1021 } 1034 }
1022} 1035}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 35d57d8..463b052 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1570,5 +1570,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1570 return new ArrayList(); 1570 return new ArrayList();
1571 } 1571 }
1572 } 1572 }
1573
1574 public void SuspendScript(UUID itemID)
1575 {
1576 IScriptInstance instance = GetInstance(itemID);
1577 if (instance == null)
1578 return;
1579
1580 instance.Suspend();
1581 }
1582
1583 public void ResumeScript(UUID itemID)
1584 {
1585 IScriptInstance instance = GetInstance(itemID);
1586 if (instance == null)
1587 return;
1588
1589 instance.Resume();
1590 }
1573 } 1591 }
1574} 1592}