mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 11:57:03 +08:00
* Tleiades grid mode inventory (#444) - thanx Tleiades!
* updated to rev 1413 on libsecondlife.dll and libsecondlife.dll.config (#423)
This commit is contained in:
@@ -26,37 +26,34 @@
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenGrid.Framework.Data;
|
||||
using libsecondlife;
|
||||
using System.Reflection;
|
||||
|
||||
using System.Xml;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework.Sims;
|
||||
using OpenSim.Framework.Inventory;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Data;
|
||||
using InventoryCategory = OpenSim.Framework.Data.InventoryCategory;
|
||||
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace OpenGridServices.InventoryServer
|
||||
namespace OpenSim.Grid.InventoryServer
|
||||
{
|
||||
class InventoryManager
|
||||
class InventoryManager : IInventoryData
|
||||
{
|
||||
Dictionary<string, IInventoryData> _plugins = new Dictionary<string, IInventoryData>();
|
||||
IInventoryData _databasePlugin;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
|
||||
/// </summary>
|
||||
/// <param name="FileName">The filename to the inventory server plugin DLL</param>
|
||||
public void AddPlugin(string FileName)
|
||||
public void AddDatabasePlugin(string FileName)
|
||||
{
|
||||
OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Attempting to load " + FileName);
|
||||
MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Attempting to load " + FileName);
|
||||
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
|
||||
|
||||
OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
|
||||
MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
|
||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||
{
|
||||
if (!pluginType.IsAbstract)
|
||||
@@ -67,8 +64,9 @@ namespace OpenGridServices.InventoryServer
|
||||
{
|
||||
IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
plug.Initialise();
|
||||
this._plugins.Add(plug.getName(), plug);
|
||||
OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Added IUserData Interface");
|
||||
_databasePlugin = plug;
|
||||
MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Added IInventoryData Interface");
|
||||
break;
|
||||
}
|
||||
|
||||
typeInterface = null;
|
||||
@@ -80,46 +78,87 @@ namespace OpenGridServices.InventoryServer
|
||||
|
||||
public List<InventoryFolderBase> getRootFolders(LLUUID user)
|
||||
{
|
||||
foreach (KeyValuePair<string, IInventoryData> kvp in _plugins)
|
||||
{
|
||||
try
|
||||
{
|
||||
return kvp.Value.getUserRootFolders(user);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
OpenSim.Framework.Console.MainConsole.Instance.Notice("Unable to get root folders via " + kvp.Key + " (" + e.ToString() + ")");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public XmlRpcResponse XmlRpcInventoryRequest(XmlRpcRequest request)
|
||||
#region IInventoryData Members
|
||||
|
||||
|
||||
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
||||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
|
||||
Hashtable responseData = new Hashtable();
|
||||
|
||||
// Stuff happens here
|
||||
|
||||
if (requestData.ContainsKey("Access-type"))
|
||||
{
|
||||
if (requestData["access-type"] == "rootfolders")
|
||||
{
|
||||
// responseData["rootfolders"] =
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responseData["error"] = "No access-type specified.";
|
||||
}
|
||||
|
||||
|
||||
// Stuff stops happening here
|
||||
|
||||
response.Value = responseData;
|
||||
return response;
|
||||
return _databasePlugin.getInventoryInFolder(folderID);
|
||||
}
|
||||
|
||||
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
||||
{
|
||||
return _databasePlugin.getUserRootFolders(user);
|
||||
}
|
||||
|
||||
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
|
||||
{
|
||||
return _databasePlugin.getInventoryFolders(parentID);
|
||||
}
|
||||
|
||||
public InventoryItemBase getInventoryItem(LLUUID item)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
||||
{
|
||||
return _databasePlugin.getInventoryFolder(folder);
|
||||
}
|
||||
|
||||
public void addInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
_databasePlugin.addInventoryItem(item);
|
||||
}
|
||||
|
||||
public void updateInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void deleteInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void addInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
_databasePlugin.addInventoryFolder(folder);
|
||||
}
|
||||
|
||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public string getName()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public string getVersion()
|
||||
{
|
||||
throw new Exception("The method or operation is not implemented.");
|
||||
}
|
||||
|
||||
public void deleteInventoryCategory(InventoryCategory inventoryCategory)
|
||||
{
|
||||
_databasePlugin.deleteInventoryCategory(inventoryCategory);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
136
OpenSim/Grid/InventoryServer/InventoryService.cs
Normal file
136
OpenSim/Grid/InventoryServer/InventoryService.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Remoting.Channels.Tcp;
|
||||
using System.Runtime.Serialization.Formatters;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Framework.Configuration;
|
||||
using InventoryCategory = OpenSim.Framework.Data.InventoryCategory;
|
||||
|
||||
namespace OpenSim.Grid.InventoryServer
|
||||
{
|
||||
class InventoryServiceSingleton : OpenSim.Framework.Communications.InventoryServiceBase
|
||||
{
|
||||
static InventoryManager _inventoryManager;
|
||||
|
||||
static public InventoryManager InventoryManager
|
||||
{
|
||||
set { _inventoryManager = value; }
|
||||
get { return _inventoryManager; }
|
||||
}
|
||||
|
||||
#region Singleton Pattern
|
||||
static InventoryServiceSingleton instance=null;
|
||||
|
||||
InventoryServiceSingleton()
|
||||
{
|
||||
}
|
||||
|
||||
public static InventoryServiceSingleton Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance==null)
|
||||
{
|
||||
instance = new InventoryServiceSingleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IInventoryServices Members
|
||||
|
||||
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack)
|
||||
{
|
||||
List<InventoryFolderBase> folders = this.RequestFirstLevelFolders(userID);
|
||||
InventoryFolderBase rootFolder = null;
|
||||
|
||||
//need to make sure we send root folder first
|
||||
foreach (InventoryFolderBase folder in folders)
|
||||
{
|
||||
if (folder.parentID == libsecondlife.LLUUID.Zero)
|
||||
{
|
||||
rootFolder = folder;
|
||||
folderCallBack(userID, folder);
|
||||
}
|
||||
}
|
||||
|
||||
if (rootFolder != null)
|
||||
{
|
||||
foreach (InventoryFolderBase folder in folders)
|
||||
{
|
||||
if (folder.folderID != rootFolder.folderID)
|
||||
{
|
||||
folderCallBack(userID, folder);
|
||||
|
||||
List<InventoryItemBase> items = this.RequestFolderItems(folder.folderID);
|
||||
foreach (InventoryItemBase item in items)
|
||||
{
|
||||
itemCallBack(userID, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
|
||||
{
|
||||
_inventoryManager.addInventoryFolder(folder);
|
||||
}
|
||||
|
||||
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
|
||||
{
|
||||
throw new Exception("Not implemented exception");
|
||||
}
|
||||
|
||||
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
|
||||
{
|
||||
throw new Exception("Not implemented exception");
|
||||
}
|
||||
|
||||
public List<InventoryItemBase> RequestFolderItems(LLUUID folderID)
|
||||
{
|
||||
return _inventoryManager.getInventoryInFolder(folderID);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
class InventoryService
|
||||
{
|
||||
InventoryServiceSingleton _inventoryServiceMethods;
|
||||
public InventoryService(InventoryManager inventoryManager, InventoryConfig cfg)
|
||||
{
|
||||
// we only need to register the tcp channel once, and we don't know which other modules use remoting
|
||||
if (ChannelServices.GetChannel("tcp") == null)
|
||||
{
|
||||
// Creating a custom formatter for a TcpChannel sink chain.
|
||||
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
|
||||
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
|
||||
|
||||
IDictionary props = new Hashtable();
|
||||
props["port"] = cfg.RemotingPort;
|
||||
props["typeFilterLevel"] = TypeFilterLevel.Full;
|
||||
|
||||
// Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.)
|
||||
ChannelServices.RegisterChannel(new TcpChannel(props, null, serverProvider), true);
|
||||
}
|
||||
|
||||
// Register the object
|
||||
RemotingConfiguration.RegisterWellKnownServiceType(typeof(InventoryServiceSingleton), "Inventory", WellKnownObjectMode.Singleton);
|
||||
|
||||
_inventoryServiceMethods = InventoryServiceSingleton.Instance;
|
||||
InventoryServiceSingleton.InventoryManager = inventoryManager;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,49 +31,130 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.User;
|
||||
using OpenSim.Framework.Sims;
|
||||
using OpenSim.Framework.Inventory;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Servers;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Configuration;
|
||||
using OpenSim.Framework.Data;
|
||||
using InventoryCategory = OpenSim.Framework.Data.InventoryCategory;
|
||||
|
||||
namespace OpenGridServices.InventoryServer
|
||||
namespace OpenSim.Grid.InventoryServer
|
||||
{
|
||||
public class OpenInventory_Main : BaseServer, conscmd_callback
|
||||
{
|
||||
ConsoleBase m_console;
|
||||
InventoryManager m_inventoryManager;
|
||||
|
||||
public class OpenInventory_Main : conscmd_callback
|
||||
{
|
||||
|
||||
public const string MainLogName = "INVENTORY";
|
||||
|
||||
private InventoryConfig m_config;
|
||||
LogBase m_console;
|
||||
InventoryManager m_inventoryManager; ///connection the database backend
|
||||
InventoryService m_inventoryService; ///Remoting interface, where messages arrive
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Launching InventoryServer...");
|
||||
|
||||
OpenInventory_Main inventoryServer = new OpenInventory_Main();
|
||||
|
||||
inventoryServer.Startup();
|
||||
|
||||
// inventoryServer.RunCmd("load", new string[] { "library", "inventory_library.xml" });
|
||||
// inventoryServer.RunCmd("load", new string[] { "default", "inventory_default.xml" });
|
||||
|
||||
inventoryServer.Work();
|
||||
}
|
||||
|
||||
public OpenInventory_Main()
|
||||
{
|
||||
m_console = new ConsoleBase("opengrid-inventory-console.log", "OpenInventory", this, false);
|
||||
MainConsole.Instance = m_console;
|
||||
|
||||
if (!Directory.Exists(Util.logDir()))
|
||||
{
|
||||
Directory.CreateDirectory(Util.logDir());
|
||||
}
|
||||
|
||||
m_console = new LogBase(Path.Combine(Util.logDir(), "opensim-inventory-console.log"), "OpenInventory", this, false);
|
||||
MainLog.Instance = m_console;
|
||||
}
|
||||
|
||||
private void Work()
|
||||
{
|
||||
m_console.Notice(OpenInventory_Main.MainLogName, "Enter help for a list of commands\n");
|
||||
|
||||
while (true)
|
||||
{
|
||||
m_console.MainLogPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
public void Startup()
|
||||
{
|
||||
MainConsole.Instance.Notice("Initialising inventory manager...");
|
||||
MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Initialising inventory manager...");
|
||||
|
||||
m_config = new InventoryConfig(OpenInventory_Main.MainLogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
|
||||
|
||||
// instantiate the manager, responsible for doing the actual storage
|
||||
m_inventoryManager = new InventoryManager();
|
||||
m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider);
|
||||
|
||||
MainConsole.Instance.Notice("Starting HTTP server");
|
||||
BaseHttpServer httpServer = new BaseHttpServer(8004);
|
||||
m_inventoryService = new InventoryService(m_inventoryManager, m_config);
|
||||
|
||||
httpServer.AddXmlRPCHandler("rootfolders", m_inventoryManager.XmlRpcInventoryRequest);
|
||||
//httpServer.AddRestHandler("GET","/rootfolders/",Rest
|
||||
// Dig out the embedded version number of this assembly
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
string serverExeName = assembly.ManifestModule.Name;
|
||||
Version serverExeVersion = AssemblyName.GetAssemblyName(serverExeName).Version;
|
||||
|
||||
m_console.Status(OpenInventory_Main.MainLogName, "Inventoryserver {0}.{1}.{2}.{3} - Startup complete", serverExeVersion.Major, serverExeVersion.Minor, serverExeVersion.Revision, serverExeVersion.Build);
|
||||
}
|
||||
|
||||
|
||||
public void Load(string[] cmdparams)
|
||||
{
|
||||
string cmd = cmdparams[0];
|
||||
string fileName = cmdparams[1];
|
||||
|
||||
if (cmdparams.Length != 2)
|
||||
{
|
||||
cmd = "help";
|
||||
}
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case "library":
|
||||
InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Library, fileName);
|
||||
break;
|
||||
case "default":
|
||||
InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Default, fileName);
|
||||
break;
|
||||
case "user":
|
||||
InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.User, fileName);
|
||||
break;
|
||||
case "help":
|
||||
m_console.Notice("load library <filename>, load library inventory, shared between all users");
|
||||
m_console.Notice("load default <filename>, load template inventory, used when creating a new user inventory");
|
||||
m_console.Notice("load user <first> <last>, load inventory for a specific users, warning this will reset the contents of the inventory");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void RunCmd(string cmd, string[] cmdparams)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
{
|
||||
case "help":
|
||||
m_console.Notice("load - load verious inventories, use \"load help\", to see a list of commands");
|
||||
m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
|
||||
m_console.Notice("quit - shutdown the grid (USE CAUTION!)");
|
||||
break;
|
||||
case "load":
|
||||
Load(cmdparams);
|
||||
break;
|
||||
case "quit":
|
||||
case "shutdown":
|
||||
MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Shutting down inventory server");
|
||||
m_console.Close();
|
||||
Environment.Exit(0);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user