diff options
author | BlueWall | 2011-03-21 22:06:43 -0400 |
---|---|---|
committer | BlueWall | 2011-03-21 22:06:43 -0400 |
commit | e3c327a305dcf795f372b940f34538a19bf92218 (patch) | |
tree | b034355a12c4d87410809aa19bf6015e611e1e22 /OpenSim/Region | |
parent | Merge branch 'master' of /home/opensim/src/OpenSim/Core (diff) | |
parent | Thanks Kevin Cozens for a patch that: (diff) | |
download | opensim-SC_OLD-e3c327a305dcf795f372b940f34538a19bf92218.zip opensim-SC_OLD-e3c327a305dcf795f372b940f34538a19bf92218.tar.gz opensim-SC_OLD-e3c327a305dcf795f372b940f34538a19bf92218.tar.bz2 opensim-SC_OLD-e3c327a305dcf795f372b940f34538a19bf92218.tar.xz |
Merge branch 'master' of /home/opensim/src/OpenSim/Core
Diffstat (limited to 'OpenSim/Region')
46 files changed, 1660 insertions, 1108 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs index 584c577..583214c 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs | |||
@@ -845,7 +845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
845 | 845 | ||
846 | private void HandleUseCircuitCode(object o) | 846 | private void HandleUseCircuitCode(object o) |
847 | { | 847 | { |
848 | DateTime startTime = DateTime.Now; | 848 | // DateTime startTime = DateTime.Now; |
849 | object[] array = (object[])o; | 849 | object[] array = (object[])o; |
850 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; | 850 | UDPPacketBuffer buffer = (UDPPacketBuffer)array[0]; |
851 | UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; | 851 | UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1]; |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 6ed4867..9adb68b 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -92,9 +92,9 @@ namespace Flotsam.RegionModules.AssetCache | |||
92 | // Expiration is expressed in hours. | 92 | // Expiration is expressed in hours. |
93 | private const double m_DefaultMemoryExpiration = 1.0; | 93 | private const double m_DefaultMemoryExpiration = 1.0; |
94 | private const double m_DefaultFileExpiration = 48; | 94 | private const double m_DefaultFileExpiration = 48; |
95 | private TimeSpan m_MemoryExpiration = TimeSpan.Zero; | 95 | private TimeSpan m_MemoryExpiration = TimeSpan.FromHours(m_DefaultMemoryExpiration); |
96 | private TimeSpan m_FileExpiration = TimeSpan.Zero; | 96 | private TimeSpan m_FileExpiration = TimeSpan.FromHours(m_DefaultFileExpiration); |
97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.Zero; | 97 | private TimeSpan m_FileExpirationCleanupTimer = TimeSpan.FromHours(m_DefaultFileExpiration); |
98 | 98 | ||
99 | private static int m_CacheDirectoryTiers = 1; | 99 | private static int m_CacheDirectoryTiers = 1; |
100 | private static int m_CacheDirectoryTierLen = 3; | 100 | private static int m_CacheDirectoryTierLen = 3; |
@@ -147,7 +147,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
147 | } | 147 | } |
148 | 148 | ||
149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); | 149 | m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); |
150 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); | 150 | m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_CacheDirectory); |
151 | 151 | ||
152 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); | 152 | m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); |
153 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); | 153 | m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); |
@@ -245,16 +245,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
245 | private void UpdateMemoryCache(string key, AssetBase asset) | 245 | private void UpdateMemoryCache(string key, AssetBase asset) |
246 | { | 246 | { |
247 | if (m_MemoryCacheEnabled) | 247 | if (m_MemoryCacheEnabled) |
248 | { | 248 | m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration); |
249 | if (m_MemoryExpiration > TimeSpan.Zero) | ||
250 | { | ||
251 | m_MemoryCache.AddOrUpdate(key, asset, m_MemoryExpiration); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | m_MemoryCache.AddOrUpdate(key, asset, Double.MaxValue); | ||
256 | } | ||
257 | } | ||
258 | } | 249 | } |
259 | 250 | ||
260 | public void Cache(AssetBase asset) | 251 | public void Cache(AssetBase asset) |
@@ -450,7 +441,7 @@ namespace Flotsam.RegionModules.AssetCache | |||
450 | private void CleanupExpiredFiles(object source, ElapsedEventArgs e) | 441 | private void CleanupExpiredFiles(object source, ElapsedEventArgs e) |
451 | { | 442 | { |
452 | if (m_LogLevel >= 2) | 443 | if (m_LogLevel >= 2) |
453 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration.ToString()); | 444 | m_log.DebugFormat("[FLOTSAM ASSET CACHE]: Checking for expired files older then {0}.", m_FileExpiration); |
454 | 445 | ||
455 | // Purge all files last accessed prior to this point | 446 | // Purge all files last accessed prior to this point |
456 | DateTime purgeLine = DateTime.Now - m_FileExpiration; | 447 | DateTime purgeLine = DateTime.Now - m_FileExpiration; |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index f8ce444..08ac624 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -167,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); | 170 | m_log.DebugFormat("[AVFACTORY]: complete texture check for {0}", client.AgentId); |
171 | 171 | ||
172 | // If we only found default textures, then the appearance is not cached | 172 | // If we only found default textures, then the appearance is not cached |
173 | return (defonly ? false : true); | 173 | return (defonly ? false : true); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 2b3d2a9..8a977c9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -49,16 +49,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
49 | { | 49 | { |
50 | m_scene = scene; | 50 | m_scene = scene; |
51 | m_scene.RegisterModuleInterface<IDialogModule>(this); | 51 | m_scene.RegisterModuleInterface<IDialogModule>(this); |
52 | 52 | ||
53 | m_scene.AddCommand( | 53 | m_scene.AddCommand( |
54 | this, "alert", "alert <first> <last> <message>", | 54 | this, "alert", "alert <message>", |
55 | "Send an alert to a user", | 55 | "Send an alert to everyone", |
56 | HandleAlertConsoleCommand); | 56 | HandleAlertConsoleCommand); |
57 | 57 | ||
58 | m_scene.AddCommand( | 58 | m_scene.AddCommand( |
59 | this, "alert general", "alert [general] <message>", | 59 | this, "alert-user", "alert-user <first> <last> <message>", |
60 | "Send an alert to everyone", | 60 | "Send an alert to a user", |
61 | "If keyword 'general' is omitted, then <message> must be surrounded by quotation marks.", | ||
62 | HandleAlertConsoleCommand); | 61 | HandleAlertConsoleCommand); |
63 | } | 62 | } |
64 | 63 | ||
@@ -177,55 +176,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
177 | { | 176 | { |
178 | if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) | 177 | if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) |
179 | return; | 178 | return; |
180 | 179 | ||
181 | bool isGeneral = false; | ||
182 | string firstName = string.Empty; | ||
183 | string lastName = string.Empty; | ||
184 | string message = string.Empty; | 180 | string message = string.Empty; |
185 | 181 | ||
186 | if (cmdparams.Length > 1) | 182 | if (cmdparams[0].ToLower().Equals("alert")) |
187 | { | ||
188 | firstName = cmdparams[1]; | ||
189 | isGeneral = firstName.ToLower().Equals("general"); | ||
190 | } | ||
191 | if (cmdparams.Length == 2 && !isGeneral) | ||
192 | { | 183 | { |
193 | // alert "message" | 184 | message = CombineParams(cmdparams, 1); |
194 | message = cmdparams[1]; | 185 | m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", |
195 | isGeneral = true; | 186 | m_scene.RegionInfo.RegionName, message); |
196 | } | 187 | SendGeneralAlert(message); |
197 | else if (cmdparams.Length > 2 && isGeneral) | ||
198 | { | ||
199 | // alert general <message> | ||
200 | message = CombineParams(cmdparams, 2); | ||
201 | } | 188 | } |
202 | else if (cmdparams.Length > 3) | 189 | else if (cmdparams.Length > 3) |
203 | { | 190 | { |
204 | // alert <first> <last> <message> | 191 | string firstName = cmdparams[1]; |
205 | lastName = cmdparams[2]; | 192 | string lastName = cmdparams[2]; |
206 | message = CombineParams(cmdparams, 3); | 193 | message = CombineParams(cmdparams, 3); |
194 | m_log.InfoFormat( | ||
195 | "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", | ||
196 | m_scene.RegionInfo.RegionName, firstName, lastName, message); | ||
197 | SendAlertToUser(firstName, lastName, message, false); | ||
207 | } | 198 | } |
208 | else | 199 | else |
209 | { | 200 | { |
210 | OpenSim.Framework.Console.MainConsole.Instance.Output( | 201 | OpenSim.Framework.Console.MainConsole.Instance.Output( |
211 | "Usage: alert \"message\" | alert general <message> | alert <first> <last> <message>"); | 202 | "Usage: alert <message> | alert-user <first> <last> <message>"); |
212 | return; | 203 | return; |
213 | } | 204 | } |
214 | |||
215 | if (isGeneral) | ||
216 | { | ||
217 | m_log.InfoFormat( | ||
218 | "[DIALOG]: Sending general alert in region {0} with message {1}", | ||
219 | m_scene.RegionInfo.RegionName, message); | ||
220 | SendGeneralAlert(message); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | m_log.InfoFormat( | ||
225 | "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", | ||
226 | m_scene.RegionInfo.RegionName, firstName, lastName, message); | ||
227 | SendAlertToUser(firstName, lastName, message, false); | ||
228 | } | ||
229 | } | 205 | } |
230 | 206 | ||
231 | private string CombineParams(string[] commandParams, int pos) | 207 | private string CombineParams(string[] commandParams, int pos) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 6030706..9b98de3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization; | |||
41 | using OpenSim.Framework.Serialization.External; | 41 | using OpenSim.Framework.Serialization.External; |
42 | using OpenSim.Region.CoreModules.World.Archiver; | 42 | using OpenSim.Region.CoreModules.World.Archiver; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
46 | 47 | ||
@@ -75,6 +76,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
75 | /// The stream from which the inventory archive will be loaded. | 76 | /// The stream from which the inventory archive will be loaded. |
76 | /// </value> | 77 | /// </value> |
77 | private Stream m_loadStream; | 78 | private Stream m_loadStream; |
79 | |||
80 | protected bool m_controlFileLoaded; | ||
81 | protected bool m_assetsLoaded; | ||
82 | protected bool m_inventoryNodesLoaded; | ||
83 | |||
84 | protected int m_successfulAssetRestores; | ||
85 | protected int m_failedAssetRestores; | ||
86 | protected int m_successfulItemRestores; | ||
87 | |||
88 | /// <summary> | ||
89 | /// Root destination folder for the IAR load. | ||
90 | /// </summary> | ||
91 | protected InventoryFolderBase m_rootDestinationFolder; | ||
92 | |||
93 | /// <summary> | ||
94 | /// Inventory nodes loaded from the iar. | ||
95 | /// </summary> | ||
96 | protected HashSet<InventoryNodeBase> m_loadedNodes = new HashSet<InventoryNodeBase>(); | ||
97 | |||
98 | /// <summary> | ||
99 | /// In order to load identically named folders, we need to keep track of the folders that we have already | ||
100 | /// resolved. | ||
101 | /// </summary> | ||
102 | Dictionary <string, InventoryFolderBase> m_resolvedFolders = new Dictionary<string, InventoryFolderBase>(); | ||
103 | |||
104 | /// <summary> | ||
105 | /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids | ||
106 | /// after OSP resolution (since OSP creators are only stored in the item | ||
107 | /// </summary> | ||
108 | protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>(); | ||
78 | 109 | ||
79 | public InventoryArchiveReadRequest( | 110 | public InventoryArchiveReadRequest( |
80 | Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) | 111 | Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) |
@@ -100,20 +131,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
100 | /// <summary> | 131 | /// <summary> |
101 | /// Execute the request | 132 | /// Execute the request |
102 | /// </summary> | 133 | /// </summary> |
134 | /// <remarks> | ||
135 | /// Only call this once. To load another IAR, construct another request object. | ||
136 | /// </remarks> | ||
103 | /// <returns> | 137 | /// <returns> |
104 | /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are | 138 | /// A list of the inventory nodes loaded. If folders were loaded then only the root folders are |
105 | /// returned | 139 | /// returned |
106 | /// </returns> | 140 | /// </returns> |
141 | /// <exception cref="System.Exception">Thrown if load fails.</exception> | ||
107 | public HashSet<InventoryNodeBase> Execute() | 142 | public HashSet<InventoryNodeBase> Execute() |
108 | { | 143 | { |
109 | try | 144 | try |
110 | { | 145 | { |
111 | string filePath = "ERROR"; | 146 | string filePath = "ERROR"; |
112 | int successfulAssetRestores = 0; | ||
113 | int failedAssetRestores = 0; | ||
114 | int successfulItemRestores = 0; | ||
115 | |||
116 | HashSet<InventoryNodeBase> loadedNodes = new HashSet<InventoryNodeBase>(); | ||
117 | 147 | ||
118 | List<InventoryFolderBase> folderCandidates | 148 | List<InventoryFolderBase> folderCandidates |
119 | = InventoryArchiveUtils.FindFolderByPath( | 149 | = InventoryArchiveUtils.FindFolderByPath( |
@@ -124,16 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
124 | // Possibly provide an option later on to automatically create this folder if it does not exist | 154 | // Possibly provide an option later on to automatically create this folder if it does not exist |
125 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); | 155 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath); |
126 | 156 | ||
127 | return loadedNodes; | 157 | return m_loadedNodes; |
128 | } | 158 | } |
129 | 159 | ||
130 | InventoryFolderBase rootDestinationFolder = folderCandidates[0]; | 160 | m_rootDestinationFolder = folderCandidates[0]; |
131 | archive = new TarArchiveReader(m_loadStream); | 161 | archive = new TarArchiveReader(m_loadStream); |
132 | |||
133 | // In order to load identically named folders, we need to keep track of the folders that we have already | ||
134 | // resolved | ||
135 | Dictionary <string, InventoryFolderBase> resolvedFolders = new Dictionary<string, InventoryFolderBase>(); | ||
136 | |||
137 | byte[] data; | 162 | byte[] data; |
138 | TarArchiveReader.TarEntryType entryType; | 163 | TarArchiveReader.TarEntryType entryType; |
139 | 164 | ||
@@ -142,45 +167,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
142 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) | 167 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) |
143 | { | 168 | { |
144 | LoadControlFile(filePath, data); | 169 | LoadControlFile(filePath, data); |
145 | } | 170 | } |
146 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | 171 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
147 | { | 172 | { |
148 | if (LoadAsset(filePath, data)) | 173 | LoadAssetFile(filePath, data); |
149 | successfulAssetRestores++; | ||
150 | else | ||
151 | failedAssetRestores++; | ||
152 | |||
153 | if ((successfulAssetRestores) % 50 == 0) | ||
154 | m_log.DebugFormat( | ||
155 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | ||
156 | successfulAssetRestores); | ||
157 | } | 174 | } |
158 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 175 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
159 | { | 176 | { |
160 | filePath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length); | 177 | LoadInventoryFile(filePath, entryType, data); |
161 | |||
162 | // Trim off the file portion if we aren't already dealing with a directory path | ||
163 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
164 | filePath = filePath.Remove(filePath.LastIndexOf("/") + 1); | ||
165 | |||
166 | InventoryFolderBase foundFolder | ||
167 | = ReplicateArchivePathToUserInventory( | ||
168 | filePath, rootDestinationFolder, resolvedFolders, loadedNodes); | ||
169 | |||
170 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
171 | { | ||
172 | InventoryItemBase item = LoadItem(data, foundFolder); | ||
173 | |||
174 | if (item != null) | ||
175 | { | ||
176 | successfulItemRestores++; | ||
177 | |||
178 | // If we aren't loading the folder containing the item then well need to update the | ||
179 | // viewer separately for that item. | ||
180 | if (!loadedNodes.Contains(foundFolder)) | ||
181 | loadedNodes.Add(item); | ||
182 | } | ||
183 | } | ||
184 | } | 178 | } |
185 | } | 179 | } |
186 | 180 | ||
@@ -188,10 +182,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
188 | 182 | ||
189 | m_log.DebugFormat( | 183 | m_log.DebugFormat( |
190 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", | 184 | "[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures", |
191 | successfulAssetRestores, failedAssetRestores); | 185 | m_successfulAssetRestores, m_failedAssetRestores); |
192 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", successfulItemRestores); | 186 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Successfully loaded {0} items", m_successfulItemRestores); |
193 | 187 | ||
194 | return loadedNodes; | 188 | return m_loadedNodes; |
195 | } | 189 | } |
196 | finally | 190 | finally |
197 | { | 191 | { |
@@ -400,9 +394,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
400 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); | 394 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); |
401 | if (UUID.Zero != ospResolvedId) // The user exists in this grid | 395 | if (UUID.Zero != ospResolvedId) // The user exists in this grid |
402 | { | 396 | { |
397 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); | ||
398 | |||
403 | item.CreatorIdAsUuid = ospResolvedId; | 399 | item.CreatorIdAsUuid = ospResolvedId; |
404 | 400 | ||
405 | // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the | 401 | // Don't preserve the OSPA in the creator id (which actually gets persisted to the |
406 | // database). Instead, replace with the UUID that we found. | 402 | // database). Instead, replace with the UUID that we found. |
407 | item.CreatorId = ospResolvedId.ToString(); | 403 | item.CreatorId = ospResolvedId.ToString(); |
408 | 404 | ||
@@ -410,7 +406,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
410 | } | 406 | } |
411 | else if (item.CreatorData == null || item.CreatorData == String.Empty) | 407 | else if (item.CreatorData == null || item.CreatorData == String.Empty) |
412 | { | 408 | { |
413 | item.CreatorIdAsUuid = m_userInfo.PrincipalID; | 409 | item.CreatorId = m_userInfo.PrincipalID.ToString(); |
410 | item.CreatorIdAsUuid = new UUID(item.CreatorId); | ||
414 | } | 411 | } |
415 | 412 | ||
416 | item.Owner = m_userInfo.PrincipalID; | 413 | item.Owner = m_userInfo.PrincipalID; |
@@ -418,6 +415,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
418 | // Reset folder ID to the one in which we want to load it | 415 | // Reset folder ID to the one in which we want to load it |
419 | item.Folder = loadFolder.ID; | 416 | item.Folder = loadFolder.ID; |
420 | 417 | ||
418 | // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset | ||
419 | // is loaded. | ||
420 | // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger | ||
421 | // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than | ||
422 | // relying on native tar tools. | ||
423 | m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid; | ||
424 | |||
421 | m_scene.AddInventoryItem(item); | 425 | m_scene.AddInventoryItem(item); |
422 | 426 | ||
423 | return item; | 427 | return item; |
@@ -446,18 +450,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
446 | } | 450 | } |
447 | 451 | ||
448 | string extension = filename.Substring(i); | 452 | string extension = filename.Substring(i); |
449 | string uuid = filename.Remove(filename.Length - extension.Length); | 453 | string rawUuid = filename.Remove(filename.Length - extension.Length); |
454 | UUID assetId = new UUID(rawUuid); | ||
450 | 455 | ||
451 | if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) | 456 | if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) |
452 | { | 457 | { |
453 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | 458 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; |
454 | 459 | ||
455 | if (assetType == (sbyte)AssetType.Unknown) | 460 | if (assetType == (sbyte)AssetType.Unknown) |
456 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); | 461 | { |
462 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId); | ||
463 | } | ||
464 | else if (assetType == (sbyte)AssetType.Object) | ||
465 | { | ||
466 | if (m_creatorIdForAssetId.ContainsKey(assetId)) | ||
467 | { | ||
468 | string xmlData = Utils.BytesToString(data); | ||
469 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
470 | foreach (SceneObjectPart sop in sog.Parts) | ||
471 | { | ||
472 | if (sop.CreatorData == null || sop.CreatorData == "") | ||
473 | { | ||
474 | sop.CreatorID = m_creatorIdForAssetId[assetId]; | ||
475 | } | ||
476 | } | ||
477 | |||
478 | data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)); | ||
479 | } | ||
480 | } | ||
457 | 481 | ||
458 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); | 482 | //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); |
459 | 483 | ||
460 | AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); | 484 | AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString()); |
461 | asset.Data = data; | 485 | asset.Data = data; |
462 | 486 | ||
463 | m_scene.AssetService.Store(asset); | 487 | m_scene.AssetService.Store(asset); |
@@ -495,7 +519,88 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
495 | majorVersion, MAX_MAJOR_VERSION)); | 519 | majorVersion, MAX_MAJOR_VERSION)); |
496 | } | 520 | } |
497 | 521 | ||
498 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | 522 | m_controlFileLoaded = true; |
523 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | ||
499 | } | 524 | } |
525 | |||
526 | /// <summary> | ||
527 | /// Load inventory file | ||
528 | /// </summary> | ||
529 | /// <param name="path"></param> | ||
530 | /// <param name="entryType"></param> | ||
531 | /// <param name="data"></param> | ||
532 | protected void LoadInventoryFile(string path, TarArchiveReader.TarEntryType entryType, byte[] data) | ||
533 | { | ||
534 | if (!m_controlFileLoaded) | ||
535 | throw new Exception( | ||
536 | string.Format( | ||
537 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | ||
538 | ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.INVENTORY_PATH)); | ||
539 | |||
540 | if (m_assetsLoaded) | ||
541 | throw new Exception( | ||
542 | string.Format( | ||
543 | "The IAR you are trying to load does not list all {0} before {1}. Aborting load", | ||
544 | ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); | ||
545 | |||
546 | path = path.Substring(ArchiveConstants.INVENTORY_PATH.Length); | ||
547 | |||
548 | // Trim off the file portion if we aren't already dealing with a directory path | ||
549 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
550 | path = path.Remove(path.LastIndexOf("/") + 1); | ||
551 | |||
552 | InventoryFolderBase foundFolder | ||
553 | = ReplicateArchivePathToUserInventory( | ||
554 | path, m_rootDestinationFolder, m_resolvedFolders, m_loadedNodes); | ||
555 | |||
556 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) | ||
557 | { | ||
558 | InventoryItemBase item = LoadItem(data, foundFolder); | ||
559 | |||
560 | if (item != null) | ||
561 | { | ||
562 | m_successfulItemRestores++; | ||
563 | |||
564 | // If we aren't loading the folder containing the item then well need to update the | ||
565 | // viewer separately for that item. | ||
566 | if (!m_loadedNodes.Contains(foundFolder)) | ||
567 | m_loadedNodes.Add(item); | ||
568 | } | ||
569 | } | ||
570 | |||
571 | m_inventoryNodesLoaded = true; | ||
572 | } | ||
573 | |||
574 | /// <summary> | ||
575 | /// Load asset file | ||
576 | /// </summary> | ||
577 | /// <param name="path"></param> | ||
578 | /// <param name="data"></param> | ||
579 | protected void LoadAssetFile(string path, byte[] data) | ||
580 | { | ||
581 | if (!m_controlFileLoaded) | ||
582 | throw new Exception( | ||
583 | string.Format( | ||
584 | "The IAR you are trying to load does not list {0} before {1}. Aborting load", | ||
585 | ArchiveConstants.CONTROL_FILE_PATH, ArchiveConstants.ASSETS_PATH)); | ||
586 | |||
587 | if (!m_inventoryNodesLoaded) | ||
588 | throw new Exception( | ||
589 | string.Format( | ||
590 | "The IAR you are trying to load does not list all {0} before {1}. Aborting load", | ||
591 | ArchiveConstants.INVENTORY_PATH, ArchiveConstants.ASSETS_PATH)); | ||
592 | |||
593 | if (LoadAsset(path, data)) | ||
594 | m_successfulAssetRestores++; | ||
595 | else | ||
596 | m_failedAssetRestores++; | ||
597 | |||
598 | if ((m_successfulAssetRestores) % 50 == 0) | ||
599 | m_log.DebugFormat( | ||
600 | "[INVENTORY ARCHIVER]: Loaded {0} assets...", | ||
601 | m_successfulAssetRestores); | ||
602 | |||
603 | m_assetsLoaded = true; | ||
604 | } | ||
500 | } | 605 | } |
501 | } \ No newline at end of file | 606 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 26edba4..576a154 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -109,9 +109,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
109 | 109 | ||
110 | scene.AddCommand( | 110 | scene.AddCommand( |
111 | this, "load iar", | 111 | this, "load iar", |
112 | "load iar [--merge] <first> <last> <inventory path> <password> [<IAR path>]", | 112 | "load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]", |
113 | "Load user inventory archive (IAR).", | 113 | "Load user inventory archive (IAR).", |
114 | "--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" | 114 | "-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" |
115 | + "<first> is user's first name." + Environment.NewLine | 115 | + "<first> is user's first name." + Environment.NewLine |
116 | + "<last> is user's last name." + Environment.NewLine | 116 | + "<last> is user's last name." + Environment.NewLine |
117 | + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine | 117 | + "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine |
@@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
181 | catch (EntryPointNotFoundException e) | 181 | catch (EntryPointNotFoundException e) |
182 | { | 182 | { |
183 | m_log.ErrorFormat( | 183 | m_log.ErrorFormat( |
184 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | 184 | "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." |
185 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | 185 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); |
186 | m_log.Error(e); | 186 | m_log.Error(e); |
187 | 187 | ||
@@ -221,7 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
221 | catch (EntryPointNotFoundException e) | 221 | catch (EntryPointNotFoundException e) |
222 | { | 222 | { |
223 | m_log.ErrorFormat( | 223 | m_log.ErrorFormat( |
224 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | 224 | "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." |
225 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | 225 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); |
226 | m_log.Error(e); | 226 | m_log.Error(e); |
227 | 227 | ||
@@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
269 | catch (EntryPointNotFoundException e) | 269 | catch (EntryPointNotFoundException e) |
270 | { | 270 | { |
271 | m_log.ErrorFormat( | 271 | m_log.ErrorFormat( |
272 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | 272 | "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." |
273 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | 273 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); |
274 | m_log.Error(e); | 274 | m_log.Error(e); |
275 | 275 | ||
@@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
317 | catch (EntryPointNotFoundException e) | 317 | catch (EntryPointNotFoundException e) |
318 | { | 318 | { |
319 | m_log.ErrorFormat( | 319 | m_log.ErrorFormat( |
320 | "[ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." | 320 | "[INVENTORY ARCHIVER]: Mismatch between Mono and zlib1g library version when trying to create compression stream." |
321 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); | 321 | + "If you've manually installed Mono, have you appropriately updated zlib1g as well?"); |
322 | m_log.Error(e); | 322 | m_log.Error(e); |
323 | 323 | ||
@@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
358 | if (mainParams.Count < 6) | 358 | if (mainParams.Count < 6) |
359 | { | 359 | { |
360 | m_log.Error( | 360 | m_log.Error( |
361 | "[INVENTORY ARCHIVER]: usage is load iar [--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); | 361 | "[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | 364 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs new file mode 100644 index 0000000..e5127a0 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using NUnit.Framework; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Serialization; | ||
38 | using OpenSim.Framework.Serialization.External; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
41 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | using OpenSim.Tests.Common.Setup; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | ||
50 | { | ||
51 | [TestFixture] | ||
52 | public class InventoryArchiveTestCase | ||
53 | { | ||
54 | protected ManualResetEvent mre = new ManualResetEvent(false); | ||
55 | |||
56 | /// <summary> | ||
57 | /// A raw array of bytes that we'll use to create an IAR memory stream suitable for isolated use in each test. | ||
58 | /// </summary> | ||
59 | protected byte[] m_iarStreamBytes; | ||
60 | |||
61 | /// <summary> | ||
62 | /// Stream of data representing a common IAR for load tests. | ||
63 | /// </summary> | ||
64 | protected MemoryStream m_iarStream; | ||
65 | |||
66 | protected UserAccount m_uaMT | ||
67 | = new UserAccount { | ||
68 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), | ||
69 | FirstName = "Mr", | ||
70 | LastName = "Tiddles" }; | ||
71 | protected UserAccount m_uaLL1 | ||
72 | = new UserAccount { | ||
73 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), | ||
74 | FirstName = "Lord", | ||
75 | LastName = "Lucan" }; | ||
76 | protected UserAccount m_uaLL2 | ||
77 | = new UserAccount { | ||
78 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000777"), | ||
79 | FirstName = "Lord", | ||
80 | LastName = "Lucan" }; | ||
81 | protected string m_item1Name = "Ray Gun Item"; | ||
82 | |||
83 | [SetUp] | ||
84 | public virtual void SetUp() | ||
85 | { | ||
86 | m_iarStream = new MemoryStream(m_iarStreamBytes); | ||
87 | } | ||
88 | |||
89 | [TestFixtureSetUp] | ||
90 | public void FixtureSetup() | ||
91 | { | ||
92 | ConstructDefaultIarBytesForTestLoad(); | ||
93 | } | ||
94 | |||
95 | protected void ConstructDefaultIarBytesForTestLoad() | ||
96 | { | ||
97 | // log4net.Config.XmlConfigurator.Configure(); | ||
98 | |||
99 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
100 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
101 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
102 | |||
103 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | ||
104 | |||
105 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
106 | |||
107 | // Create asset | ||
108 | SceneObjectGroup object1; | ||
109 | SceneObjectPart part1; | ||
110 | { | ||
111 | string partName = "Ray Gun Object"; | ||
112 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
113 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
114 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
115 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
116 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
117 | |||
118 | part1 | ||
119 | = new SceneObjectPart( | ||
120 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
121 | part1.Name = partName; | ||
122 | |||
123 | object1 = new SceneObjectGroup(part1); | ||
124 | scene.AddNewSceneObject(object1, false); | ||
125 | } | ||
126 | |||
127 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
128 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
129 | scene.AssetService.Store(asset1); | ||
130 | |||
131 | // Create item | ||
132 | InventoryItemBase item1 = new InventoryItemBase(); | ||
133 | item1.Name = m_item1Name; | ||
134 | item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
135 | item1.AssetID = asset1.FullID; | ||
136 | item1.GroupID = UUID.Random(); | ||
137 | item1.CreatorIdAsUuid = m_uaLL1.PrincipalID; | ||
138 | item1.Owner = m_uaLL1.PrincipalID; | ||
139 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; | ||
140 | scene.AddInventoryItem(item1); | ||
141 | |||
142 | archiverModule.ArchiveInventory( | ||
143 | Guid.NewGuid(), m_uaLL1.FirstName, m_uaLL1.LastName, m_item1Name, "hampshire", archiveWriteStream); | ||
144 | |||
145 | m_iarStreamBytes = archiveWriteStream.ToArray(); | ||
146 | } | ||
147 | |||
148 | protected void SaveCompleted( | ||
149 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | ||
150 | Exception reportedException) | ||
151 | { | ||
152 | mre.Set(); | ||
153 | } | ||
154 | } | ||
155 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 76d0b85..7f156f8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -31,7 +31,6 @@ using System.IO; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using NUnit.Framework; | 33 | using NUnit.Framework; |
34 | using NUnit.Framework.SyntaxHelpers; | ||
35 | using OpenMetaverse; | 34 | using OpenMetaverse; |
36 | using OpenSim.Data; | 35 | using OpenSim.Data; |
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
@@ -50,182 +49,21 @@ using OpenSim.Tests.Common.Setup; | |||
50 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | 49 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests |
51 | { | 50 | { |
52 | [TestFixture] | 51 | [TestFixture] |
53 | public class InventoryArchiverTests | 52 | public class InventoryArchiverTests : InventoryArchiveTestCase |
54 | { | 53 | { |
55 | protected ManualResetEvent mre = new ManualResetEvent(false); | 54 | protected TestScene m_scene; |
56 | 55 | protected InventoryArchiverModule m_archiverModule; | |
57 | /// <summary> | 56 | |
58 | /// Stream of data representing a common IAR that can be reused in load tests. | ||
59 | /// </summary> | ||
60 | protected MemoryStream m_iarStream; | ||
61 | |||
62 | protected UserAccount m_ua1 | ||
63 | = new UserAccount { | ||
64 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000555"), | ||
65 | FirstName = "Mr", | ||
66 | LastName = "Tiddles" }; | ||
67 | protected UserAccount m_ua2 | ||
68 | = new UserAccount { | ||
69 | PrincipalID = UUID.Parse("00000000-0000-0000-0000-000000000666"), | ||
70 | FirstName = "Lord", | ||
71 | LastName = "Lucan" }; | ||
72 | string m_item1Name = "b.lsl"; | ||
73 | |||
74 | private void SaveCompleted( | ||
75 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | ||
76 | Exception reportedException) | ||
77 | { | ||
78 | mre.Set(); | ||
79 | } | ||
80 | |||
81 | [SetUp] | 57 | [SetUp] |
82 | public void Init() | 58 | public override void SetUp() |
83 | { | ||
84 | ConstructDefaultIarForTestLoad(); | ||
85 | } | ||
86 | |||
87 | protected void ConstructDefaultIarForTestLoad() | ||
88 | { | ||
89 | string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(m_item1Name, UUID.Random()); | ||
90 | |||
91 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
92 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
93 | |||
94 | InventoryItemBase item1 = new InventoryItemBase(); | ||
95 | item1.Name = m_item1Name; | ||
96 | item1.AssetID = UUID.Random(); | ||
97 | item1.GroupID = UUID.Random(); | ||
98 | //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); | ||
99 | //item1.CreatorId = userUuid.ToString(); | ||
100 | item1.CreatorId = m_ua2.PrincipalID.ToString(); | ||
101 | item1.Owner = UUID.Zero; | ||
102 | |||
103 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
104 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); | ||
105 | |||
106 | string item1FileName | ||
107 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | ||
108 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService)); | ||
109 | tar.Close(); | ||
110 | m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive | ||
115 | /// (subject to change since there is no fixed format yet). | ||
116 | /// </summary> | ||
117 | [Test] | ||
118 | public void TestSavePathToIarV0_1() | ||
119 | { | 59 | { |
120 | TestHelper.InMethod(); | 60 | base.SetUp(); |
121 | // log4net.Config.XmlConfigurator.Configure(); | ||
122 | |||
123 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
124 | |||
125 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
126 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
127 | |||
128 | // Create user | ||
129 | string userFirstName = "Jock"; | ||
130 | string userLastName = "Stirrup"; | ||
131 | string userPassword = "troll"; | ||
132 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
133 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | ||
134 | 61 | ||
135 | // Create asset | 62 | SerialiserModule serialiserModule = new SerialiserModule(); |
136 | SceneObjectGroup object1; | 63 | m_archiverModule = new InventoryArchiverModule(); |
137 | SceneObjectPart part1; | ||
138 | { | ||
139 | string partName = "My Little Dog Object"; | ||
140 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
141 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
142 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
143 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
144 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
145 | |||
146 | part1 | ||
147 | = new SceneObjectPart( | ||
148 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
149 | part1.Name = partName; | ||
150 | |||
151 | object1 = new SceneObjectGroup(part1); | ||
152 | scene.AddNewSceneObject(object1, false); | ||
153 | } | ||
154 | |||
155 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
156 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
157 | scene.AssetService.Store(asset1); | ||
158 | |||
159 | // Create item | ||
160 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
161 | InventoryItemBase item1 = new InventoryItemBase(); | ||
162 | item1.Name = "My Little Dog"; | ||
163 | item1.AssetID = asset1.FullID; | ||
164 | item1.ID = item1Id; | ||
165 | InventoryFolderBase objsFolder | ||
166 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | ||
167 | item1.Folder = objsFolder.ID; | ||
168 | scene.AddInventoryItem(item1); | ||
169 | |||
170 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
171 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
172 | |||
173 | // Test saving a particular path | ||
174 | mre.Reset(); | ||
175 | archiverModule.ArchiveInventory( | ||
176 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
177 | mre.WaitOne(60000, false); | ||
178 | |||
179 | byte[] archive = archiveWriteStream.ToArray(); | ||
180 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
181 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
182 | |||
183 | //bool gotControlFile = false; | ||
184 | bool gotObject1File = false; | ||
185 | //bool gotObject2File = false; | ||
186 | string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
187 | string expectedObject1FilePath = string.Format( | ||
188 | "{0}{1}{2}", | ||
189 | ArchiveConstants.INVENTORY_PATH, | ||
190 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), | ||
191 | expectedObject1FileName); | ||
192 | |||
193 | string filePath; | ||
194 | TarArchiveReader.TarEntryType tarEntryType; | ||
195 | |||
196 | // Console.WriteLine("Reading archive"); | ||
197 | |||
198 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | ||
199 | { | ||
200 | // Console.WriteLine("Got {0}", filePath); | ||
201 | |||
202 | // if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | ||
203 | // { | ||
204 | // gotControlFile = true; | ||
205 | // } | ||
206 | |||
207 | if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | ||
208 | { | ||
209 | // string fileName = filePath.Remove(0, "Objects/".Length); | ||
210 | // | ||
211 | // if (fileName.StartsWith(part1.Name)) | ||
212 | // { | ||
213 | Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); | ||
214 | gotObject1File = true; | ||
215 | // } | ||
216 | // else if (fileName.StartsWith(part2.Name)) | ||
217 | // { | ||
218 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
219 | // gotObject2File = true; | ||
220 | // } | ||
221 | } | ||
222 | } | ||
223 | |||
224 | // Assert.That(gotControlFile, Is.True, "No control file in archive"); | ||
225 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | ||
226 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | ||
227 | 64 | ||
228 | // TODO: Test presence of more files and contents of files. | 65 | m_scene = SceneSetupHelpers.SetupScene("Inventory"); |
66 | SceneSetupHelpers.SetupSceneModules(m_scene, serialiserModule, m_archiverModule); | ||
229 | } | 67 | } |
230 | 68 | ||
231 | /// <summary> | 69 | /// <summary> |
@@ -238,17 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
238 | TestHelper.InMethod(); | 76 | TestHelper.InMethod(); |
239 | // log4net.Config.XmlConfigurator.Configure(); | 77 | // log4net.Config.XmlConfigurator.Configure(); |
240 | 78 | ||
241 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
242 | |||
243 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
244 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
245 | |||
246 | // Create user | 79 | // Create user |
247 | string userFirstName = "Jock"; | 80 | string userFirstName = "Jock"; |
248 | string userLastName = "Stirrup"; | 81 | string userLastName = "Stirrup"; |
249 | string userPassword = "troll"; | 82 | string userPassword = "troll"; |
250 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 83 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
251 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | 84 | UserProfileTestUtils.CreateUserWithInventory(m_scene, userFirstName, userLastName, userId, userPassword); |
252 | 85 | ||
253 | // Create asset | 86 | // Create asset |
254 | SceneObjectGroup object1; | 87 | SceneObjectGroup object1; |
@@ -267,12 +100,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
267 | part1.Name = partName; | 100 | part1.Name = partName; |
268 | 101 | ||
269 | object1 = new SceneObjectGroup(part1); | 102 | object1 = new SceneObjectGroup(part1); |
270 | scene.AddNewSceneObject(object1, false); | 103 | m_scene.AddNewSceneObject(object1, false); |
271 | } | 104 | } |
272 | 105 | ||
273 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | 106 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); |
274 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | 107 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); |
275 | scene.AssetService.Store(asset1); | 108 | m_scene.AssetService.Store(asset1); |
276 | 109 | ||
277 | // Create item | 110 | // Create item |
278 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | 111 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); |
@@ -282,15 +115,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
282 | item1.AssetID = asset1.FullID; | 115 | item1.AssetID = asset1.FullID; |
283 | item1.ID = item1Id; | 116 | item1.ID = item1Id; |
284 | InventoryFolderBase objsFolder | 117 | InventoryFolderBase objsFolder |
285 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | 118 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, userId, "Objects")[0]; |
286 | item1.Folder = objsFolder.ID; | 119 | item1.Folder = objsFolder.ID; |
287 | scene.AddInventoryItem(item1); | 120 | m_scene.AddInventoryItem(item1); |
288 | 121 | ||
289 | MemoryStream archiveWriteStream = new MemoryStream(); | 122 | MemoryStream archiveWriteStream = new MemoryStream(); |
290 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | 123 | m_archiverModule.OnInventoryArchiveSaved += SaveCompleted; |
291 | 124 | ||
292 | mre.Reset(); | 125 | mre.Reset(); |
293 | archiverModule.ArchiveInventory( | 126 | m_archiverModule.ArchiveInventory( |
294 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); | 127 | Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); |
295 | mre.WaitOne(60000, false); | 128 | mre.WaitOne(60000, false); |
296 | 129 | ||
@@ -346,474 +179,99 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
346 | } | 179 | } |
347 | 180 | ||
348 | /// <summary> | 181 | /// <summary> |
349 | /// Test that things work when the load path specified starts with a slash | 182 | /// Test case where a creator account exists for the creator UUID embedded in item metadata and serialized |
350 | /// </summary> | 183 | /// objects. |
184 | /// </summary> | ||
351 | [Test] | 185 | [Test] |
352 | public void TestLoadIarPathStartsWithSlash() | 186 | public void TestLoadIarCreatorAccountPresent() |
353 | { | 187 | { |
354 | TestHelper.InMethod(); | 188 | TestHelper.InMethod(); |
355 | // log4net.Config.XmlConfigurator.Configure(); | 189 | // log4net.Config.XmlConfigurator.Configure(); |
356 | |||
357 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
358 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
359 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
360 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
361 | |||
362 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "password"); | ||
363 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/Objects", "password", m_iarStream); | ||
364 | 190 | ||
191 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL1, "meowfood"); | ||
192 | |||
193 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "meowfood", m_iarStream); | ||
365 | InventoryItemBase foundItem1 | 194 | InventoryItemBase foundItem1 |
366 | = InventoryArchiveUtils.FindItemByPath( | 195 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaLL1.PrincipalID, m_item1Name); |
367 | scene.InventoryService, m_ua1.PrincipalID, "/Objects/" + m_item1Name); | 196 | |
197 | Assert.That( | ||
198 | foundItem1.CreatorId, Is.EqualTo(m_uaLL1.PrincipalID.ToString()), | ||
199 | "Loaded item non-uuid creator doesn't match original"); | ||
200 | Assert.That( | ||
201 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL1.PrincipalID), | ||
202 | "Loaded item uuid creator doesn't match original"); | ||
203 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaLL1.PrincipalID), | ||
204 | "Loaded item owner doesn't match inventory reciever"); | ||
368 | 205 | ||
369 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); | 206 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
207 | string xmlData = Utils.BytesToString(asset1.Data); | ||
208 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
209 | |||
210 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL1.PrincipalID)); | ||
370 | } | 211 | } |
371 | 212 | ||
372 | /// <summary> | 213 | /// <summary> |
373 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 214 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
374 | /// an account exists with the creator name. | 215 | /// an account exists with the same name as the creator, though not the same id. |
375 | /// </summary> | 216 | /// </summary> |
376 | /// | ||
377 | /// This test also does some deeper probing of loading into nested inventory structures | ||
378 | [Test] | 217 | [Test] |
379 | public void TestLoadIarV0_1ExistingUsers() | 218 | public void TestLoadIarV0_1SameNameCreator() |
380 | { | 219 | { |
381 | TestHelper.InMethod(); | 220 | TestHelper.InMethod(); |
382 | //log4net.Config.XmlConfigurator.Configure(); | 221 | // log4net.Config.XmlConfigurator.Configure(); |
383 | |||
384 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
385 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
386 | |||
387 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
388 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
389 | |||
390 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
391 | 222 | ||
392 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); | 223 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "meowfood"); |
393 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); | 224 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaLL2, "hampshire"); |
394 | 225 | ||
395 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "/", "meowfood", m_iarStream); | 226 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
396 | |||
397 | InventoryItemBase foundItem1 | 227 | InventoryItemBase foundItem1 |
398 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, m_item1Name); | 228 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
399 | |||
400 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | ||
401 | 229 | ||
402 | // We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the | ||
403 | // UUID, not the OSPA itself. | ||
404 | // Assert.That( | ||
405 | // foundItem1.CreatorId, Is.EqualTo(item1.CreatorId), | ||
406 | // "Loaded item non-uuid creator doesn't match original"); | ||
407 | Assert.That( | 230 | Assert.That( |
408 | foundItem1.CreatorId, Is.EqualTo(m_ua2.PrincipalID.ToString()), | 231 | foundItem1.CreatorId, Is.EqualTo(m_uaLL2.PrincipalID.ToString()), |
409 | "Loaded item non-uuid creator doesn't match original"); | 232 | "Loaded item non-uuid creator doesn't match original"); |
410 | |||
411 | Assert.That( | 233 | Assert.That( |
412 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_ua2.PrincipalID), | 234 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaLL2.PrincipalID), |
413 | "Loaded item uuid creator doesn't match original"); | 235 | "Loaded item uuid creator doesn't match original"); |
414 | Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), | 236 | Assert.That(foundItem1.Owner, Is.EqualTo(m_uaMT.PrincipalID), |
415 | "Loaded item owner doesn't match inventory reciever"); | 237 | "Loaded item owner doesn't match inventory reciever"); |
416 | |||
417 | // Now try loading to a root child folder | ||
418 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xA"); | ||
419 | MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); | ||
420 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xA", "meowfood", archiveReadStream); | ||
421 | |||
422 | InventoryItemBase foundItem2 | ||
423 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xA/" + m_item1Name); | ||
424 | Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); | ||
425 | |||
426 | // Now try loading to a more deeply nested folder | ||
427 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_ua1.PrincipalID, "xB/xC"); | ||
428 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); | ||
429 | archiverModule.DearchiveInventory(m_ua1.FirstName, m_ua1.LastName, "xB/xC", "meowfood", archiveReadStream); | ||
430 | |||
431 | InventoryItemBase foundItem3 | ||
432 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_ua1.PrincipalID, "xB/xC/" + m_item1Name); | ||
433 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); | ||
434 | } | ||
435 | |||
436 | [Test] | ||
437 | public void TestIarV0_1WithEscapedChars() | ||
438 | { | ||
439 | TestHelper.InMethod(); | ||
440 | // log4net.Config.XmlConfigurator.Configure(); | ||
441 | |||
442 | string itemName = "You & you are a mean/man/"; | ||
443 | string humanEscapedItemName = @"You & you are a mean\/man\/"; | ||
444 | string userPassword = "meowfood"; | ||
445 | |||
446 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
447 | |||
448 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
449 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
450 | |||
451 | // Create user | ||
452 | string userFirstName = "Jock"; | ||
453 | string userLastName = "Stirrup"; | ||
454 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
455 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); | ||
456 | |||
457 | // Create asset | ||
458 | SceneObjectGroup object1; | ||
459 | SceneObjectPart part1; | ||
460 | { | ||
461 | string partName = "part name"; | ||
462 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
463 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
464 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
465 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
466 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
467 | |||
468 | part1 | ||
469 | = new SceneObjectPart( | ||
470 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
471 | part1.Name = partName; | ||
472 | |||
473 | object1 = new SceneObjectGroup(part1); | ||
474 | scene.AddNewSceneObject(object1, false); | ||
475 | } | ||
476 | |||
477 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
478 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
479 | scene.AssetService.Store(asset1); | ||
480 | |||
481 | // Create item | ||
482 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
483 | InventoryItemBase item1 = new InventoryItemBase(); | ||
484 | item1.Name = itemName; | ||
485 | item1.AssetID = asset1.FullID; | ||
486 | item1.ID = item1Id; | ||
487 | InventoryFolderBase objsFolder | ||
488 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | ||
489 | item1.Folder = objsFolder.ID; | ||
490 | scene.AddInventoryItem(item1); | ||
491 | |||
492 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
493 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
494 | |||
495 | mre.Reset(); | ||
496 | archiverModule.ArchiveInventory( | ||
497 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
498 | mre.WaitOne(60000, false); | ||
499 | |||
500 | // LOAD ITEM | ||
501 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
502 | 238 | ||
503 | archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); | 239 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
504 | 240 | string xmlData = Utils.BytesToString(asset1.Data); | |
505 | InventoryItemBase foundItem1 | 241 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
506 | = InventoryArchiveUtils.FindItemByPath( | ||
507 | scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); | ||
508 | 242 | ||
509 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | 243 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaLL2.PrincipalID)); |
510 | // Assert.That( | ||
511 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
512 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
513 | Assert.That( | ||
514 | foundItem1.Name, Is.EqualTo(itemName), | ||
515 | "Loaded item name doesn't match saved name"); | ||
516 | } | 244 | } |
517 | 245 | ||
518 | /// <summary> | 246 | /// <summary> |
519 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 247 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
520 | /// embedded creators do not exist in the system | 248 | /// the creator or an account with the creator's name does not exist within the system. |
521 | /// </summary> | 249 | /// </summary> |
522 | /// | ||
523 | /// This may possibly one day get overtaken by the as yet incomplete temporary profiles feature | ||
524 | /// (as tested in the a later commented out test) | ||
525 | /// This test is currently disabled | ||
526 | [Test] | 250 | [Test] |
527 | public void TestLoadIarV0_1AbsentUsers() | 251 | public void TestLoadIarV0_1AbsentCreator() |
528 | { | 252 | { |
529 | TestHelper.InMethod(); | 253 | TestHelper.InMethod(); |
530 | //log4net.Config.XmlConfigurator.Configure(); | 254 | // log4net.Config.XmlConfigurator.Configure(); |
531 | |||
532 | string userFirstName = "Charlie"; | ||
533 | string userLastName = "Chan"; | ||
534 | UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000999"); | ||
535 | string userItemCreatorFirstName = "Bat"; | ||
536 | string userItemCreatorLastName = "Man"; | ||
537 | //UUID userItemCreatorUuid = UUID.Parse("00000000-0000-0000-0000-000000008888"); | ||
538 | |||
539 | string itemName = "b.lsl"; | ||
540 | string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | ||
541 | |||
542 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
543 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
544 | |||
545 | InventoryItemBase item1 = new InventoryItemBase(); | ||
546 | item1.Name = itemName; | ||
547 | item1.AssetID = UUID.Random(); | ||
548 | item1.GroupID = UUID.Random(); | ||
549 | item1.CreatorId = OspResolver.MakeOspa(userItemCreatorFirstName, userItemCreatorLastName); | ||
550 | //item1.CreatorId = userUuid.ToString(); | ||
551 | //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; | ||
552 | item1.Owner = UUID.Zero; | ||
553 | |||
554 | string item1FileName | ||
555 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | ||
556 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null)); | ||
557 | tar.Close(); | ||
558 | |||
559 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
560 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
561 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
562 | |||
563 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
564 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
565 | |||
566 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
567 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userUuid, "meowfood"); | ||
568 | 255 | ||
569 | archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "meowfood", archiveReadStream); | 256 | UserProfileTestUtils.CreateUserWithInventory(m_scene, m_uaMT, "password"); |
257 | m_archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "password", m_iarStream); | ||
570 | 258 | ||
571 | InventoryItemBase foundItem1 | 259 | InventoryItemBase foundItem1 |
572 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userUuid, itemName); | 260 | = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
573 | 261 | ||
574 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | 262 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); |
575 | // Assert.That( | ||
576 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
577 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
578 | Assert.That( | 263 | Assert.That( |
579 | foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), | 264 | foundItem1.CreatorId, Is.EqualTo(m_uaMT.PrincipalID.ToString()), |
265 | "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
266 | Assert.That( | ||
267 | foundItem1.CreatorIdAsUuid, Is.EqualTo(m_uaMT.PrincipalID), | ||
580 | "Loaded item uuid creator doesn't match that of the loading user"); | 268 | "Loaded item uuid creator doesn't match that of the loading user"); |
581 | } | ||
582 | |||
583 | /// <summary> | ||
584 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | ||
585 | /// no account exists with the creator name | ||
586 | /// </summary> | ||
587 | /// Disabled since temporary profiles have not yet been implemented. | ||
588 | /// | ||
589 | //[Test] | ||
590 | //public void TestLoadIarV0_1TempProfiles() | ||
591 | //{ | ||
592 | // TestHelper.InMethod(); | ||
593 | |||
594 | // //log4net.Config.XmlConfigurator.Configure(); | ||
595 | 269 | ||
596 | // string userFirstName = "Dennis"; | 270 | AssetBase asset1 = m_scene.AssetService.Get(foundItem1.AssetID.ToString()); |
597 | // string userLastName = "Menace"; | 271 | string xmlData = Utils.BytesToString(asset1.Data); |
598 | // UUID userUuid = UUID.Parse("00000000-0000-0000-0000-000000000aaa"); | 272 | SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
599 | // string user2FirstName = "Walter"; | ||
600 | // string user2LastName = "Mitty"; | ||
601 | 273 | ||
602 | // string itemName = "b.lsl"; | 274 | Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_uaMT.PrincipalID)); |
603 | // string archiveItemName = InventoryArchiveWriteRequest.CreateArchiveItemName(itemName, UUID.Random()); | ||
604 | |||
605 | // MemoryStream archiveWriteStream = new MemoryStream(); | ||
606 | // TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
607 | |||
608 | // InventoryItemBase item1 = new InventoryItemBase(); | ||
609 | // item1.Name = itemName; | ||
610 | // item1.AssetID = UUID.Random(); | ||
611 | // item1.GroupID = UUID.Random(); | ||
612 | // item1.CreatorId = OspResolver.MakeOspa(user2FirstName, user2LastName); | ||
613 | // item1.Owner = UUID.Zero; | ||
614 | |||
615 | // string item1FileName | ||
616 | // = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | ||
617 | // tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | ||
618 | // tar.Close(); | ||
619 | |||
620 | // MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
621 | // SerialiserModule serialiserModule = new SerialiserModule(); | ||
622 | // InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
623 | |||
624 | // // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
625 | // Scene scene = SceneSetupHelpers.SetupScene(); | ||
626 | // IUserAdminService userAdminService = scene.CommsManager.UserAdminService; | ||
627 | |||
628 | // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
629 | // userAdminService.AddUser( | ||
630 | // userFirstName, userLastName, "meowfood", String.Empty, 1000, 1000, userUuid); | ||
631 | |||
632 | // archiverModule.DearchiveInventory(userFirstName, userLastName, "/", "troll", archiveReadStream); | ||
633 | |||
634 | // // Check that a suitable temporary user profile has been created. | ||
635 | // UserProfileData user2Profile | ||
636 | // = scene.CommsManager.UserService.GetUserProfile( | ||
637 | // OspResolver.HashName(user2FirstName + " " + user2LastName)); | ||
638 | // Assert.That(user2Profile, Is.Not.Null); | ||
639 | // Assert.That(user2Profile.FirstName == user2FirstName); | ||
640 | // Assert.That(user2Profile.SurName == user2LastName); | ||
641 | |||
642 | // CachedUserInfo userInfo | ||
643 | // = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | ||
644 | // userInfo.OnInventoryReceived += InventoryReceived; | ||
645 | |||
646 | // lock (this) | ||
647 | // { | ||
648 | // userInfo.FetchInventory(); | ||
649 | // Monitor.Wait(this, 60000); | ||
650 | // } | ||
651 | |||
652 | // InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); | ||
653 | |||
654 | // Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); | ||
655 | // Assert.That( | ||
656 | // foundItem.CreatorIdAsUuid, Is.EqualTo(OspResolver.HashName(user2FirstName + " " + user2LastName))); | ||
657 | // Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); | ||
658 | |||
659 | // Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); | ||
660 | //} | ||
661 | |||
662 | /// <summary> | ||
663 | /// Test replication of an archive path to the user's inventory. | ||
664 | /// </summary> | ||
665 | [Test] | ||
666 | public void TestNewIarPath() | ||
667 | { | ||
668 | TestHelper.InMethod(); | ||
669 | // log4net.Config.XmlConfigurator.Configure(); | ||
670 | |||
671 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
672 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
673 | |||
674 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | ||
675 | HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>(); | ||
676 | |||
677 | string folder1Name = "1"; | ||
678 | string folder2aName = "2a"; | ||
679 | string folder2bName = "2b"; | ||
680 | |||
681 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); | ||
682 | string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); | ||
683 | string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); | ||
684 | |||
685 | string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); | ||
686 | string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); | ||
687 | |||
688 | { | ||
689 | // Test replication of path1 | ||
690 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
691 | .ReplicateArchivePathToUserInventory( | ||
692 | iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
693 | foldersCreated, nodesLoaded); | ||
694 | |||
695 | List<InventoryFolderBase> folder1Candidates | ||
696 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
697 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
698 | |||
699 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
700 | List<InventoryFolderBase> folder2aCandidates | ||
701 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
702 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
703 | } | ||
704 | |||
705 | { | ||
706 | // Test replication of path2 | ||
707 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
708 | .ReplicateArchivePathToUserInventory( | ||
709 | iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
710 | foldersCreated, nodesLoaded); | ||
711 | |||
712 | List<InventoryFolderBase> folder1Candidates | ||
713 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
714 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
715 | |||
716 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
717 | |||
718 | List<InventoryFolderBase> folder2aCandidates | ||
719 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
720 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
721 | |||
722 | List<InventoryFolderBase> folder2bCandidates | ||
723 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName); | ||
724 | Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); | ||
725 | } | ||
726 | } | ||
727 | |||
728 | /// <summary> | ||
729 | /// Test replication of a partly existing archive path to the user's inventory. This should create | ||
730 | /// a duplicate path without the merge option. | ||
731 | /// </summary> | ||
732 | [Test] | ||
733 | public void TestPartExistingIarPath() | ||
734 | { | ||
735 | TestHelper.InMethod(); | ||
736 | //log4net.Config.XmlConfigurator.Configure(); | ||
737 | |||
738 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
739 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
740 | |||
741 | string folder1ExistingName = "a"; | ||
742 | string folder2Name = "b"; | ||
743 | |||
744 | InventoryFolderBase folder1 | ||
745 | = UserInventoryTestUtils.CreateInventoryFolder( | ||
746 | scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
747 | |||
748 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | ||
749 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | ||
750 | |||
751 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | ||
752 | |||
753 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
754 | .ReplicateArchivePathToUserInventory( | ||
755 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
756 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | ||
757 | |||
758 | List<InventoryFolderBase> folder1PostCandidates | ||
759 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
760 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); | ||
761 | |||
762 | // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. | ||
763 | InventoryFolderBase folder1Post = null; | ||
764 | foreach (InventoryFolderBase folder in folder1PostCandidates) | ||
765 | { | ||
766 | if (folder.ID != folder1.ID) | ||
767 | { | ||
768 | folder1Post = folder; | ||
769 | break; | ||
770 | } | ||
771 | } | ||
772 | // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | ||
773 | |||
774 | List<InventoryFolderBase> folder2PostCandidates | ||
775 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); | ||
776 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); | ||
777 | } | ||
778 | |||
779 | /// <summary> | ||
780 | /// Test replication of a partly existing archive path to the user's inventory. This should create | ||
781 | /// a merged path. | ||
782 | /// </summary> | ||
783 | [Test] | ||
784 | public void TestMergeIarPath() | ||
785 | { | ||
786 | TestHelper.InMethod(); | ||
787 | // log4net.Config.XmlConfigurator.Configure(); | ||
788 | |||
789 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
790 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
791 | |||
792 | string folder1ExistingName = "a"; | ||
793 | string folder2Name = "b"; | ||
794 | |||
795 | InventoryFolderBase folder1 | ||
796 | = UserInventoryTestUtils.CreateInventoryFolder( | ||
797 | scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
798 | |||
799 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | ||
800 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | ||
801 | |||
802 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | ||
803 | |||
804 | new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) | ||
805 | .ReplicateArchivePathToUserInventory( | ||
806 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
807 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | ||
808 | |||
809 | List<InventoryFolderBase> folder1PostCandidates | ||
810 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
811 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(1)); | ||
812 | Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID)); | ||
813 | |||
814 | List<InventoryFolderBase> folder2PostCandidates | ||
815 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b"); | ||
816 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); | ||
817 | } | 275 | } |
818 | } | 276 | } |
819 | } \ No newline at end of file | 277 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs new file mode 100644 index 0000000..0e8f647 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/PathTests.cs | |||
@@ -0,0 +1,478 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using NUnit.Framework; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Serialization; | ||
38 | using OpenSim.Framework.Serialization.External; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | ||
41 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | using OpenSim.Tests.Common; | ||
46 | using OpenSim.Tests.Common.Mock; | ||
47 | using OpenSim.Tests.Common.Setup; | ||
48 | |||
49 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | ||
50 | { | ||
51 | [TestFixture] | ||
52 | public class PathTests : InventoryArchiveTestCase | ||
53 | { | ||
54 | /// <summary> | ||
55 | /// Test saving an inventory path to a V0.1 OpenSim Inventory Archive | ||
56 | /// (subject to change since there is no fixed format yet). | ||
57 | /// </summary> | ||
58 | [Test] | ||
59 | public void TestSavePathToIarV0_1() | ||
60 | { | ||
61 | TestHelper.InMethod(); | ||
62 | // log4net.Config.XmlConfigurator.Configure(); | ||
63 | |||
64 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
65 | |||
66 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
67 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
68 | |||
69 | // Create user | ||
70 | string userFirstName = "Jock"; | ||
71 | string userLastName = "Stirrup"; | ||
72 | string userPassword = "troll"; | ||
73 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
74 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | ||
75 | |||
76 | // Create asset | ||
77 | SceneObjectGroup object1; | ||
78 | SceneObjectPart part1; | ||
79 | { | ||
80 | string partName = "My Little Dog Object"; | ||
81 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
82 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
83 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
84 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
85 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
86 | |||
87 | part1 = new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
88 | part1.Name = partName; | ||
89 | |||
90 | object1 = new SceneObjectGroup(part1); | ||
91 | scene.AddNewSceneObject(object1, false); | ||
92 | } | ||
93 | |||
94 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
95 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
96 | scene.AssetService.Store(asset1); | ||
97 | |||
98 | // Create item | ||
99 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
100 | InventoryItemBase item1 = new InventoryItemBase(); | ||
101 | item1.Name = "My Little Dog"; | ||
102 | item1.AssetID = asset1.FullID; | ||
103 | item1.ID = item1Id; | ||
104 | InventoryFolderBase objsFolder | ||
105 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | ||
106 | item1.Folder = objsFolder.ID; | ||
107 | scene.AddInventoryItem(item1); | ||
108 | |||
109 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
110 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
111 | |||
112 | // Test saving a particular path | ||
113 | mre.Reset(); | ||
114 | archiverModule.ArchiveInventory( | ||
115 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
116 | mre.WaitOne(60000, false); | ||
117 | |||
118 | byte[] archive = archiveWriteStream.ToArray(); | ||
119 | MemoryStream archiveReadStream = new MemoryStream(archive); | ||
120 | TarArchiveReader tar = new TarArchiveReader(archiveReadStream); | ||
121 | |||
122 | //bool gotControlFile = false; | ||
123 | bool gotObject1File = false; | ||
124 | //bool gotObject2File = false; | ||
125 | string expectedObject1FileName = InventoryArchiveWriteRequest.CreateArchiveItemName(item1); | ||
126 | string expectedObject1FilePath = string.Format( | ||
127 | "{0}{1}{2}", | ||
128 | ArchiveConstants.INVENTORY_PATH, | ||
129 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), | ||
130 | expectedObject1FileName); | ||
131 | |||
132 | string filePath; | ||
133 | TarArchiveReader.TarEntryType tarEntryType; | ||
134 | |||
135 | // Console.WriteLine("Reading archive"); | ||
136 | |||
137 | while (tar.ReadEntry(out filePath, out tarEntryType) != null) | ||
138 | { | ||
139 | // Console.WriteLine("Got {0}", filePath); | ||
140 | |||
141 | // if (ArchiveConstants.CONTROL_FILE_PATH == filePath) | ||
142 | // { | ||
143 | // gotControlFile = true; | ||
144 | // } | ||
145 | |||
146 | if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml")) | ||
147 | { | ||
148 | // string fileName = filePath.Remove(0, "Objects/".Length); | ||
149 | // | ||
150 | // if (fileName.StartsWith(part1.Name)) | ||
151 | // { | ||
152 | Assert.That(expectedObject1FilePath, Is.EqualTo(filePath)); | ||
153 | gotObject1File = true; | ||
154 | // } | ||
155 | // else if (fileName.StartsWith(part2.Name)) | ||
156 | // { | ||
157 | // Assert.That(fileName, Is.EqualTo(expectedObject2FileName)); | ||
158 | // gotObject2File = true; | ||
159 | // } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | // Assert.That(gotControlFile, Is.True, "No control file in archive"); | ||
164 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | ||
165 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | ||
166 | |||
167 | // TODO: Test presence of more files and contents of files. | ||
168 | } | ||
169 | |||
170 | /// <summary> | ||
171 | /// Test loading an IAR to various different inventory paths. | ||
172 | /// </summary> | ||
173 | [Test] | ||
174 | public void TestLoadIarToInventoryPaths() | ||
175 | { | ||
176 | TestHelper.InMethod(); | ||
177 | // log4net.Config.XmlConfigurator.Configure(); | ||
178 | |||
179 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
180 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
181 | |||
182 | // Annoyingly, we have to set up a scene even though inventory loading has nothing to do with a scene | ||
183 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
184 | |||
185 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
186 | |||
187 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "meowfood"); | ||
188 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); | ||
189 | |||
190 | archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); | ||
191 | InventoryItemBase foundItem1 | ||
192 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); | ||
193 | |||
194 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | ||
195 | |||
196 | // Now try loading to a root child folder | ||
197 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA"); | ||
198 | MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); | ||
199 | archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream); | ||
200 | |||
201 | InventoryItemBase foundItem2 | ||
202 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name); | ||
203 | Assert.That(foundItem2, Is.Not.Null, "Didn't find loaded item 2"); | ||
204 | |||
205 | // Now try loading to a more deeply nested folder | ||
206 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC"); | ||
207 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); | ||
208 | archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream); | ||
209 | |||
210 | InventoryItemBase foundItem3 | ||
211 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name); | ||
212 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); | ||
213 | } | ||
214 | |||
215 | /// <summary> | ||
216 | /// Test that things work when the load path specified starts with a slash | ||
217 | /// </summary> | ||
218 | [Test] | ||
219 | public void TestLoadIarPathStartsWithSlash() | ||
220 | { | ||
221 | TestHelper.InMethod(); | ||
222 | // log4net.Config.XmlConfigurator.Configure(); | ||
223 | |||
224 | SerialiserModule serialiserModule = new SerialiserModule(); | ||
225 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
226 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
227 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | ||
228 | |||
229 | UserProfileTestUtils.CreateUserWithInventory(scene, m_uaMT, "password"); | ||
230 | archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); | ||
231 | |||
232 | InventoryItemBase foundItem1 | ||
233 | = InventoryArchiveUtils.FindItemByPath( | ||
234 | scene.InventoryService, m_uaMT.PrincipalID, "/Objects/" + m_item1Name); | ||
235 | |||
236 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1 in TestLoadIarFolderStartsWithSlash()"); | ||
237 | } | ||
238 | |||
239 | [Test] | ||
240 | public void TestLoadIarPathWithEscapedChars() | ||
241 | { | ||
242 | TestHelper.InMethod(); | ||
243 | // log4net.Config.XmlConfigurator.Configure(); | ||
244 | |||
245 | string itemName = "You & you are a mean/man/"; | ||
246 | string humanEscapedItemName = @"You & you are a mean\/man\/"; | ||
247 | string userPassword = "meowfood"; | ||
248 | |||
249 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(); | ||
250 | |||
251 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
252 | SceneSetupHelpers.SetupSceneModules(scene, archiverModule); | ||
253 | |||
254 | // Create user | ||
255 | string userFirstName = "Jock"; | ||
256 | string userLastName = "Stirrup"; | ||
257 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
258 | UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "meowfood"); | ||
259 | |||
260 | // Create asset | ||
261 | SceneObjectGroup object1; | ||
262 | SceneObjectPart part1; | ||
263 | { | ||
264 | string partName = "part name"; | ||
265 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
266 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
267 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
268 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
269 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
270 | |||
271 | part1 | ||
272 | = new SceneObjectPart( | ||
273 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
274 | part1.Name = partName; | ||
275 | |||
276 | object1 = new SceneObjectGroup(part1); | ||
277 | scene.AddNewSceneObject(object1, false); | ||
278 | } | ||
279 | |||
280 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
281 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, object1); | ||
282 | scene.AssetService.Store(asset1); | ||
283 | |||
284 | // Create item | ||
285 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
286 | InventoryItemBase item1 = new InventoryItemBase(); | ||
287 | item1.Name = itemName; | ||
288 | item1.AssetID = asset1.FullID; | ||
289 | item1.ID = item1Id; | ||
290 | InventoryFolderBase objsFolder | ||
291 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects")[0]; | ||
292 | item1.Folder = objsFolder.ID; | ||
293 | scene.AddInventoryItem(item1); | ||
294 | |||
295 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
296 | archiverModule.OnInventoryArchiveSaved += SaveCompleted; | ||
297 | |||
298 | mre.Reset(); | ||
299 | archiverModule.ArchiveInventory( | ||
300 | Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); | ||
301 | mre.WaitOne(60000, false); | ||
302 | |||
303 | // LOAD ITEM | ||
304 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
305 | |||
306 | archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); | ||
307 | |||
308 | InventoryItemBase foundItem1 | ||
309 | = InventoryArchiveUtils.FindItemByPath( | ||
310 | scene.InventoryService, userId, "Scripts/Objects/" + humanEscapedItemName); | ||
311 | |||
312 | Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1"); | ||
313 | // Assert.That( | ||
314 | // foundItem1.CreatorId, Is.EqualTo(userUuid), | ||
315 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | ||
316 | Assert.That( | ||
317 | foundItem1.Name, Is.EqualTo(itemName), | ||
318 | "Loaded item name doesn't match saved name"); | ||
319 | } | ||
320 | |||
321 | /// <summary> | ||
322 | /// Test replication of an archive path to the user's inventory. | ||
323 | /// </summary> | ||
324 | [Test] | ||
325 | public void TestNewIarPath() | ||
326 | { | ||
327 | TestHelper.InMethod(); | ||
328 | // log4net.Config.XmlConfigurator.Configure(); | ||
329 | |||
330 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
331 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
332 | |||
333 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); | ||
334 | HashSet<InventoryNodeBase> nodesLoaded = new HashSet<InventoryNodeBase>(); | ||
335 | |||
336 | string folder1Name = "1"; | ||
337 | string folder2aName = "2a"; | ||
338 | string folder2bName = "2b"; | ||
339 | |||
340 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1Name, UUID.Random()); | ||
341 | string folder2aArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2aName, UUID.Random()); | ||
342 | string folder2bArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2bName, UUID.Random()); | ||
343 | |||
344 | string iarPath1 = string.Join("", new string[] { folder1ArchiveName, folder2aArchiveName }); | ||
345 | string iarPath2 = string.Join("", new string[] { folder1ArchiveName, folder2bArchiveName }); | ||
346 | |||
347 | { | ||
348 | // Test replication of path1 | ||
349 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
350 | .ReplicateArchivePathToUserInventory( | ||
351 | iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
352 | foldersCreated, nodesLoaded); | ||
353 | |||
354 | List<InventoryFolderBase> folder1Candidates | ||
355 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
356 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
357 | |||
358 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
359 | List<InventoryFolderBase> folder2aCandidates | ||
360 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
361 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
362 | } | ||
363 | |||
364 | { | ||
365 | // Test replication of path2 | ||
366 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
367 | .ReplicateArchivePathToUserInventory( | ||
368 | iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
369 | foldersCreated, nodesLoaded); | ||
370 | |||
371 | List<InventoryFolderBase> folder1Candidates | ||
372 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1Name); | ||
373 | Assert.That(folder1Candidates.Count, Is.EqualTo(1)); | ||
374 | |||
375 | InventoryFolderBase folder1 = folder1Candidates[0]; | ||
376 | |||
377 | List<InventoryFolderBase> folder2aCandidates | ||
378 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2aName); | ||
379 | Assert.That(folder2aCandidates.Count, Is.EqualTo(1)); | ||
380 | |||
381 | List<InventoryFolderBase> folder2bCandidates | ||
382 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, folder2bName); | ||
383 | Assert.That(folder2bCandidates.Count, Is.EqualTo(1)); | ||
384 | } | ||
385 | } | ||
386 | |||
387 | /// <summary> | ||
388 | /// Test replication of a partly existing archive path to the user's inventory. This should create | ||
389 | /// a duplicate path without the merge option. | ||
390 | /// </summary> | ||
391 | [Test] | ||
392 | public void TestPartExistingIarPath() | ||
393 | { | ||
394 | TestHelper.InMethod(); | ||
395 | //log4net.Config.XmlConfigurator.Configure(); | ||
396 | |||
397 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
398 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
399 | |||
400 | string folder1ExistingName = "a"; | ||
401 | string folder2Name = "b"; | ||
402 | |||
403 | InventoryFolderBase folder1 | ||
404 | = UserInventoryTestUtils.CreateInventoryFolder( | ||
405 | scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
406 | |||
407 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | ||
408 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | ||
409 | |||
410 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | ||
411 | |||
412 | new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) | ||
413 | .ReplicateArchivePathToUserInventory( | ||
414 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
415 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | ||
416 | |||
417 | List<InventoryFolderBase> folder1PostCandidates | ||
418 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
419 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(2)); | ||
420 | |||
421 | // FIXME: Temporarily, we're going to do something messy to make sure we pick up the created folder. | ||
422 | InventoryFolderBase folder1Post = null; | ||
423 | foreach (InventoryFolderBase folder in folder1PostCandidates) | ||
424 | { | ||
425 | if (folder.ID != folder1.ID) | ||
426 | { | ||
427 | folder1Post = folder; | ||
428 | break; | ||
429 | } | ||
430 | } | ||
431 | // Assert.That(folder1Post.ID, Is.EqualTo(folder1.ID)); | ||
432 | |||
433 | List<InventoryFolderBase> folder2PostCandidates | ||
434 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1Post, "b"); | ||
435 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); | ||
436 | } | ||
437 | |||
438 | /// <summary> | ||
439 | /// Test replication of a partly existing archive path to the user's inventory. This should create | ||
440 | /// a merged path. | ||
441 | /// </summary> | ||
442 | [Test] | ||
443 | public void TestMergeIarPath() | ||
444 | { | ||
445 | TestHelper.InMethod(); | ||
446 | // log4net.Config.XmlConfigurator.Configure(); | ||
447 | |||
448 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | ||
449 | UserAccount ua1 = UserProfileTestUtils.CreateUserWithInventory(scene); | ||
450 | |||
451 | string folder1ExistingName = "a"; | ||
452 | string folder2Name = "b"; | ||
453 | |||
454 | InventoryFolderBase folder1 | ||
455 | = UserInventoryTestUtils.CreateInventoryFolder( | ||
456 | scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
457 | |||
458 | string folder1ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder1ExistingName, UUID.Random()); | ||
459 | string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); | ||
460 | |||
461 | string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); | ||
462 | |||
463 | new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) | ||
464 | .ReplicateArchivePathToUserInventory( | ||
465 | itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), | ||
466 | new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); | ||
467 | |||
468 | List<InventoryFolderBase> folder1PostCandidates | ||
469 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, ua1.PrincipalID, folder1ExistingName); | ||
470 | Assert.That(folder1PostCandidates.Count, Is.EqualTo(1)); | ||
471 | Assert.That(folder1PostCandidates[0].ID, Is.EqualTo(folder1.ID)); | ||
472 | |||
473 | List<InventoryFolderBase> folder2PostCandidates | ||
474 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1PostCandidates[0], "b"); | ||
475 | Assert.That(folder2PostCandidates.Count, Is.EqualTo(1)); | ||
476 | } | ||
477 | } | ||
478 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 1337143..c88be7d 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -284,9 +284,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
284 | return; | 284 | return; |
285 | } | 285 | } |
286 | 286 | ||
287 | if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero)) | 287 | string reason; |
288 | if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out reason)) | ||
288 | { | 289 | { |
289 | sp.ControllingClient.SendTeleportFailed("The destination region has refused access"); | 290 | sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason); |
290 | return; | 291 | return; |
291 | } | 292 | } |
292 | 293 | ||
@@ -317,14 +318,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
317 | agentCircuit.Id0 = currentAgentCircuit.Id0; | 318 | agentCircuit.Id0 = currentAgentCircuit.Id0; |
318 | } | 319 | } |
319 | 320 | ||
320 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | 321 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) |
321 | { | 322 | { |
322 | // brand new agent, let's create a new caps seed | 323 | // brand new agent, let's create a new caps seed |
323 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | 324 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); |
324 | } | 325 | } |
325 | 326 | ||
326 | string reason = String.Empty; | ||
327 | |||
328 | // Let's create an agent there if one doesn't exist yet. | 327 | // Let's create an agent there if one doesn't exist yet. |
329 | bool logout = false; | 328 | bool logout = false; |
330 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) | 329 | if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout)) |
@@ -337,7 +336,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
337 | // OK, it got this agent. Let's close some child agents | 336 | // OK, it got this agent. Let's close some child agents |
338 | sp.CloseChildAgents(newRegionX, newRegionY); | 337 | sp.CloseChildAgents(newRegionX, newRegionY); |
339 | IClientIPEndpoint ipepClient; | 338 | IClientIPEndpoint ipepClient; |
340 | if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY)) | 339 | if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY)) |
341 | { | 340 | { |
342 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); | 341 | //sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent..."); |
343 | #region IP Translation for NAT | 342 | #region IP Translation for NAT |
@@ -400,6 +399,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
400 | if (!UpdateAgent(reg, finalDestination, agent)) | 399 | if (!UpdateAgent(reg, finalDestination, agent)) |
401 | { | 400 | { |
402 | // Region doesn't take it | 401 | // Region doesn't take it |
402 | m_log.WarnFormat( | ||
403 | "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.", | ||
404 | sp.Name, finalDestination.RegionName); | ||
405 | |||
403 | Fail(sp, finalDestination); | 406 | Fail(sp, finalDestination); |
404 | return; | 407 | return; |
405 | } | 408 | } |
@@ -426,16 +429,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
426 | // that the client contacted the destination before we send the attachments and close things here. | 429 | // that the client contacted the destination before we send the attachments and close things here. |
427 | if (!WaitForCallback(sp.UUID)) | 430 | if (!WaitForCallback(sp.UUID)) |
428 | { | 431 | { |
429 | Fail(sp, finalDestination); | 432 | m_log.WarnFormat( |
433 | "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} failed due to no callback from destination region. Returning avatar to source region.", | ||
434 | sp.Name, finalDestination.RegionName); | ||
435 | |||
436 | Fail(sp, finalDestination); | ||
430 | return; | 437 | return; |
431 | } | 438 | } |
432 | 439 | ||
433 | |||
434 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it | 440 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it |
435 | CrossAttachmentsIntoNewRegion(finalDestination, sp, true); | 441 | CrossAttachmentsIntoNewRegion(finalDestination, sp, true); |
436 | 442 | ||
437 | // Well, this is it. The agent is over there. | 443 | // Well, this is it. The agent is over there. |
438 | |||
439 | KillEntity(sp.Scene, sp.LocalId); | 444 | KillEntity(sp.Scene, sp.LocalId); |
440 | 445 | ||
441 | // May need to logout or other cleanup | 446 | // May need to logout or other cleanup |
@@ -448,7 +453,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
448 | 453 | ||
449 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | 454 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone |
450 | 455 | ||
451 | if (NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 456 | if (NeedsClosing(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) |
452 | { | 457 | { |
453 | Thread.Sleep(5000); | 458 | Thread.Sleep(5000); |
454 | sp.Close(); | 459 | sp.Close(); |
@@ -522,14 +527,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
522 | return region; | 527 | return region; |
523 | } | 528 | } |
524 | 529 | ||
525 | protected virtual bool NeedsNewAgent(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) | 530 | protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) |
526 | { | 531 | { |
527 | return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); | 532 | return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); |
528 | } | 533 | } |
529 | 534 | ||
530 | protected virtual bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) | 535 | protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) |
531 | { | 536 | { |
532 | return Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY); | 537 | return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); |
533 | } | 538 | } |
534 | 539 | ||
535 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) | 540 | protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) |
@@ -778,7 +783,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
778 | 783 | ||
779 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); | 784 | GridRegion neighbourRegion = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); |
780 | 785 | ||
781 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos)) | 786 | string reason; |
787 | if (!scene.SimulationService.QueryAccess(neighbourRegion, agent.ControllingClient.AgentId, newpos, out reason)) | ||
782 | { | 788 | { |
783 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); | 789 | agent.ControllingClient.SendAlertMessage("Cannot region cross into banned parcel"); |
784 | if (r == null) | 790 | if (r == null) |
@@ -1045,7 +1051,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1045 | 1051 | ||
1046 | if (m_regionInfo != null) | 1052 | if (m_regionInfo != null) |
1047 | { | 1053 | { |
1048 | neighbours = RequestNeighbours(sp.Scene, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | 1054 | neighbours = RequestNeighbours(sp, m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); |
1049 | } | 1055 | } |
1050 | else | 1056 | else |
1051 | { | 1057 | { |
@@ -1272,8 +1278,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1272 | /// <param name="pRegionLocX"></param> | 1278 | /// <param name="pRegionLocX"></param> |
1273 | /// <param name="pRegionLocY"></param> | 1279 | /// <param name="pRegionLocY"></param> |
1274 | /// <returns></returns> | 1280 | /// <returns></returns> |
1275 | protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) | 1281 | protected List<GridRegion> RequestNeighbours(ScenePresence avatar, uint pRegionLocX, uint pRegionLocY) |
1276 | { | 1282 | { |
1283 | Scene pScene = avatar.Scene; | ||
1277 | RegionInfo m_regionInfo = pScene.RegionInfo; | 1284 | RegionInfo m_regionInfo = pScene.RegionInfo; |
1278 | 1285 | ||
1279 | Border[] northBorders = pScene.NorthBorders.ToArray(); | 1286 | Border[] northBorders = pScene.NorthBorders.ToArray(); |
@@ -1281,10 +1288,24 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1281 | Border[] eastBorders = pScene.EastBorders.ToArray(); | 1288 | Border[] eastBorders = pScene.EastBorders.ToArray(); |
1282 | Border[] westBorders = pScene.WestBorders.ToArray(); | 1289 | Border[] westBorders = pScene.WestBorders.ToArray(); |
1283 | 1290 | ||
1284 | // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. | 1291 | // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't |
1292 | // clear what should be done with a "far view" given that megaregions already extended the | ||
1293 | // view to include everything in the megaregion | ||
1285 | if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) | 1294 | if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) |
1286 | { | 1295 | { |
1287 | return pScene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); | 1296 | int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance; |
1297 | |||
1298 | int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); | ||
1299 | int startY = (int)pRegionLocY * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); | ||
1300 | |||
1301 | int endX = (int)pRegionLocX * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); | ||
1302 | int endY = (int)pRegionLocY * (int)Constants.RegionSize + dd + (int)(Constants.RegionSize/2); | ||
1303 | |||
1304 | List<GridRegion> neighbours = | ||
1305 | avatar.Scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); | ||
1306 | |||
1307 | neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); | ||
1308 | return neighbours; | ||
1288 | } | 1309 | } |
1289 | else | 1310 | else |
1290 | { | 1311 | { |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 35dcd95..79e76b4 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -130,9 +130,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
130 | return region; | 130 | return region; |
131 | } | 131 | } |
132 | 132 | ||
133 | protected override bool NeedsClosing(uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) | 133 | protected override bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg) |
134 | { | 134 | { |
135 | if (base.NeedsClosing(oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) | 135 | if (base.NeedsClosing(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY, reg)) |
136 | return true; | 136 | return true; |
137 | 137 | ||
138 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); | 138 | int flags = m_aScene.GridService.GetRegionFlags(m_aScene.RegionInfo.ScopeID, reg.RegionID); |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 7bb8789..798547a 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -148,6 +148,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
148 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 148 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
149 | item = m_Scene.InventoryService.GetItem(item); | 149 | item = m_Scene.InventoryService.GetItem(item); |
150 | 150 | ||
151 | if (item.Owner != remoteClient.AgentId) | ||
152 | return UUID.Zero; | ||
153 | |||
151 | if (item != null) | 154 | if (item != null) |
152 | { | 155 | { |
153 | if ((InventoryType)item.InvType == InventoryType.Notecard) | 156 | if ((InventoryType)item.InvType == InventoryType.Notecard) |
@@ -524,6 +527,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
524 | 527 | ||
525 | if (item != null) | 528 | if (item != null) |
526 | { | 529 | { |
530 | item.Owner = remoteClient.AgentId; | ||
531 | |||
527 | AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); | 532 | AssetBase rezAsset = m_Scene.AssetService.Get(item.AssetID.ToString()); |
528 | 533 | ||
529 | if (rezAsset != null) | 534 | if (rezAsset != null) |
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs index 88f392d..00b0aa9 100644 --- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
75 | m_scene = scene; | 75 | m_scene = scene; |
76 | m_scene.RegisterModuleInterface<IRegionModule>(this); | 76 | m_scene.RegisterModuleInterface<IRegionModule>(this); |
77 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 77 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
78 | 78 | ||
79 | // ini file settings | 79 | // ini file settings |
80 | try | 80 | try |
81 | { | 81 | { |
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
229 | { | 229 | { |
230 | Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast"); | 230 | Command wlload = new Command("load", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleLoad, "Load windlight profile from the database and broadcast"); |
231 | Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin"); | 231 | Command wlenable = new Command("enable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleEnable, "Enable the windlight plugin"); |
232 | Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Enable the windlight plugin"); | 232 | Command wldisable = new Command("disable", CommandIntentions.COMMAND_NON_HAZARDOUS, HandleDisable, "Disable the windlight plugin"); |
233 | 233 | ||
234 | m_commander.RegisterCommand("load", wlload); | 234 | m_commander.RegisterCommand("load", wlload); |
235 | m_commander.RegisterCommand("enable", wlenable); | 235 | m_commander.RegisterCommand("enable", wlenable); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index e54ee02..18db9fa 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -32,7 +32,6 @@ using System.Reflection; | |||
32 | using System.Threading; | 32 | using System.Threading; |
33 | using log4net.Config; | 33 | using log4net.Config; |
34 | using NUnit.Framework; | 34 | using NUnit.Framework; |
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | 35 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
38 | using Nini.Config; | 37 | using Nini.Config; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index ef910f4..e471f75 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -32,7 +32,6 @@ using System.Reflection; | |||
32 | using System.Threading; | 32 | using System.Threading; |
33 | using log4net.Config; | 33 | using log4net.Config; |
34 | using NUnit.Framework; | 34 | using NUnit.Framework; |
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | 35 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
38 | using Nini.Config; | 37 | using Nini.Config; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 56720b7..a298b65 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -257,15 +257,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
257 | return false; | 257 | return false; |
258 | } | 258 | } |
259 | 259 | ||
260 | public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) | 260 | public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason) |
261 | { | 261 | { |
262 | reason = "Communications failure"; | ||
262 | if (destination == null) | 263 | if (destination == null) |
263 | return false; | 264 | return false; |
264 | 265 | ||
265 | foreach (Scene s in m_sceneList) | 266 | foreach (Scene s in m_sceneList) |
266 | { | 267 | { |
267 | if (s.RegionInfo.RegionID == destination.RegionID) | 268 | if (s.RegionInfo.RegionID == destination.RegionID) |
268 | return s.QueryAccess(id, position); | 269 | return s.QueryAccess(id, position, out reason); |
269 | } | 270 | } |
270 | //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); | 271 | //m_log.Debug("[LOCAL COMMS]: region not found for QueryAccess"); |
271 | return false; | 272 | return false; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index c4919b3..67f4d60 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -192,15 +192,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
192 | return false; | 192 | return false; |
193 | 193 | ||
194 | // Try local first | 194 | // Try local first |
195 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | 195 | if (m_localBackend.IsLocalRegion(destination.RegionHandle)) |
196 | return true; | 196 | return m_localBackend.UpdateAgent(destination, cAgentData); |
197 | |||
198 | // else do the remote thing | ||
199 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
200 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
201 | |||
202 | return false; | ||
203 | 197 | ||
198 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
204 | } | 199 | } |
205 | 200 | ||
206 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) | 201 | public bool UpdateAgent(GridRegion destination, AgentPosition cAgentData) |
@@ -209,15 +204,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
209 | return false; | 204 | return false; |
210 | 205 | ||
211 | // Try local first | 206 | // Try local first |
212 | if (m_localBackend.UpdateAgent(destination, cAgentData)) | 207 | if (m_localBackend.IsLocalRegion(destination.RegionHandle)) |
213 | return true; | 208 | return m_localBackend.UpdateAgent(destination, cAgentData); |
214 | |||
215 | // else do the remote thing | ||
216 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | ||
217 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
218 | |||
219 | return false; | ||
220 | 209 | ||
210 | return m_remoteConnector.UpdateAgent(destination, cAgentData); | ||
221 | } | 211 | } |
222 | 212 | ||
223 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | 213 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) |
@@ -239,18 +229,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
239 | 229 | ||
240 | } | 230 | } |
241 | 231 | ||
242 | public bool QueryAccess(GridRegion destination, UUID id, Vector3 position) | 232 | public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string reason) |
243 | { | 233 | { |
234 | reason = "Communications failure"; | ||
244 | if (destination == null) | 235 | if (destination == null) |
245 | return false; | 236 | return false; |
246 | 237 | ||
247 | // Try local first | 238 | // Try local first |
248 | if (m_localBackend.QueryAccess(destination, id, position)) | 239 | if (m_localBackend.QueryAccess(destination, id, position, out reason)) |
249 | return true; | 240 | return true; |
250 | 241 | ||
251 | // else do the remote thing | 242 | // else do the remote thing |
252 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) | 243 | if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) |
253 | return m_remoteConnector.QueryAccess(destination, id, position); | 244 | return m_remoteConnector.QueryAccess(destination, id, position, out reason); |
254 | 245 | ||
255 | return false; | 246 | return false; |
256 | 247 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 04b6e3d..e2760a2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -32,7 +32,6 @@ using System.Reflection; | |||
32 | using System.Threading; | 32 | using System.Threading; |
33 | using log4net.Config; | 33 | using log4net.Config; |
34 | using NUnit.Framework; | 34 | using NUnit.Framework; |
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | 35 | using OpenMetaverse; |
37 | using OpenMetaverse.Assets; | 36 | using OpenMetaverse.Assets; |
38 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index 071314a..aa14054 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
188 | } | 188 | } |
189 | catch (DllNotFoundException) | 189 | catch (DllNotFoundException) |
190 | { | 190 | { |
191 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is emtpy for {0}", id); | 191 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); |
192 | 192 | ||
193 | } | 193 | } |
194 | catch (IndexOutOfRangeException) | 194 | catch (IndexOutOfRangeException) |
195 | { | 195 | { |
196 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); | 196 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); |
197 | 197 | ||
198 | } | 198 | } |
199 | catch (Exception) | 199 | catch (Exception) |
200 | { | 200 | { |
201 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is emtpy for {0}", id); | 201 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); |
202 | 202 | ||
203 | } | 203 | } |
204 | return null; | 204 | return null; |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs index 7c5d044..898ca4a 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/MoapModule.cs | |||
@@ -50,7 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
50 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | 50 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
52 | 52 | ||
53 | namespace OpenSim.Region.CoreModules.Media.Moap | 53 | namespace OpenSim.Region.CoreModules.World.Media.Moap |
54 | { | 54 | { |
55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] | 55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MoapModule")] |
56 | public class MoapModule : INonSharedRegionModule, IMoapModule | 56 | public class MoapModule : INonSharedRegionModule, IMoapModule |
@@ -225,24 +225,62 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
225 | return me; | 225 | return me; |
226 | } | 226 | } |
227 | 227 | ||
228 | /// <summary> | ||
229 | /// Set the media entry on the face of the given part. | ||
230 | /// </summary> | ||
231 | /// <param name="part">/param> | ||
232 | /// <param name="face"></param> | ||
233 | /// <param name="me">If null, then the media entry is cleared.</param> | ||
228 | public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) | 234 | public void SetMediaEntry(SceneObjectPart part, int face, MediaEntry me) |
229 | { | 235 | { |
236 | // m_log.DebugFormat("[MOAP]: SetMediaEntry for {0}, face {1}", part.Name, face); | ||
237 | |||
230 | CheckFaceParam(part, face); | 238 | CheckFaceParam(part, face); |
231 | 239 | ||
232 | if (null == part.Shape.Media) | 240 | if (null == part.Shape.Media) |
233 | part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); | 241 | { |
234 | 242 | if (me == null) | |
243 | return; | ||
244 | else | ||
245 | part.Shape.Media = new PrimitiveBaseShape.MediaList(new MediaEntry[part.GetNumberOfSides()]); | ||
246 | } | ||
247 | |||
235 | lock (part.Shape.Media) | 248 | lock (part.Shape.Media) |
236 | part.Shape.Media[face] = me; | 249 | part.Shape.Media[face] = me; |
237 | 250 | ||
238 | UpdateMediaUrl(part, UUID.Zero); | 251 | UpdateMediaUrl(part, UUID.Zero); |
252 | |||
253 | SetPartMediaFlags(part, face, me != null); | ||
254 | |||
239 | part.ScheduleFullUpdate(); | 255 | part.ScheduleFullUpdate(); |
240 | part.TriggerScriptChangedEvent(Changed.MEDIA); | 256 | part.TriggerScriptChangedEvent(Changed.MEDIA); |
241 | } | 257 | } |
242 | 258 | ||
259 | /// <summary> | ||
260 | /// Clear the media entry from the face of the given part. | ||
261 | /// </summary> | ||
262 | /// <param name="part"></param> | ||
263 | /// <param name="face"></param> | ||
243 | public void ClearMediaEntry(SceneObjectPart part, int face) | 264 | public void ClearMediaEntry(SceneObjectPart part, int face) |
244 | { | 265 | { |
245 | SetMediaEntry(part, face, null); | 266 | SetMediaEntry(part, face, null); |
267 | } | ||
268 | |||
269 | /// <summary> | ||
270 | /// Set the media flags on the texture face of the given part. | ||
271 | /// </summary> | ||
272 | /// <remarks> | ||
273 | /// The fact that we need a separate function to do what should be a simple one line operation is BUTT UGLY. | ||
274 | /// </remarks> | ||
275 | /// <param name="part"></param> | ||
276 | /// <param name="face"></param> | ||
277 | /// <param name="flag"></param> | ||
278 | protected void SetPartMediaFlags(SceneObjectPart part, int face, bool flag) | ||
279 | { | ||
280 | Primitive.TextureEntry te = part.Shape.Textures; | ||
281 | Primitive.TextureEntryFace teFace = te.CreateFace((uint)face); | ||
282 | teFace.MediaFlags = flag; | ||
283 | part.Shape.Textures = te; | ||
246 | } | 284 | } |
247 | 285 | ||
248 | /// <summary> | 286 | /// <summary> |
@@ -333,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
333 | } | 371 | } |
334 | 372 | ||
335 | // m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); | 373 | // m_log.DebugFormat("[MOAP]: Received {0} media entries for prim {1}", omu.FaceMedia.Length, primId); |
336 | 374 | // | |
337 | // for (int i = 0; i < omu.FaceMedia.Length; i++) | 375 | // for (int i = 0; i < omu.FaceMedia.Length; i++) |
338 | // { | 376 | // { |
339 | // MediaEntry me = omu.FaceMedia[i]; | 377 | // MediaEntry me = omu.FaceMedia[i]; |
@@ -368,10 +406,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
368 | // FIXME: Race condition here since some other texture entry manipulator may overwrite/get | 406 | // FIXME: Race condition here since some other texture entry manipulator may overwrite/get |
369 | // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry | 407 | // overwritten. Unfortunately, PrimitiveBaseShape does not allow us to change texture entry |
370 | // directly. | 408 | // directly. |
371 | Primitive.TextureEntry te = part.Shape.Textures; | 409 | SetPartMediaFlags(part, i, true); |
372 | Primitive.TextureEntryFace face = te.CreateFace((uint)i); | ||
373 | face.MediaFlags = true; | ||
374 | part.Shape.Textures = te; | ||
375 | // m_log.DebugFormat( | 410 | // m_log.DebugFormat( |
376 | // "[MOAP]: Media flags for face {0} is {1}", | 411 | // "[MOAP]: Media flags for face {0} is {1}", |
377 | // i, part.Shape.Textures.FaceTextures[i].MediaFlags); | 412 | // i, part.Shape.Textures.FaceTextures[i].MediaFlags); |
@@ -380,6 +415,8 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
380 | } | 415 | } |
381 | else | 416 | else |
382 | { | 417 | { |
418 | // m_log.DebugFormat("[MOAP]: Setting existing media list for {0}", part.Name); | ||
419 | |||
383 | // We need to go through the media textures one at a time to make sure that we have permission | 420 | // We need to go through the media textures one at a time to make sure that we have permission |
384 | // to change them | 421 | // to change them |
385 | 422 | ||
@@ -401,8 +438,7 @@ namespace OpenSim.Region.CoreModules.Media.Moap | |||
401 | if (null == media[i]) | 438 | if (null == media[i]) |
402 | continue; | 439 | continue; |
403 | 440 | ||
404 | Primitive.TextureEntryFace face = te.CreateFace((uint)i); | 441 | SetPartMediaFlags(part, i, true); |
405 | face.MediaFlags = true; | ||
406 | 442 | ||
407 | // m_log.DebugFormat( | 443 | // m_log.DebugFormat( |
408 | // "[MOAP]: Media flags for face {0} is {1}", | 444 | // "[MOAP]: Media flags for face {0} is {1}", |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs new file mode 100644 index 0000000..5b85830 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | |||
@@ -0,0 +1,102 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.CoreModules.World.Media.Moap; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
41 | using OpenSim.Tests.Common; | ||
42 | using OpenSim.Tests.Common.Mock; | ||
43 | using OpenSim.Tests.Common.Setup; | ||
44 | |||
45 | namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | ||
46 | { | ||
47 | [TestFixture] | ||
48 | public class MoapTests | ||
49 | { | ||
50 | protected TestScene m_scene; | ||
51 | protected MoapModule m_module; | ||
52 | |||
53 | [SetUp] | ||
54 | public void SetUp() | ||
55 | { | ||
56 | m_module = new MoapModule(); | ||
57 | m_scene = SceneSetupHelpers.SetupScene(); | ||
58 | SceneSetupHelpers.SetupSceneModules(m_scene, m_module); | ||
59 | } | ||
60 | |||
61 | [Test] | ||
62 | public void TestClearMediaUrl() | ||
63 | { | ||
64 | TestHelper.InMethod(); | ||
65 | // log4net.Config.XmlConfigurator.Configure(); | ||
66 | |||
67 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); | ||
68 | MediaEntry me = new MediaEntry(); | ||
69 | |||
70 | m_module.SetMediaEntry(part, 1, me); | ||
71 | m_module.ClearMediaEntry(part, 1); | ||
72 | |||
73 | Assert.That(part.Shape.Media[1], Is.EqualTo(null)); | ||
74 | |||
75 | // Although we've cleared one face, other faces may still be present. So we need to check for an | ||
76 | // update media url version | ||
77 | Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000001/" + UUID.Zero)); | ||
78 | |||
79 | // By changing media flag to false, the face texture once again becomes identical to the DefaultTexture. | ||
80 | // Therefore, when libOMV reserializes it, it disappears and we are left with no face texture in this slot. | ||
81 | // Not at all confusing, eh? | ||
82 | Assert.That(part.Shape.Textures.FaceTextures[1], Is.Null); | ||
83 | } | ||
84 | |||
85 | [Test] | ||
86 | public void TestSetMediaUrl() | ||
87 | { | ||
88 | TestHelper.InMethod(); | ||
89 | |||
90 | string homeUrl = "opensimulator.org"; | ||
91 | |||
92 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(m_scene); | ||
93 | MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; | ||
94 | |||
95 | m_module.SetMediaEntry(part, 1, me); | ||
96 | |||
97 | Assert.That(part.Shape.Media[1].HomeURL, Is.EqualTo(homeUrl)); | ||
98 | Assert.That(part.MediaUrl, Is.EqualTo("x-mv:0000000000/" + UUID.Zero)); | ||
99 | Assert.That(part.Shape.Textures.FaceTextures[1].MediaFlags, Is.True); | ||
100 | } | ||
101 | } | ||
102 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 364dd6c..170c35f 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -642,7 +642,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
642 | /// implemented by callers. | 642 | /// implemented by callers. |
643 | /// </summary> | 643 | /// </summary> |
644 | /// <param name="currentUser"></param> | 644 | /// <param name="currentUser"></param> |
645 | /// <param name="objId"></param> | 645 | /// <param name="objId">This is a scene object group UUID</param> |
646 | /// <param name="denyOnLocked"></param> | 646 | /// <param name="denyOnLocked"></param> |
647 | /// <returns></returns> | 647 | /// <returns></returns> |
648 | protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked) | 648 | protected bool GenericObjectPermission(UUID currentUser, UUID objId, bool denyOnLocked) |
@@ -1896,7 +1896,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1896 | // "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", | 1896 | // "[PERMISSIONS]: Checking CanControlPrimMedia for {0} on {1} face {2} with control permissions {3}", |
1897 | // agentID, primID, face, me.ControlPermissions); | 1897 | // agentID, primID, face, me.ControlPermissions); |
1898 | 1898 | ||
1899 | return GenericPrimMediaPermission(part, agentID, me.ControlPermissions); | 1899 | return GenericObjectPermission(agentID, part.ParentGroup.UUID, true); |
1900 | } | 1900 | } |
1901 | 1901 | ||
1902 | private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) | 1902 | private bool CanInteractWithPrimMedia(UUID agentID, UUID primID, int face) |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index f10e848..dafaa0c 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -30,7 +30,6 @@ using System.IO; | |||
30 | using System.Xml; | 30 | using System.Xml; |
31 | using log4net.Config; | 31 | using log4net.Config; |
32 | using NUnit.Framework; | 32 | using NUnit.Framework; |
33 | using NUnit.Framework.SyntaxHelpers; | ||
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index a9e46d0..7bb7544 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
113 | data = new MapBlockData(); | 113 | data = new MapBlockData(); |
114 | data.Agents = 0; | 114 | data.Agents = 0; |
115 | data.Access = info.Access; | 115 | data.Access = info.Access; |
116 | data.MapImageId = info.TerrainImage; | 116 | data.MapImageId = UUID.Zero; // could use info.TerrainImage but it seems to break viewer2 |
117 | data.Name = info.RegionName; | 117 | data.Name = info.RegionName; |
118 | data.RegionFlags = 0; // TODO not used? | 118 | data.RegionFlags = 0; // TODO not used? |
119 | data.WaterHeight = 0; // not used | 119 | data.WaterHeight = 0; // not used |
@@ -135,7 +135,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
135 | data.Y = 0; | 135 | data.Y = 0; |
136 | blocks.Add(data); | 136 | blocks.Add(data); |
137 | 137 | ||
138 | remoteClient.SendMapBlock(blocks, 0); | 138 | // not sure what the flags do here, but seems to be necessary |
139 | // to set to "2" for viewer 2 | ||
140 | remoteClient.SendMapBlock(blocks, 2); | ||
139 | } | 141 | } |
140 | 142 | ||
141 | // private Scene GetClientScene(IClientAPI client) | 143 | // private Scene GetClientScene(IClientAPI client) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e2d96d9..fcbcf59 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -321,6 +321,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | // Passing something to another avatar or a an object will already | 321 | // Passing something to another avatar or a an object will already |
322 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 322 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
323 | item = InventoryService.GetItem(item); | 323 | item = InventoryService.GetItem(item); |
324 | if (item.Owner != remoteClient.AgentId) | ||
325 | return; | ||
324 | 326 | ||
325 | if (item != null) | 327 | if (item != null) |
326 | { | 328 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 355671c..1a6a70b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -83,6 +83,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
83 | public bool m_useFlySlow; | 83 | public bool m_useFlySlow; |
84 | public bool m_usePreJump; | 84 | public bool m_usePreJump; |
85 | public bool m_seeIntoRegionFromNeighbor; | 85 | public bool m_seeIntoRegionFromNeighbor; |
86 | |||
87 | protected float m_defaultDrawDistance = 255.0f; | ||
88 | public float DefaultDrawDistance | ||
89 | { | ||
90 | get { return m_defaultDrawDistance; } | ||
91 | } | ||
92 | |||
86 | // TODO: need to figure out how allow client agents but deny | 93 | // TODO: need to figure out how allow client agents but deny |
87 | // root agents when ACL denies access to root agent | 94 | // root agents when ACL denies access to root agent |
88 | public bool m_strictAccessControl = true; | 95 | public bool m_strictAccessControl = true; |
@@ -129,7 +136,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | protected ICapabilitiesModule m_capsModule; | 136 | protected ICapabilitiesModule m_capsModule; |
130 | // Central Update Loop | 137 | // Central Update Loop |
131 | protected int m_fps = 10; | 138 | protected int m_fps = 10; |
132 | protected uint m_frame; | 139 | |
140 | /// <summary> | ||
141 | /// Current scene frame number | ||
142 | /// </summary> | ||
143 | public uint Frame | ||
144 | { | ||
145 | get; | ||
146 | protected set; | ||
147 | } | ||
148 | |||
133 | protected float m_timespan = 0.089f; | 149 | protected float m_timespan = 0.089f; |
134 | protected DateTime m_lastupdate = DateTime.UtcNow; | 150 | protected DateTime m_lastupdate = DateTime.UtcNow; |
135 | 151 | ||
@@ -618,6 +634,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | // | 634 | // |
619 | IConfig startupConfig = m_config.Configs["Startup"]; | 635 | IConfig startupConfig = m_config.Configs["Startup"]; |
620 | 636 | ||
637 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); | ||
638 | |||
621 | //Animation states | 639 | //Animation states |
622 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 640 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
623 | // TODO: Change default to true once the feature is supported | 641 | // TODO: Change default to true once the feature is supported |
@@ -1183,7 +1201,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | 1201 | ||
1184 | try | 1202 | try |
1185 | { | 1203 | { |
1186 | Update(); | 1204 | while (!shuttingdown) |
1205 | Update(); | ||
1187 | 1206 | ||
1188 | m_lastUpdate = Util.EnvironmentTickCount(); | 1207 | m_lastUpdate = Util.EnvironmentTickCount(); |
1189 | m_firstHeartbeat = false; | 1208 | m_firstHeartbeat = false; |
@@ -1200,187 +1219,176 @@ namespace OpenSim.Region.Framework.Scenes | |||
1200 | Watchdog.RemoveThread(); | 1219 | Watchdog.RemoveThread(); |
1201 | } | 1220 | } |
1202 | 1221 | ||
1203 | /// <summary> | ||
1204 | /// Performs per-frame updates on the scene, this should be the central scene loop | ||
1205 | /// </summary> | ||
1206 | public override void Update() | 1222 | public override void Update() |
1207 | { | 1223 | { |
1208 | float physicsFPS; | 1224 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; |
1209 | int maintc; | 1225 | float physicsFPS = 0f; |
1210 | 1226 | ||
1211 | while (!shuttingdown) | 1227 | int maintc = Util.EnvironmentTickCount(); |
1228 | int tmpFrameMS = maintc; | ||
1229 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | ||
1230 | |||
1231 | // Increment the frame counter | ||
1232 | ++Frame; | ||
1233 | |||
1234 | try | ||
1212 | { | 1235 | { |
1213 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1236 | // Check if any objects have reached their targets |
1214 | physicsFPS = 0f; | 1237 | CheckAtTargets(); |
1215 | 1238 | ||
1216 | maintc = Util.EnvironmentTickCount(); | 1239 | // Update SceneObjectGroups that have scheduled themselves for updates |
1217 | int tmpFrameMS = maintc; | 1240 | // Objects queue their updates onto all scene presences |
1218 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | 1241 | if (Frame % m_update_objects == 0) |
1242 | m_sceneGraph.UpdateObjectGroups(); | ||
1219 | 1243 | ||
1220 | // Increment the frame counter | 1244 | // Run through all ScenePresences looking for updates |
1221 | ++m_frame; | 1245 | // Presence updates and queued object updates for each presence are sent to clients |
1246 | if (Frame % m_update_presences == 0) | ||
1247 | m_sceneGraph.UpdatePresences(); | ||
1222 | 1248 | ||
1223 | try | 1249 | // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) |
1250 | if (Frame % m_update_coarse_locations == 0) | ||
1224 | { | 1251 | { |
1225 | // Check if any objects have reached their targets | 1252 | List<Vector3> coarseLocations; |
1226 | CheckAtTargets(); | 1253 | List<UUID> avatarUUIDs; |
1254 | SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); | ||
1255 | // Send coarse locations to clients | ||
1256 | ForEachScenePresence(delegate(ScenePresence presence) | ||
1257 | { | ||
1258 | presence.SendCoarseLocations(coarseLocations, avatarUUIDs); | ||
1259 | }); | ||
1260 | } | ||
1227 | 1261 | ||
1228 | // Update SceneObjectGroups that have scheduled themselves for updates | 1262 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); |
1229 | // Objects queue their updates onto all scene presences | 1263 | if ((Frame % m_update_physics == 0) && m_physics_enabled) |
1230 | if (m_frame % m_update_objects == 0) | 1264 | m_sceneGraph.UpdatePreparePhysics(); |
1231 | m_sceneGraph.UpdateObjectGroups(); | 1265 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); |
1232 | 1266 | ||
1233 | // Run through all ScenePresences looking for updates | 1267 | // Apply any pending avatar force input to the avatar's velocity |
1234 | // Presence updates and queued object updates for each presence are sent to clients | 1268 | if (Frame % m_update_entitymovement == 0) |
1235 | if (m_frame % m_update_presences == 0) | 1269 | m_sceneGraph.UpdateScenePresenceMovement(); |
1236 | m_sceneGraph.UpdatePresences(); | ||
1237 | 1270 | ||
1238 | // Coarse locations relate to positions of green dots on the mini-map (on a SecondLife client) | 1271 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their |
1239 | if (m_frame % m_update_coarse_locations == 0) | 1272 | // velocity |
1240 | { | 1273 | int tmpPhysicsMS = Util.EnvironmentTickCount(); |
1241 | List<Vector3> coarseLocations; | 1274 | if (Frame % m_update_physics == 0) |
1242 | List<UUID> avatarUUIDs; | 1275 | { |
1243 | SceneGraph.GetCoarseLocations(out coarseLocations, out avatarUUIDs, 60); | 1276 | if (m_physics_enabled) |
1244 | // Send coarse locations to clients | 1277 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); |
1245 | ForEachScenePresence(delegate(ScenePresence presence) | 1278 | if (SynchronizeScene != null) |
1246 | { | 1279 | SynchronizeScene(this); |
1247 | presence.SendCoarseLocations(coarseLocations, avatarUUIDs); | 1280 | } |
1248 | }); | 1281 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); |
1249 | } | ||
1250 | |||
1251 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); | ||
1252 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | ||
1253 | m_sceneGraph.UpdatePreparePhysics(); | ||
1254 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); | ||
1255 | 1282 | ||
1256 | // Apply any pending avatar force input to the avatar's velocity | 1283 | // Delete temp-on-rez stuff |
1257 | if (m_frame % m_update_entitymovement == 0) | 1284 | if (Frame % 1000 == 0 && !m_cleaningTemps) |
1258 | m_sceneGraph.UpdateScenePresenceMovement(); | 1285 | { |
1286 | int tmpTempOnRezMS = Util.EnvironmentTickCount(); | ||
1287 | m_cleaningTemps = true; | ||
1288 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | ||
1289 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | ||
1290 | } | ||
1259 | 1291 | ||
1260 | // Perform the main physics update. This will do the actual work of moving objects and avatars according to their | 1292 | if (RegionStatus != RegionStatus.SlaveScene) |
1261 | // velocity | 1293 | { |
1262 | int tmpPhysicsMS = Util.EnvironmentTickCount(); | 1294 | if (Frame % m_update_events == 0) |
1263 | if (m_frame % m_update_physics == 0) | ||
1264 | { | 1295 | { |
1265 | if (m_physics_enabled) | 1296 | int evMS = Util.EnvironmentTickCount(); |
1266 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); | 1297 | UpdateEvents(); |
1267 | if (SynchronizeScene != null) | 1298 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1268 | SynchronizeScene(this); | ||
1269 | } | 1299 | } |
1270 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); | ||
1271 | 1300 | ||
1272 | // Delete temp-on-rez stuff | 1301 | if (Frame % m_update_backup == 0) |
1273 | if (m_frame % 1000 == 0 && !m_cleaningTemps) | ||
1274 | { | 1302 | { |
1275 | int tmpTempOnRezMS = Util.EnvironmentTickCount(); | 1303 | int backMS = Util.EnvironmentTickCount(); |
1276 | m_cleaningTemps = true; | 1304 | UpdateStorageBackup(); |
1277 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | 1305 | backupMS = Util.EnvironmentTickCountSubtract(backMS); |
1278 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | ||
1279 | } | 1306 | } |
1280 | 1307 | ||
1281 | if (RegionStatus != RegionStatus.SlaveScene) | 1308 | if (Frame % m_update_terrain == 0) |
1282 | { | 1309 | { |
1283 | if (m_frame % m_update_events == 0) | 1310 | int terMS = Util.EnvironmentTickCount(); |
1284 | { | 1311 | UpdateTerrain(); |
1285 | int evMS = Util.EnvironmentTickCount(); | 1312 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1286 | UpdateEvents(); | 1313 | } |
1287 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | ||
1288 | } | ||
1289 | |||
1290 | if (m_frame % m_update_backup == 0) | ||
1291 | { | ||
1292 | int backMS = Util.EnvironmentTickCount(); | ||
1293 | UpdateStorageBackup(); | ||
1294 | backupMS = Util.EnvironmentTickCountSubtract(backMS); | ||
1295 | } | ||
1296 | 1314 | ||
1297 | if (m_frame % m_update_terrain == 0) | 1315 | //if (Frame % m_update_land == 0) |
1298 | { | 1316 | //{ |
1299 | int terMS = Util.EnvironmentTickCount(); | 1317 | // int ldMS = Util.EnvironmentTickCount(); |
1300 | UpdateTerrain(); | 1318 | // UpdateLand(); |
1301 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1319 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1302 | } | 1320 | //} |
1303 | 1321 | ||
1304 | //if (m_frame % m_update_land == 0) | 1322 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1305 | //{ | 1323 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
1306 | // int ldMS = Util.EnvironmentTickCount(); | 1324 | lastCompletedFrame = Util.EnvironmentTickCount(); |
1307 | // UpdateLand(); | 1325 | |
1308 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1326 | // if (Frame%m_update_avatars == 0) |
1309 | //} | 1327 | // UpdateInWorldTime(); |
1328 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1329 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1330 | StatsReporter.AddFPS(1); | ||
1331 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1332 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1333 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1334 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1335 | StatsReporter.addFrameMS(frameMS); | ||
1336 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1337 | StatsReporter.addOtherMS(otherMS); | ||
1338 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1339 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1340 | } | ||
1310 | 1341 | ||
1311 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1342 | if (LoginsDisabled && Frame == 20) |
1312 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1343 | { |
1313 | lastCompletedFrame = Util.EnvironmentTickCount(); | 1344 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, |
1314 | 1345 | // this is a rare case where we know we have just went through a long cycle of heap | |
1315 | // if (m_frame%m_update_avatars == 0) | 1346 | // allocations, and there is no more work to be done until someone logs in |
1316 | // UpdateInWorldTime(); | 1347 | GC.Collect(); |
1317 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1318 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1319 | StatsReporter.AddFPS(1); | ||
1320 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1321 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1322 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1323 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1324 | StatsReporter.addFrameMS(frameMS); | ||
1325 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1326 | StatsReporter.addOtherMS(otherMS); | ||
1327 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1328 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1329 | } | ||
1330 | 1348 | ||
1331 | if (LoginsDisabled && m_frame == 20) | 1349 | IConfig startupConfig = m_config.Configs["Startup"]; |
1350 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) | ||
1332 | { | 1351 | { |
1333 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, | 1352 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); |
1334 | // this is a rare case where we know we have just went through a long cycle of heap | 1353 | LoginsDisabled = false; |
1335 | // allocations, and there is no more work to be done until someone logs in | 1354 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); |
1336 | GC.Collect(); | ||
1337 | |||
1338 | IConfig startupConfig = m_config.Configs["Startup"]; | ||
1339 | if (startupConfig == null || !startupConfig.GetBoolean("StartDisabled", false)) | ||
1340 | { | ||
1341 | m_log.DebugFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName); | ||
1342 | LoginsDisabled = false; | ||
1343 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); | ||
1344 | } | ||
1345 | } | 1355 | } |
1346 | } | 1356 | } |
1347 | catch (NotImplementedException) | 1357 | } |
1348 | { | 1358 | catch (NotImplementedException) |
1349 | throw; | 1359 | { |
1350 | } | 1360 | throw; |
1351 | catch (AccessViolationException e) | 1361 | } |
1352 | { | 1362 | catch (AccessViolationException e) |
1353 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1363 | { |
1354 | } | 1364 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1355 | //catch (NullReferenceException e) | 1365 | } |
1356 | //{ | 1366 | //catch (NullReferenceException e) |
1357 | // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1367 | //{ |
1358 | //} | 1368 | // m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1359 | catch (InvalidOperationException e) | 1369 | //} |
1360 | { | 1370 | catch (InvalidOperationException e) |
1361 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1371 | { |
1362 | } | 1372 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1363 | catch (Exception e) | 1373 | } |
1364 | { | 1374 | catch (Exception e) |
1365 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); | 1375 | { |
1366 | } | 1376 | m_log.Error("[REGION]: Failed with exception " + e.ToString() + " On Region: " + RegionInfo.RegionName); |
1367 | finally | 1377 | } |
1368 | { | 1378 | finally |
1369 | m_lastupdate = DateTime.UtcNow; | 1379 | { |
1370 | } | 1380 | m_lastupdate = DateTime.UtcNow; |
1371 | 1381 | } | |
1372 | maintc = Util.EnvironmentTickCountSubtract(maintc); | ||
1373 | maintc = (int)(m_timespan * 1000) - maintc; | ||
1374 | 1382 | ||
1375 | if (maintc > 0) | 1383 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1376 | Thread.Sleep(maintc); | 1384 | maintc = (int)(m_timespan * 1000) - maintc; |
1377 | 1385 | ||
1378 | // Tell the watchdog that this thread is still alive | 1386 | if (maintc > 0) |
1379 | Watchdog.UpdateThread(); | 1387 | Thread.Sleep(maintc); |
1380 | } | ||
1381 | } | ||
1382 | 1388 | ||
1383 | 1389 | // Tell the watchdog that this thread is still alive | |
1390 | Watchdog.UpdateThread(); | ||
1391 | } | ||
1384 | 1392 | ||
1385 | public void AddGroupTarget(SceneObjectGroup grp) | 1393 | public void AddGroupTarget(SceneObjectGroup grp) |
1386 | { | 1394 | { |
@@ -3011,7 +3019,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3011 | (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); | 3019 | (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); |
3012 | 3020 | ||
3013 | m_sceneGraph.removeUserCount(!childagentYN); | 3021 | m_sceneGraph.removeUserCount(!childagentYN); |
3014 | CapsModule.RemoveCapsHandler(agentID); | 3022 | |
3023 | if (CapsModule != null) | ||
3024 | CapsModule.RemoveCapsHandler(agentID); | ||
3015 | 3025 | ||
3016 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3026 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3017 | // this method is doing is HORRIBLE!!! | 3027 | // this method is doing is HORRIBLE!!! |
@@ -3200,7 +3210,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3200 | // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport | 3210 | // TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport |
3201 | 3211 | ||
3202 | // Don't disable this log message - it's too helpful | 3212 | // Don't disable this log message - it's too helpful |
3203 | m_log.InfoFormat( | 3213 | m_log.DebugFormat( |
3204 | "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", | 3214 | "[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})", |
3205 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3215 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3206 | agent.AgentID, agent.circuitcode, teleportFlags); | 3216 | agent.AgentID, agent.circuitcode, teleportFlags); |
@@ -3266,8 +3276,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3266 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3276 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3267 | agent.AgentID, agent.circuitcode); | 3277 | agent.AgentID, agent.circuitcode); |
3268 | 3278 | ||
3269 | CapsModule.NewUserConnection(agent); | 3279 | if (CapsModule != null) |
3270 | CapsModule.AddCapsHandler(agent.AgentID); | 3280 | { |
3281 | CapsModule.NewUserConnection(agent); | ||
3282 | CapsModule.AddCapsHandler(agent.AgentID); | ||
3283 | } | ||
3271 | } | 3284 | } |
3272 | else | 3285 | else |
3273 | { | 3286 | { |
@@ -3282,7 +3295,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3282 | agent.AgentID, RegionInfo.RegionName); | 3295 | agent.AgentID, RegionInfo.RegionName); |
3283 | 3296 | ||
3284 | sp.AdjustKnownSeeds(); | 3297 | sp.AdjustKnownSeeds(); |
3285 | CapsModule.NewUserConnection(agent); | 3298 | |
3299 | if (CapsModule != null) | ||
3300 | CapsModule.NewUserConnection(agent); | ||
3286 | } | 3301 | } |
3287 | } | 3302 | } |
3288 | 3303 | ||
@@ -3770,15 +3785,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3770 | public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, | 3785 | public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, |
3771 | Vector3 lookat, uint teleportFlags) | 3786 | Vector3 lookat, uint teleportFlags) |
3772 | { | 3787 | { |
3773 | GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName); | 3788 | List<GridRegion> regions = GridService.GetRegionsByName(RegionInfo.ScopeID, regionName, 1); |
3774 | if (regionInfo == null) | 3789 | if (regions == null || regions.Count == 0) |
3775 | { | 3790 | { |
3776 | // can't find the region: Tell viewer and abort | 3791 | // can't find the region: Tell viewer and abort |
3777 | remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); | 3792 | remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found."); |
3778 | return; | 3793 | return; |
3779 | } | 3794 | } |
3780 | 3795 | ||
3781 | RequestTeleportLocation(remoteClient, regionInfo.RegionHandle, position, lookat, teleportFlags); | 3796 | RequestTeleportLocation(remoteClient, regions[0].RegionHandle, position, lookat, teleportFlags); |
3782 | } | 3797 | } |
3783 | 3798 | ||
3784 | /// <summary> | 3799 | /// <summary> |
@@ -4923,8 +4938,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4923 | // from logging into the region, teleporting into the region | 4938 | // from logging into the region, teleporting into the region |
4924 | // or corssing the broder walking, but will NOT prevent | 4939 | // or corssing the broder walking, but will NOT prevent |
4925 | // child agent creation, thereby emulating the SL behavior. | 4940 | // child agent creation, thereby emulating the SL behavior. |
4926 | public bool QueryAccess(UUID agentID, Vector3 position) | 4941 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
4927 | { | 4942 | { |
4943 | reason = String.Empty; | ||
4928 | return true; | 4944 | return true; |
4929 | } | 4945 | } |
4930 | } | 4946 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 969ff13..734ba22 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -204,9 +204,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) | 204 | for (int i = 0; i < Math.Min(presences.Count, maxLocations); ++i) |
205 | { | 205 | { |
206 | ScenePresence sp = presences[i]; | 206 | ScenePresence sp = presences[i]; |
207 | |||
207 | // If this presence is a child agent, we don't want its coarse locations | 208 | // If this presence is a child agent, we don't want its coarse locations |
208 | if (sp.IsChildAgent) | 209 | if (sp.IsChildAgent) |
209 | return; | 210 | continue; |
210 | 211 | ||
211 | if (sp.ParentID != 0) | 212 | if (sp.ParentID != 0) |
212 | { | 213 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 67e59c6..fa404c0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -1089,9 +1089,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1089 | 1089 | ||
1090 | public Dictionary<UUID, string> GetScriptStates() | 1090 | public Dictionary<UUID, string> GetScriptStates() |
1091 | { | 1091 | { |
1092 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | ||
1093 | |||
1094 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | ||
1095 | return ret; | ||
1096 | |||
1092 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1097 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1093 | 1098 | ||
1094 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | ||
1095 | if (engines == null) // No engine at all | 1099 | if (engines == null) // No engine at all |
1096 | return ret; | 1100 | return ret; |
1097 | 1101 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd70de8..00a1487 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -626,7 +626,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
626 | Utils.LongToUInts(handle, out x, out y); | 626 | Utils.LongToUInts(handle, out x, out y); |
627 | x = x / Constants.RegionSize; | 627 | x = x / Constants.RegionSize; |
628 | y = y / Constants.RegionSize; | 628 | y = y / Constants.RegionSize; |
629 | if (Util.IsOutsideView(x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) | 629 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) |
630 | { | 630 | { |
631 | old.Add(handle); | 631 | old.Add(handle); |
632 | } | 632 | } |
@@ -700,6 +700,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | 700 | ||
701 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 701 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
702 | { | 702 | { |
703 | m_DrawDistance = world.DefaultDrawDistance; | ||
703 | m_rootRegionHandle = reginfo.RegionHandle; | 704 | m_rootRegionHandle = reginfo.RegionHandle; |
704 | m_controllingClient = client; | 705 | m_controllingClient = client; |
705 | m_firstname = m_controllingClient.FirstName; | 706 | m_firstname = m_controllingClient.FirstName; |
@@ -1161,7 +1162,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1161 | if (m_agentTransfer != null) | 1162 | if (m_agentTransfer != null) |
1162 | m_agentTransfer.EnableChildAgents(this); | 1163 | m_agentTransfer.EnableChildAgents(this); |
1163 | else | 1164 | else |
1164 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | 1165 | m_log.DebugFormat( |
1166 | "[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active for region {0}", | ||
1167 | m_scene.RegionInfo.RegionName); | ||
1165 | 1168 | ||
1166 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1169 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1167 | if (friendsModule != null) | 1170 | if (friendsModule != null) |
@@ -1277,7 +1280,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1277 | m_CameraUpAxis = agentData.CameraUpAxis; | 1280 | m_CameraUpAxis = agentData.CameraUpAxis; |
1278 | 1281 | ||
1279 | // The Agent's Draw distance setting | 1282 | // The Agent's Draw distance setting |
1280 | m_DrawDistance = agentData.Far; | 1283 | // When we get to the point of re-computing neighbors everytime this |
1284 | // changes, then start using the agent's drawdistance rather than the | ||
1285 | // region's draw distance. | ||
1286 | // m_DrawDistance = agentData.Far; | ||
1287 | m_DrawDistance = Scene.DefaultDrawDistance; | ||
1281 | 1288 | ||
1282 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1289 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1283 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1290 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
@@ -2435,7 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2435 | // If we are using the the cached appearance then send it out to everyone | 2442 | // If we are using the the cached appearance then send it out to everyone |
2436 | if (cachedappearance) | 2443 | if (cachedappearance) |
2437 | { | 2444 | { |
2438 | m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); | 2445 | m_log.DebugFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); |
2439 | 2446 | ||
2440 | // If the avatars baked textures are all in the cache, then we have a | 2447 | // If the avatars baked textures are all in the cache, then we have a |
2441 | // complete appearance... send it out, if not, then we'll send it when | 2448 | // complete appearance... send it out, if not, then we'll send it when |
@@ -2652,8 +2659,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2652 | #region Border Crossing Methods | 2659 | #region Border Crossing Methods |
2653 | 2660 | ||
2654 | /// <summary> | 2661 | /// <summary> |
2655 | /// Checks to see if the avatar is in range of a border and calls CrossToNewRegion | 2662 | /// Starts the process of moving an avatar into another region if they are crossing the border. |
2656 | /// </summary> | 2663 | /// </summary> |
2664 | /// <remarks> | ||
2665 | /// Also removes the avatar from the physical scene if transit has started. | ||
2666 | /// </remarks> | ||
2657 | protected void CheckForBorderCrossing() | 2667 | protected void CheckForBorderCrossing() |
2658 | { | 2668 | { |
2659 | if (IsChildAgent) | 2669 | if (IsChildAgent) |
@@ -2721,7 +2731,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2721 | neighbor = HaveNeighbor(Cardinals.N, ref fix); | 2731 | neighbor = HaveNeighbor(Cardinals.N, ref fix); |
2722 | } | 2732 | } |
2723 | 2733 | ||
2724 | |||
2725 | // Makes sure avatar does not end up outside region | 2734 | // Makes sure avatar does not end up outside region |
2726 | if (neighbor <= 0) | 2735 | if (neighbor <= 0) |
2727 | { | 2736 | { |
@@ -2776,6 +2785,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2776 | } | 2785 | } |
2777 | else | 2786 | else |
2778 | { | 2787 | { |
2788 | // We must remove the agent from the physical scene if it has been placed in transit. If we don't, | ||
2789 | // then this method continues to be called from ScenePresence.Update() until the handover of the client between | ||
2790 | // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms | ||
2791 | // event queue polling response from the server), this results in the avatar pausing on the border | ||
2792 | // for the handover period. | ||
2793 | RemoveFromPhysicalScene(); | ||
2794 | |||
2779 | // This constant has been inferred from experimentation | 2795 | // This constant has been inferred from experimentation |
2780 | // I'm not sure what this value should be, so I tried a few values. | 2796 | // I'm not sure what this value should be, so I tried a few values. |
2781 | timeStep = 0.04f; | 2797 | timeStep = 0.04f; |
@@ -2787,6 +2803,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2787 | } | 2803 | } |
2788 | } | 2804 | } |
2789 | 2805 | ||
2806 | /// <summary> | ||
2807 | /// Checks whether this region has a neighbour in the given direction. | ||
2808 | /// </summary> | ||
2809 | /// <param name="car"></param> | ||
2810 | /// <param name="fix"></param> | ||
2811 | /// <returns> | ||
2812 | /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. | ||
2813 | /// Returns a positive integer if there is a region in that direction, a negative integer if not. | ||
2814 | /// </returns> | ||
2790 | protected int HaveNeighbor(Cardinals car, ref int[] fix) | 2815 | protected int HaveNeighbor(Cardinals car, ref int[] fix) |
2791 | { | 2816 | { |
2792 | uint neighbourx = m_regionInfo.RegionLocX; | 2817 | uint neighbourx = m_regionInfo.RegionLocX; |
@@ -2893,7 +2918,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2893 | 2918 | ||
2894 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 2919 | //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
2895 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 2920 | //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
2896 | if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) | 2921 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) |
2897 | { | 2922 | { |
2898 | byebyeRegions.Add(handle); | 2923 | byebyeRegions.Add(handle); |
2899 | } | 2924 | } |
@@ -2969,7 +2994,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2969 | 2994 | ||
2970 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 2995 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
2971 | 2996 | ||
2972 | m_DrawDistance = cAgentData.Far; | 2997 | // When we get to the point of re-computing neighbors everytime this |
2998 | // changes, then start using the agent's drawdistance rather than the | ||
2999 | // region's draw distance. | ||
3000 | // m_DrawDistance = cAgentData.Far; | ||
3001 | m_DrawDistance = Scene.DefaultDrawDistance; | ||
3002 | |||
2973 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! | 3003 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
2974 | m_pos = cAgentData.Position + offset; | 3004 | m_pos = cAgentData.Position + offset; |
2975 | 3005 | ||
@@ -3119,7 +3149,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3119 | m_CameraLeftAxis = cAgent.LeftAxis; | 3149 | m_CameraLeftAxis = cAgent.LeftAxis; |
3120 | m_CameraUpAxis = cAgent.UpAxis; | 3150 | m_CameraUpAxis = cAgent.UpAxis; |
3121 | 3151 | ||
3122 | m_DrawDistance = cAgent.Far; | 3152 | // When we get to the point of re-computing neighbors everytime this |
3153 | // changes, then start using the agent's drawdistance rather than the | ||
3154 | // region's draw distance. | ||
3155 | // m_DrawDistance = cAgent.Far; | ||
3156 | m_DrawDistance = Scene.DefaultDrawDistance; | ||
3123 | 3157 | ||
3124 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) | 3158 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) |
3125 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); | 3159 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs new file mode 100644 index 0000000..855b589 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/AttachmentTests.cs | |||
@@ -0,0 +1,173 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
44 | using OpenSim.Tests.Common; | ||
45 | using OpenSim.Tests.Common.Mock; | ||
46 | using OpenSim.Tests.Common.Setup; | ||
47 | |||
48 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Attachment tests | ||
52 | /// </summary> | ||
53 | [TestFixture] | ||
54 | public class AttachmentTests | ||
55 | { | ||
56 | public Scene scene, scene2; | ||
57 | public UUID agent1; | ||
58 | public static Random random; | ||
59 | public ulong region1, region2; | ||
60 | public AgentCircuitData acd1; | ||
61 | public SceneObjectGroup sog1, sog2, sog3; | ||
62 | |||
63 | [TestFixtureSetUp] | ||
64 | public void Init() | ||
65 | { | ||
66 | TestHelper.InMethod(); | ||
67 | |||
68 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); | ||
69 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); | ||
70 | |||
71 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); | ||
72 | interregionComms.Initialise(new IniConfigSource()); | ||
73 | interregionComms.PostInitialise(); | ||
74 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | ||
75 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); | ||
76 | |||
77 | agent1 = UUID.Random(); | ||
78 | random = new Random(); | ||
79 | sog1 = NewSOG(UUID.Random(), scene, agent1); | ||
80 | sog2 = NewSOG(UUID.Random(), scene, agent1); | ||
81 | sog3 = NewSOG(UUID.Random(), scene, agent1); | ||
82 | |||
83 | //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
84 | region1 = scene.RegionInfo.RegionHandle; | ||
85 | region2 = scene2.RegionInfo.RegionHandle; | ||
86 | |||
87 | SceneSetupHelpers.AddRootAgent(scene, agent1); | ||
88 | } | ||
89 | |||
90 | [Test] | ||
91 | public void T030_TestAddAttachments() | ||
92 | { | ||
93 | TestHelper.InMethod(); | ||
94 | |||
95 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
96 | |||
97 | presence.AddAttachment(sog1); | ||
98 | presence.AddAttachment(sog2); | ||
99 | presence.AddAttachment(sog3); | ||
100 | |||
101 | Assert.That(presence.HasAttachments(), Is.True); | ||
102 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
103 | } | ||
104 | |||
105 | [Test] | ||
106 | public void T031_RemoveAttachments() | ||
107 | { | ||
108 | TestHelper.InMethod(); | ||
109 | |||
110 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
111 | presence.RemoveAttachment(sog1); | ||
112 | presence.RemoveAttachment(sog2); | ||
113 | presence.RemoveAttachment(sog3); | ||
114 | Assert.That(presence.HasAttachments(), Is.False); | ||
115 | } | ||
116 | |||
117 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
118 | // be non-null | ||
119 | //[Test] | ||
120 | public void T032_CrossAttachments() | ||
121 | { | ||
122 | TestHelper.InMethod(); | ||
123 | |||
124 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
125 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
126 | presence2.AddAttachment(sog1); | ||
127 | presence2.AddAttachment(sog2); | ||
128 | |||
129 | ISharedRegionModule serialiser = new SerialiserModule(); | ||
130 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
131 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
132 | |||
133 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
134 | |||
135 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | ||
136 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | ||
137 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | ||
138 | } | ||
139 | |||
140 | private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) | ||
141 | { | ||
142 | SceneObjectPart sop = new SceneObjectPart(); | ||
143 | sop.Name = RandomName(); | ||
144 | sop.Description = RandomName(); | ||
145 | sop.Text = RandomName(); | ||
146 | sop.SitName = RandomName(); | ||
147 | sop.TouchName = RandomName(); | ||
148 | sop.UUID = uuid; | ||
149 | sop.Shape = PrimitiveBaseShape.Default; | ||
150 | sop.Shape.State = 1; | ||
151 | sop.OwnerID = agent; | ||
152 | |||
153 | SceneObjectGroup sog = new SceneObjectGroup(sop); | ||
154 | sog.SetScene(scene); | ||
155 | |||
156 | return sog; | ||
157 | } | ||
158 | |||
159 | private static string RandomName() | ||
160 | { | ||
161 | StringBuilder name = new StringBuilder(); | ||
162 | int size = random.Next(5,12); | ||
163 | char ch; | ||
164 | for (int i = 0; i < size; i++) | ||
165 | { | ||
166 | ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; | ||
167 | name.Append(ch); | ||
168 | } | ||
169 | |||
170 | return name.ToString(); | ||
171 | } | ||
172 | } | ||
173 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index b3c3e22..667b74e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | |||
@@ -32,7 +32,6 @@ using System.Text; | |||
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using NUnit.Framework; | 34 | using NUnit.Framework; |
35 | using NUnit.Framework.SyntaxHelpers; | ||
36 | using OpenMetaverse; | 35 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 37 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index 9244bc3..ca635d7 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 4969b09..a6a95ef 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 39116b6..0d26026 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -30,7 +30,6 @@ using System.Collections.Generic; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using NUnit.Framework; | 32 | using NUnit.Framework; |
33 | using NUnit.Framework.SyntaxHelpers; | ||
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index b84298f..bdfcd1d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index c78038f..8876a43 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -30,7 +30,6 @@ using System.Collections.Generic; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using NUnit.Framework; | 32 | using NUnit.Framework; |
33 | using NUnit.Framework.SyntaxHelpers; | ||
34 | using OpenMetaverse; | 33 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index ef52363..efb757f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -34,12 +34,12 @@ using System.Timers; | |||
34 | using Timer=System.Timers.Timer; | 34 | using Timer=System.Timers.Timer; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using NUnit.Framework; | 36 | using NUnit.Framework; |
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | 37 | using OpenMetaverse; |
39 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | 39 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | ||
43 | using OpenSim.Region.CoreModules.World.Serialiser; | 43 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
@@ -116,9 +116,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
116 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); | 116 | agent.ChildrenCapSeeds = new Dictionary<ulong, string>(); |
117 | agent.child = true; | 117 | agent.child = true; |
118 | 118 | ||
119 | if (scene.PresenceService == null) | ||
120 | Console.WriteLine("Presence Service is null"); | ||
121 | |||
122 | scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); | 119 | scene.PresenceService.LoginAgent(agent.AgentID.ToString(), agent.SessionID, agent.SecureSessionID); |
123 | 120 | ||
124 | string reason; | 121 | string reason; |
@@ -175,25 +172,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
175 | 172 | ||
176 | Assert.That(neighbours.Count, Is.EqualTo(2)); | 173 | Assert.That(neighbours.Count, Is.EqualTo(2)); |
177 | } | 174 | } |
178 | |||
179 | public void fixNullPresence() | ||
180 | { | ||
181 | string firstName = "testfirstname"; | ||
182 | |||
183 | AgentCircuitData agent = new AgentCircuitData(); | ||
184 | agent.AgentID = agent1; | ||
185 | agent.firstname = firstName; | ||
186 | agent.lastname = "testlastname"; | ||
187 | agent.SessionID = UUID.Zero; | ||
188 | agent.SecureSessionID = UUID.Zero; | ||
189 | agent.circuitcode = 123; | ||
190 | agent.BaseFolder = UUID.Zero; | ||
191 | agent.InventoryFolder = UUID.Zero; | ||
192 | agent.startpos = Vector3.Zero; | ||
193 | agent.CapsPath = GetRandomCapsObjectPath(); | ||
194 | |||
195 | acd1 = agent; | ||
196 | } | ||
197 | 175 | ||
198 | [Test] | 176 | [Test] |
199 | public void T013_TestRemoveNeighbourRegion() | 177 | public void T013_TestRemoveNeighbourRegion() |
@@ -211,24 +189,36 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
211 | CompleteAvatarMovement | 189 | CompleteAvatarMovement |
212 | */ | 190 | */ |
213 | } | 191 | } |
214 | 192 | ||
215 | // I'm commenting this test, because this is not supposed to happen here | 193 | /// <summary> |
216 | //[Test] | 194 | /// Test that if a root agent logs into a region, a child agent is also established in the neighbouring region |
217 | public void T020_TestMakeRootAgent() | 195 | /// </summary> |
196 | /// <remarks> | ||
197 | /// Please note that unlike the other tests here, this doesn't rely on structures | ||
198 | /// </remarks> | ||
199 | [Test] | ||
200 | public void TestChildAgentEstablished() | ||
218 | { | 201 | { |
219 | TestHelper.InMethod(); | 202 | TestHelper.InMethod(); |
220 | 203 | // log4net.Config.XmlConfigurator.Configure(); | |
221 | ScenePresence presence = scene.GetScenePresence(agent1); | 204 | |
222 | Assert.That(presence.IsChildAgent, Is.False, "Starts out as a root agent"); | 205 | UUID agent1Id = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
223 | 206 | ||
224 | presence.MakeChildAgent(); | 207 | TestScene myScene1 = SceneSetupHelpers.SetupScene("Neighbour y", UUID.Random(), 1000, 1000); |
225 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); | 208 | TestScene myScene2 = SceneSetupHelpers.SetupScene("Neighbour y + 1", UUID.Random(), 1001, 1000); |
226 | 209 | ||
227 | // Accepts 0 but rejects Constants.RegionSize | 210 | IConfigSource configSource = new IniConfigSource(); |
228 | Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); | 211 | configSource.AddConfig("Modules").Set("EntityTransferModule", "BasicEntityTransferModule"); |
229 | presence.MakeRootAgent(pos,true); | 212 | EntityTransferModule etm = new EntityTransferModule(); |
230 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); | 213 | |
231 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); | 214 | SceneSetupHelpers.SetupSceneModules(myScene1, configSource, etm); |
215 | |||
216 | SceneSetupHelpers.AddRootAgent(myScene1, agent1Id); | ||
217 | ScenePresence childPresence = myScene2.GetScenePresence(agent1); | ||
218 | |||
219 | // TODO: Need to do a fair amount of work to allow synchronous establishment of child agents | ||
220 | // Assert.That(childPresence, Is.Not.Null); | ||
221 | // Assert.That(childPresence.IsChildAgent, Is.True); | ||
232 | } | 222 | } |
233 | 223 | ||
234 | // I'm commenting this test because it does not represent | 224 | // I'm commenting this test because it does not represent |
@@ -333,63 +323,26 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
333 | Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); | 323 | Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected."); |
334 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); | 324 | Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again."); |
335 | } | 325 | } |
336 | 326 | ||
337 | [Test] | 327 | public void fixNullPresence() |
338 | public void T030_TestAddAttachments() | ||
339 | { | ||
340 | TestHelper.InMethod(); | ||
341 | |||
342 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
343 | |||
344 | presence.AddAttachment(sog1); | ||
345 | presence.AddAttachment(sog2); | ||
346 | presence.AddAttachment(sog3); | ||
347 | |||
348 | Assert.That(presence.HasAttachments(), Is.True); | ||
349 | Assert.That(presence.ValidateAttachments(), Is.True); | ||
350 | } | ||
351 | |||
352 | [Test] | ||
353 | public void T031_RemoveAttachments() | ||
354 | { | ||
355 | TestHelper.InMethod(); | ||
356 | |||
357 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
358 | presence.RemoveAttachment(sog1); | ||
359 | presence.RemoveAttachment(sog2); | ||
360 | presence.RemoveAttachment(sog3); | ||
361 | Assert.That(presence.HasAttachments(), Is.False); | ||
362 | } | ||
363 | |||
364 | // I'm commenting this test because scene setup NEEDS InventoryService to | ||
365 | // be non-null | ||
366 | //[Test] | ||
367 | public void T032_CrossAttachments() | ||
368 | { | 328 | { |
369 | TestHelper.InMethod(); | 329 | string firstName = "testfirstname"; |
370 | |||
371 | ScenePresence presence = scene.GetScenePresence(agent1); | ||
372 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | ||
373 | presence2.AddAttachment(sog1); | ||
374 | presence2.AddAttachment(sog2); | ||
375 | |||
376 | ISharedRegionModule serialiser = new SerialiserModule(); | ||
377 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser); | ||
378 | SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser); | ||
379 | |||
380 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | ||
381 | 330 | ||
382 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | 331 | AgentCircuitData agent = new AgentCircuitData(); |
383 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | 332 | agent.AgentID = agent1; |
384 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | 333 | agent.firstname = firstName; |
385 | } | 334 | agent.lastname = "testlastname"; |
335 | agent.SessionID = UUID.Zero; | ||
336 | agent.SecureSessionID = UUID.Zero; | ||
337 | agent.circuitcode = 123; | ||
338 | agent.BaseFolder = UUID.Zero; | ||
339 | agent.InventoryFolder = UUID.Zero; | ||
340 | agent.startpos = Vector3.Zero; | ||
341 | agent.CapsPath = GetRandomCapsObjectPath(); | ||
386 | 342 | ||
387 | [TearDown] | 343 | acd1 = agent; |
388 | public void TearDown() | ||
389 | { | ||
390 | if (MainServer.Instance != null) MainServer.Instance.Stop(); | ||
391 | } | 344 | } |
392 | 345 | ||
393 | public static string GetRandomCapsObjectPath() | 346 | public static string GetRandomCapsObjectPath() |
394 | { | 347 | { |
395 | UUID caps = UUID.Random(); | 348 | UUID caps = UUID.Random(); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs new file mode 100644 index 0000000..abcce66 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer=System.Timers.Timer; | ||
35 | using Nini.Config; | ||
36 | using NUnit.Framework; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
44 | using OpenSim.Tests.Common; | ||
45 | using OpenSim.Tests.Common.Mock; | ||
46 | using OpenSim.Tests.Common.Setup; | ||
47 | |||
48 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Scene presence tests | ||
52 | /// </summary> | ||
53 | [TestFixture] | ||
54 | public class SceneTests | ||
55 | { | ||
56 | /// <summary> | ||
57 | /// Very basic scene update test. Should become more elaborate with time. | ||
58 | /// </summary> | ||
59 | [Test] | ||
60 | public void TestUpdateScene() | ||
61 | { | ||
62 | TestHelper.InMethod(); | ||
63 | |||
64 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
65 | scene.Update(); | ||
66 | |||
67 | Assert.That(scene.Frame, Is.EqualTo(1)); | ||
68 | } | ||
69 | } | ||
70 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs index cafe48a..8588f7f 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index fe59d4f..8138bcc 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -34,7 +34,6 @@ using System.Timers; | |||
34 | using Timer=System.Timers.Timer; | 34 | using Timer=System.Timers.Timer; |
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using NUnit.Framework; | 36 | using NUnit.Framework; |
37 | using NUnit.Framework.SyntaxHelpers; | ||
38 | using OpenMetaverse; | 37 | using OpenMetaverse; |
39 | using OpenMetaverse.Assets; | 38 | using OpenMetaverse.Assets; |
40 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 5e6124b..6b70865 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Text; | 29 | using System.Text; |
30 | using NUnit.Framework; | 30 | using NUnit.Framework; |
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index dfeecb1..6a24cc1 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.UDP.Linden | |||
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] | 51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] |
52 | public class LindenUDPInfoModule : ISharedRegionModule | 52 | public class LindenUDPInfoModule : ISharedRegionModule |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 56 | protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
57 | 57 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index e9c5453..05a1c3b 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | |||
@@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
92 | private static string m_freeSwitchUrlResetPassword; | 92 | private static string m_freeSwitchUrlResetPassword; |
93 | private uint m_freeSwitchServicePort; | 93 | private uint m_freeSwitchServicePort; |
94 | private string m_openSimWellKnownHTTPAddress; | 94 | private string m_openSimWellKnownHTTPAddress; |
95 | private string m_freeSwitchContext; | 95 | // private string m_freeSwitchContext; |
96 | 96 | ||
97 | private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); | 97 | private readonly Dictionary<string, string> m_UUIDName = new Dictionary<string, string>(); |
98 | private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); | 98 | private Dictionary<string, string> m_ParcelAddress = new Dictionary<string, string>(); |
@@ -144,7 +144,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
144 | m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); | 144 | m_freeSwitchDefaultWellKnownIP = map["DefaultWellKnownIP"].AsString(); |
145 | m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); | 145 | m_freeSwitchDefaultTimeout = map["DefaultTimeout"].AsInteger(); |
146 | m_freeSwitchUrlResetPassword = String.Empty; | 146 | m_freeSwitchUrlResetPassword = String.Empty; |
147 | m_freeSwitchContext = map["Context"].AsString(); | 147 | // m_freeSwitchContext = map["Context"].AsString(); |
148 | 148 | ||
149 | if (String.IsNullOrEmpty(m_freeSwitchRealm) || | 149 | if (String.IsNullOrEmpty(m_freeSwitchRealm) || |
150 | String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) | 150 | String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) |
@@ -662,7 +662,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
662 | resp.Append("</buddies><groups></groups></body></level0></response>"); | 662 | resp.Append("</buddies><groups></groups></body></level0></response>"); |
663 | 663 | ||
664 | response["str_response_string"] = resp.ToString(); | 664 | response["str_response_string"] = resp.ToString(); |
665 | Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); | 665 | // Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); |
666 | 666 | ||
667 | //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); | 667 | //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); |
668 | return response; | 668 | return response; |
@@ -671,9 +671,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
671 | public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) | 671 | public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) |
672 | { | 672 | { |
673 | m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); | 673 | m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called"); |
674 | string requestbody = (string)request["body"]; | 674 | // string requestbody = (string)request["body"]; |
675 | string uri = (string)request["uri"]; | 675 | // string uri = (string)request["uri"]; |
676 | string contenttype = (string)request["content-type"]; | 676 | // string contenttype = (string)request["content-type"]; |
677 | 677 | ||
678 | Hashtable requestBody = ParseRequestBody((string)request["body"]); | 678 | Hashtable requestBody = ParseRequestBody((string)request["body"]); |
679 | 679 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 81725c5..02751ea 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -712,7 +712,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
712 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); | 712 | if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); |
713 | 713 | ||
714 | GroupMembershipData data = null; | 714 | GroupMembershipData data = null; |
715 | bool foundData = false; | 715 | // bool foundData = false; |
716 | 716 | ||
717 | OSDMap UserGroupMemberInfo; | 717 | OSDMap UserGroupMemberInfo; |
718 | if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo)) | 718 | if (SimianGetGenericEntry(agentID, "GroupMember", groupID.ToString(), out UserGroupMemberInfo)) |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index bc55b04..6de97b7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | |||
@@ -29,7 +29,6 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 688dfe4..64931d0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -681,10 +681,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
681 | // | 681 | // |
682 | CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); | 682 | CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); |
683 | 683 | ||
684 | TeleportAgent(agent, regionName, position, lookat); | 684 | TeleportAgent(agent, regionName, position, lookat, false); |
685 | } | 685 | } |
686 | 686 | ||
687 | private void TeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 687 | private void TeleportAgent(string agent, string regionName, |
688 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) | ||
688 | { | 689 | { |
689 | m_host.AddScriptLPS(1); | 690 | m_host.AddScriptLPS(1); |
690 | UUID agentId = new UUID(); | 691 | UUID agentId = new UUID(); |
@@ -693,25 +694,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
693 | ScenePresence presence = World.GetScenePresence(agentId); | 694 | ScenePresence presence = World.GetScenePresence(agentId); |
694 | if (presence != null) | 695 | if (presence != null) |
695 | { | 696 | { |
696 | // agent must be over owners land to avoid abuse | 697 | // For osTeleportAgent, agent must be over owners land to avoid abuse |
697 | if (m_host.OwnerID | 698 | // For osTeleportOwner, this restriction isn't necessary |
699 | if (relaxRestrictions || | ||
700 | m_host.OwnerID | ||
698 | == World.LandChannel.GetLandObject( | 701 | == World.LandChannel.GetLandObject( |
699 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 702 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
700 | { | 703 | { |
701 | // Check for hostname, attempt to make a HG link, | ||
702 | // and convert the regionName to the target region | ||
703 | if (regionName.Contains(".") && regionName.Contains(":")) | ||
704 | { | ||
705 | // Even though we use none of the results, we need to perform this call because it appears | ||
706 | // to have some the side effect of setting up hypergrid teleport locations. | ||
707 | World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1); | ||
708 | // List<GridRegion> regions = World.GridService.GetRegionsByName(World.RegionInfo.ScopeID, regionName, 1); | ||
709 | |||
710 | string[] parts = regionName.Split(new char[] { ':' }); | ||
711 | if (parts.Length > 2) | ||
712 | regionName = parts[0] + ':' + parts[1] + "/ " + parts[2]; | ||
713 | regionName = "http://" + regionName; | ||
714 | } | ||
715 | World.RequestTeleportLocation(presence.ControllingClient, regionName, | 704 | World.RequestTeleportLocation(presence.ControllingClient, regionName, |
716 | new Vector3((float)position.x, (float)position.y, (float)position.z), | 705 | new Vector3((float)position.x, (float)position.y, (float)position.z), |
717 | new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); | 706 | new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation); |
@@ -728,10 +717,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
728 | // | 717 | // |
729 | CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); | 718 | CheckThreatLevel(ThreatLevel.High, "osTeleportAgent"); |
730 | 719 | ||
731 | TeleportAgent(agent, regionX, regionY, position, lookat); | 720 | TeleportAgent(agent, regionX, regionY, position, lookat, false); |
732 | } | 721 | } |
733 | 722 | ||
734 | private void TeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 723 | private void TeleportAgent(string agent, int regionX, int regionY, |
724 | LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) | ||
735 | { | 725 | { |
736 | ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); | 726 | ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); |
737 | 727 | ||
@@ -742,8 +732,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
742 | ScenePresence presence = World.GetScenePresence(agentId); | 732 | ScenePresence presence = World.GetScenePresence(agentId); |
743 | if (presence != null) | 733 | if (presence != null) |
744 | { | 734 | { |
745 | // agent must be over owners land to avoid abuse | 735 | // For osTeleportAgent, agent must be over owners land to avoid abuse |
746 | if (m_host.OwnerID | 736 | // For osTeleportOwner, this restriction isn't necessary |
737 | if (relaxRestrictions || | ||
738 | m_host.OwnerID | ||
747 | == World.LandChannel.GetLandObject( | 739 | == World.LandChannel.GetLandObject( |
748 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) | 740 | presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID) |
749 | { | 741 | { |
@@ -766,7 +758,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
766 | // Threat level None because this is what can already be done with the World Map in the viewer | 758 | // Threat level None because this is what can already be done with the World Map in the viewer |
767 | CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); | 759 | CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); |
768 | 760 | ||
769 | TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat); | 761 | TeleportAgent(m_host.OwnerID.ToString(), regionName, position, lookat, true); |
770 | } | 762 | } |
771 | 763 | ||
772 | public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) | 764 | public void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat) |
@@ -778,7 +770,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
778 | { | 770 | { |
779 | CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); | 771 | CheckThreatLevel(ThreatLevel.None, "osTeleportOwner"); |
780 | 772 | ||
781 | TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat); | 773 | TeleportAgent(m_host.OwnerID.ToString(), regionX, regionY, position, lookat, true); |
782 | } | 774 | } |
783 | 775 | ||
784 | // Functions that get information from the agent itself. | 776 | // Functions that get information from the agent itself. |