diff options
Diffstat (limited to 'OpenSim/Grid/InventoryServer/InventoryManager.cs')
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryManager.cs | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs index 1070bcf..a003ce3 100644 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs | |||
@@ -25,26 +25,23 @@ | |||
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 | */ |
28 | |||
28 | using System; | 29 | using System; |
29 | using System.IO; | 30 | using System.IO; |
30 | using System.Text; | ||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Collections; | 32 | using System.Text; |
33 | using System.Collections.Generic; | ||
34 | using System.Xml; | 33 | using System.Xml; |
35 | using System.Xml.Serialization; | 34 | using System.Xml.Serialization; |
36 | using libsecondlife; | 35 | using libsecondlife; |
37 | |||
38 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Servers; | 38 | using OpenSim.Framework.Servers; |
41 | 39 | ||
42 | namespace OpenSim.Grid.InventoryServer | 40 | namespace OpenSim.Grid.InventoryServer |
43 | { | 41 | { |
44 | |||
45 | public class InventoryManager | 42 | public class InventoryManager |
46 | { | 43 | { |
47 | IInventoryData _databasePlugin; | 44 | private IInventoryData _databasePlugin; |
48 | 45 | ||
49 | /// <summary> | 46 | /// <summary> |
50 | /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. | 47 | /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. |
@@ -55,7 +52,8 @@ namespace OpenSim.Grid.InventoryServer | |||
55 | MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName); | 52 | MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName); |
56 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | 53 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); |
57 | 54 | ||
58 | MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | 55 | MainLog.Instance.Verbose(OpenInventory_Main.LogName, |
56 | "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | ||
59 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 57 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
60 | { | 58 | { |
61 | if (!pluginType.IsAbstract) | 59 | if (!pluginType.IsAbstract) |
@@ -64,10 +62,12 @@ namespace OpenSim.Grid.InventoryServer | |||
64 | 62 | ||
65 | if (typeInterface != null) | 63 | if (typeInterface != null) |
66 | { | 64 | { |
67 | IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | 65 | IInventoryData plug = |
66 | (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
68 | plug.Initialise(); | 67 | plug.Initialise(); |
69 | _databasePlugin = plug; | 68 | _databasePlugin = plug; |
70 | MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Added IInventoryData Interface"); | 69 | MainLog.Instance.Verbose(OpenInventory_Main.LogName, |
70 | "Invenstorage: Added IInventoryData Interface"); | ||
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | 73 | ||
@@ -82,8 +82,8 @@ namespace OpenSim.Grid.InventoryServer | |||
82 | { | 82 | { |
83 | FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); | 83 | FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); |
84 | XmlReader reader = new XmlTextReader(fs); | 84 | XmlReader reader = new XmlTextReader(fs); |
85 | XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); | 85 | XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); |
86 | SerializableInventory inventory = (SerializableInventory)x.Deserialize(reader); | 86 | SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader); |
87 | fs.Close(); | 87 | fs.Close(); |
88 | fs.Dispose(); | 88 | fs.Dispose(); |
89 | return inventory; | 89 | return inventory; |
@@ -93,11 +93,12 @@ namespace OpenSim.Grid.InventoryServer | |||
93 | { | 93 | { |
94 | XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8); | 94 | XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8); |
95 | writer.Formatting = Formatting.Indented; | 95 | writer.Formatting = Formatting.Indented; |
96 | XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); | 96 | XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); |
97 | x.Serialize(writer, inventory); | 97 | x.Serialize(writer, inventory); |
98 | } | 98 | } |
99 | 99 | ||
100 | protected static bool fixupFolder(SerializableInventory.SerializableFolder f, SerializableInventory.SerializableFolder parent) | 100 | protected static bool fixupFolder(SerializableInventory.SerializableFolder f, |
101 | SerializableInventory.SerializableFolder parent) | ||
101 | { | 102 | { |
102 | bool modified = false; | 103 | bool modified = false; |
103 | 104 | ||
@@ -142,6 +143,7 @@ namespace OpenSim.Grid.InventoryServer | |||
142 | { | 143 | { |
143 | private SerializableInventory _inventory; | 144 | private SerializableInventory _inventory; |
144 | private InventoryManager _manager; | 145 | private InventoryManager _manager; |
146 | |||
145 | public GetInventory(InventoryManager manager) | 147 | public GetInventory(InventoryManager manager) |
146 | : base("GET", "/inventory") | 148 | : base("GET", "/inventory") |
147 | { | 149 | { |
@@ -165,23 +167,24 @@ namespace OpenSim.Grid.InventoryServer | |||
165 | private byte[] GetUserInventory(LLUUID userID) | 167 | private byte[] GetUserInventory(LLUUID userID) |
166 | { | 168 | { |
167 | MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString()); | 169 | MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString()); |
168 | byte[] result = new byte[] { }; | 170 | byte[] result = new byte[] {}; |
169 | 171 | ||
170 | InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); | 172 | InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); |
171 | if (fb == null) | 173 | if (fb == null) |
172 | { | 174 | { |
173 | MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", userID.ToString()); | 175 | MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new", |
176 | userID.ToString()); | ||
174 | CreateDefaultInventory(userID); | 177 | CreateDefaultInventory(userID); |
175 | } | 178 | } |
176 | 179 | ||
177 | return result; | 180 | return result; |
178 | } | 181 | } |
179 | 182 | ||
180 | override public byte[] Handle(string path, Stream request) | 183 | public override byte[] Handle(string path, Stream request) |
181 | { | 184 | { |
182 | byte[] result = new byte[] { }; | 185 | byte[] result = new byte[] {}; |
183 | 186 | ||
184 | string[] parms = path.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); | 187 | string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); |
185 | if (parms.Length > 1) | 188 | if (parms.Length > 1) |
186 | { | 189 | { |
187 | if (string.Compare(parms[1], "library", true) == 0) | 190 | if (string.Compare(parms[1], "library", true) == 0) |
@@ -190,7 +193,7 @@ namespace OpenSim.Grid.InventoryServer | |||
190 | saveInventoryToStream(_inventory, ms); | 193 | saveInventoryToStream(_inventory, ms); |
191 | 194 | ||
192 | result = ms.GetBuffer(); | 195 | result = ms.GetBuffer(); |
193 | Array.Resize<byte>(ref result, (int)ms.Length); | 196 | Array.Resize<byte>(ref result, (int) ms.Length); |
194 | } | 197 | } |
195 | else if (string.Compare(parms[1], "user", true) == 0) | 198 | else if (string.Compare(parms[1], "user", true) == 0) |
196 | { | 199 | { |
@@ -204,4 +207,4 @@ namespace OpenSim.Grid.InventoryServer | |||
204 | } | 207 | } |
205 | } | 208 | } |
206 | } | 209 | } |
207 | } | 210 | } \ No newline at end of file |