aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs127
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs85
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs105
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs202
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs67
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs97
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs52
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs138
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs32
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs38
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs124
-rw-r--r--OpenSim/Region/CoreModules/LightShare/LightShareModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs31
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs153
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs23
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs15
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs79
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs456
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs85
-rw-r--r--OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs38
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs2
38 files changed, 1668 insertions, 468 deletions
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index ec4dfd0..4cedfe6 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Collections.Generic;
31using log4net; 32using log4net;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
@@ -38,6 +39,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
38{ 39{
39 public class AssetXferUploader 40 public class AssetXferUploader
40 { 41 {
42 // Viewer's notion of the default texture
43 private List<UUID> defaultIDs = new List<UUID> {
44 new UUID("5748decc-f629-461c-9a36-a35a221fe21f"),
45 new UUID("7ca39b4c-bd19-4699-aff7-f93fd03d3e7b"),
46 new UUID("6522e74d-1660-4e7f-b601-6f48c1659a77"),
47 new UUID("c228d1cf-4b5d-4ba8-84f4-899a0796aa97")
48 };
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 50
43 /// <summary> 51 /// <summary>
@@ -65,6 +73,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
65 private UUID TransactionID = UUID.Zero; 73 private UUID TransactionID = UUID.Zero;
66 private sbyte type = 0; 74 private sbyte type = 0;
67 private byte wearableType = 0; 75 private byte wearableType = 0;
76 private byte[] m_oldData = null;
68 public ulong XferID; 77 public ulong XferID;
69 private Scene m_Scene; 78 private Scene m_Scene;
70 79
@@ -302,6 +311,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
302 311
303 private void DoCreateItem(uint callbackID) 312 private void DoCreateItem(uint callbackID)
304 { 313 {
314 ValidateAssets();
305 m_Scene.AssetService.Store(m_asset); 315 m_Scene.AssetService.Store(m_asset);
306 316
307 InventoryItemBase item = new InventoryItemBase(); 317 InventoryItemBase item = new InventoryItemBase();
@@ -322,12 +332,84 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
322 item.Flags = (uint) wearableType; 332 item.Flags = (uint) wearableType;
323 item.CreationDate = Util.UnixTimeSinceEpoch(); 333 item.CreationDate = Util.UnixTimeSinceEpoch();
324 334
335 m_log.DebugFormat("[XFER]: Created item {0} with asset {1}",
336 item.ID, item.AssetID);
337
325 if (m_Scene.AddInventoryItem(item)) 338 if (m_Scene.AddInventoryItem(item))
326 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 339 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
327 else 340 else
328 ourClient.SendAlertMessage("Unable to create inventory item"); 341 ourClient.SendAlertMessage("Unable to create inventory item");
329 } 342 }
330 343
344 private void ValidateAssets()
345 {
346 if (m_asset.Type == (sbyte)AssetType.Clothing ||
347 m_asset.Type == (sbyte)AssetType.Bodypart)
348 {
349 string content = System.Text.Encoding.ASCII.GetString(m_asset.Data);
350 string[] lines = content.Split(new char[] {'\n'});
351
352 List<string> validated = new List<string>();
353
354 Dictionary<int, UUID> allowed = ExtractTexturesFromOldData();
355
356 int textures = 0;
357
358 foreach (string line in lines)
359 {
360 try
361 {
362 if (line.StartsWith("textures "))
363 {
364 textures = Convert.ToInt32(line.Substring(9));
365 validated.Add(line);
366 }
367 else if (textures > 0)
368 {
369 string[] parts = line.Split(new char[] {' '});
370
371 UUID tx = new UUID(parts[1]);
372 int id = Convert.ToInt32(parts[0]);
373
374 if (defaultIDs.Contains(tx) || tx == UUID.Zero ||
375 (allowed.ContainsKey(id) && allowed[id] == tx))
376 {
377 validated.Add(parts[0] + " " + tx.ToString());
378 }
379 else
380 {
381 int perms = m_Scene.InventoryService.GetAssetPermissions(ourClient.AgentId, tx);
382 int full = (int)(PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Copy);
383
384 if ((perms & full) != full)
385 {
386 m_log.ErrorFormat("[ASSET UPLOADER]: REJECTED update with texture {0} from {1} because they do not own the texture", tx, ourClient.AgentId);
387 validated.Add(parts[0] + " " + UUID.Zero.ToString());
388 }
389 else
390 {
391 validated.Add(line);
392 }
393 }
394 textures--;
395 }
396 else
397 {
398 validated.Add(line);
399 }
400 }
401 catch
402 {
403 // If it's malformed, skip it
404 }
405 }
406
407 string final = String.Join("\n", validated.ToArray());
408
409 m_asset.Data = System.Text.Encoding.ASCII.GetBytes(final);
410 }
411 }
412
331 /// <summary> 413 /// <summary>
332 /// Get the asset data uploaded in this transfer. 414 /// Get the asset data uploaded in this transfer.
333 /// </summary> 415 /// </summary>
@@ -336,10 +418,55 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
336 { 418 {
337 if (m_finished) 419 if (m_finished)
338 { 420 {
421 ValidateAssets();
339 return m_asset; 422 return m_asset;
340 } 423 }
341 424
342 return null; 425 return null;
343 } 426 }
427
428 public void SetOldData(byte[] d)
429 {
430 m_oldData = d;
431 }
432
433 private Dictionary<int,UUID> ExtractTexturesFromOldData()
434 {
435 Dictionary<int,UUID> result = new Dictionary<int,UUID>();
436 if (m_oldData == null)
437 return result;
438
439 string content = System.Text.Encoding.ASCII.GetString(m_oldData);
440 string[] lines = content.Split(new char[] {'\n'});
441
442 int textures = 0;
443
444 foreach (string line in lines)
445 {
446 try
447 {
448 if (line.StartsWith("textures "))
449 {
450 textures = Convert.ToInt32(line.Substring(9));
451 }
452 else if (textures > 0)
453 {
454 string[] parts = line.Split(new char[] {' '});
455
456 UUID tx = new UUID(parts[1]);
457 int id = Convert.ToInt32(parts[0]);
458 result[id] = tx;
459 textures--;
460 }
461 }
462 catch
463 {
464 // If it's malformed, skip it
465 }
466 }
467
468 return result;
469 }
344 } 470 }
345} 471}
472
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index 22c301b..8e2dba4 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -257,53 +257,66 @@ namespace Flotsam.RegionModules.AssetCache
257 257
258 private void UpdateFileCache(string key, AssetBase asset) 258 private void UpdateFileCache(string key, AssetBase asset)
259 { 259 {
260 string filename = GetFileName(asset.ID); 260 // TODO: Spawn this off to some seperate thread to do the actual writing
261 261 if (asset != null)
262 try
263 { 262 {
264 // If the file is already cached, don't cache it, just touch it so access time is updated 263 string filename = GetFileName(key);
265 if (File.Exists(filename)) 264
266 { 265 try
267 File.SetLastAccessTime(filename, DateTime.Now);
268 }
269 else
270 { 266 {
271 // Once we start writing, make sure we flag that we're writing 267 // If the file is already cached, don't cache it, just touch it so access time is updated
272 // that object to the cache so that we don't try to write the 268 if (File.Exists(filename))
273 // same file multiple times.
274 lock (m_CurrentlyWriting)
275 { 269 {
276#if WAIT_ON_INPROGRESS_REQUESTS 270 // We don't really want to know about sharing
277 if (m_CurrentlyWriting.ContainsKey(filename)) 271 // violations here. If the file is locked, then
272 // the other thread has updated the time for us.
273 try
278 { 274 {
279 return; 275 File.SetLastAccessTime(filename, DateTime.Now);
280 } 276 }
281 else 277 catch
282 {
283 m_CurrentlyWriting.Add(filename, new ManualResetEvent(false));
284 }
285
286#else
287 if (m_CurrentlyWriting.Contains(filename))
288 { 278 {
289 return;
290 } 279 }
291 else 280 } else {
281
282 // Once we start writing, make sure we flag that we're writing
283 // that object to the cache so that we don't try to write the
284 // same file multiple times.
285 lock (m_CurrentlyWriting)
292 { 286 {
293 m_CurrentlyWriting.Add(filename); 287#if WAIT_ON_INPROGRESS_REQUESTS
294 } 288 if (m_CurrentlyWriting.ContainsKey(filename))
289 {
290 return;
291 }
292 else
293 {
294 m_CurrentlyWriting.Add(filename, new ManualResetEvent(false));
295 }
296
297#else
298 if (m_CurrentlyWriting.Contains(filename))
299 {
300 return;
301 }
302 else
303 {
304 m_CurrentlyWriting.Add(filename);
305 }
295#endif 306#endif
296 }
297 307
298 Util.FireAndForget( 308 }
299 delegate { WriteFileCache(filename, asset); }); 309
310 Util.FireAndForget(
311 delegate { WriteFileCache(filename, asset); });
312 }
313 }
314 catch (Exception e)
315 {
316 m_log.ErrorFormat(
317 "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}",
318 asset.ID, e.Message, e.StackTrace);
300 } 319 }
301 }
302 catch (Exception e)
303 {
304 m_log.ErrorFormat(
305 "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}",
306 asset.ID, e.Message, e.StackTrace);
307 } 320 }
308 } 321 }
309 322
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2142d02..83beff4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Xml;
31using log4net; 32using log4net;
32using Mono.Addins; 33using Mono.Addins;
33using Nini.Config; 34using Nini.Config;
@@ -137,7 +138,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
137 // If we're an NPC then skip all the item checks and manipulations since we don't have an 138 // If we're an NPC then skip all the item checks and manipulations since we don't have an
138 // inventory right now. 139 // inventory right now.
139 if (sp.PresenceType == PresenceType.Npc) 140 if (sp.PresenceType == PresenceType.Npc)
140 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); 141 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null);
141 else 142 else
142 RezSingleAttachmentFromInventory(sp, attach.ItemID, p); 143 RezSingleAttachmentFromInventory(sp, attach.ItemID, p);
143 } 144 }
@@ -267,6 +268,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
267 } 268 }
268 269
269 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 270 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
271 {
272 return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, true, null);
273 }
274
275 public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc)
270 { 276 {
271 if (!Enabled) 277 if (!Enabled)
272 return null; 278 return null;
@@ -305,7 +311,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
305 return null; 311 return null;
306 } 312 }
307 313
308 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); 314 SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc);
309 315
310 if (att == null) 316 if (att == null)
311 DetachSingleAttachmentToInv(sp, itemID); 317 DetachSingleAttachmentToInv(sp, itemID);
@@ -584,11 +590,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
584 590
585 Vector3 inventoryStoredPosition = new Vector3 591 Vector3 inventoryStoredPosition = new Vector3
586 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) 592 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
587 ? Constants.RegionSize - 6 593 ? (float)Constants.RegionSize - 6
588 : grp.AbsolutePosition.X) 594 : grp.AbsolutePosition.X)
589 , 595 ,
590 (grp.AbsolutePosition.Y > (int)Constants.RegionSize) 596 (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
591 ? Constants.RegionSize - 6 597 ? (float)Constants.RegionSize - 6
592 : grp.AbsolutePosition.Y, 598 : grp.AbsolutePosition.Y,
593 grp.AbsolutePosition.Z); 599 grp.AbsolutePosition.Z);
594 600
@@ -706,8 +712,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
706 } 712 }
707 } 713 }
708 714
709 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 715 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
710 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) 716 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc)
711 { 717 {
712 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 718 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
713 if (invAccess != null) 719 if (invAccess != null)
@@ -715,7 +721,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
715 lock (sp.AttachmentsSyncLock) 721 lock (sp.AttachmentsSyncLock)
716 { 722 {
717 SceneObjectGroup objatt; 723 SceneObjectGroup objatt;
718 724
719 if (itemID != UUID.Zero) 725 if (itemID != UUID.Zero)
720 objatt = invAccess.RezObject(sp.ControllingClient, 726 objatt = invAccess.RezObject(sp.ControllingClient,
721 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 727 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
@@ -724,11 +730,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
724 objatt = invAccess.RezObject(sp.ControllingClient, 730 objatt = invAccess.RezObject(sp.ControllingClient,
725 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 731 null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
726 false, false, sp.UUID, true); 732 false, false, sp.UUID, true);
727 733
728 // m_log.DebugFormat( 734 // m_log.DebugFormat(
729 // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", 735 // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}",
730 // objatt.Name, remoteClient.Name, AttachmentPt); 736 // objatt.Name, remoteClient.Name, AttachmentPt);
731 737
732 if (objatt != null) 738 if (objatt != null)
733 { 739 {
734 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. 740 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
@@ -736,7 +742,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
736 bool tainted = false; 742 bool tainted = false;
737 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) 743 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
738 tainted = true; 744 tainted = true;
739 745
740 // This will throw if the attachment fails 746 // This will throw if the attachment fails
741 try 747 try
742 { 748 {
@@ -747,21 +753,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
747 m_log.ErrorFormat( 753 m_log.ErrorFormat(
748 "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", 754 "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
749 objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); 755 objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
750 756
751 // Make sure the object doesn't stick around and bail 757 // Make sure the object doesn't stick around and bail
752 sp.RemoveAttachment(objatt); 758 sp.RemoveAttachment(objatt);
753 m_scene.DeleteSceneObject(objatt, false); 759 m_scene.DeleteSceneObject(objatt, false);
754 return null; 760 return null;
755 } 761 }
756 762
757 if (tainted) 763 if (tainted)
758 objatt.HasGroupChanged = true; 764 objatt.HasGroupChanged = true;
765
766 if (doc != null)
767 {
768 objatt.LoadScriptState(doc);
769 objatt.ResetOwnerChangeFlag();
770 }
759 771
760 // Fire after attach, so we don't get messy perms dialogs 772 // Fire after attach, so we don't get messy perms dialogs
761 // 4 == AttachedRez 773 // 4 == AttachedRez
762 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); 774 objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
763 objatt.ResumeScripts(); 775 objatt.ResumeScripts();
764 776
765 // Do this last so that event listeners have access to all the effects of the attachment 777 // Do this last so that event listeners have access to all the effects of the attachment
766 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); 778 m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
767 779
@@ -775,7 +787,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
775 } 787 }
776 } 788 }
777 } 789 }
778 790
779 return null; 791 return null;
780 } 792 }
781 793
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index 10b4c37..4d8fb90 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -49,7 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
49 private int m_shoutdistance = 100; 49 private int m_shoutdistance = 100;
50 private int m_whisperdistance = 10; 50 private int m_whisperdistance = 10;
51 private List<Scene> m_scenes = new List<Scene>(); 51 private List<Scene> m_scenes = new List<Scene>();
52 52 private List<string> FreezeCache = new List<string>();
53 private string m_adminPrefix = "";
53 internal object m_syncy = new object(); 54 internal object m_syncy = new object();
54 55
55 internal IConfig m_config; 56 internal IConfig m_config;
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
76 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); 77 m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
77 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); 78 m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
78 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); 79 m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
80 m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
79 } 81 }
80 82
81 public virtual void AddRegion(Scene scene) 83 public virtual void AddRegion(Scene scene)
@@ -171,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
171 return; 173 return;
172 } 174 }
173 175
174 DeliverChatToAvatars(ChatSourceType.Agent, c); 176 if (FreezeCache.Contains(c.Sender.AgentId.ToString()))
177 {
178 if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping)
179 c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false);
180 }
181 else
182 {
183 DeliverChatToAvatars(ChatSourceType.Agent, c);
184 }
175 } 185 }
176 186
177 public virtual void OnChatFromWorld(Object sender, OSChatMessage c) 187 public virtual void OnChatFromWorld(Object sender, OSChatMessage c)
@@ -185,6 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
185 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) 195 protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
186 { 196 {
187 string fromName = c.From; 197 string fromName = c.From;
198 string fromNamePrefix = "";
188 UUID fromID = UUID.Zero; 199 UUID fromID = UUID.Zero;
189 string message = c.Message; 200 string message = c.Message;
190 IScene scene = c.Scene; 201 IScene scene = c.Scene;
@@ -207,7 +218,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
207 fromPos = avatar.AbsolutePosition; 218 fromPos = avatar.AbsolutePosition;
208 fromName = avatar.Name; 219 fromName = avatar.Name;
209 fromID = c.Sender.AgentId; 220 fromID = c.Sender.AgentId;
210 221 if (avatar.GodLevel >= 200)
222 {
223 fromNamePrefix = m_adminPrefix;
224 }
211 break; 225 break;
212 226
213 case ChatSourceType.Object: 227 case ChatSourceType.Object:
@@ -233,8 +247,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
233 s.ForEachRootScenePresence( 247 s.ForEachRootScenePresence(
234 delegate(ScenePresence presence) 248 delegate(ScenePresence presence)
235 { 249 {
236 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType)) 250 ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y);
237 receiverIDs.Add(presence.UUID); 251 if (Presencecheck != null)
252 {
253 // This will pass all chat from objects. Not
254 // perfect, but it will do. For now. Better
255 // than the prior behavior of muting all
256 // objects on a parcel with access restrictions
257 if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true)
258 {
259 if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType))
260 receiverIDs.Add(presence.UUID);
261 }
262 }
263
238 } 264 }
239 ); 265 );
240 } 266 }
@@ -278,26 +304,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
278 } 304 }
279 305
280 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); 306 // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
281
282 HashSet<UUID> receiverIDs = new HashSet<UUID>(); 307 HashSet<UUID> receiverIDs = new HashSet<UUID>();
283 308
284 ((Scene)c.Scene).ForEachRootClient( 309 if (c.Scene != null)
285 delegate(IClientAPI client) 310 {
286 { 311 ((Scene)c.Scene).ForEachRootClient
287 // don't forward SayOwner chat from objects to 312 (
288 // non-owner agents 313 delegate(IClientAPI client)
289 if ((c.Type == ChatTypeEnum.Owner) && 314 {
290 (null != c.SenderObject) && 315 // don't forward SayOwner chat from objects to
291 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) 316 // non-owner agents
292 return; 317 if ((c.Type == ChatTypeEnum.Owner) &&
293 318 (null != c.SenderObject) &&
294 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, 319 (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId))
295 (byte)sourceType, (byte)ChatAudibleLevel.Fully); 320 return;
296 receiverIDs.Add(client.AgentId); 321
297 }); 322 client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
298 323 (byte)sourceType, (byte)ChatAudibleLevel.Fully);
299 (c.Scene as Scene).EventManager.TriggerOnChatToClients( 324 receiverIDs.Add(client.AgentId);
300 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); 325 }
326 );
327 (c.Scene as Scene).EventManager.TriggerOnChatToClients(
328 fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully);
329 }
301 } 330 }
302 331
303 /// <summary> 332 /// <summary>
@@ -340,5 +369,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
340 369
341 return true; 370 return true;
342 } 371 }
372
373 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
374 public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
375 {
376 System.Threading.Timer Timer;
377 if (flags == 0)
378 {
379 FreezeCache.Add(target.ToString());
380 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
381 Timer = new System.Threading.Timer(timeCB, target, 30000, 0);
382 Timers.Add(target, Timer);
383 }
384 else
385 {
386 FreezeCache.Remove(target.ToString());
387 Timers.TryGetValue(target, out Timer);
388 Timers.Remove(target);
389 Timer.Dispose();
390 }
391 }
392
393 private void OnEndParcelFrozen(object avatar)
394 {
395 UUID target = (UUID)avatar;
396 FreezeCache.Remove(target.ToString());
397 System.Threading.Timer Timer;
398 Timers.TryGetValue(target, out Timer);
399 Timers.Remove(target);
400 Timer.Dispose();
401 }
343 } 402 }
344} 403}
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index ffe7718..bb2cd1f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -216,4 +216,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
216 return result; 216 return result;
217 } 217 }
218 } 218 }
219} \ No newline at end of file 219}
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index c266fe5..5d94ff7 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -328,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
328 //m_log.DebugFormat("[XXX]: OnClientLogin!"); 328 //m_log.DebugFormat("[XXX]: OnClientLogin!");
329 // Inform the friends that this user is online 329 // Inform the friends that this user is online
330 StatusChange(agentID, true); 330 StatusChange(agentID, true);
331 331
332 // Register that we need to send the list of online friends to this user 332 // Register that we need to send the list of online friends to this user
333 lock (m_NeedsListOfOnlineFriends) 333 lock (m_NeedsListOfOnlineFriends)
334 m_NeedsListOfOnlineFriends.Add(agentID); 334 m_NeedsListOfOnlineFriends.Add(agentID);
@@ -603,6 +603,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
603 { 603 {
604 StoreFriendships(client.AgentId, friendID); 604 StoreFriendships(client.AgentId, friendID);
605 605
606 ICallingCardModule ccm = client.Scene.RequestModuleInterface<ICallingCardModule>();
607 if (ccm != null)
608 {
609 ccm.CreateCallingCard(client.AgentId, friendID, UUID.Zero);
610 }
611
606 // Update the local cache 612 // Update the local cache
607 RecacheFriends(client); 613 RecacheFriends(client);
608 614
@@ -779,6 +785,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
779 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero); 785 (byte)OpenMetaverse.InstantMessageDialog.FriendshipAccepted, userID.ToString(), false, Vector3.Zero);
780 friendClient.SendInstantMessage(im); 786 friendClient.SendInstantMessage(im);
781 787
788 ICallingCardModule ccm = friendClient.Scene.RequestModuleInterface<ICallingCardModule>();
789 if (ccm != null)
790 {
791 ccm.CreateCallingCard(friendID, userID, UUID.Zero);
792 }
793
794
782 // Update the local cache 795 // Update the local cache
783 RecacheFriends(friendClient); 796 RecacheFriends(friendClient);
784 797
@@ -801,7 +814,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
801 // we're done 814 // we're done
802 return true; 815 return true;
803 } 816 }
804 817
805 return false; 818 return false;
806 } 819 }
807 820
@@ -853,7 +866,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
853 866
854 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online) 867 public bool LocalStatusNotification(UUID userID, UUID friendID, bool online)
855 { 868 {
856// m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online); 869 //m_log.DebugFormat("[FRIENDS]: Local Status Notify {0} that user {1} is {2}", friendID, userID, online);
857 IClientAPI friendClient = LocateClientObject(friendID); 870 IClientAPI friendClient = LocateClientObject(friendID);
858 if (friendClient != null) 871 if (friendClient != null)
859 { 872 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 2e3312f..1492302 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -31,16 +31,40 @@ using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes; 32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using System;
35using System.Reflection;
36using System.Collections;
37using System.Collections.Specialized;
38using System.Reflection;
39using System.IO;
40using System.Web;
41using System.Xml;
42using log4net;
43using Mono.Addins;
44using OpenMetaverse.Messages.Linden;
45using OpenMetaverse.StructuredData;
46using OpenSim.Framework.Capabilities;
47using OpenSim.Framework.Servers;
48using OpenSim.Framework.Servers.HttpServer;
49using Caps = OpenSim.Framework.Capabilities.Caps;
50using OSDArray = OpenMetaverse.StructuredData.OSDArray;
51using OSDMap = OpenMetaverse.StructuredData.OSDMap;
34 52
35namespace OpenSim.Region.CoreModules.Avatar.Gods 53namespace OpenSim.Region.CoreModules.Avatar.Gods
36{ 54{
37 public class GodsModule : IRegionModule, IGodsModule 55 public class GodsModule : IRegionModule, IGodsModule
38 { 56 {
57 private static readonly ILog m_log =
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59
39 /// <summary>Special UUID for actions that apply to all agents</summary> 60 /// <summary>Special UUID for actions that apply to all agents</summary>
40 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); 61 private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb");
41 62
42 protected Scene m_scene; 63 protected Scene m_scene;
43 protected IDialogModule m_dialogModule; 64 protected IDialogModule m_dialogModule;
65
66 protected Dictionary<UUID, string> m_capsDict =
67 new Dictionary<UUID, string>();
44 68
45 public void Initialise(Scene scene, IConfigSource source) 69 public void Initialise(Scene scene, IConfigSource source)
46 { 70 {
@@ -48,6 +72,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
48 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); 72 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
49 m_scene.RegisterModuleInterface<IGodsModule>(this); 73 m_scene.RegisterModuleInterface<IGodsModule>(this);
50 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 74 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
75 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
76 m_scene.EventManager.OnClientClosed += OnClientClosed;
77 scene.EventManager.OnIncomingInstantMessage +=
78 OnIncomingInstantMessage;
51 } 79 }
52 80
53 public void PostInitialise() {} 81 public void PostInitialise() {}
@@ -67,6 +95,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
67 client.OnRequestGodlikePowers -= RequestGodlikePowers; 95 client.OnRequestGodlikePowers -= RequestGodlikePowers;
68 } 96 }
69 97
98 private void OnClientClosed(UUID agentID, Scene scene)
99 {
100 m_capsDict.Remove(agentID);
101 }
102
103 private void OnRegisterCaps(UUID agentID, Caps caps)
104 {
105 string uri = "/CAPS/" + UUID.Random();
106 m_capsDict[agentID] = uri;
107
108 caps.RegisterHandler("UntrustedSimulatorMessage",
109 new RestStreamHandler("POST", uri,
110 HandleUntrustedSimulatorMessage));
111 }
112
113 private string HandleUntrustedSimulatorMessage(string request,
114 string path, string param, IOSHttpRequest httpRequest,
115 IOSHttpResponse httpResponse)
116 {
117 OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request);
118
119 string message = osd["message"].AsString();
120
121 if (message == "GodKickUser")
122 {
123 OSDMap body = (OSDMap)osd["body"];
124 OSDArray userInfo = (OSDArray)body["UserInfo"];
125 OSDMap userData = (OSDMap)userInfo[0];
126
127 UUID agentID = userData["AgentID"].AsUUID();
128 UUID godID = userData["GodID"].AsUUID();
129 UUID godSessionID = userData["GodSessionID"].AsUUID();
130 uint kickFlags = userData["KickFlags"].AsUInteger();
131 string reason = userData["Reason"].AsString();
132
133 ScenePresence god = m_scene.GetScenePresence(godID);
134 if (god == null || god.ControllingClient.SessionId != godSessionID)
135 return String.Empty;
136
137 KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason));
138 }
139 else
140 {
141 m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message);
142 }
143 return String.Empty;
144 }
145
70 public void RequestGodlikePowers( 146 public void RequestGodlikePowers(
71 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) 147 UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient)
72 { 148 {
@@ -115,69 +191,85 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
115 /// <param name="reason">The message to send to the user after it's been turned into a field</param> 191 /// <param name="reason">The message to send to the user after it's been turned into a field</param>
116 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) 192 public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason)
117 { 193 {
118 UUID kickUserID = ALL_AGENTS; 194 if (!m_scene.Permissions.IsGod(godID))
119 195 return;
196
120 ScenePresence sp = m_scene.GetScenePresence(agentID); 197 ScenePresence sp = m_scene.GetScenePresence(agentID);
121 198
122 if (sp != null || agentID == kickUserID) 199 if (sp == null && agentID != ALL_AGENTS)
123 { 200 {
124 if (m_scene.Permissions.IsGod(godID)) 201 IMessageTransferModule transferModule =
202 m_scene.RequestModuleInterface<IMessageTransferModule>();
203 if (transferModule != null)
125 { 204 {
126 if (kickflags == 0) 205 m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID);
127 { 206 transferModule.SendInstantMessage(new GridInstantMessage(
128 if (agentID == kickUserID) 207 m_scene, godID, "God", agentID, (byte)250, false,
129 { 208 Utils.BytesToString(reason), UUID.Zero, true,
130 string reasonStr = Utils.BytesToString(reason); 209 new Vector3(), new byte[] {(byte)kickflags}),
131 210 delegate(bool success) {} );
132 m_scene.ForEachClient( 211 }
133 delegate(IClientAPI controller) 212 return;
134 { 213 }
135 if (controller.AgentId != godID)
136 controller.Kick(reasonStr);
137 }
138 );
139
140 // This is a bit crude. It seems the client will be null before it actually stops the thread
141 // The thread will kill itself eventually :/
142 // Is there another way to make sure *all* clients get this 'inter region' message?
143 m_scene.ForEachRootClient(
144 delegate(IClientAPI client)
145 {
146 if (client.AgentId != godID)
147 {
148 client.Close();
149 }
150 }
151 );
152 }
153 else
154 {
155 m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent);
156 214
157 sp.ControllingClient.Kick(Utils.BytesToString(reason)); 215 switch (kickflags)
158 sp.ControllingClient.Close(); 216 {
159 } 217 case 0:
160 } 218 if (sp != null)
161 219 {
162 if (kickflags == 1) 220 KickPresence(sp, Utils.BytesToString(reason));
163 {
164 sp.AllowMovement = false;
165 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
166 m_dialogModule.SendAlertToUser(godID, "User Frozen");
167 }
168
169 if (kickflags == 2)
170 {
171 sp.AllowMovement = true;
172 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
173 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
174 }
175 } 221 }
176 else 222 else if (agentID == ALL_AGENTS)
177 { 223 {
178 m_dialogModule.SendAlertToUser(godID, "Kick request denied"); 224 m_scene.ForEachRootScenePresence(
225 delegate(ScenePresence p)
226 {
227 if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID)))
228 KickPresence(p, Utils.BytesToString(reason));
229 }
230 );
179 } 231 }
232 break;
233 case 1:
234 if (sp != null)
235 {
236 sp.AllowMovement = false;
237 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
238 m_dialogModule.SendAlertToUser(godID, "User Frozen");
239 }
240 break;
241 case 2:
242 if (sp != null)
243 {
244 sp.AllowMovement = true;
245 m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason));
246 m_dialogModule.SendAlertToUser(godID, "User Unfrozen");
247 }
248 break;
249 default:
250 break;
251 }
252 }
253
254 private void KickPresence(ScenePresence sp, string reason)
255 {
256 if (sp.IsChildAgent)
257 return;
258 sp.ControllingClient.Kick(reason);
259 sp.Scene.IncomingCloseAgent(sp.UUID);
260 }
261
262 private void OnIncomingInstantMessage(GridInstantMessage msg)
263 {
264 if (msg.dialog == (uint)250) // Nonlocal kick
265 {
266 UUID agentID = new UUID(msg.toAgentID);
267 string reason = msg.message;
268 UUID godID = new UUID(msg.fromAgentID);
269 uint kickMode = (uint)msg.binaryBucket[0];
270
271 KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason));
180 } 272 }
181 } 273 }
182 } 274 }
183} \ No newline at end of file 275}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index ca5d485..727f1c9 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -27,6 +27,7 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using System.Timers;
30using log4net; 31using log4net;
31using Nini.Config; 32using Nini.Config;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -42,6 +43,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
42 private static readonly ILog m_log = LogManager.GetLogger( 43 private static readonly ILog m_log = LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
44 45
46 private Timer m_logTimer = new Timer(10000);
47 private List<GridInstantMessage> m_logData = new List<GridInstantMessage>();
48 private string m_restUrl;
49
45 /// <value> 50 /// <value>
46 /// Is this module enabled? 51 /// Is this module enabled?
47 /// </value> 52 /// </value>
@@ -61,9 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
61 "InstantMessageModule", "InstantMessageModule") != 66 "InstantMessageModule", "InstantMessageModule") !=
62 "InstantMessageModule") 67 "InstantMessageModule")
63 return; 68 return;
69 m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty);
64 } 70 }
65 71
66 m_enabled = true; 72 m_enabled = true;
73 m_logTimer.AutoReset = false;
74 m_logTimer.Elapsed += LogTimerElapsed;
67 } 75 }
68 76
69 public void AddRegion(Scene scene) 77 public void AddRegion(Scene scene)
@@ -148,6 +156,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
148 { 156 {
149 byte dialog = im.dialog; 157 byte dialog = im.dialog;
150 158
159 if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent)
160 LogInstantMesssage(im);
161
151 if (dialog != (byte)InstantMessageDialog.MessageFromAgent 162 if (dialog != (byte)InstantMessageDialog.MessageFromAgent
152 && dialog != (byte)InstantMessageDialog.StartTyping 163 && dialog != (byte)InstantMessageDialog.StartTyping
153 && dialog != (byte)InstantMessageDialog.StopTyping 164 && dialog != (byte)InstantMessageDialog.StopTyping
@@ -157,6 +168,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
157 return; 168 return;
158 } 169 }
159 170
171 //DateTime dt = DateTime.UtcNow;
172
173 // Ticks from UtcNow, but make it look like local. Evil, huh?
174 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
175
176 //try
177 //{
178 // // Convert that to the PST timezone
179 // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
180 // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
181 //}
182 //catch
183 //{
184 // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
185 //}
186
187 //// And make it look local again to fool the unix time util
188 //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
189
190 // If client is null, this message comes from storage and IS offline
191 if (client != null)
192 im.offline = 0;
193
194 if (im.offline == 0)
195 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
196
160 if (m_TransferModule != null) 197 if (m_TransferModule != null)
161 { 198 {
162 if (client != null) 199 if (client != null)
@@ -200,5 +237,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
200 // 237 //
201 OnInstantMessage(null, msg); 238 OnInstantMessage(null, msg);
202 } 239 }
240
241 private void LogInstantMesssage(GridInstantMessage im)
242 {
243 if (m_logData.Count < 20)
244 {
245 // Restart the log write timer
246 m_logTimer.Stop();
247 }
248 if (!m_logTimer.Enabled)
249 m_logTimer.Start();
250
251 lock (m_logData)
252 {
253 m_logData.Add(im);
254 }
255 }
256
257 private void LogTimerElapsed(object source, ElapsedEventArgs e)
258 {
259 lock (m_logData)
260 {
261 if (m_restUrl != String.Empty && m_logData.Count > 0)
262 {
263 bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData);
264 if (!success)
265 m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data");
266 }
267 m_logData.Clear();
268 }
269 }
203 } 270 }
204} 271}
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
index 0dad3c4..6064ddc 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private bool m_Enabled = false; 50 private bool m_Enabled = false;
51 protected string m_MessageKey = String.Empty;
51 protected List<Scene> m_Scenes = new List<Scene>(); 52 protected List<Scene> m_Scenes = new List<Scene>();
52 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); 53 protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>();
53 54
@@ -67,14 +68,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
67 public virtual void Initialise(IConfigSource config) 68 public virtual void Initialise(IConfigSource config)
68 { 69 {
69 IConfig cnf = config.Configs["Messaging"]; 70 IConfig cnf = config.Configs["Messaging"];
70 if (cnf != null && cnf.GetString( 71 if (cnf != null)
71 "MessageTransferModule", "MessageTransferModule") !=
72 "MessageTransferModule")
73 { 72 {
74 m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); 73 if (cnf.GetString("MessageTransferModule",
75 return; 74 "MessageTransferModule") != "MessageTransferModule")
76 } 75 {
76 return;
77 }
77 78
79 m_MessageKey = cnf.GetString("MessageKey", String.Empty);
80 }
81 m_log.Debug("[MESSAGE TRANSFER]: Module enabled");
78 m_Enabled = true; 82 m_Enabled = true;
79 } 83 }
80 84
@@ -244,6 +248,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
244 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") 248 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
245 && requestData.ContainsKey("binary_bucket")) 249 && requestData.ContainsKey("binary_bucket"))
246 { 250 {
251 if (m_MessageKey != String.Empty)
252 {
253 XmlRpcResponse error_resp = new XmlRpcResponse();
254 Hashtable error_respdata = new Hashtable();
255 error_respdata["success"] = "FALSE";
256 error_resp.Value = error_respdata;
257
258 if (!requestData.Contains("message_key"))
259 return error_resp;
260 if (m_MessageKey != (string)requestData["message_key"])
261 return error_resp;
262 }
263
247 // Do the easy way of validating the UUIDs 264 // Do the easy way of validating the UUIDs
248 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); 265 UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID);
249 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); 266 UUID.TryParse((string)requestData["to_agent_id"], out toAgentID);
@@ -420,24 +437,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
420 return resp; 437 return resp;
421 } 438 }
422 439
423 /// <summary> 440 private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result);
424 /// delegate for sending a grid instant message asynchronously
425 /// </summary>
426 public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID);
427 441
428 protected virtual void GridInstantMessageCompleted(IAsyncResult iar) 442 private class GIM {
429 { 443 public GridInstantMessage im;
430 GridInstantMessageDelegate icon = 444 public MessageResultNotification result;
431 (GridInstantMessageDelegate)iar.AsyncState; 445 };
432 icon.EndInvoke(iar);
433 }
434 446
447 private Queue<GIM> pendingInstantMessages = new Queue<GIM>();
448 private int numInstantMessageThreads = 0;
435 449
436 protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) 450 private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result)
437 { 451 {
438 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; 452 lock (pendingInstantMessages) {
453 if (numInstantMessageThreads >= 4) {
454 GIM gim = new GIM();
455 gim.im = im;
456 gim.result = result;
457 pendingInstantMessages.Enqueue(gim);
458 } else {
459 ++ numInstantMessageThreads;
460 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads);
461 GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain;
462 d.BeginInvoke(im, result, GridInstantMessageCompleted, d);
463 }
464 }
465 }
439 466
440 d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); 467 private void GridInstantMessageCompleted(IAsyncResult iar)
468 {
469 GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState;
470 d.EndInvoke(iar);
441 } 471 }
442 472
443 /// <summary> 473 /// <summary>
@@ -452,8 +482,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
452 /// Pass in 0 the first time this method is called. It will be called recursively with the last 482 /// Pass in 0 the first time this method is called. It will be called recursively with the last
453 /// regionhandle tried 483 /// regionhandle tried
454 /// </param> 484 /// </param>
455 protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) 485 private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result)
456 { 486 {
487 GIM gim;
488 do {
489 try {
490 SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero);
491 } catch (Exception e) {
492 m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message);
493 }
494 lock (pendingInstantMessages) {
495 if (pendingInstantMessages.Count > 0) {
496 gim = pendingInstantMessages.Dequeue();
497 im = gim.im;
498 result = gim.result;
499 } else {
500 gim = null;
501 -- numInstantMessageThreads;
502 //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads);
503 }
504 }
505 } while (gim != null);
506 }
507 private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID)
508 {
509
457 UUID toAgentID = new UUID(im.toAgentID); 510 UUID toAgentID = new UUID(im.toAgentID);
458 511
459 PresenceInfo upd = null; 512 PresenceInfo upd = null;
@@ -520,7 +573,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
520 573
521 if (upd != null) 574 if (upd != null)
522 { 575 {
523 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, 576 GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero,
524 upd.RegionID); 577 upd.RegionID);
525 if (reginfo != null) 578 if (reginfo != null)
526 { 579 {
@@ -669,6 +722,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
669 gim["position_z"] = msg.Position.Z.ToString(); 722 gim["position_z"] = msg.Position.Z.ToString();
670 gim["region_id"] = msg.RegionID.ToString(); 723 gim["region_id"] = msg.RegionID.ToString();
671 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); 724 gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None);
725 if (m_MessageKey != String.Empty)
726 gim["message_key"] = m_MessageKey;
672 return gim; 727 return gim;
673 } 728 }
674 729
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index de25048..b27b07d 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -171,7 +171,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
171 171
172 private void RetrieveInstantMessages(IClientAPI client) 172 private void RetrieveInstantMessages(IClientAPI client)
173 { 173 {
174 if (m_RestURL != "") 174 if (m_RestURL == String.Empty)
175 {
176 return;
177 }
178 else
175 { 179 {
176 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); 180 m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId);
177 181
@@ -179,22 +183,25 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
179 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( 183 = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>(
180 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); 184 "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
181 185
182 if (msglist == null) 186 if (msglist != null)
183 m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list.");
184
185 foreach (GridInstantMessage im in msglist)
186 { 187 {
187 // client.SendInstantMessage(im); 188 foreach (GridInstantMessage im in msglist)
188 189 {
189 // Send through scene event manager so all modules get a chance 190 // client.SendInstantMessage(im);
190 // to look at this message before it gets delivered. 191
191 // 192 // Send through scene event manager so all modules get a chance
192 // Needed for proper state management for stored group 193 // to look at this message before it gets delivered.
193 // invitations 194 //
194 // 195 // Needed for proper state management for stored group
195 Scene s = FindScene(client.AgentId); 196 // invitations
196 if (s != null) 197 //
197 s.EventManager.TriggerIncomingInstantMessage(im); 198
199 im.offline = 1;
200
201 Scene s = FindScene(client.AgentId);
202 if (s != null)
203 s.EventManager.TriggerIncomingInstantMessage(im);
204 }
198 } 205 }
199 } 206 }
200 } 207 }
@@ -205,24 +212,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
205 im.dialog != (byte)InstantMessageDialog.MessageFromAgent && 212 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
206 im.dialog != (byte)InstantMessageDialog.GroupNotice && 213 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
207 im.dialog != (byte)InstantMessageDialog.GroupInvitation && 214 im.dialog != (byte)InstantMessageDialog.GroupInvitation &&
208 im.dialog != (byte)InstantMessageDialog.InventoryOffered) 215 im.dialog != (byte)InstantMessageDialog.InventoryOffered &&
216 im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered)
209 { 217 {
210 return; 218 return;
211 } 219 }
212 220
213 if (!m_ForwardOfflineGroupMessages)
214 {
215 if (im.dialog == (byte)InstantMessageDialog.GroupNotice ||
216 im.dialog != (byte)InstantMessageDialog.GroupInvitation)
217 return;
218 }
219
220 Scene scene = FindScene(new UUID(im.fromAgentID)); 221 Scene scene = FindScene(new UUID(im.fromAgentID));
221 if (scene == null) 222 if (scene == null)
222 scene = m_SceneList[0]; 223 scene = m_SceneList[0];
223 224
224 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( 225 bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>(
225 "POST", m_RestURL+"/SaveMessage/", im); 226 "POST", m_RestURL+"/SaveMessage/?scope=" +
227 scene.RegionInfo.ScopeID.ToString(), im);
226 228
227 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 229 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
228 { 230 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index ee10d04..0833154 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -635,4 +635,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
635 m_assetsLoaded = true; 635 m_assetsLoaded = true;
636 } 636 }
637 } 637 }
638} \ No newline at end of file 638}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index 36ecb3b..63fde07 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -178,9 +178,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
178 InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, 178 InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself,
179 Dictionary<string, object> options, IUserAccountService userAccountService) 179 Dictionary<string, object> options, IUserAccountService userAccountService)
180 { 180 {
181 if (options.ContainsKey("verbose"))
182 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saving folder {0}", inventoryFolder.Name);
183
184 if (saveThisFolderItself) 181 if (saveThisFolderItself)
185 { 182 {
186 path += CreateArchiveFolderName(inventoryFolder); 183 path += CreateArchiveFolderName(inventoryFolder);
@@ -449,4 +446,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
449 return s; 446 return s;
450 } 447 }
451 } 448 }
452} \ No newline at end of file 449}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 19c774f..da708d2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -175,8 +175,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
175 if (im.binaryBucket.Length < 17) // Invalid 175 if (im.binaryBucket.Length < 17) // Invalid
176 return; 176 return;
177 177
178 UUID receipientID = new UUID(im.toAgentID); 178 UUID recipientID = new UUID(im.toAgentID);
179 ScenePresence user = scene.GetScenePresence(receipientID); 179 ScenePresence user = scene.GetScenePresence(recipientID);
180 UUID copyID; 180 UUID copyID;
181 181
182 // First byte is the asset type 182 // First byte is the asset type
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
191 folderID, new UUID(im.toAgentID)); 191 folderID, new UUID(im.toAgentID));
192 192
193 InventoryFolderBase folderCopy 193 InventoryFolderBase folderCopy
194 = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); 194 = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero);
195 195
196 if (folderCopy == null) 196 if (folderCopy == null)
197 { 197 {
@@ -244,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
244 im.imSessionID = itemID.Guid; 244 im.imSessionID = itemID.Guid;
245 } 245 }
246 246
247 im.offline = 0;
248
247 // Send the IM to the recipient. The item is already 249 // Send the IM to the recipient. The item is already
248 // in their inventory, so it will not be lost if 250 // in their inventory, so it will not be lost if
249 // they are offline. 251 // they are offline.
@@ -263,7 +265,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
263 }); 265 });
264 } 266 }
265 } 267 }
266 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) 268 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
269 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
267 { 270 {
268 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); 271 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
269 272
@@ -274,30 +277,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
274 else 277 else
275 { 278 {
276 if (m_TransferModule != null) 279 if (m_TransferModule != null)
277 m_TransferModule.SendInstantMessage(im, delegate(bool success) { 280 m_TransferModule.SendInstantMessage(im, delegate(bool success) {});
278
279 // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011
280 // and is apparently supposed to fix bulk inventory updates after accepting items. But
281 // instead it appears to cause two copies of an accepted folder for the receiving user in
282 // at least some cases. Folder/item update is already done when the offer is made (see code above)
283
284// // Send BulkUpdateInventory
285// IInventoryService invService = scene.InventoryService;
286// UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip
287//
288// InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId);
289// folder = invService.GetFolder(folder);
290//
291// ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID));
292//
293// // If the user has left the scene by the time the message comes back then we can't send
294// // them the update.
295// if (fromUser != null)
296// fromUser.ControllingClient.SendBulkUpdateInventory(folder);
297 });
298 } 281 }
299 } 282 }
300 else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) 283 else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined ||
284 im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined)
301 { 285 {
302 // Here, the recipient is local and we can assume that the 286 // Here, the recipient is local and we can assume that the
303 // inventory is loaded. Courtesy of the above bulk update, 287 // inventory is loaded. Courtesy of the above bulk update,
@@ -333,6 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
333 { 317 {
334 folder.ParentID = trashFolder.ID; 318 folder.ParentID = trashFolder.ID;
335 invService.MoveFolder(folder); 319 invService.MoveFolder(folder);
320 client.SendBulkUpdateInventory(folder);
336 } 321 }
337 } 322 }
338 323
@@ -433,22 +418,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
433 /// 418 ///
434 /// </summary> 419 /// </summary>
435 /// <param name="msg"></param> 420 /// <param name="msg"></param>
436 private void OnGridInstantMessage(GridInstantMessage msg) 421 private void OnGridInstantMessage(GridInstantMessage im)
437 { 422 {
438 // Check if this is ours to handle 423 // Check if this is ours to handle
439 // 424 //
440 Scene scene = FindClientScene(new UUID(msg.toAgentID)); 425 Scene scene = FindClientScene(new UUID(im.toAgentID));
441 426
442 if (scene == null) 427 if (scene == null)
443 return; 428 return;
444 429
445 // Find agent to deliver to 430 // Find agent to deliver to
446 // 431 //
447 ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); 432 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
433 if (user == null)
434 return;
435
436 // This requires a little bit of processing because we have to make the
437 // new item visible in the recipient's inventory here
438 //
439 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
440 {
441 if (im.binaryBucket.Length < 17) // Invalid
442 return;
443
444 UUID recipientID = new UUID(im.toAgentID);
445
446 // First byte is the asset type
447 AssetType assetType = (AssetType)im.binaryBucket[0];
448
449 if (AssetType.Folder == assetType)
450 {
451 UUID folderID = new UUID(im.binaryBucket, 1);
448 452
449 // Just forward to local handling 453 InventoryFolderBase given =
450 OnInstantMessage(user.ControllingClient, msg); 454 new InventoryFolderBase(folderID, recipientID);
455 InventoryFolderBase folder =
456 scene.InventoryService.GetFolder(given);
451 457
458 if (folder != null)
459 user.ControllingClient.SendBulkUpdateInventory(folder);
460 }
461 else
462 {
463 UUID itemID = new UUID(im.binaryBucket, 1);
464
465 InventoryItemBase given =
466 new InventoryItemBase(itemID, recipientID);
467 InventoryItemBase item =
468 scene.InventoryService.GetItem(given);
469
470 if (item != null)
471 {
472 user.ControllingClient.SendBulkUpdateInventory(item);
473 }
474 }
475 user.ControllingClient.SendInstantMessage(im);
476 }
477 if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered)
478 {
479 if (im.binaryBucket.Length < 1) // Invalid
480 return;
481
482 UUID recipientID = new UUID(im.toAgentID);
483
484 // Bucket is the asset type
485 AssetType assetType = (AssetType)im.binaryBucket[0];
486
487 if (AssetType.Folder == assetType)
488 {
489 UUID folderID = new UUID(im.imSessionID);
490
491 InventoryFolderBase given =
492 new InventoryFolderBase(folderID, recipientID);
493 InventoryFolderBase folder =
494 scene.InventoryService.GetFolder(given);
495
496 if (folder != null)
497 user.ControllingClient.SendBulkUpdateInventory(folder);
498 }
499 else
500 {
501 UUID itemID = new UUID(im.imSessionID);
502
503 InventoryItemBase given =
504 new InventoryItemBase(itemID, recipientID);
505 InventoryItemBase item =
506 scene.InventoryService.GetItem(given);
507
508 if (item != null)
509 {
510 user.ControllingClient.SendBulkUpdateInventory(item);
511 }
512 }
513
514 // Fix up binary bucket since this may be 17 chars long here
515 Byte[] bucket = new Byte[1];
516 bucket[0] = im.binaryBucket[0];
517 im.binaryBucket = bucket;
518
519 user.ControllingClient.SendInstantMessage(im);
520 }
521 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted ||
522 im.dialog == (byte) InstantMessageDialog.InventoryDeclined ||
523 im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined ||
524 im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted)
525 {
526 user.ControllingClient.SendInstantMessage(im);
527 }
452 } 528 }
453 } 529 }
454} 530}
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
index d295384..dcfdf8f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs
@@ -155,16 +155,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
155 scene.RegionInfo.RegionHandle, 155 scene.RegionInfo.RegionHandle,
156 (uint)presence.AbsolutePosition.X, 156 (uint)presence.AbsolutePosition.X,
157 (uint)presence.AbsolutePosition.Y, 157 (uint)presence.AbsolutePosition.Y,
158 (uint)presence.AbsolutePosition.Z); 158 (uint)presence.AbsolutePosition.Z + 2);
159 159
160 m_log.DebugFormat("TP invite with message {0}", message); 160 m_log.DebugFormat("[LURE]: TP invite with message {0}", message);
161
162 GridInstantMessage m;
163
164 if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid)))
165 {
166 m = new GridInstantMessage(scene, client.AgentId,
167 client.FirstName+" "+client.LastName, targetid,
168 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
169 message, dest, false, presence.AbsolutePosition,
170 new Byte[0]);
171 }
172 else
173 {
174 m = new GridInstantMessage(scene, client.AgentId,
175 client.FirstName+" "+client.LastName, targetid,
176 (byte)InstantMessageDialog.RequestTeleport, false,
177 message, dest, false, presence.AbsolutePosition,
178 new Byte[0]);
179 }
161 180
162 GridInstantMessage m = new GridInstantMessage(scene, client.AgentId,
163 client.FirstName+" "+client.LastName, targetid,
164 (byte)InstantMessageDialog.RequestTeleport, false,
165 message, dest, false, presence.AbsolutePosition,
166 new Byte[0]);
167
168 if (m_TransferModule != null) 181 if (m_TransferModule != null)
169 { 182 {
170 m_TransferModule.SendInstantMessage(m, 183 m_TransferModule.SendInstantMessage(m,
@@ -199,7 +212,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure
199 { 212 {
200 // Forward remote teleport requests 213 // Forward remote teleport requests
201 // 214 //
202 if (msg.dialog != 22) 215 if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport &&
216 msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport)
203 return; 217 return;
204 218
205 if (m_TransferModule != null) 219 if (m_TransferModule != null)
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 9d1538f..97cd738 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -101,7 +101,8 @@ namespace OpenSim.Region.CoreModules.Framework
101 101
102 public void CreateCaps(UUID agentId) 102 public void CreateCaps(UUID agentId)
103 { 103 {
104 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) 104 int flags = m_scene.GetUserFlags(agentId);
105 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
105 return; 106 return;
106 107
107 String capsObjectPath = GetCapsPath(agentId); 108 String capsObjectPath = GetCapsPath(agentId);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 928bcd0..f1399af 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
126 126
127 protected virtual void OnNewClient(IClientAPI client) 127 protected virtual void OnNewClient(IClientAPI client)
128 { 128 {
129 client.OnTeleportHomeRequest += TeleportHome; 129 client.OnTeleportHomeRequest += TriggerTeleportHome;
130 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 130 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
131 } 131 }
132 132
@@ -204,6 +204,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
204 sp.ControllingClient.SendTeleportStart(teleportFlags); 204 sp.ControllingClient.SendTeleportStart(teleportFlags);
205 205
206 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); 206 sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
207 sp.TeleportFlags = (Constants.TeleportFlags)teleportFlags;
207 sp.Teleport(position); 208 sp.Teleport(position);
208 209
209 foreach (SceneObjectGroup grp in sp.GetAttachments()) 210 foreach (SceneObjectGroup grp in sp.GetAttachments())
@@ -319,7 +320,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
319 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, 320 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
320 // it's actually doing a lot of work. 321 // it's actually doing a lot of work.
321 IPEndPoint endPoint = finalDestination.ExternalEndPoint; 322 IPEndPoint endPoint = finalDestination.ExternalEndPoint;
322 if (endPoint.Address != null) 323 if (endPoint != null && endPoint.Address != null)
323 { 324 {
324 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from 325 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
325 // both regions 326 // both regions
@@ -630,7 +631,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
630 631
631 #region Teleport Home 632 #region Teleport Home
632 633
633 public virtual void TeleportHome(UUID id, IClientAPI client) 634 public virtual void TriggerTeleportHome(UUID id, IClientAPI client)
635 {
636 TeleportHome(id, client);
637 }
638
639 public virtual bool TeleportHome(UUID id, IClientAPI client)
634 { 640 {
635 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 641 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
636 642
@@ -639,12 +645,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
639 645
640 if (uinfo != null) 646 if (uinfo != null)
641 { 647 {
648 if (uinfo.HomeRegionID == UUID.Zero)
649 {
650 // can't find the Home region: Tell viewer and abort
651 client.SendTeleportFailed("You don't have a home position set.");
652 return false;
653 }
642 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID); 654 GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
643 if (regionInfo == null) 655 if (regionInfo == null)
644 { 656 {
645 // can't find the Home region: Tell viewer and abort 657 // can't find the Home region: Tell viewer and abort
646 client.SendTeleportFailed("Your home region could not be found."); 658 client.SendTeleportFailed("Your home region could not be found.");
647 return; 659 return false;
648 } 660 }
649 661
650 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})", 662 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: User's home region is {0} {1} ({2}-{3})",
@@ -655,6 +667,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
655 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt, 667 client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
656 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome)); 668 (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
657 } 669 }
670 else
671 {
672 // can't find the Home region: Tell viewer and abort
673 client.SendTeleportFailed("Your home region could not be found.");
674 return false;
675 }
676 return true;
658 } 677 }
659 678
660 #endregion 679 #endregion
@@ -1124,10 +1143,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1124 agent.Id0 = currentAgentCircuit.Id0; 1143 agent.Id0 = currentAgentCircuit.Id0;
1125 } 1144 }
1126 1145
1127 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1146 IPEndPoint external = region.ExternalEndPoint;
1128 d.BeginInvoke(sp, agent, region, region.ExternalEndPoint, true, 1147 if (external != null)
1148 {
1149 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1150 d.BeginInvoke(sp, agent, region, external, true,
1129 InformClientOfNeighbourCompleted, 1151 InformClientOfNeighbourCompleted,
1130 d); 1152 d);
1153 }
1131 } 1154 }
1132 #endregion 1155 #endregion
1133 1156
@@ -1261,6 +1284,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1261 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 1284 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
1262 try 1285 try
1263 { 1286 {
1287 //neighbour.ExternalEndPoint may return null, which will be caught
1264 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, 1288 d.BeginInvoke(sp, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
1265 InformClientOfNeighbourCompleted, 1289 InformClientOfNeighbourCompleted,
1266 d); 1290 d);
@@ -1374,8 +1398,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1374 1398
1375 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); 1399 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1376 } 1400 }
1377 if (!regionAccepted)
1378 m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Region {0} did not accept agent: {1}", reg.RegionName, reason);
1379 } 1401 }
1380 1402
1381 /// <summary> 1403 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 8d41728..b16d0d3 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
84 84
85 protected override void OnNewClient(IClientAPI client) 85 protected override void OnNewClient(IClientAPI client)
86 { 86 {
87 client.OnTeleportHomeRequest += TeleportHome; 87 client.OnTeleportHomeRequest += TriggerTeleportHome;
88 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 88 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
89 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed); 89 client.OnConnectionClosed += new Action<IClientAPI>(OnConnectionClosed);
90 } 90 }
@@ -182,7 +182,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
182 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 182 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
183 } 183 }
184 184
185 public override void TeleportHome(UUID id, IClientAPI client) 185 public void TriggerTeleportHome(UUID id, IClientAPI client)
186 {
187 TeleportHome(id, client);
188 }
189
190 public override bool TeleportHome(UUID id, IClientAPI client)
186 { 191 {
187 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName); 192 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
188 193
@@ -192,8 +197,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
192 { 197 {
193 // local grid user 198 // local grid user
194 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local"); 199 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
195 base.TeleportHome(id, client); 200 return base.TeleportHome(id, client);
196 return;
197 } 201 }
198 202
199 // Foreign user wants to go home 203 // Foreign user wants to go home
@@ -203,7 +207,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
203 { 207 {
204 client.SendTeleportFailed("Your information has been lost"); 208 client.SendTeleportFailed("Your information has been lost");
205 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information"); 209 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
206 return; 210 return false;
207 } 211 }
208 212
209 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString()); 213 IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
@@ -213,7 +217,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
213 { 217 {
214 client.SendTeleportFailed("Your home region could not be found"); 218 client.SendTeleportFailed("Your home region could not be found");
215 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found"); 219 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
216 return; 220 return false;
217 } 221 }
218 222
219 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId); 223 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
@@ -221,7 +225,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
221 { 225 {
222 client.SendTeleportFailed("Internal error"); 226 client.SendTeleportFailed("Internal error");
223 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be"); 227 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
224 return; 228 return false;
225 } 229 }
226 230
227 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>(); 231 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
@@ -231,6 +235,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
231 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName); 235 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ServerURI, homeGatekeeper.RegionName);
232 236
233 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq); 237 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
238 return true;
234 } 239 }
235 240
236 /// <summary> 241 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 54b422b..7ebf002 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -476,8 +476,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
476 IClientAPI remoteClient) 476 IClientAPI remoteClient)
477 { 477 {
478 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7; 478 uint effectivePerms = (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify | PermissionMask.Move) | 7;
479 // For the porposes of inventory, an object is modify if the prims
480 // are modify. This allows renaming an object that contains no
481 // mod items.
479 foreach (SceneObjectGroup grp in objsForEffectivePermissions) 482 foreach (SceneObjectGroup grp in objsForEffectivePermissions)
480 effectivePerms &= grp.GetEffectivePermissions(); 483 {
484 uint groupPerms = grp.GetEffectivePermissions(true);
485 if ((grp.RootPart.BaseMask & (uint)PermissionMask.Modify) != 0)
486 groupPerms |= (uint)PermissionMask.Modify;
487
488 effectivePerms &= groupPerms;
489 }
481 effectivePerms |= (uint)PermissionMask.Move; 490 effectivePerms |= (uint)PermissionMask.Move;
482 491
483 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) 492 if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions())
@@ -644,7 +653,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
644 if (so.RootPart.FromFolderID != UUID.Zero) 653 if (so.RootPart.FromFolderID != UUID.Zero)
645 { 654 {
646 InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID); 655 InventoryFolderBase f = new InventoryFolderBase(so.RootPart.FromFolderID, userID);
647 folder = m_Scene.InventoryService.GetFolder(f); 656 if (f != null)
657 folder = m_Scene.InventoryService.GetFolder(f);
648 } 658 }
649 } 659 }
650 660
@@ -674,15 +684,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
674 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) 684 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
675 { 685 {
676// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID); 686// m_log.DebugFormat("[INVENTORY ACCESS MODULE]: RezObject for {0}, item {1}", remoteClient.Name, itemID);
677
678 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 687 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
679 item = m_Scene.InventoryService.GetItem(item); 688 item = m_Scene.InventoryService.GetItem(item);
680 689
681 if (item == null) 690 if (item == null)
682 { 691 {
683 m_log.WarnFormat(
684 "[InventoryAccessModule]: Could not find item {0} for {1} in RezObject()",
685 itemID, remoteClient.Name);
686 692
687 return null; 693 return null;
688 } 694 }
@@ -782,12 +788,35 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
782 } 788 }
783 } 789 }
784 790
791 int primcount = 0;
792 foreach (SceneObjectGroup g in objlist)
793 primcount += g.PrimCount;
794
795 if (!m_Scene.Permissions.CanRezObject(
796 primcount, remoteClient.AgentId, pos)
797 && !attachment)
798 {
799 // The client operates in no fail mode. It will
800 // have already removed the item from the folder
801 // if it's no copy.
802 // Put it back if it's not an attachment
803 //
804 if (item != null)
805 {
806 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
807 remoteClient.SendBulkUpdateInventory(item);
808 }
809
810 return null;
811 }
812
785 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment)) 813 if (item != null && !DoPreRezWhenFromItem(remoteClient, item, objlist, pos, attachment))
786 return null; 814 return null;
787 815
788 for (int i = 0; i < objlist.Count; i++) 816 for (int i = 0; i < objlist.Count; i++)
789 { 817 {
790 group = objlist[i]; 818 group = objlist[i];
819 SceneObjectPart rootPart = group.RootPart;
791 820
792// Vector3 storedPosition = group.AbsolutePosition; 821// Vector3 storedPosition = group.AbsolutePosition;
793 if (group.UUID == UUID.Zero) 822 if (group.UUID == UUID.Zero)
@@ -842,8 +871,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
842 871
843 if (!attachment) 872 if (!attachment)
844 { 873 {
845 SceneObjectPart rootPart = group.RootPart;
846
847 if (rootPart.Shape.PCode == (byte)PCode.Prim) 874 if (rootPart.Shape.PCode == (byte)PCode.Prim)
848 group.ClearPartAttachmentData(); 875 group.ClearPartAttachmentData();
849 876
@@ -853,12 +880,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
853 880
854 rootPart.ScheduleFullUpdate(); 881 rootPart.ScheduleFullUpdate();
855 } 882 }
856
857// m_log.DebugFormat(
858// "[InventoryAccessModule]: Rezzed {0} {1} {2} for {3}",
859// group.Name, group.LocalId, group.UUID, remoteClient.Name);
860 } 883 }
861 884
885 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
886
862 if (item != null) 887 if (item != null)
863 DoPostRezWhenFromItem(item, attachment); 888 DoPostRezWhenFromItem(item, attachment);
864 889
@@ -898,25 +923,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
898 } 923 }
899 } 924 }
900 925
901 int primcount = 0;
902 foreach (SceneObjectGroup g in objlist)
903 primcount += g.PrimCount;
904
905 if (!m_Scene.Permissions.CanRezObject(
906 primcount, remoteClient.AgentId, pos)
907 && !isAttachment)
908 {
909 // The client operates in no fail mode. It will
910 // have already removed the item from the folder
911 // if it's no copy.
912 // Put it back if it's not an attachment
913 //
914 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!isAttachment))
915 remoteClient.SendBulkUpdateInventory(item);
916
917 return false;
918 }
919
920 for (int i = 0; i < objlist.Count; i++) 926 for (int i = 0; i < objlist.Count; i++)
921 { 927 {
922 SceneObjectGroup so = objlist[i]; 928 SceneObjectGroup so = objlist[i];
@@ -932,14 +938,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
932 { 938 {
933 rootPart.Name = item.Name; 939 rootPart.Name = item.Name;
934 rootPart.Description = item.Description; 940 rootPart.Description = item.Description;
935 rootPart.ObjectSaleType = item.SaleType; 941 if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
936 rootPart.SalePrice = item.SalePrice; 942 {
943 rootPart.ObjectSaleType = item.SaleType;
944 rootPart.SalePrice = item.SalePrice;
945 }
937 } 946 }
938 947
939 rootPart.FromFolderID = item.Folder; 948 rootPart.FromFolderID = item.Folder;
940 949
941 if ((rootPart.OwnerID != item.Owner) || 950 if ((rootPart.OwnerID != item.Owner) ||
942 (item.CurrentPermissions & 16) != 0) 951 (item.CurrentPermissions & 16) != 0 ||
952 (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)
943 { 953 {
944 //Need to kill the for sale here 954 //Need to kill the for sale here
945 rootPart.ObjectSaleType = 0; 955 rootPart.ObjectSaleType = 0;
@@ -949,31 +959,43 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
949 { 959 {
950 foreach (SceneObjectPart part in so.Parts) 960 foreach (SceneObjectPart part in so.Parts)
951 { 961 {
952 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
953 {
954 part.EveryoneMask = item.EveryOnePermissions;
955 part.NextOwnerMask = item.NextPermissions;
956 }
957 part.GroupMask = 0; // DO NOT propagate here 962 part.GroupMask = 0; // DO NOT propagate here
963
964 part.LastOwnerID = part.OwnerID;
965 part.OwnerID = item.Owner;
966 part.Inventory.ChangeInventoryOwner(item.Owner);
958 } 967 }
959 968
960 so.ApplyNextOwnerPermissions(); 969 so.ApplyNextOwnerPermissions();
970
971 // In case the user has changed flags on a received item
972 // we have to apply those changes after the slam. Else we
973 // get a net loss of permissions
974 foreach (SceneObjectPart part in so.Parts)
975 {
976 if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0)
977 {
978 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
979 part.EveryoneMask = item.EveryOnePermissions & part.BaseMask;
980 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
981 part.NextOwnerMask = item.NextPermissions & part.BaseMask;
982 }
983 }
961 } 984 }
962 } 985 }
963 986 else
964 foreach (SceneObjectPart part in so.Parts)
965 { 987 {
966 part.FromUserInventoryItemID = fromUserInventoryItemId; 988 foreach (SceneObjectPart part in so.Parts)
967
968 if ((part.OwnerID != item.Owner) ||
969 (item.CurrentPermissions & 16) != 0)
970 { 989 {
971 part.Inventory.ChangeInventoryOwner(item.Owner); 990 part.FromUserInventoryItemID = fromUserInventoryItemId;
972 part.GroupMask = 0; // DO NOT propagate here 991
992 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
993 part.EveryoneMask = item.EveryOnePermissions;
994 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
995 part.NextOwnerMask = item.NextPermissions;
996 if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
997 part.GroupMask = item.GroupPermissions;
973 } 998 }
974
975 part.EveryoneMask = item.EveryOnePermissions;
976 part.NextOwnerMask = item.NextPermissions;
977 } 999 }
978 1000
979 rootPart.TrimPermissions(); 1001 rootPart.TrimPermissions();
@@ -1111,4 +1133,4 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
1111 1133
1112 #endregion 1134 #endregion
1113 } 1135 }
1114} \ No newline at end of file 1136}
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
index 16cbbf5..f49641f 100644
--- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
+++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs
@@ -170,7 +170,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare
170 170
171 private void EventManager_OnMakeRootAgent(ScenePresence presence) 171 private void EventManager_OnMakeRootAgent(ScenePresence presence)
172 { 172 {
173 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client"); 173 if (m_enableWindlight && m_scene.RegionInfo.WindlightSettings.valid)
174 m_log.Debug("[WINDLIGHT]: Sending windlight scene to new client");
174 SendProfileToClient(presence.ControllingClient); 175 SendProfileToClient(presence.ControllingClient);
175 } 176 }
176 177
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index d328eb3..9dac6b9 100644
--- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -382,6 +382,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
382 try 382 try
383 { 383 {
384 Request = (HttpWebRequest) WebRequest.Create(Url); 384 Request = (HttpWebRequest) WebRequest.Create(Url);
385
386 //This works around some buggy HTTP Servers like Lighttpd
387 Request.ServicePoint.Expect100Continue = false;
388
385 Request.Method = HttpMethod; 389 Request.Method = HttpMethod;
386 Request.ContentType = HttpMIMEType; 390 Request.ContentType = HttpMIMEType;
387 391
@@ -458,15 +462,36 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
458 462
459 // continue building the string 463 // continue building the string
460 sb.Append(tempString); 464 sb.Append(tempString);
465 if (sb.Length > 2048)
466 break;
461 } 467 }
462 } while (count > 0); // any more data to read? 468 } while (count > 0); // any more data to read?
463 469
464 ResponseBody = sb.ToString(); 470 ResponseBody = sb.ToString().Replace("\r", "");
465 } 471 }
466 catch (Exception e) 472 catch (Exception e)
467 { 473 {
468 Status = (int)OSHttpStatusCode.ClientErrorJoker; 474 if (e is WebException && ((WebException)e).Status == WebExceptionStatus.ProtocolError)
469 ResponseBody = e.Message; 475 {
476 HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response;
477 Status = (int)webRsp.StatusCode;
478 try
479 {
480 using (Stream responseStream = webRsp.GetResponseStream())
481 {
482 ResponseBody = responseStream.GetStreamString();
483 }
484 }
485 catch
486 {
487 ResponseBody = webRsp.StatusDescription;
488 }
489 }
490 else
491 {
492 Status = (int)OSHttpStatusCode.ClientErrorJoker;
493 ResponseBody = e.Message;
494 }
470 495
471 _finished = true; 496 _finished = true;
472 return; 497 return;
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 93e75b3..f4cf6b4 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
61 //public ManualResetEvent ev; 61 //public ManualResetEvent ev;
62 public bool requestDone; 62 public bool requestDone;
63 public int startTime; 63 public int startTime;
64 public bool responseSent;
64 public string uri; 65 public string uri;
65 } 66 }
66 67
@@ -77,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
77 new Dictionary<string, UrlData>(); 78 new Dictionary<string, UrlData>();
78 79
79 80
80 private int m_TotalUrls = 100; 81 private int m_TotalUrls = 5000;
81 82
82 private uint https_port = 0; 83 private uint https_port = 0;
83 private IHttpServer m_HttpServer = null; 84 private IHttpServer m_HttpServer = null;
@@ -157,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
157 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); 158 engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" });
158 return urlcode; 159 return urlcode;
159 } 160 }
160 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; 161 string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString();
161 162
162 UrlData urlData = new UrlData(); 163 UrlData urlData = new UrlData();
163 urlData.hostID = host.UUID; 164 urlData.hostID = host.UUID;
@@ -166,10 +167,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
166 urlData.url = url; 167 urlData.url = url;
167 urlData.urlcode = urlcode; 168 urlData.urlcode = urlcode;
168 urlData.requests = new Dictionary<UUID, RequestData>(); 169 urlData.requests = new Dictionary<UUID, RequestData>();
169 170
170 m_UrlMap[url] = urlData; 171 m_UrlMap[url] = urlData;
171 172
172 string uri = "/lslhttp/" + urlcode.ToString() + "/"; 173 string uri = "/lslhttp/" + urlcode.ToString();
173 174
174 m_HttpServer.AddPollServiceHTTPHandler( 175 m_HttpServer.AddPollServiceHTTPHandler(
175 uri, 176 uri,
@@ -234,9 +235,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
234 return; 235 return;
235 } 236 }
236 237
237 foreach (UUID req in data.requests.Keys) 238 lock (m_RequestMap)
238 m_RequestMap.Remove(req); 239 {
239 240 foreach (UUID req in data.requests.Keys)
241 m_RequestMap.Remove(req);
242 }
243
240 RemoveUrl(data); 244 RemoveUrl(data);
241 m_UrlMap.Remove(url); 245 m_UrlMap.Remove(url);
242 } 246 }
@@ -244,32 +248,42 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
244 248
245 public void HttpResponse(UUID request, int status, string body) 249 public void HttpResponse(UUID request, int status, string body)
246 { 250 {
247 if (m_RequestMap.ContainsKey(request)) 251 lock (m_RequestMap)
248 {
249 UrlData urlData = m_RequestMap[request];
250 urlData.requests[request].responseCode = status;
251 urlData.requests[request].responseBody = body;
252 //urlData.requests[request].ev.Set();
253 urlData.requests[request].requestDone =true;
254 }
255 else
256 { 252 {
257 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); 253 if (m_RequestMap.ContainsKey(request))
254 {
255 UrlData urlData = m_RequestMap[request];
256 if (!urlData.requests[request].responseSent)
257 {
258 urlData.requests[request].responseCode = status;
259 urlData.requests[request].responseBody = body;
260 //urlData.requests[request].ev.Set();
261 urlData.requests[request].requestDone = true;
262 urlData.requests[request].responseSent = true;
263 }
264 }
265 else
266 {
267 m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
268 }
258 } 269 }
259 } 270 }
260 271
261 public string GetHttpHeader(UUID requestId, string header) 272 public string GetHttpHeader(UUID requestId, string header)
262 { 273 {
263 if (m_RequestMap.ContainsKey(requestId)) 274 lock (m_RequestMap)
264 {
265 UrlData urlData=m_RequestMap[requestId];
266 string value;
267 if (urlData.requests[requestId].headers.TryGetValue(header,out value))
268 return value;
269 }
270 else
271 { 275 {
272 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); 276 if (m_RequestMap.ContainsKey(requestId))
277 {
278 UrlData urlData = m_RequestMap[requestId];
279 string value;
280 if (urlData.requests[requestId].headers.TryGetValue(header, out value))
281 return value;
282 }
283 else
284 {
285 m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId);
286 }
273 } 287 }
274 return String.Empty; 288 return String.Empty;
275 } 289 }
@@ -293,8 +307,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
293 { 307 {
294 RemoveUrl(url.Value); 308 RemoveUrl(url.Value);
295 removeURLs.Add(url.Key); 309 removeURLs.Add(url.Key);
296 foreach (UUID req in url.Value.requests.Keys) 310 lock (m_RequestMap)
297 m_RequestMap.Remove(req); 311 {
312 foreach (UUID req in url.Value.requests.Keys)
313 m_RequestMap.Remove(req);
314 }
298 } 315 }
299 } 316 }
300 317
@@ -315,8 +332,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
315 { 332 {
316 RemoveUrl(url.Value); 333 RemoveUrl(url.Value);
317 removeURLs.Add(url.Key); 334 removeURLs.Add(url.Key);
318 foreach (UUID req in url.Value.requests.Keys) 335 lock (m_RequestMap)
319 m_RequestMap.Remove(req); 336 {
337 foreach (UUID req in url.Value.requests.Keys)
338 m_RequestMap.Remove(req);
339 }
320 } 340 }
321 } 341 }
322 342
@@ -335,14 +355,16 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
335 { 355 {
336 Hashtable response = new Hashtable(); 356 Hashtable response = new Hashtable();
337 UrlData url; 357 UrlData url;
358 int startTime = 0;
338 lock (m_RequestMap) 359 lock (m_RequestMap)
339 { 360 {
340 if (!m_RequestMap.ContainsKey(requestID)) 361 if (!m_RequestMap.ContainsKey(requestID))
341 return response; 362 return response;
342 url = m_RequestMap[requestID]; 363 url = m_RequestMap[requestID];
364 startTime = url.requests[requestID].startTime;
343 } 365 }
344 366
345 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) 367 if (System.Environment.TickCount - startTime > 25000)
346 { 368 {
347 response["int_response_code"] = 500; 369 response["int_response_code"] = 500;
348 response["str_response_string"] = "Script timeout"; 370 response["str_response_string"] = "Script timeout";
@@ -351,9 +373,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
351 response["reusecontext"] = false; 373 response["reusecontext"] = false;
352 374
353 //remove from map 375 //remove from map
354 lock (url) 376 lock (url.requests)
355 { 377 {
356 url.requests.Remove(requestID); 378 url.requests.Remove(requestID);
379 }
380 lock (m_RequestMap)
381 {
357 m_RequestMap.Remove(requestID); 382 m_RequestMap.Remove(requestID);
358 } 383 }
359 384
@@ -375,22 +400,25 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
375 return false; 400 return false;
376 } 401 }
377 url = m_RequestMap[requestID]; 402 url = m_RequestMap[requestID];
403 }
404 lock (url.requests)
405 {
378 if (!url.requests.ContainsKey(requestID)) 406 if (!url.requests.ContainsKey(requestID))
379 { 407 {
380 return false; 408 return false;
381 } 409 }
410 else
411 {
412 if (System.Environment.TickCount - url.requests[requestID].startTime > 25000)
413 {
414 return true;
415 }
416 if (url.requests[requestID].requestDone)
417 return true;
418 else
419 return false;
420 }
382 } 421 }
383
384 if (System.Environment.TickCount-url.requests[requestID].startTime>25000)
385 {
386 return true;
387 }
388
389 if (url.requests[requestID].requestDone)
390 return true;
391 else
392 return false;
393
394 } 422 }
395 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) 423 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
396 { 424 {
@@ -402,9 +430,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
402 if (!m_RequestMap.ContainsKey(requestID)) 430 if (!m_RequestMap.ContainsKey(requestID))
403 return NoEvents(requestID,sessionID); 431 return NoEvents(requestID,sessionID);
404 url = m_RequestMap[requestID]; 432 url = m_RequestMap[requestID];
433 }
434 lock (url.requests)
435 {
405 requestData = url.requests[requestID]; 436 requestData = url.requests[requestID];
406 } 437 }
407 438
408 if (!requestData.requestDone) 439 if (!requestData.requestDone)
409 return NoEvents(requestID,sessionID); 440 return NoEvents(requestID,sessionID);
410 441
@@ -427,14 +458,18 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
427 response["reusecontext"] = false; 458 response["reusecontext"] = false;
428 459
429 //remove from map 460 //remove from map
430 lock (url) 461 lock (url.requests)
431 { 462 {
432 url.requests.Remove(requestID); 463 url.requests.Remove(requestID);
464 }
465 lock (m_RequestMap)
466 {
433 m_RequestMap.Remove(requestID); 467 m_RequestMap.Remove(requestID);
434 } 468 }
435 469
436 return response; 470 return response;
437 } 471 }
472
438 public void HttpRequestHandler(UUID requestID, Hashtable request) 473 public void HttpRequestHandler(UUID requestID, Hashtable request)
439 { 474 {
440 lock (request) 475 lock (request)
@@ -450,8 +485,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
450 485
451 int pos1 = uri.IndexOf("/");// /lslhttp 486 int pos1 = uri.IndexOf("/");// /lslhttp
452 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ 487 int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/
453 int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ 488 int pos3 = pos2 + 37; // /lslhttp/urlcode
454 string uri_tmp = uri.Substring(0, pos3 + 1); 489 string uri_tmp = uri.Substring(0, pos3);
455 //HTTP server code doesn't provide us with QueryStrings 490 //HTTP server code doesn't provide us with QueryStrings
456 string pathInfo; 491 string pathInfo;
457 string queryString; 492 string queryString;
@@ -460,10 +495,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
460 pathInfo = uri.Substring(pos3); 495 pathInfo = uri.Substring(pos3);
461 496
462 UrlData url = null; 497 UrlData url = null;
498 string urlkey;
463 if (!is_ssl) 499 if (!is_ssl)
464 url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; 500 urlkey = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp;
501 //m_UrlMap[];
465 else 502 else
466 url = m_UrlMap["https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp]; 503 urlkey = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp;
504
505 if (m_UrlMap.ContainsKey(urlkey))
506 {
507 url = m_UrlMap[urlkey];
508 }
509 else
510 {
511 m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString());
512 }
467 513
468 //for llGetHttpHeader support we need to store original URI here 514 //for llGetHttpHeader support we need to store original URI here
469 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers 515 //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers
@@ -493,7 +539,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
493 if (request.ContainsKey(key)) 539 if (request.ContainsKey(key))
494 { 540 {
495 string val = (String)request[key]; 541 string val = (String)request[key];
496 queryString = queryString + key + "=" + val + "&"; 542 if (key != "")
543 {
544 queryString = queryString + key + "=" + val + "&";
545 }
546 else
547 {
548 queryString = queryString + val + "&";
549 }
497 } 550 }
498 } 551 }
499 if (queryString.Length > 1) 552 if (queryString.Length > 1)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index a17c6ae..faa1def 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -271,7 +271,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
271 if (s.RegionInfo.RegionID == destination.RegionID) 271 if (s.RegionInfo.RegionID == destination.RegionID)
272 return s.QueryAccess(id, position, out reason); 272 return s.QueryAccess(id, position, out reason);
273 } 273 }
274 //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess");
275 return false; 274 return false;
276 } 275 }
277 276
@@ -301,10 +300,24 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
301 if (s.RegionInfo.RegionID == destination.RegionID) 300 if (s.RegionInfo.RegionID == destination.RegionID)
302 { 301 {
303 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent"); 302 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
304 // Let's spawn a threadlet right here, because this may take 303 return s.IncomingCloseAgent(id);
305 // a while 304 }
306 Util.FireAndForget(delegate { s.IncomingCloseAgent(id); }); 305 }
307 return true; 306 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
307 return false;
308 }
309
310 public bool CloseChildAgent(GridRegion destination, UUID id)
311 {
312 if (destination == null)
313 return false;
314
315 foreach (Scene s in m_sceneList)
316 {
317 if (s.RegionInfo.RegionID == destination.RegionID)
318 {
319 //m_log.Debug("[LOCAL COMMS]: Found region to SendCloseAgent");
320 return s.IncomingCloseChildAgent(id);
308 } 321 }
309 } 322 }
310 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 323 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index f8cea71..391b1a1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -261,6 +261,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
261 return false; 261 return false;
262 } 262 }
263 263
264 public bool CloseChildAgent(GridRegion destination, UUID id)
265 {
266 if (destination == null)
267 return false;
268
269 // Try local first
270 if (m_localBackend.CloseChildAgent(destination, id))
271 return true;
272
273 // else do the remote thing
274 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
275 return m_remoteConnector.CloseChildAgent(destination, id);
276
277 return false;
278 }
264 279
265 public bool CloseAgent(GridRegion destination, UUID id) 280 public bool CloseAgent(GridRegion destination, UUID id)
266 { 281 {
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
index 0a0ce3c..1ffd480 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs
@@ -127,6 +127,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
127 // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner 127 // FIXME: Why do we bother setting this module and caching up if we just end up registering the inner
128 // user account service?! 128 // user account service?!
129 scene.RegisterModuleInterface<IUserAccountService>(UserAccountService); 129 scene.RegisterModuleInterface<IUserAccountService>(UserAccountService);
130 scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache);
130 } 131 }
131 132
132 public void RemoveRegion(Scene scene) 133 public void RemoveRegion(Scene scene)
@@ -179,6 +180,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
179 return UserAccountService.GetUserAccount(scopeID, Email); 180 return UserAccountService.GetUserAccount(scopeID, Email);
180 } 181 }
181 182
183 public List<UserAccount> GetUserAccountsWhere(UUID scopeID, string query)
184 {
185 return null;
186 }
187
182 public List<UserAccount> GetUserAccounts(UUID scopeID, string query) 188 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
183 { 189 {
184 return UserAccountService.GetUserAccounts(scopeID, query); 190 return UserAccountService.GetUserAccounts(scopeID, query);
@@ -193,4 +199,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
193 199
194 #endregion 200 #endregion
195 } 201 }
196} \ No newline at end of file 202}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
index 3321b38..f6b6aeb 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs
@@ -33,6 +33,7 @@ using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors; 35using OpenSim.Services.Connectors;
36using OpenSim.Framework;
36 37
37using OpenMetaverse; 38using OpenMetaverse;
38 39
@@ -101,6 +102,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
101 return; 102 return;
102 103
103 scene.RegisterModuleInterface<IUserAccountService>(this); 104 scene.RegisterModuleInterface<IUserAccountService>(this);
105 scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache);
106
107 scene.EventManager.OnNewClient += OnNewClient;
104 } 108 }
105 109
106 public void RemoveRegion(Scene scene) 110 public void RemoveRegion(Scene scene)
@@ -115,6 +119,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
115 return; 119 return;
116 } 120 }
117 121
122 // When a user actually enters the sim, clear them from
123 // cache so the sim will have the current values for
124 // flags, title, etc. And country, don't forget country!
125 private void OnNewClient(IClientAPI client)
126 {
127 m_Cache.Remove(client.Name);
128 }
129
118 #region Overwritten methods from IUserAccountService 130 #region Overwritten methods from IUserAccountService
119 131
120 public override UserAccount GetUserAccount(UUID scopeID, UUID userID) 132 public override UserAccount GetUserAccount(UUID scopeID, UUID userID)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
index ddef75f..cbe2eaa 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs
@@ -34,7 +34,7 @@ using log4net;
34 34
35namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts 35namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
36{ 36{
37 public class UserAccountCache 37 public class UserAccountCache : IUserAccountCacheModule
38 { 38 {
39 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! 39 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
40 40
@@ -92,5 +92,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
92 92
93 return null; 93 return null;
94 } 94 }
95
96 public void Remove(string name)
97 {
98 if (!m_NameCache.Contains(name))
99 return;
100
101 UUID uuid = UUID.Zero;
102 if (m_NameCache.TryGetValue(name, out uuid))
103 {
104 m_NameCache.Remove(name);
105 m_UUIDCache.Remove(uuid);
106 }
107 }
95 } 108 }
96} 109}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index a6dbaba..38db239 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -298,6 +298,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
298 // being no copy/no mod for everyone 298 // being no copy/no mod for everyone
299 lock (part.TaskInventory) 299 lock (part.TaskInventory)
300 { 300 {
301 if (!ResolveUserUuid(part.CreatorID))
302 part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
303
304 if (!ResolveUserUuid(part.OwnerID))
305 part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
306
307 if (!ResolveUserUuid(part.LastOwnerID))
308 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
309
310 // And zap any troublesome sit target information
311 part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
312 part.SitTargetPosition = new Vector3(0, 0, 0);
313
314 // Fix ownership/creator of inventory items
315 // Not doing so results in inventory items
316 // being no copy/no mod for everyone
317 part.TaskInventory.LockItemsForRead(true);
301 TaskInventoryDictionary inv = part.TaskInventory; 318 TaskInventoryDictionary inv = part.TaskInventory;
302 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) 319 foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
303 { 320 {
@@ -313,6 +330,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
313 if (UserManager != null) 330 if (UserManager != null)
314 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); 331 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
315 } 332 }
333 part.TaskInventory.LockItemsForRead(false);
316 } 334 }
317 } 335 }
318 336
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 948aac8..900260d 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -251,18 +251,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
251 251
252 if (asset != null) 252 if (asset != null)
253 { 253 {
254 if (m_options.ContainsKey("verbose")) 254// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
255 m_log.InfoFormat("[ARCHIVER]: Writing asset {0}", id);
256
257 m_foundAssetUuids.Add(asset.FullID); 255 m_foundAssetUuids.Add(asset.FullID);
258 256
259 m_assetsArchiver.WriteAsset(PostProcess(asset)); 257 m_assetsArchiver.WriteAsset(PostProcess(asset));
260 } 258 }
261 else 259 else
262 { 260 {
263 if (m_options.ContainsKey("verbose")) 261// m_log.DebugFormat("[ARCHIVER]: Recording asset {0} as not found", id);
264 m_log.InfoFormat("[ARCHIVER]: Recording asset {0} as not found", id);
265
266 m_notFoundAssetUuids.Add(new UUID(id)); 262 m_notFoundAssetUuids.Add(new UUID(id));
267 } 263 }
268 264
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 2e1487f..d5e3314 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Security; 32using System.Security;
33using System.Timers;
33using log4net; 34using log4net;
34using Mono.Addins; 35using Mono.Addins;
35using Nini.Config; 36using Nini.Config;
@@ -47,6 +48,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
47 48
48 private delegate void LookupUUIDS(List<UUID> uuidLst); 49 private delegate void LookupUUIDS(List<UUID> uuidLst);
49 50
51 private Timer m_regionChangeTimer = new Timer();
50 public Scene Scene { get; private set; } 52 public Scene Scene { get; private set; }
51 public IUserManagement UserManager { get; private set; } 53 public IUserManagement UserManager { get; private set; }
52 54
@@ -61,6 +63,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
61 63
62 #region Packet Data Responders 64 #region Packet Data Responders
63 65
66 private void clientSendDetailedEstateData(IClientAPI remote_client, UUID invoice)
67 {
68 sendDetailedEstateData(remote_client, invoice);
69 sendEstateLists(remote_client, invoice);
70 }
71
64 private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) 72 private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice)
65 { 73 {
66 uint sun = 0; 74 uint sun = 0;
@@ -82,7 +90,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
82 Scene.RegionInfo.RegionSettings.Covenant, 90 Scene.RegionInfo.RegionSettings.Covenant,
83 Scene.RegionInfo.EstateSettings.AbuseEmail, 91 Scene.RegionInfo.EstateSettings.AbuseEmail,
84 estateOwner); 92 estateOwner);
93 }
85 94
95 private void sendEstateLists(IClientAPI remote_client, UUID invoice)
96 {
86 remote_client.SendEstateList(invoice, 97 remote_client.SendEstateList(invoice,
87 (int)Constants.EstateAccessCodex.EstateManagers, 98 (int)Constants.EstateAccessCodex.EstateManagers,
88 Scene.RegionInfo.EstateSettings.EstateManagers, 99 Scene.RegionInfo.EstateSettings.EstateManagers,
@@ -245,6 +256,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
245 IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); 256 IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>();
246 if (restartModule != null) 257 if (restartModule != null)
247 { 258 {
259 if (timeInSeconds == -1)
260 {
261 restartModule.AbortRestart("Restart aborted by region manager");
262 return;
263 }
264
248 List<int> times = new List<int>(); 265 List<int> times = new List<int>();
249 while (timeInSeconds > 0) 266 while (timeInSeconds > 0)
250 { 267 {
@@ -257,7 +274,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
257 timeInSeconds -= 15; 274 timeInSeconds -= 15;
258 } 275 }
259 276
260 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); 277 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), false);
261 } 278 }
262 } 279 }
263 280
@@ -464,7 +481,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
464 { 481 {
465 if (!s.IsChildAgent) 482 if (!s.IsChildAgent)
466 { 483 {
467 Scene.TeleportClientHome(user, s.ControllingClient); 484 if (!Scene.TeleportClientHome(user, s.ControllingClient))
485 {
486 s.ControllingClient.Kick("Your access to the region was revoked and TP home failed - you have been logged out.");
487 s.ControllingClient.Close();
488 }
468 } 489 }
469 } 490 }
470 491
@@ -473,7 +494,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
473 { 494 {
474 remote_client.SendAlertMessage("User is already on the region ban list"); 495 remote_client.SendAlertMessage("User is already on the region ban list");
475 } 496 }
476 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 497 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
477 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); 498 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
478 } 499 }
479 else 500 else
@@ -528,7 +549,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
528 remote_client.SendAlertMessage("User is not on the region ban list"); 549 remote_client.SendAlertMessage("User is not on the region ban list");
529 } 550 }
530 551
531 //m_scene.RegionInfo.regionBanlist.Add(Manager(user); 552 //Scene.RegionInfo.regionBanlist.Add(Manager(user);
532 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID); 553 remote_client.SendBannedUserList(invoice, Scene.RegionInfo.EstateSettings.EstateBans, Scene.RegionInfo.EstateSettings.EstateID);
533 } 554 }
534 else 555 else
@@ -693,7 +714,11 @@ namespace OpenSim.Region.CoreModules.World.Estate
693 ScenePresence s = Scene.GetScenePresence(prey); 714 ScenePresence s = Scene.GetScenePresence(prey);
694 if (s != null) 715 if (s != null)
695 { 716 {
696 Scene.TeleportClientHome(prey, s.ControllingClient); 717 if (!Scene.TeleportClientHome(prey, s.ControllingClient))
718 {
719 s.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
720 s.ControllingClient.Close();
721 }
697 } 722 }
698 } 723 }
699 } 724 }
@@ -711,7 +736,13 @@ namespace OpenSim.Region.CoreModules.World.Estate
711 // Also make sure they are actually in the region 736 // Also make sure they are actually in the region
712 ScenePresence p; 737 ScenePresence p;
713 if(Scene.TryGetScenePresence(client.AgentId, out p)) 738 if(Scene.TryGetScenePresence(client.AgentId, out p))
714 Scene.TeleportClientHome(p.UUID, p.ControllingClient); 739 {
740 if (!Scene.TeleportClientHome(p.UUID, p.ControllingClient))
741 {
742 p.ControllingClient.Kick("You were teleported home by the region owner, but the TP failed - you have been logged out.");
743 p.ControllingClient.Close();
744 }
745 }
715 } 746 }
716 }); 747 });
717 } 748 }
@@ -955,7 +986,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
955 986
956 for (int i = 0; i < uuidarr.Length; i++) 987 for (int i = 0; i < uuidarr.Length; i++)
957 { 988 {
958 // string lookupname = m_scene.CommsManager.UUIDNameRequestString(uuidarr[i]); 989 // string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
959 990
960 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>(); 991 IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
961 if (userManager != null) 992 if (userManager != null)
@@ -1096,6 +1127,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
1096 1127
1097 public void AddRegion(Scene scene) 1128 public void AddRegion(Scene scene)
1098 { 1129 {
1130 m_regionChangeTimer.AutoReset = false;
1131 m_regionChangeTimer.Interval = 2000;
1132 m_regionChangeTimer.Elapsed += RaiseRegionInfoChange;
1133
1099 Scene = scene; 1134 Scene = scene;
1100 Scene.RegisterModuleInterface<IEstateModule>(this); 1135 Scene.RegisterModuleInterface<IEstateModule>(this);
1101 Scene.EventManager.OnNewClient += EventManager_OnNewClient; 1136 Scene.EventManager.OnNewClient += EventManager_OnNewClient;
@@ -1146,7 +1181,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
1146 1181
1147 private void EventManager_OnNewClient(IClientAPI client) 1182 private void EventManager_OnNewClient(IClientAPI client)
1148 { 1183 {
1149 client.OnDetailedEstateDataRequest += sendDetailedEstateData; 1184 client.OnDetailedEstateDataRequest += clientSendDetailedEstateData;
1150 client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler; 1185 client.OnSetEstateFlagsRequest += estateSetRegionInfoHandler;
1151// client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture; 1186// client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
1152 client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture; 1187 client.OnSetEstateTerrainDetailTexture += setEstateTerrainBaseTexture;
@@ -1198,6 +1233,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
1198 flags |= RegionFlags.AllowParcelChanges; 1233 flags |= RegionFlags.AllowParcelChanges;
1199 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch) 1234 if (Scene.RegionInfo.RegionSettings.BlockShowInSearch)
1200 flags |= RegionFlags.BlockParcelSearch; 1235 flags |= RegionFlags.BlockParcelSearch;
1236 if (Scene.RegionInfo.RegionSettings.GodBlockSearch)
1237 flags |= (RegionFlags)(1 << 11);
1238 if (Scene.RegionInfo.RegionSettings.Casino)
1239 flags |= (RegionFlags)(1 << 10);
1201 1240
1202 if (Scene.RegionInfo.RegionSettings.FixedSun) 1241 if (Scene.RegionInfo.RegionSettings.FixedSun)
1203 flags |= RegionFlags.SunFixed; 1242 flags |= RegionFlags.SunFixed;
@@ -1205,11 +1244,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
1205 flags |= RegionFlags.Sandbox; 1244 flags |= RegionFlags.Sandbox;
1206 if (Scene.RegionInfo.EstateSettings.AllowVoice) 1245 if (Scene.RegionInfo.EstateSettings.AllowVoice)
1207 flags |= RegionFlags.AllowVoice; 1246 flags |= RegionFlags.AllowVoice;
1247 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1248 flags |= RegionFlags.AllowLandmark;
1249 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1250 flags |= RegionFlags.AllowSetHome;
1251 if (Scene.RegionInfo.EstateSettings.BlockDwell)
1252 flags |= RegionFlags.BlockDwell;
1253 if (Scene.RegionInfo.EstateSettings.ResetHomeOnTeleport)
1254 flags |= RegionFlags.ResetHomeOnTeleport;
1208 1255
1209 // Fudge these to always on, so the menu options activate
1210 //
1211 flags |= RegionFlags.AllowLandmark;
1212 flags |= RegionFlags.AllowSetHome;
1213 1256
1214 // TODO: SkipUpdateInterestList 1257 // TODO: SkipUpdateInterestList
1215 1258
@@ -1250,6 +1293,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1250 flags |= RegionFlags.ResetHomeOnTeleport; 1293 flags |= RegionFlags.ResetHomeOnTeleport;
1251 if (Scene.RegionInfo.EstateSettings.TaxFree) 1294 if (Scene.RegionInfo.EstateSettings.TaxFree)
1252 flags |= RegionFlags.TaxFree; 1295 flags |= RegionFlags.TaxFree;
1296 if (Scene.RegionInfo.EstateSettings.AllowLandmark)
1297 flags |= RegionFlags.AllowLandmark;
1298 if (Scene.RegionInfo.EstateSettings.AllowParcelChanges)
1299 flags |= RegionFlags.AllowParcelChanges;
1300 if (Scene.RegionInfo.EstateSettings.AllowSetHome)
1301 flags |= RegionFlags.AllowSetHome;
1253 if (Scene.RegionInfo.EstateSettings.DenyMinors) 1302 if (Scene.RegionInfo.EstateSettings.DenyMinors)
1254 flags |= (RegionFlags)(1 << 30); 1303 flags |= (RegionFlags)(1 << 30);
1255 1304
@@ -1270,6 +1319,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
1270 1319
1271 public void TriggerRegionInfoChange() 1320 public void TriggerRegionInfoChange()
1272 { 1321 {
1322 m_regionChangeTimer.Stop();
1323 m_regionChangeTimer.Start();
1324 }
1325
1326 protected void RaiseRegionInfoChange(object sender, ElapsedEventArgs e)
1327 {
1273 ChangeDelegate change = OnRegionInfoChange; 1328 ChangeDelegate change = OnRegionInfoChange;
1274 1329
1275 if (change != null) 1330 if (change != null)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 94bba83..7a236bc 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -91,6 +91,8 @@ namespace OpenSim.Region.CoreModules.World.Land
91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1; 91 private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
92 92
93 private bool m_allowedForcefulBans = true; 93 private bool m_allowedForcefulBans = true;
94 private UUID DefaultGodParcelGroup;
95 private string DefaultGodParcelName;
94 96
95 // caches ExtendedLandData 97 // caches ExtendedLandData
96 private Cache parcelInfoCache; 98 private Cache parcelInfoCache;
@@ -106,6 +108,12 @@ namespace OpenSim.Region.CoreModules.World.Land
106 108
107 public void Initialise(IConfigSource source) 109 public void Initialise(IConfigSource source)
108 { 110 {
111 IConfig cnf = source.Configs["LandManagement"];
112 if (cnf != null)
113 {
114 DefaultGodParcelGroup = new UUID(cnf.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
115 DefaultGodParcelName = cnf.GetString("DefaultAdministratorParcelName", "Default Parcel");
116 }
109 } 117 }
110 118
111 public void AddRegion(Scene scene) 119 public void AddRegion(Scene scene)
@@ -157,13 +165,6 @@ namespace OpenSim.Region.CoreModules.World.Land
157 m_scene.UnregisterModuleCommander(m_commander.Name); 165 m_scene.UnregisterModuleCommander(m_commander.Name);
158 } 166 }
159 167
160// private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
161// {
162// ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
163// reason = "You are not allowed to enter this sim.";
164// return nearestParcel != null;
165// }
166
167 /// <summary> 168 /// <summary>
168 /// Processes commandline input. Do not call directly. 169 /// Processes commandline input. Do not call directly.
169 /// </summary> 170 /// </summary>
@@ -215,36 +216,6 @@ namespace OpenSim.Region.CoreModules.World.Land
215 216
216 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) 217 void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
217 { 218 {
218 //If we are forcing a position for them to go
219 if (forcedPosition.ContainsKey(remoteClient.AgentId))
220 {
221 ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
222
223 //Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
224 //When the avatar walks into a ban line on the ground, it prevents getting stuck
225 agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
226
227
228 //Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
229 if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) < .2)
230 {
231 Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition[remoteClient.AgentId], clientAvatar.AbsolutePosition));
232 forcedPosition.Remove(remoteClient.AgentId);
233 }
234 //if we are far away, teleport
235 else if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition[remoteClient.AgentId]) > 3)
236 {
237 Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}", forcedPosition[remoteClient.AgentId], clientAvatar.AbsolutePosition));
238 clientAvatar.Teleport(forcedPosition[remoteClient.AgentId]);
239 forcedPosition.Remove(remoteClient.AgentId);
240 }
241 else
242 {
243 //Forces them toward the forced position we want if they aren't there yet
244 agentData.UseClientAgentPosition = true;
245 agentData.ClientAgentPosition = forcedPosition[remoteClient.AgentId];
246 }
247 }
248 } 219 }
249 220
250 public void Close() 221 public void Close()
@@ -363,10 +334,16 @@ namespace OpenSim.Region.CoreModules.World.Land
363 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position) 334 private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
364 { 335 {
365 if (m_scene.Permissions.IsGod(avatar.UUID)) return; 336 if (m_scene.Permissions.IsGod(avatar.UUID)) return;
366 if (position.HasValue) 337
367 { 338 if (!position.HasValue)
368 forcedPosition[avatar.ControllingClient.AgentId] = (Vector3)position; 339 return;
369 } 340
341 bool isFlying = avatar.PhysicsActor.Flying;
342 avatar.RemoveFromPhysicalScene();
343
344 avatar.AbsolutePosition = (Vector3)position;
345
346 avatar.AddToPhysicalScene(isFlying);
370 } 347 }
371 348
372 public void SendYouAreRestrictedNotice(ScenePresence avatar) 349 public void SendYouAreRestrictedNotice(ScenePresence avatar)
@@ -386,29 +363,7 @@ namespace OpenSim.Region.CoreModules.World.Land
386 } 363 }
387 364
388 if (parcelAvatarIsEntering != null) 365 if (parcelAvatarIsEntering != null)
389 { 366 EnforceBans(parcelAvatarIsEntering, avatar);
390 if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
391 {
392 if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
393 {
394 SendYouAreBannedNotice(avatar);
395 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
396 }
397 else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
398 {
399 SendYouAreRestrictedNotice(avatar);
400 ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
401 }
402 else
403 {
404 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
405 }
406 }
407 else
408 {
409 avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
410 }
411 }
412 } 367 }
413 } 368 }
414 369
@@ -512,6 +467,7 @@ namespace OpenSim.Region.CoreModules.World.Land
512 //when we are finally in a safe place, lets release the forced position lock 467 //when we are finally in a safe place, lets release the forced position lock
513 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId); 468 forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
514 } 469 }
470 EnforceBans(parcel, clientAvatar);
515 } 471 }
516 } 472 }
517 473
@@ -720,7 +676,7 @@ namespace OpenSim.Region.CoreModules.World.Land
720 int x; 676 int x;
721 int y; 677 int y;
722 678
723 if (x_float >= Constants.RegionSize || x_float < 0 || y_float >= Constants.RegionSize || y_float < 0) 679 if (x_float > Constants.RegionSize || x_float < 0 || y_float > Constants.RegionSize || y_float < 0)
724 return null; 680 return null;
725 681
726 try 682 try
@@ -770,14 +726,13 @@ namespace OpenSim.Region.CoreModules.World.Land
770 { 726 {
771 try 727 try
772 { 728 {
773 return m_landList[m_landIDList[x / 4, y / 4]]; 729 //if (m_landList.ContainsKey(m_landIDList[x / 4, y / 4]))
730 return m_landList[m_landIDList[x / 4, y / 4]];
731 //else
732 // return null;
774 } 733 }
775 catch (IndexOutOfRangeException) 734 catch (IndexOutOfRangeException)
776 { 735 {
777// m_log.WarnFormat(
778// "[LAND MANAGEMENT MODULE]: Tried to retrieve land object from out of bounds co-ordinate ({0},{1}) in {2}",
779// x, y, m_scene.RegionInfo.RegionName);
780
781 return null; 736 return null;
782 } 737 }
783 } 738 }
@@ -1060,6 +1015,10 @@ namespace OpenSim.Region.CoreModules.World.Land
1060 //Owner Flag 1015 //Owner Flag
1061 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER); 1016 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_REQUESTER);
1062 } 1017 }
1018 else if (currentParcelBlock.LandData.IsGroupOwned && remote_client.IsGroupMember(currentParcelBlock.LandData.GroupID))
1019 {
1020 tempByte = Convert.ToByte(tempByte | LandChannel.LAND_TYPE_OWNED_BY_GROUP);
1021 }
1063 else if (currentParcelBlock.LandData.SalePrice > 0 && 1022 else if (currentParcelBlock.LandData.SalePrice > 0 &&
1064 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero || 1023 (currentParcelBlock.LandData.AuthBuyerID == UUID.Zero ||
1065 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId)) 1024 currentParcelBlock.LandData.AuthBuyerID == remote_client.AgentId))
@@ -1360,18 +1319,31 @@ namespace OpenSim.Region.CoreModules.World.Land
1360 1319
1361 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) 1320 public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data)
1362 { 1321 {
1363 for (int i = 0; i < data.Count; i++) 1322 lock (m_landList)
1364 { 1323 {
1365 IncomingLandObjectFromStorage(data[i]); 1324 //Remove all the land objects in the sim and then process our new data
1325 foreach (int n in m_landList.Keys)
1326 {
1327 m_scene.EventManager.TriggerLandObjectRemoved(m_landList[n].LandData.GlobalID);
1328 }
1329 m_landIDList.Initialize();
1330 m_landList.Clear();
1331
1332 for (int i = 0; i < data.Count; i++)
1333 {
1334 IncomingLandObjectFromStorage(data[i]);
1335 }
1366 } 1336 }
1367 } 1337 }
1368 1338
1369 public void IncomingLandObjectFromStorage(LandData data) 1339 public void IncomingLandObjectFromStorage(LandData data)
1370 { 1340 {
1341
1371 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene); 1342 ILandObject new_land = new LandObject(data.OwnerID, data.IsGroupOwned, m_scene);
1372 new_land.LandData = data.Copy(); 1343 new_land.LandData = data.Copy();
1373 new_land.SetLandBitmapFromByteArray(); 1344 new_land.SetLandBitmapFromByteArray();
1374 AddLandObject(new_land); 1345 AddLandObject(new_land);
1346 new_land.SendLandUpdateToAvatarsOverMe();
1375 } 1347 }
1376 1348
1377 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient) 1349 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
@@ -1649,6 +1621,322 @@ namespace OpenSim.Region.CoreModules.World.Land
1649 1621
1650 UpdateLandObject(localID, land.LandData); 1622 UpdateLandObject(localID, land.LandData);
1651 } 1623 }
1624
1625 public void ClientOnParcelGodMark(IClientAPI client, UUID god, int landID)
1626 {
1627 ILandObject land = null;
1628 List<ILandObject> Land = ((Scene)client.Scene).LandChannel.AllParcels();
1629 foreach (ILandObject landObject in Land)
1630 {
1631 if (landObject.LandData.LocalID == landID)
1632 {
1633 land = landObject;
1634 }
1635 }
1636 land.DeedToGroup(DefaultGodParcelGroup);
1637 land.LandData.Name = DefaultGodParcelName;
1638 land.SendLandUpdateToAvatarsOverMe();
1639 }
1640
1641 private void ClientOnSimWideDeletes(IClientAPI client, UUID agentID, int flags, UUID targetID)
1642 {
1643 ScenePresence SP;
1644 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out SP);
1645 List<SceneObjectGroup> returns = new List<SceneObjectGroup>();
1646 if (SP.UserLevel != 0)
1647 {
1648 if (flags == 0) //All parcels, scripted or not
1649 {
1650 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1651 {
1652 if (e.OwnerID == targetID)
1653 {
1654 returns.Add(e);
1655 }
1656 }
1657 );
1658 }
1659 if (flags == 4) //All parcels, scripted object
1660 {
1661 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1662 {
1663 if (e.OwnerID == targetID)
1664 {
1665 if (e.scriptScore >= 0.01)
1666 {
1667 returns.Add(e);
1668 }
1669 }
1670 }
1671 );
1672 }
1673 if (flags == 4) //not target parcel, scripted object
1674 {
1675 ((Scene)client.Scene).ForEachSOG(delegate(SceneObjectGroup e)
1676 {
1677 if (e.OwnerID == targetID)
1678 {
1679 ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
1680 if (landobject.LandData.OwnerID != e.OwnerID)
1681 {
1682 if (e.scriptScore >= 0.01)
1683 {
1684 returns.Add(e);
1685 }
1686 }
1687 }
1688 }
1689 );
1690 }
1691 foreach (SceneObjectGroup ol in returns)
1692 {
1693 ReturnObject(ol, client);
1694 }
1695 }
1696 }
1697 public void ReturnObject(SceneObjectGroup obj, IClientAPI client)
1698 {
1699 SceneObjectGroup[] objs = new SceneObjectGroup[1];
1700 objs[0] = obj;
1701 ((Scene)client.Scene).returnObjects(objs, client.AgentId);
1702 }
1703
1704 Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>();
1705
1706 public void ClientOnParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1707 {
1708 ScenePresence targetAvatar = null;
1709 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1710 ScenePresence parcelManager = null;
1711 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1712 System.Threading.Timer Timer;
1713
1714 if (targetAvatar.UserLevel == 0)
1715 {
1716 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1717 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1718 return;
1719 if (flags == 0)
1720 {
1721 targetAvatar.AllowMovement = false;
1722 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has frozen you for 30 seconds. You cannot move or interact with the world.");
1723 parcelManager.ControllingClient.SendAlertMessage("Avatar Frozen.");
1724 System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen);
1725 Timer = new System.Threading.Timer(timeCB, targetAvatar, 30000, 0);
1726 Timers.Add(targetAvatar.UUID, Timer);
1727 }
1728 else
1729 {
1730 targetAvatar.AllowMovement = true;
1731 targetAvatar.ControllingClient.SendAlertMessage(parcelManager.Firstname + " " + parcelManager.Lastname + " has unfrozen you.");
1732 parcelManager.ControllingClient.SendAlertMessage("Avatar Unfrozen.");
1733 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1734 Timers.Remove(targetAvatar.UUID);
1735 Timer.Dispose();
1736 }
1737 }
1738 }
1739 private void OnEndParcelFrozen(object avatar)
1740 {
1741 ScenePresence targetAvatar = (ScenePresence)avatar;
1742 targetAvatar.AllowMovement = true;
1743 System.Threading.Timer Timer;
1744 Timers.TryGetValue(targetAvatar.UUID, out Timer);
1745 Timers.Remove(targetAvatar.UUID);
1746 targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
1747 }
1748
1749
1750 public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
1751 {
1752 ScenePresence targetAvatar = null;
1753 ((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
1754 ScenePresence parcelManager = null;
1755 ((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
1756 //Just eject
1757 if (flags == 0)
1758 {
1759 if (targetAvatar.UserLevel == 0)
1760 {
1761 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1762 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1763 return;
1764
1765 Vector3 position = new Vector3(0, 0, 0);
1766 List<ILandObject> allParcels = new List<ILandObject>();
1767 allParcels = AllParcels();
1768 if (allParcels.Count != 1)
1769 {
1770 foreach (ILandObject parcel in allParcels)
1771 {
1772 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1773 {
1774 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1775 {
1776 for (int x = 1; x <= Constants.RegionSize; x += 2)
1777 {
1778 for (int y = 1; y <= Constants.RegionSize; y += 2)
1779 {
1780 if (parcel.ContainsPoint(x, y))
1781 {
1782 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1783 targetAvatar.TeleportWithMomentum(position);
1784 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1785 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1786 return;
1787 }
1788 }
1789 }
1790 }
1791 }
1792 }
1793 }
1794 Vector3 targetVector;
1795 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1796 {
1797 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1798 {
1799 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1800 targetAvatar.TeleportWithMomentum(targetVector);
1801 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1802 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1803 return;
1804 }
1805 else
1806 {
1807 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1808 targetAvatar.TeleportWithMomentum(targetVector);
1809 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1810 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1811 return;
1812 }
1813 }
1814 else
1815 {
1816 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1817 {
1818 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1819 targetAvatar.TeleportWithMomentum(targetVector);
1820 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1821 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1822 return;
1823 }
1824 else
1825 {
1826 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1827 targetAvatar.TeleportWithMomentum(targetVector);
1828 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1829 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
1830 return;
1831 }
1832 }
1833 }
1834 }
1835 //Eject and ban
1836 if (flags == 1)
1837 {
1838 if (targetAvatar.UserLevel == 0)
1839 {
1840 ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
1841 if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
1842 return;
1843
1844 Vector3 position = new Vector3(0, 0, 0);
1845 List<ILandObject> allParcels = new List<ILandObject>();
1846 allParcels = AllParcels();
1847 if (allParcels.Count != 1)
1848 {
1849 foreach (ILandObject parcel in allParcels)
1850 {
1851 if (parcel.LandData.GlobalID != land.LandData.GlobalID)
1852 {
1853 if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
1854 {
1855 for (int x = 1; x <= Constants.RegionSize; x += 2)
1856 {
1857 for (int y = 1; y <= Constants.RegionSize; y += 2)
1858 {
1859 if (parcel.ContainsPoint(x, y))
1860 {
1861 position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
1862 targetAvatar.TeleportWithMomentum(position);
1863 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1864 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1865 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1866 entry.AgentID = targetAvatar.UUID;
1867 entry.Flags = AccessList.Ban;
1868 entry.Time = new DateTime();
1869 land.LandData.ParcelAccessList.Add(entry);
1870 return;
1871 }
1872 }
1873 }
1874 }
1875 }
1876 }
1877 }
1878 Vector3 targetVector;
1879 if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
1880 {
1881 if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
1882 {
1883 targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1884 targetAvatar.TeleportWithMomentum(targetVector);
1885 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1886 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1887 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1888 entry.AgentID = targetAvatar.UUID;
1889 entry.Flags = AccessList.Ban;
1890 entry.Time = new DateTime();
1891 land.LandData.ParcelAccessList.Add(entry);
1892 return;
1893 }
1894 else
1895 {
1896 targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
1897 targetAvatar.TeleportWithMomentum(targetVector);
1898 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1899 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1900 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1901 entry.AgentID = targetAvatar.UUID;
1902 entry.Flags = AccessList.Ban;
1903 entry.Time = new DateTime();
1904 land.LandData.ParcelAccessList.Add(entry);
1905 return;
1906 }
1907 }
1908 else
1909 {
1910 if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
1911 {
1912 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
1913 targetAvatar.TeleportWithMomentum(targetVector);
1914 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1915 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1916 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1917 entry.AgentID = targetAvatar.UUID;
1918 entry.Flags = AccessList.Ban;
1919 entry.Time = new DateTime();
1920 land.LandData.ParcelAccessList.Add(entry);
1921 return;
1922 }
1923 else
1924 {
1925 targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
1926 targetAvatar.TeleportWithMomentum(targetVector);
1927 targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
1928 parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
1929 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
1930 entry.AgentID = targetAvatar.UUID;
1931 entry.Flags = AccessList.Ban;
1932 entry.Time = new DateTime();
1933 land.LandData.ParcelAccessList.Add(entry);
1934 return;
1935 }
1936 }
1937 }
1938 }
1939 }
1652 1940
1653 protected void InstallInterfaces() 1941 protected void InstallInterfaces()
1654 { 1942 {
@@ -1711,5 +1999,27 @@ namespace OpenSim.Region.CoreModules.World.Land
1711 1999
1712 MainConsole.Instance.Output(report.ToString()); 2000 MainConsole.Instance.Output(report.ToString());
1713 } 2001 }
2002
2003 public void EnforceBans(ILandObject land, ScenePresence avatar)
2004 {
2005 if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HIEGHT)
2006 return;
2007
2008 if (land.IsEitherBannedOrRestricted(avatar.UUID))
2009 {
2010 if (land.ContainsPoint(Convert.ToInt32(avatar.lastKnownAllowedPosition.X), Convert.ToInt32(avatar.lastKnownAllowedPosition.Y)))
2011 {
2012 Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
2013 if (pos == null)
2014 m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
2015 else
2016 ForceAvatarToPosition(avatar, (Vector3)pos);
2017 }
2018 else
2019 {
2020 ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
2021 }
2022 }
2023 }
1714 } 2024 }
1715} \ No newline at end of file 2025}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index 79b13c3..07b28c7 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -190,10 +190,27 @@ namespace OpenSim.Region.CoreModules.World.Land
190 else 190 else
191 { 191 {
192 // Normal Calculations 192 // Normal Calculations
193 int parcelMax = (int)(((float)LandData.Area / 65536.0f) 193 int parcelMax = (int)((long)LandData.Area
194 * (float)m_scene.RegionInfo.ObjectCapacity 194 * (long)m_scene.RegionInfo.ObjectCapacity
195 * (float)m_scene.RegionInfo.RegionSettings.ObjectBonus); 195 * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus
196 // TODO: The calculation of ObjectBonus should be refactored. It does still not work in the same manner as SL! 196 / 65536L);
197 m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax);
198 return parcelMax;
199 }
200 }
201
202 private int GetParcelBasePrimCount()
203 {
204 if (overrideParcelMaxPrimCount != null)
205 {
206 return overrideParcelMaxPrimCount(this);
207 }
208 else
209 {
210 // Normal Calculations
211 int parcelMax = (int)((long)LandData.Area
212 * (long)m_scene.RegionInfo.ObjectCapacity
213 / 65536L);
197 return parcelMax; 214 return parcelMax;
198 } 215 }
199 } 216 }
@@ -207,8 +224,9 @@ namespace OpenSim.Region.CoreModules.World.Land
207 else 224 else
208 { 225 {
209 //Normal Calculations 226 //Normal Calculations
210 int simMax = (int)(((float)LandData.SimwideArea / 65536.0f) 227 int simMax = (int)((long)LandData.SimwideArea
211 * (float)m_scene.RegionInfo.ObjectCapacity); 228 * (long)m_scene.RegionInfo.ObjectCapacity / 65536L);
229 // m_log.DebugFormat("Simwide Area: {0}, Capacity {1}, SimMax {2}", LandData.SimwideArea, m_scene.RegionInfo.ObjectCapacity, simMax);
212 return simMax; 230 return simMax;
213 } 231 }
214 } 232 }
@@ -245,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Land
245 remote_client.SendLandProperties(seq_id, 263 remote_client.SendLandProperties(seq_id,
246 snap_selection, request_result, this, 264 snap_selection, request_result, this,
247 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus, 265 (float)m_scene.RegionInfo.RegionSettings.ObjectBonus,
248 GetParcelMaxPrimCount(), 266 GetParcelBasePrimCount(),
249 GetSimulatorMaxPrimCount(), regionFlags); 267 GetSimulatorMaxPrimCount(), regionFlags);
250 } 268 }
251 269
@@ -304,7 +322,7 @@ namespace OpenSim.Region.CoreModules.World.Land
304 322
305 allowedDelta |= (uint)(ParcelFlags.ShowDirectory | 323 allowedDelta |= (uint)(ParcelFlags.ShowDirectory |
306 ParcelFlags.AllowPublish | 324 ParcelFlags.AllowPublish |
307 ParcelFlags.MaturePublish); 325 ParcelFlags.MaturePublish) | (uint)(1 << 23);
308 } 326 }
309 327
310 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity)) 328 if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId,this, GroupPowers.LandChangeIdentity))
@@ -416,9 +434,43 @@ namespace OpenSim.Region.CoreModules.World.Land
416 return false; 434 return false;
417 } 435 }
418 436
437 public bool HasGroupAccess(UUID avatar)
438 {
439 if (LandData.GroupID != UUID.Zero && (LandData.Flags & (uint)ParcelFlags.UseAccessGroup) == (uint)ParcelFlags.UseAccessGroup)
440 {
441 ScenePresence sp;
442 if (!m_scene.TryGetScenePresence(avatar, out sp))
443 {
444 IGroupsModule groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
445 if (groupsModule == null)
446 return false;
447
448 GroupMembershipData[] membership = groupsModule.GetMembershipData(avatar);
449 if (membership == null || membership.Length == 0)
450 return false;
451
452 foreach (GroupMembershipData d in membership)
453 {
454 if (d.GroupID == LandData.GroupID)
455 return true;
456 }
457 return false;
458 }
459
460 if (!sp.ControllingClient.IsGroupMember(LandData.GroupID))
461 return false;
462
463 return true;
464 }
465 return false;
466 }
467
419 public bool IsBannedFromLand(UUID avatar) 468 public bool IsBannedFromLand(UUID avatar)
420 { 469 {
421 if (m_scene.Permissions.CanEditParcelProperties(avatar, this, 0)) 470 if (m_scene.Permissions.IsAdministrator(avatar))
471 return false;
472
473 if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar))
422 return false; 474 return false;
423 475
424 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0) 476 if ((LandData.Flags & (uint) ParcelFlags.UseBanList) > 0)
@@ -429,7 +481,7 @@ namespace OpenSim.Region.CoreModules.World.Land
429 if (e.AgentID == avatar && e.Flags == AccessList.Ban) 481 if (e.AgentID == avatar && e.Flags == AccessList.Ban)
430 return true; 482 return true;
431 return false; 483 return false;
432 }) != -1) 484 }) != -1 && LandData.OwnerID != avatar)
433 { 485 {
434 return true; 486 return true;
435 } 487 }
@@ -439,7 +491,10 @@ namespace OpenSim.Region.CoreModules.World.Land
439 491
440 public bool IsRestrictedFromLand(UUID avatar) 492 public bool IsRestrictedFromLand(UUID avatar)
441 { 493 {
442 if (m_scene.Permissions.CanEditParcelProperties(avatar, this, 0)) 494 if (m_scene.Permissions.IsAdministrator(avatar))
495 return false;
496
497 if (m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar))
443 return false; 498 return false;
444 499
445 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0) 500 if ((LandData.Flags & (uint) ParcelFlags.UseAccessList) > 0)
@@ -450,11 +505,15 @@ namespace OpenSim.Region.CoreModules.World.Land
450 if (e.AgentID == avatar && e.Flags == AccessList.Access) 505 if (e.AgentID == avatar && e.Flags == AccessList.Access)
451 return true; 506 return true;
452 return false; 507 return false;
453 }) == -1) 508 }) == -1 && LandData.OwnerID != avatar)
454 { 509 {
455 return true; 510 if (!HasGroupAccess(avatar))
511 {
512 return true;
513 }
456 } 514 }
457 } 515 }
516
458 return false; 517 return false;
459 } 518 }
460 519
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
index efede5c..5122734 100644
--- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.World.Land
206 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts)) 206 if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
207 { 207 {
208 UUID landOwner = landData.OwnerID; 208 UUID landOwner = landData.OwnerID;
209 int partCount = obj.Parts.Length; 209 int partCount = obj.GetPartCount();
210 210
211 m_SimwideCounts[landOwner] += partCount; 211 m_SimwideCounts[landOwner] += partCount;
212 if (parcelCounts.Users.ContainsKey(obj.OwnerID)) 212 if (parcelCounts.Users.ContainsKey(obj.OwnerID))
@@ -593,4 +593,4 @@ namespace OpenSim.Region.CoreModules.World.Land
593 } 593 }
594 } 594 }
595 } 595 }
596} \ No newline at end of file 596}
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
index 1e4f0a4..eb4731c 100644
--- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
+++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs
@@ -176,6 +176,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
176 return false; 176 return false;
177 } 177 }
178 178
179 if ((perms & (uint)PermissionMask.Copy) == 0)
180 {
181 if (m_dialogModule != null)
182 m_dialogModule.SendAlertToUser(remoteClient, "This sale has been blocked by the permissions system");
183 return false;
184 }
185
179 AssetBase asset = m_scene.CreateAsset( 186 AssetBase asset = m_scene.CreateAsset(
180 group.GetPartName(localID), 187 group.GetPartName(localID),
181 group.GetPartDescription(localID), 188 group.GetPartDescription(localID),
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index cdecd2f..5e7d37a 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -363,7 +363,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions
363 363
364 public string Name 364 public string Name
365 { 365 {
366 get { return "PermissionsModule"; } 366 get { return "DefaultPermissionsModule"; }
367 } 367 }
368 368
369 public bool IsSharedModule 369 public bool IsSharedModule
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
index 0f37ddd..86821c6 100644
--- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -28,6 +28,8 @@
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Timers; 30using System.Timers;
31using System.IO;
32using System.Diagnostics;
31using System.Threading; 33using System.Threading;
32using System.Collections.Generic; 34using System.Collections.Generic;
33using log4net; 35using log4net;
@@ -56,13 +58,23 @@ namespace OpenSim.Region.CoreModules.World.Region
56 protected UUID m_Initiator; 58 protected UUID m_Initiator;
57 protected bool m_Notice = false; 59 protected bool m_Notice = false;
58 protected IDialogModule m_DialogModule = null; 60 protected IDialogModule m_DialogModule = null;
61 protected string m_MarkerPath = String.Empty;
59 62
60 public void Initialise(IConfigSource config) 63 public void Initialise(IConfigSource config)
61 { 64 {
65 IConfig restartConfig = config.Configs["RestartModule"];
66 if (restartConfig != null)
67 {
68 m_MarkerPath = restartConfig.GetString("MarkerPath", String.Empty);
69 }
62 } 70 }
63 71
64 public void AddRegion(Scene scene) 72 public void AddRegion(Scene scene)
65 { 73 {
74 if (m_MarkerPath != String.Empty)
75 File.Delete(Path.Combine(m_MarkerPath,
76 scene.RegionInfo.RegionID.ToString()));
77
66 m_Scene = scene; 78 m_Scene = scene;
67 79
68 scene.RegisterModuleInterface<IRestartModule>(this); 80 scene.RegisterModuleInterface<IRestartModule>(this);
@@ -121,6 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Region
121 133
122 if (alerts == null) 134 if (alerts == null)
123 { 135 {
136 CreateMarkerFile();
124 m_Scene.RestartNow(); 137 m_Scene.RestartNow();
125 return; 138 return;
126 } 139 }
@@ -134,6 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Region
134 147
135 if (m_Alerts[0] == 0) 148 if (m_Alerts[0] == 0)
136 { 149 {
150 CreateMarkerFile();
137 m_Scene.RestartNow(); 151 m_Scene.RestartNow();
138 return; 152 return;
139 } 153 }
@@ -147,6 +161,7 @@ namespace OpenSim.Region.CoreModules.World.Region
147 { 161 {
148 if (m_Alerts.Count == 0 || m_Alerts[0] == 0) 162 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
149 { 163 {
164 CreateMarkerFile();
150 m_Scene.RestartNow(); 165 m_Scene.RestartNow();
151 return 0; 166 return 0;
152 } 167 }
@@ -225,6 +240,9 @@ namespace OpenSim.Region.CoreModules.World.Region
225 if (m_DialogModule != null && message != String.Empty) 240 if (m_DialogModule != null && message != String.Empty)
226 m_DialogModule.SendGeneralAlert(message); 241 m_DialogModule.SendGeneralAlert(message);
227 } 242 }
243 if (m_MarkerPath != String.Empty)
244 File.Delete(Path.Combine(m_MarkerPath,
245 m_Scene.RegionInfo.RegionID.ToString()));
228 } 246 }
229 247
230 private void HandleRegionRestart(string module, string[] args) 248 private void HandleRegionRestart(string module, string[] args)
@@ -266,5 +284,25 @@ namespace OpenSim.Region.CoreModules.World.Region
266 284
267 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); 285 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
268 } 286 }
287
288 protected void CreateMarkerFile()
289 {
290 if (m_MarkerPath == String.Empty)
291 return;
292
293 string path = Path.Combine(m_MarkerPath, m_Scene.RegionInfo.RegionID.ToString());
294 try
295 {
296 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
297 FileStream fs = File.Create(path);
298 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
299 Byte[] buf = enc.GetBytes(pidstring);
300 fs.Write(buf, 0, buf.Length);
301 fs.Close();
302 }
303 catch (Exception)
304 {
305 }
306 }
269 } 307 }
270} 308}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index cf000a4..4805ccb 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -606,6 +606,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
606 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised()); 606 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
607 m_scene.SaveTerrain(); 607 m_scene.SaveTerrain();
608 608
609 m_scene.EventManager.TriggerTerrainUpdate();
610
609 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out. 611 // Clients who look at the map will never see changes after they looked at the map, so i've commented this out.
610 //m_scene.CreateTerrainTexture(true); 612 //m_scene.CreateTerrainTexture(true);
611 } 613 }
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 657975b..f9384e9 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -86,9 +86,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
86 86
87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
88 { 88 {
89 if (mapName.Length < 3) 89 if (mapName.Length < 2)
90 { 90 {
91 remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); 91 remoteClient.SendAlertMessage("Use a search string with at least 2 characters");
92 return; 92 return;
93 } 93 }
94 94
@@ -96,10 +96,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
96 96
97 // try to fetch from GridServer 97 // try to fetch from GridServer
98 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); 98 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
99 if (regionInfos.Count == 0) 99// if (regionInfos.Count == 0)
100 remoteClient.SendAlertMessage("Hyperlink could not be established."); 100// remoteClient.SendAlertMessage("Hyperlink could not be established.");
101 101
102 m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); 102 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
103 List<MapBlockData> blocks = new List<MapBlockData>(); 103 List<MapBlockData> blocks = new List<MapBlockData>();
104 104
105 MapBlockData data; 105 MapBlockData data;
@@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
128 data.Agents = 0; 128 data.Agents = 0;
129 data.Access = 255; 129 data.Access = 255;
130 data.MapImageId = UUID.Zero; 130 data.MapImageId = UUID.Zero;
131 data.Name = ""; // mapName; 131 data.Name = mapName;
132 data.RegionFlags = 0; 132 data.RegionFlags = 0;
133 data.WaterHeight = 0; // not used 133 data.WaterHeight = 0; // not used
134 data.X = 0; 134 data.X = 0;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index ac95598..37296af 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -1239,7 +1239,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1239 } 1239 }
1240 else 1240 else
1241 { 1241 {
1242 OSDArray responsearr = new OSDArray(m_scene.GetRootAgentCount()); 1242 OSDArray responsearr = new OSDArray(); // Don't preallocate. MT (m_scene.GetRootAgentCount());
1243 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 1243 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
1244 { 1244 {
1245 OSDMap responsemapdata = new OSDMap(); 1245 OSDMap responsemapdata = new OSDMap();