From 8616230fcffbc5c8a919e4ee721be7f871d9f698 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 20:04:18 +0100 Subject: refactor: replace some uses of iar module reference with scene instead --- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 55d7997..36e17b4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -126,7 +126,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, userInfo, invPath, saveStream).Execute(); + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); } } @@ -137,7 +137,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, userInfo, invPath, savePath).Execute(); + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); } } -- cgit v1.1 From 79c22651d7673b61a0c62786eb16f8b6433d6928 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sun, 6 Sep 2009 20:16:56 +0100 Subject: refactor: use direct scene reference in inventory archive read request --- .../Inventory/Archiver/InventoryArchiverModule.cs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 36e17b4..2c36270 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -69,19 +69,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// private Dictionary m_scenes = new Dictionary(); private Scene m_aScene; - - /// - /// The comms manager we will use for all comms requests - /// - protected internal CommunicationsManager CommsManager; - protected internal IAssetService AssetService; public void Initialise(Scene scene, IConfigSource source) { if (m_scenes.Count == 0) { scene.RegisterModuleInterface(this); - CommsManager = scene.CommsManager; OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; scene.AddCommand( @@ -99,11 +92,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver m_scenes[scene.RegionInfo.RegionID] = scene; } - - public void PostInitialise() - { - AssetService = m_aScene.AssetService; - } + + public void PostInitialise() {} public void Close() {} @@ -150,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager, AssetService); + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); UpdateClientWithLoadedNodes(userInfo, request.Execute()); } } @@ -165,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager, AssetService); + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); UpdateClientWithLoadedNodes(userInfo, request.Execute()); } } @@ -261,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// protected CachedUserInfo GetUserInfo(string firstName, string lastName) { - CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); + CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); if (null == userInfo) { m_log.ErrorFormat( -- cgit v1.1 From 10b075a33da1105ae440a57d5488baa9c161e444 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 7 Sep 2009 18:42:53 +0100 Subject: change default iar filename --- .../CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2c36270..3869de2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// The file to load and save inventory if no filename has been specified /// - protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory_iar.tar.gz"; + protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; /// /// Pending save completions initiated from the console -- cgit v1.1 From fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 7 Sep 2009 19:57:44 +0100 Subject: Only allow iar load/save if user is logged in to the region simulator --- .../Inventory/Archiver/InventoryArchiverModule.cs | 128 +++++++++++++++++---- 1 file changed, 106 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 3869de2..2340fad 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -51,6 +51,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver public string Name { get { return "Inventory Archiver Module"; } } public bool IsSharedModule { get { return true; } } + + /// + /// Enable or disable checking whether the iar user is actually logged in + /// + public bool DisablePresenceChecks { get; set; } public event InventoryArchiveSaved OnInventoryArchiveSaved; @@ -70,6 +75,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver private Dictionary m_scenes = new Dictionary(); private Scene m_aScene; + public InventoryArchiverModule() {} + + public InventoryArchiverModule(bool disablePresenceChecks) + { + DisablePresenceChecks = disablePresenceChecks; + } + public void Initialise(Scene scene, IConfigSource source) { if (m_scenes.Count == 0) @@ -109,29 +121,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); } - public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) + public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); - } + { + if (CheckPresence(userInfo.UserProfile.ID)) + { + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } + } + } + + return false; } - public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) + public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) { if (m_scenes.Count > 0) { CachedUserInfo userInfo = GetUserInfo(firstName, lastName); if (userInfo != null) - new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); - } + { + if (CheckPresence(userInfo.UserProfile.ID)) + { + new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } + } + } + + return false; } - public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) + public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) { if (m_scenes.Count > 0) { @@ -139,14 +179,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { - InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); - UpdateClientWithLoadedNodes(userInfo, request.Execute()); + if (CheckPresence(userInfo.UserProfile.ID)) + { + InventoryArchiveReadRequest request = + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); + UpdateClientWithLoadedNodes(userInfo, request.Execute()); + + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } } - } + } + + return false; } - public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) + public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) { if (m_scenes.Count > 0) { @@ -154,11 +207,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver if (userInfo != null) { - InventoryArchiveReadRequest request = - new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); - UpdateClientWithLoadedNodes(userInfo, request.Execute()); - } - } + if (CheckPresence(userInfo.UserProfile.ID)) + { + InventoryArchiveReadRequest request = + new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); + UpdateClientWithLoadedNodes(userInfo, request.Execute()); + + return true; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", + userInfo.UserProfile.Name, userInfo.UserProfile.ID); + } + } + } + + return false; } /// @@ -183,11 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", loadPath, invPath, firstName, lastName); - DearchiveInventory(firstName, lastName, invPath, loadPath); - - m_log.InfoFormat( - "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", - loadPath, firstName, lastName); + if (DearchiveInventory(firstName, lastName, invPath, loadPath)) + m_log.InfoFormat( + "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", + loadPath, firstName, lastName); } /// @@ -291,5 +356,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } } } + + /// + /// Check if the given user is present in any of the scenes. + /// + /// The user to check + /// true if the user is in any of the scenes, false otherwise + protected bool CheckPresence(UUID userId) + { + if (DisablePresenceChecks) + return true; + + foreach (Scene scene in m_scenes.Values) + { + if (scene.GetScenePresence(userId) != null) + return true; + } + + return false; + } } } -- cgit v1.1