From 6a8d8f54e88a21e6cfd78dc7981cdeec2f18094d Mon Sep 17 00:00:00 2001 From: Tleiades Hax Date: Tue, 30 Oct 2007 22:42:34 +0000 Subject: Step one on the long march towards grid based inventory. Introduction of an InevntoryServer --- OpenSim/Framework/General/InventoryConfig.cs | 67 +++++++++++++++++++++++++ OpenSim/Framework/General/InventoryItemBase.cs | 30 ++++++++++- OpenSim/Framework/General/NetworkServersInfo.cs | 6 ++- 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Framework/General/InventoryConfig.cs (limited to 'OpenSim/Framework/General') diff --git a/OpenSim/Framework/General/InventoryConfig.cs b/OpenSim/Framework/General/InventoryConfig.cs new file mode 100644 index 0000000..9ba3e07 --- /dev/null +++ b/OpenSim/Framework/General/InventoryConfig.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework +{ + /// + /// UserConfig -- For User Server Configuration + /// + public class InventoryConfig + { + public string DefaultStartupMsg = ""; + public string UserServerURL = ""; + public string UserSendKey = ""; + public string UserRecvKey = ""; + + public string DatabaseProvider = ""; + public static uint DefaultHttpPort = 8004; + + public int HttpPort = 8004; + + private ConfigurationMember configMember; + + public InventoryConfig(string description, string filename) + { + configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration); + configMember.performConfigurationRetrieve(); + } + + public void loadConfigurationOptions() + { + configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS", false); + configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:" + UserConfig.DefaultHttpPort.ToString(), false); + configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false); + configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false); + configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); + configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, "Http Listener port", DefaultHttpPort.ToString(), false); + } + + public bool handleIncomingConfiguration(string configuration_key, object configuration_result) + { + switch (configuration_key) + { + case "default_startup_message": + this.DefaultStartupMsg = (string)configuration_result; + break; + case "default_user_server": + this.UserServerURL = (string)configuration_result; + break; + case "user_send_key": + this.UserSendKey = (string)configuration_result; + break; + case "user_recv_key": + this.UserRecvKey = (string)configuration_result; + break; + case "database_provider": + this.DatabaseProvider = (string)configuration_result; + break; + case "http_port": + HttpPort = (int)configuration_result; + break; + } + + return true; + } + } +} diff --git a/OpenSim/Framework/General/InventoryItemBase.cs b/OpenSim/Framework/General/InventoryItemBase.cs index 45700ae..f782913 100644 --- a/OpenSim/Framework/General/InventoryItemBase.cs +++ b/OpenSim/Framework/General/InventoryItemBase.cs @@ -25,6 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using System; +using System.Xml.Serialization; +using System.Collections; using System.Collections.Generic; using libsecondlife; @@ -242,4 +245,29 @@ namespace OpenSim.Framework /// The id of the folder void deleteInventoryFolder(LLUUID folder); } -} \ No newline at end of file + + /* + * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder + * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize + * into this simpler class, and then use that. + */ + [XmlRoot(ElementName = "inventory", IsNullable = true)] + public class SerializableInventory + { + [XmlRoot(ElementName = "folder", IsNullable = true)] + public class SerializableFolder : InventoryFolderBase + { + [XmlArray(ElementName = "folders", IsNullable = true)] + [XmlArrayItem(ElementName = "folder", IsNullable = true, Type = typeof(SerializableFolder))] + public ArrayList SubFolders; + + [XmlArray(ElementName = "items", IsNullable = true)] + [XmlArrayItem(ElementName = "item", IsNullable = true, Type = typeof(InventoryItemBase))] + public ArrayList Items; + } + + [XmlElement(ElementName = "folder", IsNullable = true)] + public SerializableFolder root; + } + +} diff --git a/OpenSim/Framework/General/NetworkServersInfo.cs b/OpenSim/Framework/General/NetworkServersInfo.cs index 98d489e..aa8aa2b 100644 --- a/OpenSim/Framework/General/NetworkServersInfo.cs +++ b/OpenSim/Framework/General/NetworkServersInfo.cs @@ -43,6 +43,8 @@ namespace OpenSim.Framework public string UserRecvKey = ""; public bool isSandbox; + public string InventoryURL = ""; + public static int DefaultHttpListenerPort = 9000; public int HttpListenerPort = DefaultHttpListenerPort; @@ -91,6 +93,8 @@ namespace OpenSim.Framework UserSendKey = config.Configs["Network"].GetString("user_send_key", "null"); UserRecvKey = config.Configs["Network"].GetString("user_recv_key", "null"); AssetURL = config.Configs["Network"].GetString("asset_server_url", AssetURL); + InventoryURL = config.Configs["Network"].GetString("inventory_server_url", + "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString()); } } -} \ No newline at end of file +} -- cgit v1.1