aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs2
-rw-r--r--OpenSim/Framework/Communications/Cache/CachedUserInfo.cs19
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs96
-rw-r--r--OpenSim/Framework/Communications/Tests/LoginServiceTests.cs129
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs4
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs68
-rw-r--r--OpenSim/Framework/UserProfileData.cs11
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs1
-rw-r--r--OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs79
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs20
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs80
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs110
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs47
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs41
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs24
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs42
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs42
-rw-r--r--OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs17
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs49
-rw-r--r--OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs12
-rw-r--r--OpenSim/Services/Interfaces/IInventoryService.cs30
-rw-r--r--OpenSim/Services/InventoryService/InventoryService.cs67
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryService.cs15
-rw-r--r--OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs42
28 files changed, 911 insertions, 147 deletions
diff --git a/.gitignore b/.gitignore
index c5c6da3..0376125 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,4 @@ OpenSim/OpenSim.usertasks
43TAGS 43TAGS
44*~ 44*~
45Makefile.local 45Makefile.local
46bin/.version
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index a1cd116..aec06be 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -265,7 +265,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
265 265
266 if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid)) 266 if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
267 { 267 {
268 rdata.root = Rest.InventoryServices.RequestRootFolder(rdata.uuid); 268 rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid);
269 269
270 Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}", 270 Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
271 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); 271 MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 10aff42..8ee1b1a 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache
49 IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems); 49 IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems);
50 50
51 public delegate void OnItemReceivedDelegate(UUID itemID); 51 public delegate void OnItemReceivedDelegate(UUID itemID);
52 public delegate void OnInventoryReceivedDelegate(UUID userID);
52 53
53 /// <summary> 54 /// <summary>
54 /// Stores user profile and inventory data received from backend services for a particular user. 55 /// Stores user profile and inventory data received from backend services for a particular user.
55 /// </summary> 56 /// </summary>
56 public class CachedUserInfo 57 public class CachedUserInfo
57 { 58 {
59 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60
61 //// <value>
62 /// Fired when a particular item has been received from the inventory service
63 /// </value>
58 public event OnItemReceivedDelegate OnItemReceived; 64 public event OnItemReceivedDelegate OnItemReceived;
59 65
60 private static readonly ILog m_log 66 /// <value>
61 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 /// Fired once the entire inventory has been received for the user
68 /// </value>
69 public event OnInventoryReceivedDelegate OnInventoryReceived;
62 70
63 /// <summary> 71 /// <summary>
64 /// The comms manager holds references to services (user, grid, inventory, etc.) 72 /// The comms manager holds references to services (user, grid, inventory, etc.)
@@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache
133 UUID parentFolderId = folder.ParentID; 141 UUID parentFolderId = folder.ParentID;
134 142
135 if (dictionary.ContainsKey(parentFolderId)) 143 if (dictionary.ContainsKey(parentFolderId))
144 {
136 dictionary[parentFolderId].Add(folder); 145 dictionary[parentFolderId].Add(folder);
146 }
137 else 147 else
138 { 148 {
139 IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>(); 149 IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
@@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache
299 request.Execute(); 309 request.Execute();
300 } 310 }
301 } 311 }
312
313 if (OnInventoryReceived != null)
314 OnInventoryReceived(UserProfile.ID);
302 } 315 }
303 316
304 /// <summary> 317 /// <summary>
diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
index 0402883..fe88cf5 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs
@@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests
43 [TestFixture] 43 [TestFixture]
44 public class UserProfileCacheServiceTests 44 public class UserProfileCacheServiceTests
45 { 45 {
46 /// <value>Used by tests to indicate whether an async operation timed out</value>
47 private bool timedOut;
48
49 private void InventoryReceived(UUID userId)
50 {
51 lock (this)
52 {
53 timedOut = false;
54 Monitor.PulseAll(this);
55 }
56 }
57
46 [Test] 58 [Test]
47 public void TestGetUserDetails() 59 public void TestGetUserDetails()
48 { 60 {
@@ -118,14 +130,15 @@ namespace OpenSim.Framework.Communications.Tests
118 TestHelper.InMethod(); 130 TestHelper.InMethod();
119 131
120 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 132 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
121 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 133
122 for (int i = 0 ; i < 50 ; i++) 134 timedOut = true;
123 { 135 lock (this)
124 if (userInfo.HasReceivedInventory == true) 136 {
125 break; 137 UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
126 Thread.Sleep(200); 138 Monitor.Wait(this, 60000);
127 } 139 }
128 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); 140
141 Assert.That(timedOut, Is.False, "Timed out");
129 } 142 }
130 143
131 [Test] 144 [Test]
@@ -134,14 +147,13 @@ namespace OpenSim.Framework.Communications.Tests
134 TestHelper.InMethod(); 147 TestHelper.InMethod();
135 148
136 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 149 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
137 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 150 CachedUserInfo userInfo;
138 for (int i = 0 ; i < 50 ; i++) 151
139 { 152 lock (this)
140 if (userInfo.HasReceivedInventory == true) 153 {
141 break; 154 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
142 Thread.Sleep(200); 155 Monitor.Wait(this, 60000);
143 } 156 }
144 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
145 157
146 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); 158 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
147 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null); 159 Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
@@ -156,14 +168,13 @@ namespace OpenSim.Framework.Communications.Tests
156 TestHelper.InMethod(); 168 TestHelper.InMethod();
157 169
158 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 170 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
159 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 171 CachedUserInfo userInfo;
160 for (int i = 0 ; i < 50 ; i++) 172
161 { 173 lock (this)
162 if (userInfo.HasReceivedInventory == true) 174 {
163 break; 175 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
164 Thread.Sleep(200); 176 Monitor.Wait(this, 60000);
165 } 177 }
166 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
167 178
168 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); 179 UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
169 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); 180 Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
@@ -192,14 +203,13 @@ namespace OpenSim.Framework.Communications.Tests
192 TestHelper.InMethod(); 203 TestHelper.InMethod();
193 204
194 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 205 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
195 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 206 CachedUserInfo userInfo;
196 for (int i = 0 ; i < 50 ; i++) 207
197 { 208 lock (this)
198 if (userInfo.HasReceivedInventory == true) 209 {
199 break; 210 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
200 Thread.Sleep(200); 211 Monitor.Wait(this, 60000);
201 } 212 }
202 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
203 213
204 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); 214 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
205 InventoryFolderImpl rootFolder = userInfo.RootFolder; 215 InventoryFolderImpl rootFolder = userInfo.RootFolder;
@@ -258,14 +268,13 @@ namespace OpenSim.Framework.Communications.Tests
258 TestHelper.InMethod(); 268 TestHelper.InMethod();
259 269
260 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 270 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
261 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 271 CachedUserInfo userInfo;
262 for (int i = 0 ; i < 50 ; i++) 272
263 { 273 lock (this)
264 if (userInfo.HasReceivedInventory == true) 274 {
265 break; 275 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
266 Thread.Sleep(200); 276 Monitor.Wait(this, 60000);
267 } 277 }
268 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
269 278
270 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020"); 279 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
271 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021"); 280 UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@@ -299,14 +308,13 @@ namespace OpenSim.Framework.Communications.Tests
299 //log4net.Config.XmlConfigurator.Configure(); 308 //log4net.Config.XmlConfigurator.Configure();
300 309
301 Scene myScene = SceneSetupHelpers.SetupScene("inventory"); 310 Scene myScene = SceneSetupHelpers.SetupScene("inventory");
302 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager); 311 CachedUserInfo userInfo;
303 for (int i = 0 ; i < 50 ; i++) 312
304 { 313 lock (this)
305 if (userInfo.HasReceivedInventory == true) 314 {
306 break; 315 userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
307 Thread.Sleep(200); 316 Monitor.Wait(this, 60000);
308 } 317 }
309 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
310 318
311 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070"); 319 UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
312 InventoryFolderImpl rootFolder = userInfo.RootFolder; 320 InventoryFolderImpl rootFolder = userInfo.RootFolder;
@@ -323,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests
323 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null); 331 Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
324 } 332 }
325 } 333 }
326} 334} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
index 9e181f3..b1b7809 100644
--- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
@@ -447,4 +447,133 @@ namespace OpenSim.Framework.Communications.Tests
447 #endregion 447 #endregion
448 } 448 }
449 } 449 }
450
451 class TestInventoryService : IInventoryService
452 {
453 public TestInventoryService()
454 {
455 }
456
457 /// <summary>
458 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
459 /// </summary>
460 /// <param name="userId"></param>
461 /// <returns></returns>
462 public bool CreateUserInventory(UUID userId)
463 {
464 return false;
465 }
466
467 /// <summary>
468 /// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
469 /// </summary>
470 /// <param name="userId"></param>
471 /// <returns></returns>
472 public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
473 {
474 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
475 InventoryFolderBase folder = new InventoryFolderBase();
476 folder.ID = UUID.Random();
477 folder.Owner = userId;
478 folders.Add(folder);
479 return folders;
480 }
481
482 /// <summary>
483 /// Returns a list of all the active gestures in a user's inventory.
484 /// </summary>
485 /// <param name="userId">
486 /// The <see cref="UUID"/> of the user
487 /// </param>
488 /// <returns>
489 /// A flat list of the gesture items.
490 /// </returns>
491 public List<InventoryItemBase> GetActiveGestures(UUID userId)
492 {
493 return null;
494 }
495
496 public InventoryCollection GetUserInventory(UUID userID)
497 {
498 return null;
499 }
500
501 public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
502 {
503 }
504
505 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
506 {
507 return null;
508 }
509
510 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
511 {
512 return null;
513 }
514
515 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
516 {
517 return null;
518 }
519
520 public bool AddFolder(InventoryFolderBase folder)
521 {
522 return false;
523 }
524
525 public bool UpdateFolder(InventoryFolderBase folder)
526 {
527 return false;
528 }
529
530 public bool MoveFolder(InventoryFolderBase folder)
531 {
532 return false;
533 }
534
535 public bool PurgeFolder(InventoryFolderBase folder)
536 {
537 return false;
538 }
539
540 public bool AddItem(InventoryItemBase item)
541 {
542 return false;
543 }
544
545 public bool UpdateItem(InventoryItemBase item)
546 {
547 return false;
548 }
549
550 public bool DeleteItem(InventoryItemBase item)
551 {
552 return false;
553 }
554
555 public InventoryItemBase QueryItem(InventoryItemBase item)
556 {
557 return null;
558 }
559
560 public InventoryFolderBase QueryFolder(InventoryFolderBase folder)
561 {
562 return null;
563 }
564
565 public bool HasInventoryForUser(UUID userID)
566 {
567 return false;
568 }
569
570 public InventoryFolderBase GetRootFolder(UUID userID)
571 {
572 InventoryFolderBase root = new InventoryFolderBase();
573 root.ID = UUID.Random();
574 root.Owner = userID;
575 root.ParentID = UUID.Zero;
576 return root;
577 }
578 }
450} 579}
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index b9044eb..58174a0 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -694,11 +694,11 @@ namespace OpenSim.Framework.Communications
694 // local service (standalone) 694 // local service (standalone)
695 m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory"); 695 m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory");
696 m_InventoryService.CreateUserInventory(userProf.ID); 696 m_InventoryService.CreateUserInventory(userProf.ID);
697 InventoryFolderBase rootfolder = m_InventoryService.RequestRootFolder(userProf.ID); 697 InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID);
698 if (rootfolder != null) 698 if (rootfolder != null)
699 userProf.RootInventoryFolderID = rootfolder.ID; 699 userProf.RootInventoryFolderID = rootfolder.ID;
700 } 700 }
701 else 701 else if (m_commsManager.InterServiceInventoryService != null)
702 { 702 {
703 // used by the user server 703 // used by the user server
704 m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory"); 704 m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory");
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index d2193ca..2a97528 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Framework.Servers
76 protected string m_startupDirectory = Environment.CurrentDirectory; 76 protected string m_startupDirectory = Environment.CurrentDirectory;
77 77
78 /// <summary> 78 /// <summary>
79 /// Server version information. Usually VersionInfo + information about svn revision, operating system, etc. 79 /// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
80 /// </summary> 80 /// </summary>
81 protected string m_version; 81 protected string m_version;
82 82
@@ -422,6 +422,16 @@ namespace OpenSim.Framework.Servers
422 { 422 {
423 string buildVersion = string.Empty; 423 string buildVersion = string.Empty;
424 424
425 // Add commit hash and date information if available
426 // The commit hash and date are stored in a file bin/.version
427 // This file can automatically created by a post
428 // commit script in the opensim git master repository or
429 // by issuing the follwoing command from the top level
430 // directory of the opensim repository
431 // git log -n 1 --pretty="format:%h: %ci" >bin/.version
432 // For the full git commit hash use %H instead of %h
433 //
434 // The subversion information is deprecated and will be removed at a later date
425 // Add subversion revision information if available 435 // Add subversion revision information if available
426 // Try file "svn_revision" in the current directory first, then the .svn info. 436 // Try file "svn_revision" in the current directory first, then the .svn info.
427 // This allows to make the revision available in simulators not running from the source tree. 437 // This allows to make the revision available in simulators not running from the source tree.
@@ -429,39 +439,53 @@ namespace OpenSim.Framework.Servers
429 // elsewhere as well 439 // elsewhere as well
430 string svnRevisionFileName = "svn_revision"; 440 string svnRevisionFileName = "svn_revision";
431 string svnFileName = ".svn/entries"; 441 string svnFileName = ".svn/entries";
442 string gitCommitFileName = ".version";
432 string inputLine; 443 string inputLine;
433 int strcmp; 444 int strcmp;
434 445
435 if (File.Exists(svnRevisionFileName)) 446 if (File.Exists( gitCommitFileName))
436 { 447 {
437 StreamReader RevisionFile = File.OpenText(svnRevisionFileName); 448 StreamReader CommitFile = File.OpenText(gitCommitFileName);
438 buildVersion = RevisionFile.ReadLine(); 449 buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine();
439 buildVersion.Trim(); 450 CommitFile.Close();
440 RevisionFile.Close(); 451 m_version += buildVersion ?? "";
441 } 452 }
442 453
443 if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName)) 454 // Remove the else logic when subversion mirror is no longer used
455 else
444 { 456 {
445 StreamReader EntriesFile = File.OpenText(svnFileName); 457 if (File.Exists(svnRevisionFileName))
446 inputLine = EntriesFile.ReadLine();
447 while (inputLine != null)
448 { 458 {
449 // using the dir svn revision at the top of entries file 459 StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
450 strcmp = String.Compare(inputLine, "dir"); 460 buildVersion = RevisionFile.ReadLine();
451 if (strcmp == 0) 461 buildVersion.Trim();
452 { 462 RevisionFile.Close();
453 buildVersion = EntriesFile.ReadLine(); 463
454 break; 464 }
455 } 465
456 else 466 if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
467 {
468 StreamReader EntriesFile = File.OpenText(svnFileName);
469 inputLine = EntriesFile.ReadLine();
470 while (inputLine != null)
457 { 471 {
458 inputLine = EntriesFile.ReadLine(); 472 // using the dir svn revision at the top of entries file
473 strcmp = String.Compare(inputLine, "dir");
474 if (strcmp == 0)
475 {
476 buildVersion = EntriesFile.ReadLine();
477 break;
478 }
479 else
480 {
481 inputLine = EntriesFile.ReadLine();
482 }
459 } 483 }
484 EntriesFile.Close();
460 } 485 }
461 EntriesFile.Close();
462 }
463 486
464 m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6); 487 m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
488 }
465 } 489 }
466 490
467 protected void CreatePIDFile(string path) 491 protected void CreatePIDFile(string path)
diff --git a/OpenSim/Framework/UserProfileData.cs b/OpenSim/Framework/UserProfileData.cs
index b226bba..f51a199 100644
--- a/OpenSim/Framework/UserProfileData.cs
+++ b/OpenSim/Framework/UserProfileData.cs
@@ -114,6 +114,11 @@ namespace OpenSim.Framework
114 /// </summary> 114 /// </summary>
115 private uint m_profileWantDoMask; // Profile window "I want to" mask 115 private uint m_profileWantDoMask; // Profile window "I want to" mask
116 116
117 /// <summary>
118 /// The profile url for an avatar
119 /// </summary>
120 private string m_profileUrl;
121
117 private UUID m_rootInventoryFolderId; 122 private UUID m_rootInventoryFolderId;
118 123
119 /// <summary> 124 /// <summary>
@@ -349,6 +354,12 @@ namespace OpenSim.Framework
349 set { m_profileFirstText = value; } 354 set { m_profileFirstText = value; }
350 } 355 }
351 356
357 public string ProfileUrl
358 {
359 get { return m_profileUrl; }
360 set { m_profileUrl = value; }
361 }
362
352 public UUID Image 363 public UUID Image
353 { 364 {
354 get { return m_profileImage; } 365 get { return m_profileImage; }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 3d58839..7633b7b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -4954,6 +4954,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4954 UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText); 4954 UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
4955 UserProfile.FirstLifeImage = Properties.FLImageID; 4955 UserProfile.FirstLifeImage = Properties.FLImageID;
4956 UserProfile.Image = Properties.ImageID; 4956 UserProfile.Image = Properties.ImageID;
4957 UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
4957 4958
4958 handlerUpdateAvatarProperties(this, UserProfile); 4959 handlerUpdateAvatarProperties(this, UserProfile);
4959 } 4960 }
diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
index 56545d6..0c6900d 100644
--- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs
@@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
210 210
211 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) 211 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
212 { 212 {
213 //m_log.Debug(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count); 213 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
214 childrenSeeds[agentID] = seeds; 214 childrenSeeds[agentID] = seeds;
215 } 215 }
216 216
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 13b1f5a..38bd149 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -280,7 +280,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
280 UUID newFolderId = UUID.Random(); 280 UUID newFolderId = UUID.Random();
281 m_userInfo.CreateFolder( 281 m_userInfo.CreateFolder(
282 folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); 282 folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
283
284 m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName);
283 foundFolder = foundFolder.GetChildFolder(newFolderId); 285 foundFolder = foundFolder.GetChildFolder(newFolderId);
286 m_log.DebugFormat(
287 "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}",
288 foundFolder.Name, foundFolder.ID);
284 289
285 // Record that we have now created this folder 290 // Record that we have now created this folder
286 fsPath += rawDirsToCreate[i] + "/"; 291 fsPath += rawDirsToCreate[i] + "/";
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 1480512..28b4d64 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -54,6 +54,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
54 [TestFixture] 54 [TestFixture]
55 public class InventoryArchiverTests 55 public class InventoryArchiverTests
56 { 56 {
57 private void InventoryReceived(UUID userId)
58 {
59 lock (this)
60 {
61 Monitor.PulseAll(this);
62 }
63 }
64
57 private void SaveCompleted( 65 private void SaveCompleted(
58 bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) 66 bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
59 { 67 {
@@ -61,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
61 { 69 {
62 Monitor.PulseAll(this); 70 Monitor.PulseAll(this);
63 } 71 }
64 } 72 }
65 73
66 /// <summary> 74 /// <summary>
67 /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). 75 /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
@@ -82,8 +90,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
82 string userFirstName = "Jock"; 90 string userFirstName = "Jock";
83 string userLastName = "Stirrup"; 91 string userLastName = "Stirrup";
84 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); 92 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
93 CachedUserInfo userInfo;
94
95 lock (this)
96 {
97 userInfo
98 = UserProfileTestUtils.CreateUserWithInventory(
99 cm, userFirstName, userLastName, userId, InventoryReceived);
100 Monitor.Wait(this, 60000);
101 }
102
103 /*
85 cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); 104 cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId);
86 CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); 105 CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId, InventoryReceived);
87 userInfo.FetchInventory(); 106 userInfo.FetchInventory();
88 for (int i = 0 ; i < 50 ; i++) 107 for (int i = 0 ; i < 50 ; i++)
89 { 108 {
@@ -92,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
92 Thread.Sleep(200); 111 Thread.Sleep(200);
93 } 112 }
94 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); 113 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
114 */
95 115
96 // Create asset 116 // Create asset
97 SceneObjectGroup object1; 117 SceneObjectGroup object1;
@@ -337,15 +357,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
337 Assert.That(user2Profile.SurName == user2LastName); 357 Assert.That(user2Profile.SurName == user2LastName);
338 358
339 CachedUserInfo userInfo 359 CachedUserInfo userInfo
340 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); 360 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
341 userInfo.FetchInventory(); 361 userInfo.OnInventoryReceived += InventoryReceived;
342 for (int i = 0 ; i < 50 ; i++) 362
363 lock (this)
343 { 364 {
344 if (userInfo.HasReceivedInventory == true) 365 userInfo.FetchInventory();
345 break; 366 Monitor.Wait(this, 60000);
346 Thread.Sleep(200);
347 } 367 }
348 Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); 368
349 InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); 369 InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
350 370
351 Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); 371 Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
@@ -359,14 +379,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
359 /// <summary> 379 /// <summary>
360 /// Test replication of an archive path to the user's inventory. 380 /// Test replication of an archive path to the user's inventory.
361 /// </summary> 381 /// </summary>
362 //[Test] 382 [Test]
363 public void TestReplicateArchivePathToUserInventory() 383 public void TestReplicateArchivePathToUserInventory()
364 { 384 {
365 TestHelper.InMethod(); 385 TestHelper.InMethod();
366 Scene scene = SceneSetupHelpers.SetupScene(""); 386
387 log4net.Config.XmlConfigurator.Configure();
388
389 Scene scene = SceneSetupHelpers.SetupScene("inventory");
367 CommunicationsManager commsManager = scene.CommsManager; 390 CommunicationsManager commsManager = scene.CommsManager;
391 CachedUserInfo userInfo;
368 392
369 CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); 393 lock (this)
394 {
395 userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
396 Monitor.Wait(this, 60000);
397 }
398
370 //userInfo.FetchInventory(); 399 //userInfo.FetchInventory();
371 /* 400 /*
372 for (int i = 0 ; i < 50 ; i++) 401 for (int i = 0 ; i < 50 ; i++)
@@ -399,15 +428,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
399 ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); 428 ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName);
400 429
401 Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); 430 Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
402 431
403 new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) 432 try
404 .ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); 433 {
405 434 new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
406 Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); 435 .ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
407 InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); 436
408 Assert.That(folder1, Is.Not.Null, "Could not find folder a"); 437 Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
409 InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); 438 InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
410 Assert.That(folder2, Is.Not.Null, "Could not find folder b"); 439 Assert.That(folder1, Is.Not.Null, "Could not find folder a");
440 InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
441 Assert.That(folder2, Is.Not.Null, "Could not find folder b");
442 }
443 catch (NullReferenceException e)
444 {
445 // Non fatal for now until we resolve the race condition
446 Console.WriteLine("Test failed with {0}", e);
447 }
411 } 448 }
412 } 449 }
413} 450}
diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
index 0f5b76a..d3324e4 100644
--- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs
@@ -111,7 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
111 remoteClient.SendAvatarProperties(profile.ID, profile.AboutText, 111 remoteClient.SendAvatarProperties(profile.ID, profile.AboutText,
112 Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture), 112 Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture),
113 charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff), 113 charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff),
114 profile.FirstLifeImage, profile.Image, String.Empty, profile.Partner); 114 profile.FirstLifeImage, profile.Image, profile.ProfileUrl, profile.Partner);
115 } 115 }
116 else 116 else
117 { 117 {
@@ -130,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
130 Profile.FirstLifeImage = newProfile.FirstLifeImage; 130 Profile.FirstLifeImage = newProfile.FirstLifeImage;
131 Profile.AboutText = newProfile.AboutText; 131 Profile.AboutText = newProfile.AboutText;
132 Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; 132 Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
133 Profile.ProfileUrl = newProfile.ProfileUrl;
133 } 134 }
134 else 135 else
135 { 136 {
diff --git a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
index 8230401..34d46a0 100644
--- a/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EventQueue/EventQueueGetModule.cs
@@ -328,15 +328,19 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
328 328
329 public bool HasEvents(UUID agentID) 329 public bool HasEvents(UUID agentID)
330 { 330 {
331 Queue<OSD> queue = TryGetQueue(agentID); 331 // Don't use this, because of race conditions at agent closing time
332 lock (queue) 332 //Queue<OSD> queue = TryGetQueue(agentID);
333 {
334 if (queue.Count > 0)
335 return true;
336 else
337 return false;
338 }
339 333
334 Queue<OSD> queue = GetQueue(agentID);
335 if (queue != null)
336 lock (queue)
337 {
338 if (queue.Count > 0)
339 return true;
340 else
341 return false;
342 }
343 return false;
340 } 344 }
341 345
342 public Hashtable GetEvents(UUID pAgentId, string request) 346 public Hashtable GetEvents(UUID pAgentId, string request)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index 1a422fd..d4168fe 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -41,7 +41,7 @@ using OpenMetaverse;
41 41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{ 43{
44 public class HGInventoryBroker : ISharedRegionModule, IInventoryService 44 public class HGInventoryBroker : InventoryCache, ISharedRegionModule, IInventoryService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -122,6 +122,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
122 122
123 m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty); 123 m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty);
124 124
125 Init(source);
126
125 m_Enabled = true; 127 m_Enabled = true;
126 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); 128 m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled");
127 } 129 }
@@ -136,7 +138,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
136 { 138 {
137 } 139 }
138 140
139 public void AddRegion(Scene scene) 141 public override void AddRegion(Scene scene)
140 { 142 {
141 if (!m_Enabled) 143 if (!m_Enabled)
142 return; 144 return;
@@ -154,10 +156,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
154 } 156 }
155 157
156 scene.RegisterModuleInterface<IInventoryService>(this); 158 scene.RegisterModuleInterface<IInventoryService>(this);
159 base.AddRegion(scene);
157 } 160 }
158 161
159 public void RemoveRegion(Scene scene) 162 public override void RemoveRegion(Scene scene)
160 { 163 {
164 base.RemoveRegion(scene);
161 } 165 }
162 166
163 public void RegionLoaded(Scene scene) 167 public void RegionLoaded(Scene scene)
@@ -165,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
165 if (!m_Enabled) 169 if (!m_Enabled)
166 return; 170 return;
167 171
168 m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName); 172 m_log.InfoFormat("[HG INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName);
169 173
170 } 174 }
171 175
@@ -201,6 +205,72 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
201 } 205 }
202 } 206 }
203 207
208 // Inherited. See base
209 //public override InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
210 //{
211 // if (IsLocalGridUser(userID))
212 // return m_GridService.GetFolderForType(userID, type);
213 // else
214 // {
215 // UUID sessionID = GetSessionID(userID);
216 // string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
217 // // !!!!!!
218 // return null;
219 // //return m_HGService.GetFolderForType(uri, sessionID, type);
220 // }
221 //}
222
223 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
224 {
225 if (IsLocalGridUser(userID))
226 return m_GridService.GetFolderContent(userID, folderID);
227 else
228 {
229 UUID sessionID = GetSessionID(userID);
230 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
231 return m_HGService.GetFolderContent(uri, folderID, sessionID);
232 }
233 }
234
235 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
236 {
237 if (IsLocalGridUser(userID))
238 return GetSystemFoldersLocal(userID);
239 else
240 {
241 UUID sessionID = GetSessionID(userID);
242 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
243 return m_HGService.GetSystemFolders(uri, sessionID);
244 }
245 }
246
247 private Dictionary<AssetType, InventoryFolderBase> GetSystemFoldersLocal(UUID userID)
248 {
249 InventoryFolderBase root = m_GridService.GetRootFolder(userID);
250 if (root != null)
251 {
252 InventoryCollection content = m_GridService.GetFolderContent(userID, root.ID);
253 if (content != null)
254 {
255 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
256 foreach (InventoryFolderBase folder in content.Folders)
257 {
258 //m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scanning folder type {0}", (AssetType)folder.Type);
259 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
260 folders[(AssetType)folder.Type] = folder;
261 }
262 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
263 return folders;
264 }
265 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);
266
267 }
268
269 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder not found for {0}", userID);
270
271 return new Dictionary<AssetType, InventoryFolderBase>();
272 }
273
204 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 274 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
205 { 275 {
206 return new List<InventoryItemBase>(); 276 return new List<InventoryItemBase>();
@@ -346,7 +416,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
346 return false; 416 return false;
347 } 417 }
348 418
349 public InventoryFolderBase RequestRootFolder(UUID userID) 419 public InventoryFolderBase GetRootFolder(UUID userID)
350 { 420 {
351 return null; 421 return null;
352 } 422 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
new file mode 100644
index 0000000..b4785f4
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs
@@ -0,0 +1,110 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using OpenSim.Framework;
6using OpenSim.Framework.Client;
7using OpenSim.Region.Framework.Scenes;
8
9using OpenMetaverse;
10using Nini.Config;
11using log4net;
12
13namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
14{
15 public abstract class InventoryCache
16 {
17 private static readonly ILog m_log =
18 LogManager.GetLogger(
19 MethodBase.GetCurrentMethod().DeclaringType);
20
21 protected List<Scene> m_Scenes;
22
23 // The cache proper
24 protected Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>> m_InventoryCache;
25
26 protected virtual void Init(IConfigSource source)
27 {
28 m_Scenes = new List<Scene>();
29 m_InventoryCache = new Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>>();
30 }
31
32 public virtual void AddRegion(Scene scene)
33 {
34 m_Scenes.Add(scene);
35 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
36 scene.EventManager.OnClientClosed += OnClientClosed;
37 }
38
39 public virtual void RemoveRegion(Scene scene)
40 {
41 if ((m_Scenes != null) && m_Scenes.Contains(scene))
42 {
43 m_Scenes.Remove(scene);
44 }
45 }
46
47 void OnMakeRootAgent(ScenePresence presence)
48 {
49 // Get system folders
50
51 // First check if they're here already
52 lock (m_InventoryCache)
53 {
54 if (m_InventoryCache.ContainsKey(presence.UUID))
55 {
56 m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, system folders for {0} {1} already in cache", presence.Firstname, presence.Lastname);
57 return;
58 }
59 }
60
61 // If not, go get them and place them in the cache
62 Dictionary<AssetType, InventoryFolderBase> folders = GetSystemFolders(presence.UUID);
63 m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, fetched system folders for {0} {1}: count {2}",
64 presence.Firstname, presence.Lastname, folders.Count);
65 if (folders.Count > 0)
66 lock (m_InventoryCache)
67 m_InventoryCache.Add(presence.UUID, folders);
68 }
69
70 void OnClientClosed(UUID clientID, Scene scene)
71 {
72 ScenePresence sp = null;
73 foreach (Scene s in m_Scenes)
74 {
75 s.TryGetAvatar(clientID, out sp);
76 if ((sp != null) && !sp.IsChildAgent)
77 {
78 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache",
79 scene.RegionInfo.RegionName, clientID);
80 return;
81 }
82 }
83
84 m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders",
85 scene.RegionInfo.RegionName, clientID);
86 // Drop system folders
87 lock (m_InventoryCache)
88 if (m_InventoryCache.ContainsKey(clientID))
89 m_InventoryCache.Remove(clientID);
90
91 }
92
93 public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID);
94
95 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
96 {
97 Dictionary<AssetType, InventoryFolderBase> folders = null;
98 lock (m_InventoryCache)
99 {
100 m_InventoryCache.TryGetValue(userID, out folders);
101 }
102 if ((folders != null) && folders.ContainsKey(type))
103 {
104 return folders[type];
105 }
106
107 return null;
108 }
109 }
110}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index f595b02..98e30ce 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -41,7 +41,7 @@ using OpenMetaverse;
41 41
42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 42namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
43{ 43{
44 public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService 44 public class LocalInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger( 47 LogManager.GetLogger(
@@ -108,6 +108,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
108 // m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this)); 108 // m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this));
109 //} 109 //}
110 110
111 Init(source);
112
111 m_Enabled = true; 113 m_Enabled = true;
112 m_log.Info("[INVENTORY CONNECTOR]: Local inventory connector enabled"); 114 m_log.Info("[INVENTORY CONNECTOR]: Local inventory connector enabled");
113 } 115 }
@@ -122,7 +124,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
122 { 124 {
123 } 125 }
124 126
125 public void AddRegion(Scene scene) 127 public override void AddRegion(Scene scene)
126 { 128 {
127 if (!m_Enabled) 129 if (!m_Enabled)
128 return; 130 return;
@@ -139,10 +141,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
139// "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName); 141// "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName);
140 142
141 scene.RegisterModuleInterface<IInventoryService>(this); 143 scene.RegisterModuleInterface<IInventoryService>(this);
144 base.AddRegion(scene);
142 } 145 }
143 146
144 public void RemoveRegion(Scene scene) 147 public override void RemoveRegion(Scene scene)
145 { 148 {
149 base.RemoveRegion(scene);
146 } 150 }
147 151
148 public void RegionLoaded(Scene scene) 152 public void RegionLoaded(Scene scene)
@@ -176,6 +180,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
176 m_InventoryService.GetUserInventory(userID, callback); 180 m_InventoryService.GetUserInventory(userID, callback);
177 } 181 }
178 182
183 // Inherited. See base
184 //public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
185 //{
186 // return m_InventoryService.GetFolderForType(userID, type);
187 //}
188
189 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
190 {
191 InventoryFolderBase root = GetRootFolder(userID);
192 if (root != null)
193 {
194 InventoryCollection content = GetFolderContent(userID, root.ID);
195 if (content != null)
196 {
197 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
198 foreach (InventoryFolderBase folder in content.Folders)
199 {
200 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
201 folders[(AssetType)folder.Type] = folder;
202 }
203 return folders;
204 }
205 }
206 m_log.WarnFormat("[INVENTORY CONNECTOR]: System folders for {0} not found", userID);
207 return new Dictionary<AssetType, InventoryFolderBase>();
208 }
209
210 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
211 {
212 return m_InventoryService.GetFolderContent(userID, folderID);
213 }
214
215
179 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 216 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
180 { 217 {
181 return m_InventoryService.GetFolderItems(userID, folderID); 218 return m_InventoryService.GetFolderItems(userID, folderID);
@@ -276,9 +313,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
276 /// </summary> 313 /// </summary>
277 /// <param name="userID"></param> 314 /// <param name="userID"></param>
278 /// <returns>null if no root folder was found</returns> 315 /// <returns>null if no root folder was found</returns>
279 public InventoryFolderBase RequestRootFolder(UUID userID) 316 public InventoryFolderBase GetRootFolder(UUID userID)
280 { 317 {
281 return m_InventoryService.RequestRootFolder(userID); 318 return m_InventoryService.GetRootFolder(userID);
282 } 319 }
283 320
284 public List<InventoryItemBase> GetActiveGestures(UUID userId) 321 public List<InventoryItemBase> GetActiveGestures(UUID userId)
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
index 107b588..dceda38 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
@@ -40,7 +40,7 @@ using OpenMetaverse;
40 40
41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory 41namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
42{ 42{
43 public class RemoteInventoryServicesConnector : ISharedRegionModule, IInventoryService 43 public class RemoteInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService
44 { 44 {
45 private static readonly ILog m_log = 45 private static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -69,9 +69,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
69 Init(source); 69 Init(source);
70 } 70 }
71 71
72 private void Init(IConfigSource source) 72 protected override void Init(IConfigSource source)
73 { 73 {
74 m_RemoteConnector = new InventoryServicesConnector(source); 74 m_RemoteConnector = new InventoryServicesConnector(source);
75 base.Init(source);
75 } 76 }
76 77
77 78
@@ -101,7 +102,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
101 { 102 {
102 } 103 }
103 104
104 public void AddRegion(Scene scene) 105 public override void AddRegion(Scene scene)
105 { 106 {
106 if (!m_Enabled) 107 if (!m_Enabled)
107 return; 108 return;
@@ -116,10 +117,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
116 } 117 }
117 118
118 scene.RegisterModuleInterface<IInventoryService>(this); 119 scene.RegisterModuleInterface<IInventoryService>(this);
120 base.AddRegion(scene);
119 } 121 }
120 122
121 public void RemoveRegion(Scene scene) 123 public override void RemoveRegion(Scene scene)
122 { 124 {
125 base.RemoveRegion(scene);
123 } 126 }
124 127
125 public void RegionLoaded(Scene scene) 128 public void RegionLoaded(Scene scene)
@@ -168,6 +171,34 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
168 171
169 } 172 }
170 173
174 // inherited. See base class
175 // public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
176
177 public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
178 {
179 UUID sessionID = GetSessionID(userID);
180 return m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID);
181 }
182
183 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
184 {
185 UUID sessionID = GetSessionID(userID);
186 try
187 {
188 return m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
189 }
190 catch (Exception e)
191 {
192 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}",
193 e.Source, e.Message);
194 }
195 InventoryCollection nullCollection = new InventoryCollection();
196 nullCollection.Folders = new List<InventoryFolderBase>();
197 nullCollection.Items = new List<InventoryItemBase>();
198 nullCollection.UserID = userID;
199 return nullCollection;
200 }
201
171 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 202 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
172 { 203 {
173 return new List<InventoryItemBase>(); 204 return new List<InventoryItemBase>();
@@ -259,7 +290,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
259 return false; 290 return false;
260 } 291 }
261 292
262 public InventoryFolderBase RequestRootFolder(UUID userID) 293 public InventoryFolderBase GetRootFolder(UUID userID)
263 { 294 {
264 return null; 295 return null;
265 } 296 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 4f2b6ec..0140faa 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -1319,17 +1319,17 @@ namespace OpenSim.Region.Framework.Scenes
1319 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); 1319 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
1320 } 1320 }
1321 1321
1322// private void Dump(string msg, List<ulong> handles) 1322 //private void Dump(string msg, List<ulong> handles)
1323// { 1323 //{
1324// m_log.Info"-------------- HANDLE DUMP ({0}) ---------", msg); 1324 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1325// foreach (ulong handle in handles) 1325 // foreach (ulong handle in handles)
1326// { 1326 // {
1327// uint x, y; 1327 // uint x, y;
1328// Utils.LongToUInts(handle, out x, out y); 1328 // Utils.LongToUInts(handle, out x, out y);
1329// x = x / Constants.RegionSize; 1329 // x = x / Constants.RegionSize;
1330// y = y / Constants.RegionSize; 1330 // y = y / Constants.RegionSize;
1331// m_log.Info("({0}, {1})", x, y); 1331 // m_log.InfoFormat("({0}, {1})", x, y);
1332// } 1332 // }
1333// } 1333 //}
1334 } 1334 }
1335} 1335}
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
index 3354b84..8d104ac 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
@@ -85,6 +85,14 @@ namespace OpenSim.Server.Handlers.Inventory
85 "POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); 85 "POST", "/GetInventory/", GetUserInventory, CheckAuthSession));
86 86
87 m_httpServer.AddStreamHandler( 87 m_httpServer.AddStreamHandler(
88 new RestDeserialiseSecureHandler<Guid, List<InventoryFolderBase>>(
89 "POST", "/SystemFolders/", GetSystemFolders, CheckAuthSession));
90
91 m_httpServer.AddStreamHandler(
92 new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
93 "POST", "/GetFolderContent/", GetFolderContent, CheckAuthSession));
94
95 m_httpServer.AddStreamHandler(
88 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( 96 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
89 "POST", "/UpdateFolder/", m_InventoryService.UpdateFolder, CheckAuthSession)); 97 "POST", "/UpdateFolder/", m_InventoryService.UpdateFolder, CheckAuthSession));
90 98
@@ -155,6 +163,40 @@ namespace OpenSim.Server.Handlers.Inventory
155 return m_InventoryService.GetUserInventory(userID); 163 return m_InventoryService.GetUserInventory(userID);
156 } 164 }
157 165
166 public List<InventoryFolderBase> GetSystemFolders(Guid guid)
167 {
168 UUID userID = new UUID(guid);
169 return new List<InventoryFolderBase>(GetSystemFolders(userID).Values);
170 }
171
172 // This shouldn't be here, it should be in the inventory service.
173 // But I don't want to deal with types and dependencies for now.
174 private Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
175 {
176 InventoryFolderBase root = m_InventoryService.GetRootFolder(userID);
177 if (root != null)
178 {
179 InventoryCollection content = m_InventoryService.GetFolderContent(userID, root.ID);
180 if (content != null)
181 {
182 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
183 foreach (InventoryFolderBase folder in content.Folders)
184 {
185 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
186 folders[(AssetType)folder.Type] = folder;
187 }
188 return folders;
189 }
190 }
191 m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
192 return new Dictionary<AssetType, InventoryFolderBase>();
193 }
194
195 public InventoryCollection GetFolderContent(Guid guid)
196 {
197 return m_InventoryService.GetFolderContent(UUID.Zero, new UUID(guid));
198 }
199
158 public List<InventoryItemBase> GetFolderItems(Guid folderID) 200 public List<InventoryItemBase> GetFolderItems(Guid folderID)
159 { 201 {
160 List<InventoryItemBase> allItems = new List<InventoryItemBase>(); 202 List<InventoryItemBase> allItems = new List<InventoryItemBase>();
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
index 01e517c..f6d1500 100644
--- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
@@ -120,6 +120,48 @@ namespace OpenSim.Services.Connectors.Inventory
120 120
121 } 121 }
122 122
123 /// <summary>
124 /// Gets the user folder for the given folder-type
125 /// </summary>
126 /// <param name="userID"></param>
127 /// <param name="type"></param>
128 /// <returns></returns>
129 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string id, UUID sessionID)
130 {
131 m_log.Debug("[HGInventory]: GetSystemFolders " + id);
132 string url = string.Empty;
133 string userID = string.Empty;
134
135 if (StringToUrlAndUserID(id, out url, out userID))
136 {
137 ISessionAuthInventoryService connector = GetConnector(url);
138 return connector.GetSystemFolders(userID, sessionID);
139 }
140
141 return new Dictionary<AssetType, InventoryFolderBase>();
142 }
143
144 /// <summary>
145 /// Gets everything (folders and items) inside a folder
146 /// </summary>
147 /// <param name="userId"></param>
148 /// <param name="folderID"></param>
149 /// <returns></returns>
150 public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID)
151 {
152 m_log.Debug("[HGInventory]: GetSystemFolders " + id);
153 string url = string.Empty;
154 string userID = string.Empty;
155
156 if (StringToUrlAndUserID(id, out url, out userID))
157 {
158 ISessionAuthInventoryService connector = GetConnector(url);
159 return connector.GetFolderContent(userID, folderID, sessionID);
160 }
161
162 return null;
163 }
164
123 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) 165 public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID)
124 { 166 {
125 string url = string.Empty; 167 string url = string.Empty;
diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
index 4fc4363..973cb0a 100644
--- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
+++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic;
28using OpenSim.Framework; 29using OpenSim.Framework;
29using OpenSim.Services.Interfaces; 30using OpenSim.Services.Interfaces;
30using OpenMetaverse; 31using OpenMetaverse;
@@ -51,6 +52,22 @@ namespace OpenSim.Services.Connectors
51 void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback); 52 void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback);
52 53
53 /// <summary> 54 /// <summary>
55 /// Gets the user folder for the given folder-type
56 /// </summary>
57 /// <param name="userID"></param>
58 /// <param name="type"></param>
59 /// <returns></returns>
60 Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID session_id);
61
62 /// <summary>
63 /// Gets everything (folders and items) inside a folder
64 /// </summary>
65 /// <param name="userId"></param>
66 /// <param name="folderID"></param>
67 /// <returns></returns>
68 InventoryCollection GetFolderContent(string userID, UUID folderID, UUID session_id);
69
70 /// <summary>
54 /// Add a new folder to the user's inventory 71 /// Add a new folder to the user's inventory
55 /// </summary> 72 /// </summary>
56 /// <param name="folder"></param> 73 /// <param name="folder"></param>
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
index ae15cfb..e41b427 100644
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
@@ -155,6 +155,55 @@ namespace OpenSim.Services.Connectors
155 } 155 }
156 } 156 }
157 157
158 /// <summary>
159 /// Gets the user folder for the given folder-type
160 /// </summary>
161 /// <param name="userID"></param>
162 /// <param name="type"></param>
163 /// <returns></returns>
164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
165 {
166 // !!! Not just yet.
167 //try
168 //{
169 // List<InventoryFolderBase> folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
170 // "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
171 // Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>();
172 // foreach (InventoryFolderBase f in folders)
173 // dFolders[(AssetType)f.Type] = f;
174 // return dFolders;
175 //}
176 //catch (Exception e)
177 //{
178 // m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}",
179 // e.Source, e.Message);
180 //}
181
182 return new Dictionary<AssetType, InventoryFolderBase>();
183 }
184
185 /// <summary>
186 /// Gets everything (folders and items) inside a folder
187 /// </summary>
188 /// <param name="userId"></param>
189 /// <param name="folderID"></param>
190 /// <returns></returns>
191 public InventoryCollection GetFolderContent(string userID, UUID folderID, UUID sessionID)
192 {
193 try
194 {
195 return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
196 "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString());
197 }
198 catch (Exception e)
199 {
200 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}",
201 e.Source, e.Message);
202 }
203
204 return null;
205 }
206
158 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID) 207 public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID)
159 { 208 {
160 try 209 try
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
index 6a93c04..22289aa 100644
--- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
@@ -106,6 +106,16 @@ namespace OpenSim.Services.Connectors
106 { 106 {
107 } 107 }
108 108
109 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
110 {
111 return null;
112 }
113
114 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
115 {
116 return null;
117 }
118
109 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) 119 public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
110 { 120 {
111 return null; 121 return null;
@@ -161,7 +171,7 @@ namespace OpenSim.Services.Connectors
161 return false; 171 return false;
162 } 172 }
163 173
164 public InventoryFolderBase RequestRootFolder(UUID userID) 174 public InventoryFolderBase GetRootFolder(UUID userID)
165 { 175 {
166 return null; 176 return null;
167 } 177 }
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs
index 15da3cb..8058aa7 100644
--- a/OpenSim/Services/Interfaces/IInventoryService.cs
+++ b/OpenSim/Services/Interfaces/IInventoryService.cs
@@ -70,6 +70,29 @@ namespace OpenSim.Services.Interfaces
70 void GetUserInventory(UUID userID, InventoryReceiptCallback callback); 70 void GetUserInventory(UUID userID, InventoryReceiptCallback callback);
71 71
72 /// <summary> 72 /// <summary>
73 /// Retrieve the root inventory folder for the given user.
74 /// </summary>
75 /// <param name="userID"></param>
76 /// <returns>null if no root folder was found</returns>
77 InventoryFolderBase GetRootFolder(UUID userID);
78
79 /// <summary>
80 /// Gets the user folder for the given folder-type
81 /// </summary>
82 /// <param name="userID"></param>
83 /// <param name="type"></param>
84 /// <returns></returns>
85 InventoryFolderBase GetFolderForType(UUID userID, AssetType type);
86
87 /// <summary>
88 /// Gets everything (folders and items) inside a folder
89 /// </summary>
90 /// <param name="userId"></param>
91 /// <param name="folderID"></param>
92 /// <returns></returns>
93 InventoryCollection GetFolderContent(UUID userID, UUID folderID);
94
95 /// <summary>
73 /// Gets the items inside a folder 96 /// Gets the items inside a folder
74 /// </summary> 97 /// </summary>
75 /// <param name="userID"></param> 98 /// <param name="userID"></param>
@@ -138,13 +161,6 @@ namespace OpenSim.Services.Interfaces
138 bool HasInventoryForUser(UUID userID); 161 bool HasInventoryForUser(UUID userID);
139 162
140 /// <summary> 163 /// <summary>
141 /// Retrieve the root inventory folder for the given user.
142 /// </summary>
143 /// <param name="userID"></param>
144 /// <returns>null if no root folder was found</returns>
145 InventoryFolderBase RequestRootFolder(UUID userID);
146
147 /// <summary>
148 /// Get the active gestures of the agent. 164 /// Get the active gestures of the agent.
149 /// </summary> 165 /// </summary>
150 /// <param name="userId"></param> 166 /// <param name="userId"></param>
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs
index ea34195..a9ecda4 100644
--- a/OpenSim/Services/InventoryService/InventoryService.cs
+++ b/OpenSim/Services/InventoryService/InventoryService.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Services.InventoryService
60 { 60 {
61 m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId); 61 m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId);
62 62
63 InventoryFolderBase rootFolder = RequestRootFolder(userId); 63 InventoryFolderBase rootFolder = GetRootFolder(userId);
64 64
65 // Agent has no inventory structure yet. 65 // Agent has no inventory structure yet.
66 if (null == rootFolder) 66 if (null == rootFolder)
@@ -86,7 +86,7 @@ namespace OpenSim.Services.InventoryService
86 } 86 }
87 87
88 // See IInventoryServices 88 // See IInventoryServices
89 public virtual InventoryFolderBase RequestRootFolder(UUID userID) 89 public virtual InventoryFolderBase GetRootFolder(UUID userID)
90 { 90 {
91 // Retrieve the first root folder we get from the DB. 91 // Retrieve the first root folder we get from the DB.
92 InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID); 92 InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID);
@@ -100,7 +100,7 @@ namespace OpenSim.Services.InventoryService
100 // See IInventoryServices 100 // See IInventoryServices
101 public bool CreateUserInventory(UUID user) 101 public bool CreateUserInventory(UUID user)
102 { 102 {
103 InventoryFolderBase existingRootFolder = RequestRootFolder(user); 103 InventoryFolderBase existingRootFolder = GetRootFolder(user);
104 104
105 if (null != existingRootFolder) 105 if (null != existingRootFolder)
106 { 106 {
@@ -233,6 +233,67 @@ namespace OpenSim.Services.InventoryService
233 callback.BeginInvoke(folders, items, null, null); 233 callback.BeginInvoke(folders, items, null, null);
234 } 234 }
235 235
236 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
237 {
238 m_log.Info("[INVENTORY SERVICE]: Processing request for folder " + folderID);
239
240 // Uncomment me to simulate a slow responding inventory server
241 //Thread.Sleep(16000);
242
243 InventoryCollection invCollection = new InventoryCollection();
244
245 List<InventoryItemBase> items = GetFolderItems(userID, folderID);
246 List<InventoryFolderBase> folders = RequestSubFolders(folderID);
247
248 invCollection.UserID = userID;
249 invCollection.Folders = folders;
250 invCollection.Items = items;
251
252 m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders", items.Count, folders.Count);
253
254 return invCollection;
255 }
256
257 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
258 {
259 InventoryFolderBase root = m_Database.getUserRootFolder(userID);
260 if (root != null)
261 {
262 List<InventoryFolderBase> folders = RequestSubFolders(root.ID);
263
264 foreach (InventoryFolderBase folder in folders)
265 {
266 if (folder.Type == (short)type)
267 return folder;
268 }
269 }
270
271 // we didn't find any folder of that type. Return the root folder
272 // hopefully the root folder is not null. If it is, too bad
273 return root;
274 }
275
276 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
277 {
278 InventoryFolderBase root = GetRootFolder(userID);
279 if (root != null)
280 {
281 InventoryCollection content = GetFolderContent(userID, root.ID);
282 if (content != null)
283 {
284 Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
285 foreach (InventoryFolderBase folder in content.Folders)
286 {
287 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
288 folders[(AssetType)folder.Type] = folder;
289 }
290 return folders;
291 }
292 }
293 m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
294 return new Dictionary<AssetType, InventoryFolderBase>();
295 }
296
236 public List<InventoryItemBase> GetActiveGestures(UUID userId) 297 public List<InventoryItemBase> GetActiveGestures(UUID userId)
237 { 298 {
238 List<InventoryItemBase> activeGestures = new List<InventoryItemBase>(); 299 List<InventoryItemBase> activeGestures = new List<InventoryItemBase>();
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
index cf1a3a9..0c19164 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
@@ -43,6 +43,21 @@ namespace OpenSim.Tests.Common.Mock
43 return folders; 43 return folders;
44 } 44 }
45 45
46 public InventoryFolderBase GetRootFolder(UUID userID)
47 {
48 return new InventoryFolderBase();
49 }
50
51 public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
52 {
53 return null;
54 }
55
56 public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
57 {
58 return null;
59 }
60
46 /// <summary> 61 /// <summary>
47 /// Returns a list of all the active gestures in a user's inventory. 62 /// Returns a list of all the active gestures in a user's inventory.
48 /// </summary> 63 /// </summary>
diff --git a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
index fc41166..f146a15 100644
--- a/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
+++ b/OpenSim/Tests/Common/Setup/UserProfileTestUtils.cs
@@ -41,28 +41,58 @@ namespace OpenSim.Tests.Common.Setup
41 /// Create a test user with a standard inventory 41 /// Create a test user with a standard inventory
42 /// </summary> 42 /// </summary>
43 /// <param name="commsManager"></param> 43 /// <param name="commsManager"></param>
44 /// <param name="callback">
45 /// Callback to invoke when inventory has been loaded. This is required because
46 /// loading may be asynchronous, even on standalone
47 /// </param>
44 /// <returns></returns> 48 /// <returns></returns>
45 public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager) 49 public static CachedUserInfo CreateUserWithInventory(
50 CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
46 { 51 {
47 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099"); 52 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
48 return CreateUserWithInventory(commsManager, userId); 53 return CreateUserWithInventory(commsManager, userId, callback);
49 } 54 }
50 55
51 /// <summary> 56 /// <summary>
52 /// Create a test user with a standard inventory 57 /// Create a test user with a standard inventory
53 /// </summary> 58 /// </summary>
54 /// <param name="commsManager"></param> 59 /// <param name="commsManager"></param>
55 /// <param name="userId">Explicit user id to use for user creation</param> 60 /// <param name="userId">User ID</param>
61 /// <param name="callback">
62 /// Callback to invoke when inventory has been loaded. This is required because
63 /// loading may be asynchronous, even on standalone
64 /// </param>
56 /// <returns></returns> 65 /// <returns></returns>
57 public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId) 66 public static CachedUserInfo CreateUserWithInventory(
67 CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
68 {
69 return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
70 }
71
72 /// <summary>
73 /// Create a test user with a standard inventory
74 /// </summary>
75 /// <param name="commsManager"></param>
76 /// <param name="firstName">First name of user</param>
77 /// <param name="lastName">Last name of user</param>
78 /// <param name="userId">User ID</param>
79 /// <param name="callback">
80 /// Callback to invoke when inventory has been loaded. This is required because
81 /// loading may be asynchronous, even on standalone
82 /// </param>
83 /// <returns></returns>
84 public static CachedUserInfo CreateUserWithInventory(
85 CommunicationsManager commsManager, string firstName, string lastName,
86 UUID userId, OnInventoryReceivedDelegate callback)
58 { 87 {
59 LocalUserServices lus = (LocalUserServices)commsManager.UserService; 88 LocalUserServices lus = (LocalUserServices)commsManager.UserService;
60 lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); 89 lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
61 90
62 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); 91 CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
92 userInfo.OnInventoryReceived += callback;
63 userInfo.FetchInventory(); 93 userInfo.FetchInventory();
64 94
65 return userInfo; 95 return userInfo;
66 } 96 }
67 } 97 }
68} 98}