aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs33
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs29
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs13
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs3
-rw-r--r--OpenSim/Services/InventoryService/LibraryService.cs283
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs34
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs24
-rw-r--r--bin/config-include/StandaloneHypergrid.ini5
-rw-r--r--prebuild.xml1
13 files changed, 421 insertions, 58 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 0ec2ed5..25026a6 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -6962,7 +6962,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6962 assetRequestItem = invService.GetItem(assetRequestItem); 6962 assetRequestItem = invService.GetItem(assetRequestItem);
6963 if (assetRequestItem == null) 6963 if (assetRequestItem == null)
6964 { 6964 {
6965 assetRequestItem = ((Scene)m_scene).CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 6965 ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
6966 if (lib != null)
6967 assetRequestItem = lib.LibraryRootFolder.FindItem(itemID);
6966 if (assetRequestItem == null) 6968 if (assetRequestItem == null)
6967 return true; 6969 return true;
6968 } 6970 }
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
index 6941e00..f1022fd 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
@@ -37,6 +37,7 @@ using OpenSim.Region.Framework;
37using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Server.Base;
40 41
41using OpenMetaverse; 42using OpenMetaverse;
42using log4net; 43using log4net;
@@ -53,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.Library
53 private string m_LibraryName = "OpenSim Library"; 54 private string m_LibraryName = "OpenSim Library";
54 private Scene m_Scene; 55 private Scene m_Scene;
55 56
57 private ILibraryService m_Library;
58
56 #region ISharedRegionModule 59 #region ISharedRegionModule
57 60
58 public void Initialise(IConfigSource config) 61 public void Initialise(IConfigSource config)
@@ -60,9 +63,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library
60 m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); 63 m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled);
61 if (m_Enabled) 64 if (m_Enabled)
62 { 65 {
63 IConfig libConfig = config.Configs["LibraryModule"]; 66 IConfig libConfig = config.Configs["LibraryService"];
64 if (libConfig != null) 67 if (libConfig != null)
65 m_LibraryName = libConfig.GetString("LibraryName", m_LibraryName); 68 {
69 string dllName = libConfig.GetString("LocalServiceModule", string.Empty);
70 m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName);
71 if (dllName != string.Empty)
72 {
73 Object[] args = new Object[] { config };
74 m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args);
75 }
76 }
77 }
78 if (m_Library == null)
79 {
80 m_log.Warn("[LIBRARY MODULE]: No local library service. Module will be disabled.");
81 m_Enabled = false;
66 } 82 }
67 } 83 }
68 84
@@ -91,10 +107,15 @@ namespace OpenSim.Region.CoreModules.Framework.Library
91 { 107 {
92 m_Scene = scene; 108 m_Scene = scene;
93 } 109 }
110 scene.RegisterModuleInterface<ILibraryService>(m_Library);
94 } 111 }
95 112
96 public void RemoveRegion(Scene scene) 113 public void RemoveRegion(Scene scene)
97 { 114 {
115 if (!m_Enabled)
116 return;
117
118 scene.UnregisterModuleInterface<ILibraryService>(m_Library);
98 } 119 }
99 120
100 public void RegionLoaded(Scene scene) 121 public void RegionLoaded(Scene scene)
@@ -127,19 +148,17 @@ namespace OpenSim.Region.CoreModules.Framework.Library
127 148
128 protected void LoadLibrariesFromArchives() 149 protected void LoadLibrariesFromArchives()
129 { 150 {
130 InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; 151 InventoryFolderImpl lib = m_Library.LibraryRootFolder;
131 if (lib == null) 152 if (lib == null)
132 { 153 {
133 m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module"); 154 m_log.Debug("[LIBRARY MODULE]: No library. Ignoring Library Module");
134 return; 155 return;
135 } 156 }
136 157
137 lib.Name = m_LibraryName;
138
139 RegionInfo regInfo = new RegionInfo(); 158 RegionInfo regInfo = new RegionInfo();
140 Scene m_MockScene = new Scene(regInfo); 159 Scene m_MockScene = new Scene(regInfo);
141 m_MockScene.CommsManager = m_Scene.CommsManager; 160 m_MockScene.CommsManager = m_Scene.CommsManager;
142 LocalInventoryService invService = new LocalInventoryService((LibraryRootFolder)lib); 161 LocalInventoryService invService = new LocalInventoryService(lib);
143 m_MockScene.RegisterModuleInterface<IInventoryService>(invService); 162 m_MockScene.RegisterModuleInterface<IInventoryService>(invService);
144 m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); 163 m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService);
145 164
@@ -181,7 +200,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
181 200
182 private void DumpLibrary() 201 private void DumpLibrary()
183 { 202 {
184 InventoryFolderImpl lib = m_Scene.CommsManager.UserProfileCacheService.LibraryRoot; 203 InventoryFolderImpl lib = m_Library.LibraryRootFolder;
185 204
186 m_log.DebugFormat(" - folder {0}", lib.Name); 205 m_log.DebugFormat(" - folder {0}", lib.Name);
187 DumpFolder(lib); 206 DumpFolder(lib);
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs
index 2c95b5a..685c031 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs
@@ -41,9 +41,9 @@ namespace OpenSim.Region.CoreModules.Framework.Library
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private LibraryRootFolder m_Library; 44 private InventoryFolderImpl m_Library;
45 45
46 public LocalInventoryService(LibraryRootFolder lib) 46 public LocalInventoryService(InventoryFolderImpl lib)
47 { 47 {
48 m_Library = lib; 48 m_Library = lib;
49 } 49 }
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
index c9b3071..91c0a53 100644
--- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
@@ -95,6 +95,23 @@ namespace OpenSim.Region.CoreModules.World.Permissions
95 95
96 protected Scene m_scene; 96 protected Scene m_scene;
97 97
98 private InventoryFolderImpl m_libraryRootFolder;
99 protected InventoryFolderImpl LibraryRootFolder
100 {
101 get
102 {
103 if (m_libraryRootFolder != null)
104 return m_libraryRootFolder;
105
106 ILibraryService lib = m_scene.RequestModuleInterface<ILibraryService>();
107 if (lib != null)
108 {
109 m_libraryRootFolder = lib.LibraryRootFolder;
110 }
111 return m_libraryRootFolder;
112 }
113 }
114
98 #region Constants 115 #region Constants
99 // These are here for testing. They will be taken out 116 // These are here for testing. They will be taken out
100 117
@@ -1005,9 +1022,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1005 IInventoryService invService = m_scene.InventoryService; 1022 IInventoryService invService = m_scene.InventoryService;
1006 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); 1023 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
1007 assetRequestItem = invService.GetItem(assetRequestItem); 1024 assetRequestItem = invService.GetItem(assetRequestItem);
1008 if (assetRequestItem == null) // Library item 1025 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1009 { 1026 {
1010 assetRequestItem = scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); 1027 assetRequestItem = LibraryRootFolder.FindItem(notecard);
1011 1028
1012 if (assetRequestItem != null) // Implicitly readable 1029 if (assetRequestItem != null) // Implicitly readable
1013 return true; 1030 return true;
@@ -1425,9 +1442,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1425 IInventoryService invService = m_scene.InventoryService; 1442 IInventoryService invService = m_scene.InventoryService;
1426 InventoryItemBase assetRequestItem = new InventoryItemBase(script, user); 1443 InventoryItemBase assetRequestItem = new InventoryItemBase(script, user);
1427 assetRequestItem = invService.GetItem(assetRequestItem); 1444 assetRequestItem = invService.GetItem(assetRequestItem);
1428 if (assetRequestItem == null) // Library item 1445 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1429 { 1446 {
1430 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(script); 1447 assetRequestItem = LibraryRootFolder.FindItem(script);
1431 1448
1432 if (assetRequestItem != null) // Implicitly readable 1449 if (assetRequestItem != null) // Implicitly readable
1433 return true; 1450 return true;
@@ -1520,9 +1537,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions
1520 IInventoryService invService = m_scene.InventoryService; 1537 IInventoryService invService = m_scene.InventoryService;
1521 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user); 1538 InventoryItemBase assetRequestItem = new InventoryItemBase(notecard, user);
1522 assetRequestItem = invService.GetItem(assetRequestItem); 1539 assetRequestItem = invService.GetItem(assetRequestItem);
1523 if (assetRequestItem == null) // Library item 1540 if (assetRequestItem == null && LibraryRootFolder != null) // Library item
1524 { 1541 {
1525 assetRequestItem = m_scene.CommsManager.UserProfileCacheService.LibraryRoot.FindItem(notecard); 1542 assetRequestItem = LibraryRootFolder.FindItem(notecard);
1526 1543
1527 if (assetRequestItem != null) // Implicitly readable 1544 if (assetRequestItem != null) // Implicitly readable
1528 return true; 1545 return true;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 89ce4ae..f322af3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -573,7 +573,9 @@ namespace OpenSim.Region.Framework.Scenes
573 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 573 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
574 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 574 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
575 575
576 InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); 576 InventoryItemBase item = null;
577 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
578 item = LibraryService.LibraryRootFolder.FindItem(oldItemID);
577 579
578 if (item == null) 580 if (item == null)
579 { 581 {
@@ -1211,9 +1213,9 @@ namespace OpenSim.Region.Framework.Scenes
1211 item = InventoryService.GetItem(item); 1213 item = InventoryService.GetItem(item);
1212 1214
1213 // Try library 1215 // Try library
1214 if (null == item) 1216 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1215 { 1217 {
1216 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1218 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1217 } 1219 }
1218 1220
1219 if (item != null) 1221 if (item != null)
@@ -1280,9 +1282,9 @@ namespace OpenSim.Region.Framework.Scenes
1280 1282
1281 // Try library 1283 // Try library
1282 // XXX clumsy, possibly should be one call 1284 // XXX clumsy, possibly should be one call
1283 if (null == item) 1285 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1284 { 1286 {
1285 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1287 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1286 } 1288 }
1287 1289
1288 if (item != null) 1290 if (item != null)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 47fbeb4..022d79d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes
424 /// <param name="ownerID"></param> 424 /// <param name="ownerID"></param>
425 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) 425 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
426 { 426 {
427 if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) 427 if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner)
428 { 428 {
429 //m_log.Debug("request info for library item"); 429 //m_log.Debug("request info for library item");
430 return; 430 return;
@@ -458,13 +458,14 @@ namespace OpenSim.Region.Framework.Scenes
458 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 458 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
459 // can be handled transparently). 459 // can be handled transparently).
460 InventoryFolderImpl fold = null; 460 InventoryFolderImpl fold = null;
461 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 461 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
462 { 462 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
463 remoteClient.SendInventoryFolderDetails( 463 {
464 fold.Owner, folderID, fold.RequestListOfItems(), 464 remoteClient.SendInventoryFolderDetails(
465 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); 465 fold.Owner, folderID, fold.RequestListOfItems(),
466 return; 466 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems);
467 } 467 return;
468 }
468 469
469 // We're going to send the reply async, because there may be 470 // We're going to send the reply async, because there may be
470 // an enormous quantity of packets -- basically the entire inventory! 471 // an enormous quantity of packets -- basically the entire inventory!
@@ -512,15 +513,16 @@ namespace OpenSim.Region.Framework.Scenes
512 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 513 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
513 // can be handled transparently). 514 // can be handled transparently).
514 InventoryFolderImpl fold; 515 InventoryFolderImpl fold;
515 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 516 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
516 { 517 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
517 version = 0; 518 {
518 InventoryCollection ret = new InventoryCollection(); 519 version = 0;
519 ret.Folders = new List<InventoryFolderBase>(); 520 InventoryCollection ret = new InventoryCollection();
520 ret.Items = fold.RequestListOfItems(); 521 ret.Folders = new List<InventoryFolderBase>();
522 ret.Items = fold.RequestListOfItems();
521 523
522 return ret; 524 return ret;
523 } 525 }
524 526
525 InventoryCollection contents = new InventoryCollection(); 527 InventoryCollection contents = new InventoryCollection();
526 528
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 418cfbf..ae189b5 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -240,6 +240,19 @@ namespace OpenSim.Region.Framework.Scenes
240 } 240 }
241 } 241 }
242 242
243 protected ILibraryService m_LibraryService;
244
245 public ILibraryService LibraryService
246 {
247 get
248 {
249 if (m_LibraryService == null)
250 m_LibraryService = RequestModuleInterface<ILibraryService>();
251
252 return m_LibraryService;
253 }
254 }
255
243 protected IXMLRPC m_xmlrpcModule; 256 protected IXMLRPC m_xmlrpcModule;
244 protected IWorldComm m_worldCommModule; 257 protected IWorldComm m_worldCommModule;
245 protected IAvatarFactory m_AvatarFactory; 258 protected IAvatarFactory m_AvatarFactory;
diff --git a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
index d5e073c..e24055b 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginServiceInConnector.cs
@@ -51,8 +51,9 @@ namespace OpenSim.Server.Handlers.Login
51 string loginService = ReadLocalServiceFromConfig(config); 51 string loginService = ReadLocalServiceFromConfig(config);
52 52
53 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>(); 53 ISimulationService simService = scene.RequestModuleInterface<ISimulationService>();
54 ILibraryService libService = scene.RequestModuleInterface<ILibraryService>();
54 55
55 Object[] args = new Object[] { config, simService }; 56 Object[] args = new Object[] { config, simService, libService };
56 m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args); 57 m_LoginService = ServerUtils.LoadPlugin<ILoginService>(loginService, args);
57 58
58 InitializeHandlers(server); 59 InitializeHandlers(server);
diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs
new file mode 100644
index 0000000..383f311
--- /dev/null
+++ b/OpenSim/Services/InventoryService/LibraryService.cs
@@ -0,0 +1,283 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Xml;
33
34using OpenSim.Framework;
35using OpenSim.Services.Base;
36using OpenSim.Services.Interfaces;
37
38using log4net;
39using Nini.Config;
40using OpenMetaverse;
41
42namespace OpenSim.Services.InventoryService
43{
44 /// <summary>
45 /// Basically a hack to give us a Inventory library while we don't have a inventory server
46 /// once the server is fully implemented then should read the data from that
47 /// </summary>
48 public class LibraryService : ServiceBase, ILibraryService
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private InventoryFolderImpl m_LibraryRootFolder;
53
54 public InventoryFolderImpl LibraryRootFolder
55 {
56 get { return m_LibraryRootFolder; }
57 }
58
59 private UUID libOwner = new UUID("11111111-1111-0000-0000-000100bba000");
60
61 /// <summary>
62 /// Holds the root library folder and all its descendents. This is really only used during inventory
63 /// setup so that we don't have to repeatedly search the tree of library folders.
64 /// </summary>
65 protected Dictionary<UUID, InventoryFolderImpl> libraryFolders
66 = new Dictionary<UUID, InventoryFolderImpl>();
67
68 public LibraryService(IConfigSource config)
69 : base(config)
70 {
71 string pLibrariesLocation = Path.Combine("inventory", "Libraries.xml");
72 string pLibName = "OpenSim Library";
73
74 IConfig libConfig = config.Configs["LibraryService"];
75 if (libConfig != null)
76 {
77 pLibrariesLocation = libConfig.GetString("DefaultLibrary", pLibrariesLocation);
78 pLibName = libConfig.GetString("LibraryName", pLibName);
79 }
80
81 m_log.Debug("[LIBRARY]: Starting library service...");
82
83 m_LibraryRootFolder = new InventoryFolderImpl();
84 m_LibraryRootFolder.Owner = libOwner;
85 m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000");
86 m_LibraryRootFolder.Name = pLibName;
87 m_LibraryRootFolder.ParentID = UUID.Zero;
88 m_LibraryRootFolder.Type = (short)8;
89 m_LibraryRootFolder.Version = (ushort)1;
90
91 libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
92
93 LoadLibraries(pLibrariesLocation);
94 }
95
96 public InventoryItemBase CreateItem(UUID inventoryID, UUID assetID, string name, string description,
97 int assetType, int invType, UUID parentFolderID)
98 {
99 InventoryItemBase item = new InventoryItemBase();
100 item.Owner = libOwner;
101 item.CreatorId = libOwner.ToString();
102 item.ID = inventoryID;
103 item.AssetID = assetID;
104 item.Description = description;
105 item.Name = name;
106 item.AssetType = assetType;
107 item.InvType = invType;
108 item.Folder = parentFolderID;
109 item.BasePermissions = 0x7FFFFFFF;
110 item.EveryOnePermissions = 0x7FFFFFFF;
111 item.CurrentPermissions = 0x7FFFFFFF;
112 item.NextPermissions = 0x7FFFFFFF;
113 return item;
114 }
115
116 /// <summary>
117 /// Use the asset set information at path to load assets
118 /// </summary>
119 /// <param name="path"></param>
120 /// <param name="assets"></param>
121 protected void LoadLibraries(string librariesControlPath)
122 {
123 m_log.InfoFormat("[LIBRARY INVENTORY]: Loading library control file {0}", librariesControlPath);
124 LoadFromFile(librariesControlPath, "Libraries control", ReadLibraryFromConfig);
125 }
126
127 /// <summary>
128 /// Read a library set from config
129 /// </summary>
130 /// <param name="config"></param>
131 protected void ReadLibraryFromConfig(IConfig config, string path)
132 {
133 string basePath = Path.GetDirectoryName(path);
134 string foldersPath
135 = Path.Combine(
136 basePath, config.GetString("foldersFile", String.Empty));
137
138 LoadFromFile(foldersPath, "Library folders", ReadFolderFromConfig);
139
140 string itemsPath
141 = Path.Combine(
142 basePath, config.GetString("itemsFile", String.Empty));
143
144 LoadFromFile(itemsPath, "Library items", ReadItemFromConfig);
145 }
146
147 /// <summary>
148 /// Read a library inventory folder from a loaded configuration
149 /// </summary>
150 /// <param name="source"></param>
151 private void ReadFolderFromConfig(IConfig config, string path)
152 {
153 InventoryFolderImpl folderInfo = new InventoryFolderImpl();
154
155 folderInfo.ID = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString()));
156 folderInfo.Name = config.GetString("name", "unknown");
157 folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString()));
158 folderInfo.Type = (short)config.GetInt("type", 8);
159
160 folderInfo.Owner = libOwner;
161 folderInfo.Version = 1;
162
163 if (libraryFolders.ContainsKey(folderInfo.ParentID))
164 {
165 InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID];
166
167 libraryFolders.Add(folderInfo.ID, folderInfo);
168 parentFolder.AddChildFolder(folderInfo);
169
170// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
171 }
172 else
173 {
174 m_log.WarnFormat(
175 "[LIBRARY INVENTORY]: Couldn't add folder {0} ({1}) since parent folder with ID {2} does not exist!",
176 folderInfo.Name, folderInfo.ID, folderInfo.ParentID);
177 }
178 }
179
180 /// <summary>
181 /// Read a library inventory item metadata from a loaded configuration
182 /// </summary>
183 /// <param name="source"></param>
184 private void ReadItemFromConfig(IConfig config, string path)
185 {
186 InventoryItemBase item = new InventoryItemBase();
187 item.Owner = libOwner;
188 item.CreatorId = libOwner.ToString();
189 item.ID = new UUID(config.GetString("inventoryID", m_LibraryRootFolder.ID.ToString()));
190 item.AssetID = new UUID(config.GetString("assetID", item.ID.ToString()));
191 item.Folder = new UUID(config.GetString("folderID", m_LibraryRootFolder.ID.ToString()));
192 item.Name = config.GetString("name", String.Empty);
193 item.Description = config.GetString("description", item.Name);
194 item.InvType = config.GetInt("inventoryType", 0);
195 item.AssetType = config.GetInt("assetType", item.InvType);
196 item.CurrentPermissions = (uint)config.GetLong("currentPermissions", 0x7FFFFFFF);
197 item.NextPermissions = (uint)config.GetLong("nextPermissions", 0x7FFFFFFF);
198 item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", 0x7FFFFFFF);
199 item.BasePermissions = (uint)config.GetLong("basePermissions", 0x7FFFFFFF);
200 item.Flags = (uint)config.GetInt("flags", 0);
201
202 if (libraryFolders.ContainsKey(item.Folder))
203 {
204 InventoryFolderImpl parentFolder = libraryFolders[item.Folder];
205 try
206 {
207 parentFolder.Items.Add(item.ID, item);
208 }
209 catch (Exception)
210 {
211 m_log.WarnFormat("[LIBRARY INVENTORY] Item {1} [{0}] not added, duplicate item", item.ID, item.Name);
212 }
213 }
214 else
215 {
216 m_log.WarnFormat(
217 "[LIBRARY INVENTORY]: Couldn't add item {0} ({1}) since parent folder with ID {2} does not exist!",
218 item.Name, item.ID, item.Folder);
219 }
220 }
221
222 private delegate void ConfigAction(IConfig config, string path);
223
224 /// <summary>
225 /// Load the given configuration at a path and perform an action on each Config contained within it
226 /// </summary>
227 /// <param name="path"></param>
228 /// <param name="fileDescription"></param>
229 /// <param name="action"></param>
230 private static void LoadFromFile(string path, string fileDescription, ConfigAction action)
231 {
232 if (File.Exists(path))
233 {
234 try
235 {
236 XmlConfigSource source = new XmlConfigSource(path);
237
238 for (int i = 0; i < source.Configs.Count; i++)
239 {
240 action(source.Configs[i], path);
241 }
242 }
243 catch (XmlException e)
244 {
245 m_log.ErrorFormat("[LIBRARY INVENTORY]: Error loading {0} : {1}", path, e);
246 }
247 }
248 else
249 {
250 m_log.ErrorFormat("[LIBRARY INVENTORY]: {0} file {1} does not exist!", fileDescription, path);
251 }
252 }
253
254 /// <summary>
255 /// Looks like a simple getter, but is written like this for some consistency with the other Request
256 /// methods in the superclass
257 /// </summary>
258 /// <returns></returns>
259 public Dictionary<UUID, InventoryFolderImpl> GetAllFolders()
260 {
261 Dictionary<UUID, InventoryFolderImpl> fs = new Dictionary<UUID, InventoryFolderImpl>();
262 fs.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
263 List<InventoryFolderImpl> fis = TraverseFolder(m_LibraryRootFolder);
264 foreach (InventoryFolderImpl f in fis)
265 {
266 fs.Add(f.ID, f);
267 }
268 //return libraryFolders;
269 return fs;
270 }
271
272 private List<InventoryFolderImpl> TraverseFolder(InventoryFolderImpl node)
273 {
274 List<InventoryFolderImpl> folders = node.RequestListOfFolderImpls();
275 List<InventoryFolderImpl> subs = new List<InventoryFolderImpl>();
276 foreach (InventoryFolderImpl f in folders)
277 subs.AddRange(TraverseFolder(f));
278
279 folders.AddRange(subs);
280 return folders;
281 }
282 }
283}
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index c80ab7f..4db6a05 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -215,12 +215,12 @@ namespace OpenSim.Services.LLLoginService
215 } 215 }
216 216
217 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, 217 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo,
218 GridRegion destination, List<InventoryFolderBase> invSkel, 218 GridRegion destination, List<InventoryFolderBase> invSkel, ILibraryService libService,
219 string where, string startlocation, Vector3 position, Vector3 lookAt, string message, 219 string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
220 GridRegion home, IPEndPoint clientIP) 220 GridRegion home, IPEndPoint clientIP)
221 : this() 221 : this()
222 { 222 {
223 FillOutInventoryData(invSkel); 223 FillOutInventoryData(invSkel, libService);
224 224
225 CircuitCode = (int)aCircuit.circuitcode; 225 CircuitCode = (int)aCircuit.circuitcode;
226 Lastname = account.LastName; 226 Lastname = account.LastName;
@@ -243,7 +243,7 @@ namespace OpenSim.Services.LLLoginService
243 243
244 } 244 }
245 245
246 private void FillOutInventoryData(List<InventoryFolderBase> invSkel) 246 private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService)
247 { 247 {
248 InventoryData inventData = null; 248 InventoryData inventData = null;
249 249
@@ -272,13 +272,16 @@ namespace OpenSim.Services.LLLoginService
272 } 272 }
273 273
274 // Inventory Library Section 274 // Inventory Library Section
275 Hashtable InventoryLibRootHash = new Hashtable(); 275 if (libService != null && libService.LibraryRootFolder != null)
276 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 276 {
277 InventoryLibRoot = new ArrayList(); 277 Hashtable InventoryLibRootHash = new Hashtable();
278 InventoryLibRoot.Add(InventoryLibRootHash); 278 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
279 InventoryLibRoot = new ArrayList();
280 InventoryLibRoot.Add(InventoryLibRootHash);
279 281
280 InventoryLibraryOwner = GetLibraryOwner(); 282 InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder);
281 InventoryLibrary = GetInventoryLibrary(); 283 InventoryLibrary = GetInventoryLibrary(libService);
284 }
282 } 285 }
283 286
284 private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) 287 private void FillOutHomeData(PresenceInfo pinfo, GridRegion home)
@@ -646,12 +649,11 @@ namespace OpenSim.Services.LLLoginService
646 /// Converts the inventory library skeleton into the form required by the rpc request. 649 /// Converts the inventory library skeleton into the form required by the rpc request.
647 /// </summary> 650 /// </summary>
648 /// <returns></returns> 651 /// <returns></returns>
649 protected virtual ArrayList GetInventoryLibrary() 652 protected virtual ArrayList GetInventoryLibrary(ILibraryService library)
650 { 653 {
651 // While we don't have library... 654 Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders();
652 //Dictionary<UUID, InventoryFolderImpl> rootFolders 655 m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count);
653 // = m_libraryRootFolder.RequestSelfAndDescendentFolders(); 656 //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
654 Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
655 ArrayList folderHashes = new ArrayList(); 657 ArrayList folderHashes = new ArrayList();
656 658
657 foreach (InventoryFolderBase folder in rootFolders.Values) 659 foreach (InventoryFolderBase folder in rootFolders.Values)
@@ -672,11 +674,11 @@ namespace OpenSim.Services.LLLoginService
672 /// 674 ///
673 /// </summary> 675 /// </summary>
674 /// <returns></returns> 676 /// <returns></returns>
675 protected virtual ArrayList GetLibraryOwner() 677 protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder)
676 { 678 {
677 //for now create random inventory library owner 679 //for now create random inventory library owner
678 Hashtable TempHash = new Hashtable(); 680 Hashtable TempHash = new Hashtable();
679 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; 681 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner
680 ArrayList inventoryLibOwner = new ArrayList(); 682 ArrayList inventoryLibOwner = new ArrayList();
681 inventoryLibOwner.Add(TempHash); 683 inventoryLibOwner.Add(TempHash);
682 return inventoryLibOwner; 684 return inventoryLibOwner;
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 58038cb..2b74539 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -26,13 +26,14 @@ namespace OpenSim.Services.LLLoginService
26 private IGridService m_GridService; 26 private IGridService m_GridService;
27 private IPresenceService m_PresenceService; 27 private IPresenceService m_PresenceService;
28 private ISimulationService m_LocalSimulationService; 28 private ISimulationService m_LocalSimulationService;
29 private ILibraryService m_LibraryService;
29 30
30 private string m_DefaultRegionName; 31 private string m_DefaultRegionName;
31 private string m_RemoteSimulationDll; 32 private string m_RemoteSimulationDll;
32 private string m_WelcomeMessage; 33 private string m_WelcomeMessage;
33 private bool m_RequireInventory; 34 private bool m_RequireInventory;
34 35
35 public LLLoginService(IConfigSource config, ISimulationService simService) 36 public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService)
36 { 37 {
37 IConfig serverConfig = config.Configs["LoginService"]; 38 IConfig serverConfig = config.Configs["LoginService"];
38 if (serverConfig == null) 39 if (serverConfig == null)
@@ -43,13 +44,14 @@ namespace OpenSim.Services.LLLoginService
43 string invService = serverConfig.GetString("InventoryService", String.Empty); 44 string invService = serverConfig.GetString("InventoryService", String.Empty);
44 string gridService = serverConfig.GetString("GridService", String.Empty); 45 string gridService = serverConfig.GetString("GridService", String.Empty);
45 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 46 string presenceService = serverConfig.GetString("PresenceService", String.Empty);
47 string libService = serverConfig.GetString("LibraryService", String.Empty);
46 48
47 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); 49 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
48 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty); 50 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
49 m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); 51 m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
50 m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true); 52 m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true);
51 53
52 // These 3 are required; the other 2 aren't 54 // These 3 are required; the others aren't
53 if (accountService == string.Empty || authService == string.Empty || 55 if (accountService == string.Empty || authService == string.Empty ||
54 invService == string.Empty) 56 invService == string.Empty)
55 throw new Exception("LoginService is missing service specifications"); 57 throw new Exception("LoginService is missing service specifications");
@@ -62,13 +64,27 @@ namespace OpenSim.Services.LLLoginService
62 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 64 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
63 if (presenceService != string.Empty) 65 if (presenceService != string.Empty)
64 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 66 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args);
67
68 //
69 // deal with the services given as argument
70 //
65 m_LocalSimulationService = simService; 71 m_LocalSimulationService = simService;
72 if (libraryService != null)
73 {
74 m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument");
75 m_LibraryService = libraryService;
76 }
77 else if (libService != string.Empty)
78 {
79 m_log.DebugFormat("[LLOGIN SERVICE]: Using instantiated LibraryService");
80 m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args);
81 }
66 82
67 m_log.DebugFormat("[LLOGIN SERVICE]: Starting..."); 83 m_log.DebugFormat("[LLOGIN SERVICE]: Starting...");
68 84
69 } 85 }
70 86
71 public LLLoginService(IConfigSource config) : this(config, null) 87 public LLLoginService(IConfigSource config) : this(config, null, null)
72 { 88 {
73 } 89 }
74 90
@@ -171,7 +187,7 @@ namespace OpenSim.Services.LLLoginService
171 // TODO: Get Friends list... 187 // TODO: Get Friends list...
172 188
173 // Finally, fill out the response and return it 189 // Finally, fill out the response and return it
174 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, 190 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, m_LibraryService,
175 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); 191 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
176 192
177 return response; 193 return response;
diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini
index 96c25e6..d89029f 100644
--- a/bin/config-include/StandaloneHypergrid.ini
+++ b/bin/config-include/StandaloneHypergrid.ini
@@ -43,6 +43,11 @@
43 LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService" 43 LocalGridInventoryService = "OpenSim.Services.InventoryService.dll:InventoryService"
44 HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector" 44 HypergridInventoryService = "OpenSim.Services.Connectors.dll:HGInventoryServiceConnector"
45 45
46[LibraryService]
47 LocalServiceModule = "OpenSim.Services.InventoryService.dll:LibraryService"
48 LibraryName = "OpenSim Library"
49 DefaultLibrary = "./inventory/Libraries.xml"
50
46[AuthorizationService] 51[AuthorizationService]
47 LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService" 52 LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
48 53
diff --git a/prebuild.xml b/prebuild.xml
index b533f7b..f5092da 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1460,6 +1460,7 @@
1460 1460
1461 <ReferencePath>../../../bin/</ReferencePath> 1461 <ReferencePath>../../../bin/</ReferencePath>
1462 <Reference name="System"/> 1462 <Reference name="System"/>
1463 <Reference name="System.Xml"/>
1463 <Reference name="OpenMetaverseTypes.dll"/> 1464 <Reference name="OpenMetaverseTypes.dll"/>
1464 <Reference name="OpenMetaverse.dll"/> 1465 <Reference name="OpenMetaverse.dll"/>
1465 <Reference name="OpenSim.Framework"/> 1466 <Reference name="OpenSim.Framework"/>