aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/Helpers
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common/Helpers')
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs411
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs48
-rw-r--r--OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs14
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs78
4 files changed, 400 insertions, 151 deletions
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 318758d..769de83 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -58,57 +58,74 @@ namespace OpenSim.Tests.Common
58 /// </summary> 58 /// </summary>
59 public class SceneHelpers 59 public class SceneHelpers
60 { 60 {
61 public static TestScene SetupScene() 61 /// <summary>
62 /// We need a scene manager so that test clients can retrieve a scene when performing teleport tests.
63 /// </summary>
64 public SceneManager SceneManager { get; private set; }
65
66 private AgentCircuitManager m_acm = new AgentCircuitManager();
67 private ISimulationDataService m_simDataService
68 = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
69 private IEstateDataService m_estateDataService = null;
70
71 private LocalAssetServicesConnector m_assetService;
72 private LocalAuthenticationServicesConnector m_authenticationService;
73 private LocalInventoryServicesConnector m_inventoryService;
74 private LocalGridServicesConnector m_gridService;
75 private LocalUserAccountServicesConnector m_userAccountService;
76 private LocalPresenceServicesConnector m_presenceService;
77
78 private CoreAssetCache m_cache;
79
80 public SceneHelpers() : this(null) {}
81
82 public SceneHelpers(CoreAssetCache cache)
62 { 83 {
63 return SetupScene(null); 84 SceneManager = new SceneManager();
85
86 m_assetService = StartAssetService(cache);
87 m_authenticationService = StartAuthenticationService();
88 m_inventoryService = StartInventoryService();
89 m_gridService = StartGridService();
90 m_userAccountService = StartUserAccountService();
91 m_presenceService = StartPresenceService();
92
93 m_inventoryService.PostInitialise();
94 m_assetService.PostInitialise();
95 m_userAccountService.PostInitialise();
96 m_presenceService.PostInitialise();
97
98 m_cache = cache;
64 } 99 }
65 100
66 /// <summary> 101 /// <summary>
67 /// Set up a test scene 102 /// Set up a test scene
68 /// </summary> 103 /// </summary>
69 /// <remarks> 104 /// <remarks>
70 /// Automatically starts service threads, as would the normal runtime. 105 /// Automatically starts services, as would the normal runtime.
71 /// </remarks> 106 /// </remarks>
72 /// <returns></returns> 107 /// <returns></returns>
73 public static TestScene SetupScene(CoreAssetCache cache) 108 public TestScene SetupScene()
74 { 109 {
75 return SetupScene("Unit test region", UUID.Random(), 1000, 1000, cache); 110 return SetupScene("Unit test region", UUID.Random(), 1000, 1000);
76 } 111 }
77 112
78 public static TestScene SetupScene(string name, UUID id, uint x, uint y) 113 public TestScene SetupScene(string name, UUID id, uint x, uint y)
79 {
80 return SetupScene(name, id, x, y, null);
81 }
82
83 /// <summary>
84 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
85 /// or a different, to get a brand new scene with new shared region modules.
86 /// </summary>
87 /// <param name="name">Name of the region</param>
88 /// <param name="id">ID of the region</param>
89 /// <param name="x">X co-ordinate of the region</param>
90 /// <param name="y">Y co-ordinate of the region</param>
91 /// <param name="cache"></param>
92 /// <returns></returns>
93 public static TestScene SetupScene(
94 string name, UUID id, uint x, uint y, CoreAssetCache cache)
95 { 114 {
96 return SetupScene(name, id, x, y, cache, new IniConfigSource()); 115 return SetupScene(name, id, x, y, new IniConfigSource());
97 } 116 }
98 117
99 /// <summary> 118 /// <summary>
100 /// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions 119 /// Set up a scene.
101 /// or a different, to get a brand new scene with new shared region modules.
102 /// </summary> 120 /// </summary>
103 /// <param name="name">Name of the region</param> 121 /// <param name="name">Name of the region</param>
104 /// <param name="id">ID of the region</param> 122 /// <param name="id">ID of the region</param>
105 /// <param name="x">X co-ordinate of the region</param> 123 /// <param name="x">X co-ordinate of the region</param>
106 /// <param name="y">Y co-ordinate of the region</param> 124 /// <param name="y">Y co-ordinate of the region</param>
107 /// <param name="cache"></param>
108 /// <param name="configSource"></param> 125 /// <param name="configSource"></param>
109 /// <returns></returns> 126 /// <returns></returns>
110 public static TestScene SetupScene( 127 public TestScene SetupScene(
111 string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource) 128 string name, UUID id, uint x, uint y, IConfigSource configSource)
112 { 129 {
113 Console.WriteLine("Setting up test scene {0}", name); 130 Console.WriteLine("Setting up test scene {0}", name);
114 131
@@ -119,30 +136,47 @@ namespace OpenSim.Tests.Common
119 regInfo.RegionName = name; 136 regInfo.RegionName = name;
120 regInfo.RegionID = id; 137 regInfo.RegionID = id;
121 138
122 AgentCircuitManager acm = new AgentCircuitManager();
123 SceneCommunicationService scs = new SceneCommunicationService(); 139 SceneCommunicationService scs = new SceneCommunicationService();
124 140
125 ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
126 IEstateDataService estateDataService = null;
127
128 TestScene testScene = new TestScene( 141 TestScene testScene = new TestScene(
129 regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); 142 regInfo, m_acm, scs, m_simDataService, m_estateDataService, null, false, configSource, null);
130 143
131 IRegionModule godsModule = new GodsModule(); 144 IRegionModule godsModule = new GodsModule();
132 godsModule.Initialise(testScene, new IniConfigSource()); 145 godsModule.Initialise(testScene, new IniConfigSource());
133 testScene.AddModule(godsModule.Name, godsModule); 146 testScene.AddModule(godsModule.Name, godsModule);
134 147
135 LocalAssetServicesConnector assetService = StartAssetService(testScene, cache); 148 // Add scene to services
136 StartAuthenticationService(testScene); 149 m_assetService.AddRegion(testScene);
137 LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); 150
138 StartGridService(testScene); 151 if (m_cache != null)
139 LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); 152 {
140 LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); 153 m_cache.AddRegion(testScene);
141 154 m_cache.RegionLoaded(testScene);
142 inventoryService.PostInitialise(); 155 testScene.AddRegionModule(m_cache.Name, m_cache);
143 assetService.PostInitialise(); 156 }
144 userAccountService.PostInitialise(); 157
145 presenceService.PostInitialise(); 158 m_assetService.RegionLoaded(testScene);
159 testScene.AddRegionModule(m_assetService.Name, m_assetService);
160
161 m_authenticationService.AddRegion(testScene);
162 m_authenticationService.RegionLoaded(testScene);
163 testScene.AddRegionModule(m_authenticationService.Name, m_authenticationService);
164
165 m_inventoryService.AddRegion(testScene);
166 m_inventoryService.RegionLoaded(testScene);
167 testScene.AddRegionModule(m_inventoryService.Name, m_inventoryService);
168
169 m_gridService.AddRegion(testScene);
170 m_gridService.RegionLoaded(testScene);
171 testScene.AddRegionModule(m_gridService.Name, m_gridService);
172
173 m_userAccountService.AddRegion(testScene);
174 m_userAccountService.RegionLoaded(testScene);
175 testScene.AddRegionModule(m_userAccountService.Name, m_userAccountService);
176
177 m_presenceService.AddRegion(testScene);
178 m_presenceService.RegionLoaded(testScene);
179 testScene.AddRegionModule(m_presenceService.Name, m_presenceService);
146 180
147 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random(); 181 testScene.RegionInfo.EstateSettings.EstateOwner = UUID.Random();
148 testScene.SetModuleInterfaces(); 182 testScene.SetModuleInterfaces();
@@ -153,28 +187,28 @@ namespace OpenSim.Tests.Common
153 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); 187 PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
154 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); 188 physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
155 testScene.PhysicsScene 189 testScene.PhysicsScene
156 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); 190 = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
157 191
158 testScene.RegionInfo.EstateSettings = new EstateSettings(); 192 testScene.RegionInfo.EstateSettings = new EstateSettings();
159 testScene.LoginsDisabled = false; 193 testScene.LoginsDisabled = false;
160 testScene.RegisterRegionWithGrid(); 194 testScene.RegisterRegionWithGrid();
161 195
196 SceneManager.Add(testScene);
197
162 return testScene; 198 return testScene;
163 } 199 }
164 200
165 private static LocalAssetServicesConnector StartAssetService(Scene testScene, CoreAssetCache cache) 201 private static LocalAssetServicesConnector StartAssetService(CoreAssetCache cache)
166 { 202 {
167 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
168 IConfigSource config = new IniConfigSource(); 203 IConfigSource config = new IniConfigSource();
169
170 config.AddConfig("Modules"); 204 config.AddConfig("Modules");
171 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector"); 205 config.Configs["Modules"].Set("AssetServices", "LocalAssetServicesConnector");
172 config.AddConfig("AssetService"); 206 config.AddConfig("AssetService");
173 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService"); 207 config.Configs["AssetService"].Set("LocalServiceModule", "OpenSim.Services.AssetService.dll:AssetService");
174 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 208 config.Configs["AssetService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
175 209
210 LocalAssetServicesConnector assetService = new LocalAssetServicesConnector();
176 assetService.Initialise(config); 211 assetService.Initialise(config);
177 assetService.AddRegion(testScene);
178 212
179 if (cache != null) 213 if (cache != null)
180 { 214 {
@@ -184,56 +218,43 @@ namespace OpenSim.Tests.Common
184 cacheConfig.AddConfig("AssetCache"); 218 cacheConfig.AddConfig("AssetCache");
185 219
186 cache.Initialise(cacheConfig); 220 cache.Initialise(cacheConfig);
187 cache.AddRegion(testScene);
188 cache.RegionLoaded(testScene);
189 testScene.AddRegionModule(cache.Name, cache);
190 } 221 }
191
192 assetService.RegionLoaded(testScene);
193 testScene.AddRegionModule(assetService.Name, assetService);
194 222
195 return assetService; 223 return assetService;
196 } 224 }
197 225
198 private static void StartAuthenticationService(Scene testScene) 226 private static LocalAuthenticationServicesConnector StartAuthenticationService()
199 { 227 {
200 ISharedRegionModule service = new LocalAuthenticationServicesConnector();
201 IConfigSource config = new IniConfigSource(); 228 IConfigSource config = new IniConfigSource();
202
203 config.AddConfig("Modules"); 229 config.AddConfig("Modules");
204 config.AddConfig("AuthenticationService"); 230 config.AddConfig("AuthenticationService");
205 config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector"); 231 config.Configs["Modules"].Set("AuthenticationServices", "LocalAuthenticationServicesConnector");
206 config.Configs["AuthenticationService"].Set( 232 config.Configs["AuthenticationService"].Set(
207 "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"); 233 "LocalServiceModule", "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService");
208 config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); 234 config.Configs["AuthenticationService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
209 235
236 LocalAuthenticationServicesConnector service = new LocalAuthenticationServicesConnector();
210 service.Initialise(config); 237 service.Initialise(config);
211 service.AddRegion(testScene); 238
212 service.RegionLoaded(testScene); 239 return service;
213 testScene.AddRegionModule(service.Name, service);
214 //m_authenticationService = service;
215 } 240 }
216 241
217 private static LocalInventoryServicesConnector StartInventoryService(Scene testScene) 242 private static LocalInventoryServicesConnector StartInventoryService()
218 { 243 {
219 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
220
221 IConfigSource config = new IniConfigSource(); 244 IConfigSource config = new IniConfigSource();
222 config.AddConfig("Modules"); 245 config.AddConfig("Modules");
223 config.AddConfig("InventoryService"); 246 config.AddConfig("InventoryService");
224 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector"); 247 config.Configs["Modules"].Set("InventoryServices", "LocalInventoryServicesConnector");
225 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService"); 248 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:InventoryService");
226 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll"); 249 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll");
227 250
251 LocalInventoryServicesConnector inventoryService = new LocalInventoryServicesConnector();
228 inventoryService.Initialise(config); 252 inventoryService.Initialise(config);
229 inventoryService.AddRegion(testScene);
230 inventoryService.RegionLoaded(testScene);
231 testScene.AddRegionModule(inventoryService.Name, inventoryService);
232 253
233 return inventoryService; 254 return inventoryService;
234 } 255 }
235 256
236 private static LocalGridServicesConnector StartGridService(Scene testScene) 257 private static LocalGridServicesConnector StartGridService()
237 { 258 {
238 IConfigSource config = new IniConfigSource(); 259 IConfigSource config = new IniConfigSource();
239 config.AddConfig("Modules"); 260 config.AddConfig("Modules");
@@ -245,8 +266,6 @@ namespace OpenSim.Tests.Common
245 266
246 LocalGridServicesConnector gridService = new LocalGridServicesConnector(); 267 LocalGridServicesConnector gridService = new LocalGridServicesConnector();
247 gridService.Initialise(config); 268 gridService.Initialise(config);
248 gridService.AddRegion(testScene);
249 gridService.RegionLoaded(testScene);
250 269
251 return gridService; 270 return gridService;
252 } 271 }
@@ -256,7 +275,7 @@ namespace OpenSim.Tests.Common
256 /// </summary> 275 /// </summary>
257 /// <param name="testScene"></param> 276 /// <param name="testScene"></param>
258 /// <returns></returns> 277 /// <returns></returns>
259 private static LocalUserAccountServicesConnector StartUserAccountService(Scene testScene) 278 private static LocalUserAccountServicesConnector StartUserAccountService()
260 { 279 {
261 IConfigSource config = new IniConfigSource(); 280 IConfigSource config = new IniConfigSource();
262 config.AddConfig("Modules"); 281 config.AddConfig("Modules");
@@ -268,10 +287,6 @@ namespace OpenSim.Tests.Common
268 287
269 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector(); 288 LocalUserAccountServicesConnector userAccountService = new LocalUserAccountServicesConnector();
270 userAccountService.Initialise(config); 289 userAccountService.Initialise(config);
271
272 userAccountService.AddRegion(testScene);
273 userAccountService.RegionLoaded(testScene);
274 testScene.AddRegionModule(userAccountService.Name, userAccountService);
275 290
276 return userAccountService; 291 return userAccountService;
277 } 292 }
@@ -280,7 +295,7 @@ namespace OpenSim.Tests.Common
280 /// Start a presence service 295 /// Start a presence service
281 /// </summary> 296 /// </summary>
282 /// <param name="testScene"></param> 297 /// <param name="testScene"></param>
283 private static LocalPresenceServicesConnector StartPresenceService(Scene testScene) 298 private static LocalPresenceServicesConnector StartPresenceService()
284 { 299 {
285 IConfigSource config = new IniConfigSource(); 300 IConfigSource config = new IniConfigSource();
286 config.AddConfig("Modules"); 301 config.AddConfig("Modules");
@@ -292,10 +307,6 @@ namespace OpenSim.Tests.Common
292 307
293 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector(); 308 LocalPresenceServicesConnector presenceService = new LocalPresenceServicesConnector();
294 presenceService.Initialise(config); 309 presenceService.Initialise(config);
295
296 presenceService.AddRegion(testScene);
297 presenceService.RegionLoaded(testScene);
298 testScene.AddRegionModule(presenceService.Name, presenceService);
299 310
300 return presenceService; 311 return presenceService;
301 } 312 }
@@ -313,19 +324,52 @@ namespace OpenSim.Tests.Common
313 /// <summary> 324 /// <summary>
314 /// Setup modules for a scene. 325 /// Setup modules for a scene.
315 /// </summary> 326 /// </summary>
316 /// <param name="scene"></param> 327 /// <remarks>
328 /// If called directly, then all the modules must be shared modules.
329 /// </remarks>
330 /// <param name="scenes"></param>
317 /// <param name="config"></param> 331 /// <param name="config"></param>
318 /// <param name="modules"></param> 332 /// <param name="modules"></param>
319 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules) 333 public static void SetupSceneModules(Scene scene, IConfigSource config, params object[] modules)
320 { 334 {
335 SetupSceneModules(new Scene[] { scene }, config, modules);
336 }
337
338 /// <summary>
339 /// Setup modules for a scene using their default settings.
340 /// </summary>
341 /// <param name="scenes"></param>
342 /// <param name="modules"></param>
343 public static void SetupSceneModules(Scene[] scenes, params object[] modules)
344 {
345 SetupSceneModules(scenes, new IniConfigSource(), modules);
346 }
347
348 /// <summary>
349 /// Setup modules for scenes.
350 /// </summary>
351 /// <remarks>
352 /// If called directly, then all the modules must be shared modules.
353 /// </remarks>
354 /// <param name="scenes"></param>
355 /// <param name="config"></param>
356 /// <param name="modules"></param>
357 public static void SetupSceneModules(Scene[] scenes, IConfigSource config, params object[] modules)
358 {
321 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>(); 359 List<IRegionModuleBase> newModules = new List<IRegionModuleBase>();
322 foreach (object module in modules) 360 foreach (object module in modules)
323 { 361 {
362// Console.WriteLine("MODULE RAW {0}", module);
324 if (module is IRegionModule) 363 if (module is IRegionModule)
325 { 364 {
326 IRegionModule m = (IRegionModule)module; 365 IRegionModule m = (IRegionModule)module;
327 m.Initialise(scene, config); 366
328 scene.AddModule(m.Name, m); 367 foreach (Scene scene in scenes)
368 {
369 m.Initialise(scene, config);
370 scene.AddModule(m.Name, m);
371 }
372
329 m.PostInitialise(); 373 m.PostInitialise();
330 } 374 }
331 else if (module is IRegionModuleBase) 375 else if (module is IRegionModuleBase)
@@ -333,6 +377,7 @@ namespace OpenSim.Tests.Common
333 // for the new system, everything has to be initialised first, 377 // for the new system, everything has to be initialised first,
334 // shared modules have to be post-initialised, then all get an AddRegion with the scene 378 // shared modules have to be post-initialised, then all get an AddRegion with the scene
335 IRegionModuleBase m = (IRegionModuleBase)module; 379 IRegionModuleBase m = (IRegionModuleBase)module;
380// Console.WriteLine("MODULE {0}", m.Name);
336 m.Initialise(config); 381 m.Initialise(config);
337 newModules.Add(m); 382 newModules.Add(m);
338 } 383 }
@@ -345,15 +390,19 @@ namespace OpenSim.Tests.Common
345 390
346 foreach (IRegionModuleBase module in newModules) 391 foreach (IRegionModuleBase module in newModules)
347 { 392 {
348 module.AddRegion(scene); 393 foreach (Scene scene in scenes)
349 scene.AddRegionModule(module.Name, module); 394 {
395 module.AddRegion(scene);
396 scene.AddRegionModule(module.Name, module);
397 }
350 } 398 }
351 399
352 // RegionLoaded is fired after all modules have been appropriately added to all scenes 400 // RegionLoaded is fired after all modules have been appropriately added to all scenes
353 foreach (IRegionModuleBase module in newModules) 401 foreach (IRegionModuleBase module in newModules)
354 module.RegionLoaded(scene); 402 foreach (Scene scene in scenes)
403 module.RegionLoaded(scene);
355 404
356 scene.SetModuleInterfaces(); 405 foreach (Scene scene in scenes) { scene.SetModuleInterfaces(); }
357 } 406 }
358 407
359 /// <summary> 408 /// <summary>
@@ -363,31 +412,61 @@ namespace OpenSim.Tests.Common
363 /// <returns></returns> 412 /// <returns></returns>
364 public static AgentCircuitData GenerateAgentData(UUID agentId) 413 public static AgentCircuitData GenerateAgentData(UUID agentId)
365 { 414 {
366 string firstName = "testfirstname"; 415 AgentCircuitData acd = GenerateCommonAgentData();
367 416
368 AgentCircuitData agentData = new AgentCircuitData(); 417 acd.AgentID = agentId;
369 agentData.AgentID = agentId; 418 acd.firstname = "testfirstname";
370 agentData.firstname = firstName; 419 acd.lastname = "testlastname";
371 agentData.lastname = "testlastname"; 420 acd.ServiceURLs = new Dictionary<string, object>();
421
422 return acd;
423 }
424
425 /// <summary>
426 /// Generate some standard agent connection data.
427 /// </summary>
428 /// <param name="agentId"></param>
429 /// <returns></returns>
430 public static AgentCircuitData GenerateAgentData(UserAccount ua)
431 {
432 AgentCircuitData acd = GenerateCommonAgentData();
433
434 acd.AgentID = ua.PrincipalID;
435 acd.firstname = ua.FirstName;
436 acd.lastname = ua.LastName;
437 acd.ServiceURLs = ua.ServiceURLs;
438
439 return acd;
440 }
441
442 private static AgentCircuitData GenerateCommonAgentData()
443 {
444 AgentCircuitData acd = new AgentCircuitData();
372 445
373 // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData. 446 // XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData.
374 agentData.SessionID = UUID.Random(); 447 acd.SessionID = UUID.Random();
375 agentData.SecureSessionID = UUID.Random(); 448 acd.SecureSessionID = UUID.Random();
376 449
377 agentData.circuitcode = 123; 450 acd.circuitcode = 123;
378 agentData.BaseFolder = UUID.Zero; 451 acd.BaseFolder = UUID.Zero;
379 agentData.InventoryFolder = UUID.Zero; 452 acd.InventoryFolder = UUID.Zero;
380 agentData.startpos = Vector3.Zero; 453 acd.startpos = Vector3.Zero;
381 agentData.CapsPath = "http://wibble.com"; 454 acd.CapsPath = "http://wibble.com";
382 agentData.ServiceURLs = new Dictionary<string, object>(); 455 acd.Appearance = new AvatarAppearance();
383 agentData.Appearance = new AvatarAppearance(); 456
384 457 return acd;
385 return agentData;
386 } 458 }
387 459
388 /// <summary> 460 /// <summary>
389 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 461 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
390 /// </summary> 462 /// </summary>
463 /// <remarks>
464 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
465 /// and teleport doesn't take place.
466 ///
467 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
468 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
469 /// </remarks>
391 /// <param name="scene"></param> 470 /// <param name="scene"></param>
392 /// <param name="agentId"></param> 471 /// <param name="agentId"></param>
393 /// <returns></returns> 472 /// <returns></returns>
@@ -397,6 +476,33 @@ namespace OpenSim.Tests.Common
397 } 476 }
398 477
399 /// <summary> 478 /// <summary>
479 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
480 /// </summary>
481 /// <remarks>
482 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
483 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
484 /// </remarks>
485 /// <param name="scene"></param>
486 /// <param name="agentId"></param>
487 /// <param name="sceneManager"></param>
488 /// <returns></returns>
489 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
490 {
491 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
492 }
493
494 /// <summary>
495 /// Add a root agent.
496 /// </summary>
497 /// <param name="scene"></param>
498 /// <param name="ua"></param>
499 /// <returns></returns>
500 public static ScenePresence AddScenePresence(Scene scene, UserAccount ua)
501 {
502 return AddScenePresence(scene, GenerateAgentData(ua));
503 }
504
505 /// <summary>
400 /// Add a root agent. 506 /// Add a root agent.
401 /// </summary> 507 /// </summary>
402 /// <remarks> 508 /// <remarks>
@@ -416,6 +522,30 @@ namespace OpenSim.Tests.Common
416 /// <returns></returns> 522 /// <returns></returns>
417 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 523 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
418 { 524 {
525 return AddScenePresence(scene, agentData, null);
526 }
527
528 /// <summary>
529 /// Add a root agent.
530 /// </summary>
531 /// <remarks>
532 /// This function
533 ///
534 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
535 /// userserver if grid) would give initial login data back to the client and separately tell the scene that the
536 /// agent was coming.
537 ///
538 /// 2) Connects the agent with the scene
539 ///
540 /// This function performs actions equivalent with notifying the scene that an agent is
541 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first
542 /// </remarks>
543 /// <param name="scene"></param>
544 /// <param name="agentData"></param>
545 /// <param name="sceneManager"></param>
546 /// <returns></returns>
547 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager)
548 {
419 // We emulate the proper login sequence here by doing things in four stages 549 // We emulate the proper login sequence here by doing things in four stages
420 550
421 // Stage 0: login 551 // Stage 0: login
@@ -425,7 +555,7 @@ namespace OpenSim.Tests.Common
425 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID); 555 lpsc.m_PresenceService.LoginAgent(agentData.AgentID.ToString(), agentData.SessionID, agentData.SecureSessionID);
426 556
427 // Stages 1 & 2 557 // Stages 1 & 2
428 ScenePresence sp = IntroduceClientToScene(scene, agentData, TeleportFlags.ViaLogin); 558 ScenePresence sp = IntroduceClientToScene(scene, sceneManager, agentData, TeleportFlags.ViaLogin);
429 559
430 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent. 560 // Stage 3: Complete the entrance into the region. This converts the child agent into a root agent.
431 sp.CompleteMovement(sp.ControllingClient, true); 561 sp.CompleteMovement(sp.ControllingClient, true);
@@ -433,7 +563,20 @@ namespace OpenSim.Tests.Common
433 return sp; 563 return sp;
434 } 564 }
435 565
436 private static ScenePresence IntroduceClientToScene(Scene scene, AgentCircuitData agentData, TeleportFlags tf) 566 /// <summary>
567 /// Introduce an agent into the scene by adding a new client.
568 /// </summary>
569 /// <returns>The scene presence added</returns>
570 /// <param name='sceneManager'>
571 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
572 /// neighbours and where no teleporting takes place.
573 /// </param>
574 /// <param name='scene'></param>
575 /// <param name='sceneManager></param>
576 /// <param name='agentData'></param>
577 /// <param name='tf'></param>
578 private static ScenePresence IntroduceClientToScene(
579 Scene scene, SceneManager sceneManager, AgentCircuitData agentData, TeleportFlags tf)
437 { 580 {
438 string reason; 581 string reason;
439 582
@@ -442,7 +585,7 @@ namespace OpenSim.Tests.Common
442 Console.WriteLine("NewUserConnection failed: " + reason); 585 Console.WriteLine("NewUserConnection failed: " + reason);
443 586
444 // Stage 2: add the new client as a child agent to the scene 587 // Stage 2: add the new client as a child agent to the scene
445 TestClient client = new TestClient(agentData, scene); 588 TestClient client = new TestClient(agentData, scene, sceneManager);
446 scene.AddNewClient(client, PresenceType.User); 589 scene.AddNewClient(client, PresenceType.User);
447 590
448 return scene.GetScenePresence(agentData.AgentID); 591 return scene.GetScenePresence(agentData.AgentID);
@@ -454,7 +597,7 @@ namespace OpenSim.Tests.Common
454 acd.child = true; 597 acd.child = true;
455 598
456 // XXX: ViaLogin may not be correct for child agents 599 // XXX: ViaLogin may not be correct for child agents
457 return IntroduceClientToScene(scene, acd, TeleportFlags.ViaLogin); 600 return IntroduceClientToScene(scene, null, acd, TeleportFlags.ViaLogin);
458 } 601 }
459 602
460 /// <summary> 603 /// <summary>
@@ -462,9 +605,9 @@ namespace OpenSim.Tests.Common
462 /// </summary> 605 /// </summary>
463 /// <param name="scene"></param> 606 /// <param name="scene"></param>
464 /// <returns></returns> 607 /// <returns></returns>
465 public static SceneObjectPart AddSceneObject(Scene scene) 608 public static SceneObjectGroup AddSceneObject(Scene scene)
466 { 609 {
467 return AddSceneObject(scene, "Test Object"); 610 return AddSceneObject(scene, "Test Object", UUID.Zero);
468 } 611 }
469 612
470 /// <summary> 613 /// <summary>
@@ -472,17 +615,18 @@ namespace OpenSim.Tests.Common
472 /// </summary> 615 /// </summary>
473 /// <param name="scene"></param> 616 /// <param name="scene"></param>
474 /// <param name="name"></param> 617 /// <param name="name"></param>
618 /// <param name="ownerId"></param>
475 /// <returns></returns> 619 /// <returns></returns>
476 public static SceneObjectPart AddSceneObject(Scene scene, string name) 620 public static SceneObjectGroup AddSceneObject(Scene scene, string name, UUID ownerId)
477 { 621 {
478 SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), UUID.Zero); 622 SceneObjectGroup so = new SceneObjectGroup(CreateSceneObjectPart(name, UUID.Random(), ownerId));
479 623
480 //part.UpdatePrimFlags(false, false, true); 624 //part.UpdatePrimFlags(false, false, true);
481 //part.ObjectFlags |= (uint)PrimFlags.Phantom; 625 //part.ObjectFlags |= (uint)PrimFlags.Phantom;
482 626
483 scene.AddNewSceneObject(new SceneObjectGroup(part), false); 627 scene.AddNewSceneObject(so, false);
484 628
485 return part; 629 return so;
486 } 630 }
487 631
488 /// <summary> 632 /// <summary>
@@ -498,19 +642,36 @@ namespace OpenSim.Tests.Common
498 ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) 642 ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
499 { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) }; 643 { Name = name, UUID = id, Scale = new Vector3(1, 1, 1) };
500 } 644 }
501 645
502 /// <summary> 646 /// <summary>
503 /// Create a scene object but do not add it to the scene. 647 /// Create a scene object but do not add it to the scene.
504 /// </summary> 648 /// </summary>
505 /// <remarks> 649 /// <remarks>
506 /// UUID always starts at 00000000-0000-0000-0000-000000000001 650 /// UUID always starts at 00000000-0000-0000-0000-000000000001. For some purposes, (e.g. serializing direct
651 /// to another object's inventory) we do not need a scene unique ID. So it would be better to add the
652 /// UUID when we actually add an object to a scene rather than on creation.
507 /// </remarks> 653 /// </remarks>
508 /// <param name="parts">The number of parts that should be in the scene object</param> 654 /// <param name="parts">The number of parts that should be in the scene object</param>
509 /// <param name="ownerId"></param> 655 /// <param name="ownerId"></param>
510 /// <returns></returns> 656 /// <returns></returns>
511 public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) 657 public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId)
512 { 658 {
513 return CreateSceneObject(parts, ownerId, "", 0x1); 659 return CreateSceneObject(parts, ownerId, 0x1);
660 }
661
662 /// <summary>
663 /// Create a scene object but do not add it to the scene.
664 /// </summary>
665 /// <param name="parts">The number of parts that should be in the scene object</param>
666 /// <param name="ownerId"></param>
667 /// <param name="uuidTail">
668 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
669 /// will be given to the root part, and incremented for each part thereafter.
670 /// </param>
671 /// <returns></returns>
672 public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail)
673 {
674 return CreateSceneObject(parts, ownerId, "", uuidTail);
514 } 675 }
515 676
516 /// <summary> 677 /// <summary>
@@ -522,7 +683,7 @@ namespace OpenSim.Tests.Common
522 /// <param name="ownerId"></param> 683 /// <param name="ownerId"></param>
523 /// <param name="partNamePrefix"> 684 /// <param name="partNamePrefix">
524 /// The prefix to be given to part names. This will be suffixed with "Part<part no>" 685 /// The prefix to be given to part names. This will be suffixed with "Part<part no>"
525 /// (e.g. mynamePart0 for the root part) 686 /// (e.g. mynamePart1 for the root part)
526 /// </param> 687 /// </param>
527 /// <param name="uuidTail"> 688 /// <param name="uuidTail">
528 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" 689 /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
@@ -535,14 +696,14 @@ namespace OpenSim.Tests.Common
535 696
536 SceneObjectGroup sog 697 SceneObjectGroup sog
537 = new SceneObjectGroup( 698 = new SceneObjectGroup(
538 CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId)); 699 CreateSceneObjectPart(string.Format("{0}Part1", partNamePrefix), new UUID(rawSogId), ownerId));
539 700
540 if (parts > 1) 701 if (parts > 1)
541 for (int i = 1; i < parts; i++) 702 for (int i = 2; i <= parts; i++)
542 sog.AddPart( 703 sog.AddPart(
543 CreateSceneObjectPart( 704 CreateSceneObjectPart(
544 string.Format("{0}Part{1}", partNamePrefix, i), 705 string.Format("{0}Part{1}", partNamePrefix, i),
545 new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), 706 new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i - 1)),
546 ownerId)); 707 ownerId));
547 708
548 return sog; 709 return sog;
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 7058d1e..fba03ab 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -45,20 +45,23 @@ namespace OpenSim.Tests.Common
45 /// </summary> 45 /// </summary>
46 /// <param name="scene"></param> 46 /// <param name="scene"></param>
47 /// <param name="part"></param> 47 /// <param name="part"></param>
48 /// <param name="itemName"></param>
49 /// <param name="itemID"></param>
50 /// <param name="assetID"></param>
48 /// <returns>The item that was added</returns> 51 /// <returns>The item that was added</returns>
49 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) 52 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID)
50 { 53 {
51 AssetNotecard nc = new AssetNotecard(); 54 AssetNotecard nc = new AssetNotecard();
52 nc.BodyText = "Hello World!"; 55 nc.BodyText = "Hello World!";
53 nc.Encode(); 56 nc.Encode();
54 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); 57
55 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
56 AssetBase ncAsset 58 AssetBase ncAsset
57 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); 59 = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero);
58 scene.AssetService.Store(ncAsset); 60 scene.AssetService.Store(ncAsset);
61
59 TaskInventoryItem ncItem 62 TaskInventoryItem ncItem
60 = new TaskInventoryItem 63 = new TaskInventoryItem
61 { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, 64 { Name = itemName, AssetID = assetID, ItemID = itemID,
62 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; 65 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard };
63 part.Inventory.AddInventoryItem(ncItem, true); 66 part.Inventory.AddInventoryItem(ncItem, true);
64 67
@@ -66,8 +69,43 @@ namespace OpenSim.Tests.Common
66 } 69 }
67 70
68 /// <summary> 71 /// <summary>
72 /// Add a simple script to the given part.
73 /// </summary>
74 /// <remarks>
75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
76 /// functions more than once in a test.
77 /// </remarks>
78 /// <param name="scene"></param>
79 /// <param name="part"></param>
80 /// <returns>The item that was added</returns>
81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part)
82 {
83 AssetScriptText ast = new AssetScriptText();
84 ast.Source = "default { state_entry() { llSay(0, \"Hello World\"); } }";
85 ast.Encode();
86
87 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000");
88 UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000");
89 AssetBase asset
90 = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero);
91 scene.AssetService.Store(asset);
92 TaskInventoryItem item
93 = new TaskInventoryItem
94 { Name = "scriptItem", AssetID = assetUuid, ItemID = itemUuid,
95 Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL };
96 part.Inventory.AddInventoryItem(item, true);
97
98 return item;
99 }
100
101 /// <summary>
69 /// Add a scene object item to the given part. 102 /// Add a scene object item to the given part.
70 /// </summary> 103 /// </summary>
104 /// <remarks>
105 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
106 /// functions more than once in a test.
107 /// </remarks>
108 ///
71 /// <param name="scene"></param> 109 /// <param name="scene"></param>
72 /// <param name="sop"></param> 110 /// <param name="sop"></param>
73 /// <param name="itemName"></param> 111 /// <param name="itemName"></param>
diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
index b73df2c..2fbebc4 100644
--- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs
@@ -126,6 +126,11 @@ namespace OpenSim.Tests.Common
126 return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll"); 126 return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll");
127 } 127 }
128 128
129 public static UserAccount CreateUserWithInventory(Scene scene, int userId)
130 {
131 return CreateUserWithInventory(scene, "Bill", "Bailey", TestHelpers.ParseTail(userId), "troll");
132 }
133
129 public static UserAccount CreateUserWithInventory( 134 public static UserAccount CreateUserWithInventory(
130 Scene scene, string firstName, string lastName, UUID userId, string pw) 135 Scene scene, string firstName, string lastName, UUID userId, string pw)
131 { 136 {
@@ -133,6 +138,15 @@ namespace OpenSim.Tests.Common
133 CreateUserWithInventory(scene, ua, pw); 138 CreateUserWithInventory(scene, ua, pw);
134 return ua; 139 return ua;
135 } 140 }
141
142 public static UserAccount CreateUserWithInventory(
143 Scene scene, string firstName, string lastName, int userId, string pw)
144 {
145 UserAccount ua
146 = new UserAccount(TestHelpers.ParseTail(userId)) { FirstName = firstName, LastName = lastName };
147 CreateUserWithInventory(scene, ua, pw);
148 return ua;
149 }
136 150
137 public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw) 151 public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw)
138 { 152 {
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index fdc60d8..b3a7c9e 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -43,6 +43,57 @@ namespace OpenSim.Tests.Common
43 public static readonly string PATH_DELIMITER = "/"; 43 public static readonly string PATH_DELIMITER = "/";
44 44
45 /// <summary> 45 /// <summary>
46 /// Add an existing scene object as an item in the user's inventory.
47 /// </summary>
48 /// <param name='scene'></param>
49 /// <param name='so'></param>
50 /// <param name='inventoryIdTail'></param>
51 /// <param name='assetIdTail'></param>
52 /// <returns>The inventory item created.</returns>
53 public static InventoryItemBase AddInventoryItem(
54 Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail)
55 {
56 return AddInventoryItem(
57 scene,
58 so.Name,
59 TestHelpers.ParseTail(inventoryIdTail),
60 InventoryType.Object,
61 AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so),
62 so.OwnerID);
63 }
64
65 /// <summary>
66 /// Creates a notecard in the objects folder and specify an item id.
67 /// </summary>
68 /// <param name="scene"></param>
69 /// <param name="itemName"></param>
70 /// <param name="itemId"></param>
71 /// <param name="itemType"></param>
72 /// <param name="asset">The serialized asset for this item</param>
73 /// <param name="userId"></param>
74 /// <returns></returns>
75 private static InventoryItemBase AddInventoryItem(
76 Scene scene, string itemName, UUID itemId, InventoryType itemType, AssetBase asset, UUID userId)
77 {
78 scene.AssetService.Store(asset);
79
80 InventoryItemBase item = new InventoryItemBase();
81 item.Name = itemName;
82 item.AssetID = asset.FullID;
83 item.ID = itemId;
84 item.Owner = userId;
85 item.AssetType = asset.Type;
86 item.InvType = (int)itemType;
87
88 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, (AssetType)asset.Type);
89
90 item.Folder = folder.ID;
91 scene.AddInventoryItem(item);
92
93 return item;
94 }
95
96 /// <summary>
46 /// Creates a notecard in the objects folder and specify an item id. 97 /// Creates a notecard in the objects folder and specify an item id.
47 /// </summary> 98 /// </summary>
48 /// <param name="scene"></param> 99 /// <param name="scene"></param>
@@ -81,42 +132,27 @@ namespace OpenSim.Tests.Common
81 /// <param name="type">Type of item to create</param> 132 /// <param name="type">Type of item to create</param>
82 /// <returns></returns> 133 /// <returns></returns>
83 public static InventoryItemBase CreateInventoryItem( 134 public static InventoryItemBase CreateInventoryItem(
84 Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType type) 135 Scene scene, string itemName, UUID itemId, UUID assetId, UUID userId, InventoryType itemType)
85 { 136 {
86 AssetBase asset = null; 137 AssetBase asset = null;
87 138
88 if (type == InventoryType.Notecard) 139 if (itemType == InventoryType.Notecard)
89 { 140 {
90 asset = AssetHelpers.CreateNotecardAsset(); 141 asset = AssetHelpers.CreateNotecardAsset();
91 asset.CreatorID = userId.ToString(); 142 asset.CreatorID = userId.ToString();
92 } 143 }
93 else if (type == InventoryType.Object) 144 else if (itemType == InventoryType.Object)
94 { 145 {
95 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId)); 146 asset = AssetHelpers.CreateAsset(assetId, SceneHelpers.CreateSceneObject(1, userId));
96 } 147 }
97 else 148 else
98 { 149 {
99 throw new Exception(string.Format("Inventory type {0} not supported", type)); 150 throw new Exception(string.Format("Inventory type {0} not supported", itemType));
100 } 151 }
101 152
102 scene.AssetService.Store(asset); 153 return AddInventoryItem(scene, itemName, itemId, itemType, asset, userId);
103
104 InventoryItemBase item = new InventoryItemBase();
105 item.Name = itemName;
106 item.AssetID = asset.FullID;
107 item.ID = itemId;
108 item.Owner = userId;
109 item.AssetType = asset.Type;
110 item.InvType = (int)type;
111
112 InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard);
113
114 item.Folder = folder.ID;
115 scene.AddInventoryItem(item);
116
117 return item;
118 } 154 }
119 155
120 /// <summary> 156 /// <summary>
121 /// Create inventory folders starting from the user's root folder. 157 /// Create inventory folders starting from the user's root folder.
122 /// </summary> 158 /// </summary>