diff options
-rw-r--r-- | OpenSim/Grid/InventoryServer/InventoryManager.cs | 207 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 6 | ||||
-rw-r--r-- | bin/inventory/attic/Inventory_Default.xml | 62 | ||||
-rw-r--r-- | bin/inventory/attic/Inventory_Library.xml | 134 |
4 files changed, 1 insertions, 408 deletions
diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs deleted file mode 100644 index 5c65317..0000000 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ /dev/null | |||
@@ -1,207 +0,0 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using System.Xml; | ||
33 | using System.Xml.Serialization; | ||
34 | using libsecondlife; | ||
35 | using log4net; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Servers; | ||
38 | |||
39 | namespace OpenSim.Grid.InventoryServer | ||
40 | { | ||
41 | public class InventoryManager | ||
42 | { | ||
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
44 | |||
45 | private IInventoryData _databasePlugin; | ||
46 | |||
47 | /// <summary> | ||
48 | /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. | ||
49 | /// </summary> | ||
50 | /// <param name="FileName">The filename to the inventory server plugin DLL</param> | ||
51 | public void AddDatabasePlugin(string FileName, string dbconnect) | ||
52 | { | ||
53 | m_log.Info("[" + OpenInventory_Main.LogName + "]: Invenstorage: Attempting to load " + FileName); | ||
54 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
55 | |||
56 | m_log.Info("[" + OpenInventory_Main.LogName + "]: " + | ||
57 | "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | ||
58 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
59 | { | ||
60 | if (!pluginType.IsAbstract) | ||
61 | { | ||
62 | Type typeInterface = pluginType.GetInterface("IInventoryData", true); | ||
63 | |||
64 | if (typeInterface != null) | ||
65 | { | ||
66 | IInventoryData plug = | ||
67 | (IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
68 | plug.Initialise(dbconnect); | ||
69 | _databasePlugin = plug; | ||
70 | m_log.Info("[" + OpenInventory_Main.LogName + "]: " + | ||
71 | "Invenstorage: Added IInventoryData Interface"); | ||
72 | break; | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | protected static SerializableInventory loadInventoryFromXmlFile(string fileName) | ||
79 | { | ||
80 | FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); | ||
81 | XmlReader reader = new XmlTextReader(fs); | ||
82 | XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); | ||
83 | SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader); | ||
84 | fs.Close(); | ||
85 | fs.Dispose(); | ||
86 | return inventory; | ||
87 | } | ||
88 | |||
89 | protected static void saveInventoryToStream(SerializableInventory inventory, Stream s) | ||
90 | { | ||
91 | XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8); | ||
92 | writer.Formatting = Formatting.Indented; | ||
93 | XmlSerializer x = new XmlSerializer(typeof (SerializableInventory)); | ||
94 | x.Serialize(writer, inventory); | ||
95 | } | ||
96 | |||
97 | protected static bool fixupFolder(SerializableInventory.SerializableFolder f, | ||
98 | SerializableInventory.SerializableFolder parent) | ||
99 | { | ||
100 | bool modified = false; | ||
101 | |||
102 | // ensure we have a valid folder id | ||
103 | if (f.ID == LLUUID.Zero) | ||
104 | { | ||
105 | f.ID = LLUUID.Random(); | ||
106 | modified = true; | ||
107 | } | ||
108 | |||
109 | // ensure we have valid agent id | ||
110 | if (f.Owner == LLUUID.Zero) | ||
111 | { | ||
112 | if (parent != null) | ||
113 | f.Owner = parent.Owner; | ||
114 | else | ||
115 | f.Owner = f.ID; | ||
116 | modified = true; | ||
117 | } | ||
118 | |||
119 | if (f.ParentID == LLUUID.Zero && parent != null) | ||
120 | { | ||
121 | f.ParentID = parent.ID; | ||
122 | modified = true; | ||
123 | } | ||
124 | |||
125 | |||
126 | foreach (SerializableInventory.SerializableFolder child in f.SubFolders) | ||
127 | { | ||
128 | modified |= fixupFolder(child, f); | ||
129 | } | ||
130 | |||
131 | return modified; | ||
132 | } | ||
133 | |||
134 | protected static bool fixupInventory(SerializableInventory inventory) | ||
135 | { | ||
136 | return fixupFolder(inventory.root, null); | ||
137 | } | ||
138 | |||
139 | public class GetInventory : BaseStreamHandler | ||
140 | { | ||
141 | private SerializableInventory _inventory; | ||
142 | private InventoryManager _manager; | ||
143 | |||
144 | public GetInventory(InventoryManager manager) | ||
145 | : base("GET", "/inventory") | ||
146 | { | ||
147 | _manager = manager; | ||
148 | |||
149 | _inventory = loadInventoryFromXmlFile("attic/inventory/Inventory_Library.xml"); | ||
150 | if (fixupInventory(_inventory)) | ||
151 | { | ||
152 | FileStream fs = new FileStream("attic/inventory/Inventory_Library.xml", FileMode.Truncate, FileAccess.Write); | ||
153 | saveInventoryToStream(_inventory, fs); | ||
154 | fs.Flush(); | ||
155 | fs.Close(); | ||
156 | m_log.Debug("[" + OpenInventory_Main.LogName + "]: Modified"); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | private void CreateDefaultInventory(LLUUID userID) | ||
161 | { | ||
162 | } | ||
163 | |||
164 | private byte[] GetUserInventory(LLUUID userID) | ||
165 | { | ||
166 | m_log.InfoFormat("[" + OpenInventory_Main.LogName + "]: Getting Inventory for user {0}", userID.ToString()); | ||
167 | byte[] result = new byte[] {}; | ||
168 | |||
169 | InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID); | ||
170 | if (fb == null) | ||
171 | { | ||
172 | m_log.InfoFormat("[" + OpenInventory_Main.LogName + "]: Inventory not found for user {0}, creating new", | ||
173 | userID.ToString()); | ||
174 | CreateDefaultInventory(userID); | ||
175 | } | ||
176 | |||
177 | return result; | ||
178 | } | ||
179 | |||
180 | public override byte[] Handle(string path, Stream request) | ||
181 | { | ||
182 | byte[] result = new byte[] {}; | ||
183 | |||
184 | string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries); | ||
185 | if (parms.Length > 1) | ||
186 | { | ||
187 | if (string.Compare(parms[1], "library", true) == 0) | ||
188 | { | ||
189 | MemoryStream ms = new MemoryStream(); | ||
190 | saveInventoryToStream(_inventory, ms); | ||
191 | |||
192 | result = ms.GetBuffer(); | ||
193 | Array.Resize<byte>(ref result, (int) ms.Length); | ||
194 | } | ||
195 | else if (string.Compare(parms[1], "user", true) == 0) | ||
196 | { | ||
197 | if (parms.Length > 2) | ||
198 | { | ||
199 | result = GetUserInventory(new LLUUID(parms[2])); | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | return result; | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index f1bd60f..2279191 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs | |||
@@ -41,8 +41,7 @@ namespace OpenSim.Grid.InventoryServer | |||
41 | public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback | 41 | public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback |
42 | { | 42 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 44 | ||
45 | private InventoryManager m_inventoryManager; | ||
46 | private InventoryConfig m_config; | 45 | private InventoryConfig m_config; |
47 | private GridInventoryService m_inventoryService; | 46 | private GridInventoryService m_inventoryService; |
48 | 47 | ||
@@ -71,7 +70,6 @@ namespace OpenSim.Grid.InventoryServer | |||
71 | m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); | 70 | m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); |
72 | 71 | ||
73 | m_inventoryService = new GridInventoryService(); | 72 | m_inventoryService = new GridInventoryService(); |
74 | // m_inventoryManager = new InventoryManager(); | ||
75 | m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); | 73 | m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect); |
76 | 74 | ||
77 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); | 75 | m_log.Info("[" + LogName + "]: Starting HTTP server ..."); |
@@ -121,8 +119,6 @@ namespace OpenSim.Grid.InventoryServer | |||
121 | m_httpServer.AddStreamHandler( | 119 | m_httpServer.AddStreamHandler( |
122 | new RestDeserialisehandler<Guid, List<InventoryFolderBase>> | 120 | new RestDeserialisehandler<Guid, List<InventoryFolderBase>> |
123 | ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton)); | 121 | ("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton)); |
124 | |||
125 | // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); | ||
126 | } | 122 | } |
127 | 123 | ||
128 | private void Work() | 124 | private void Work() |
diff --git a/bin/inventory/attic/Inventory_Default.xml b/bin/inventory/attic/Inventory_Default.xml deleted file mode 100644 index 8d0ebc1..0000000 --- a/bin/inventory/attic/Inventory_Default.xml +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <inventory> | ||
3 | <folder> | ||
4 | <name>My Inventory</name> | ||
5 | <folderID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
6 | <type>9</type> | ||
7 | <folders> | ||
8 | <folder> | ||
9 | <name>Animations</name> | ||
10 | <type>20</type> | ||
11 | </folder> | ||
12 | <folder> | ||
13 | <name>Body Parts</name> | ||
14 | <type>13</type> | ||
15 | </folder> | ||
16 | <folder> | ||
17 | <name>Clothing</name> | ||
18 | <type>5</type> | ||
19 | </folder> | ||
20 | <folder> | ||
21 | <name>Gestures</name> | ||
22 | <type>21</type> | ||
23 | </folder> | ||
24 | <folder> | ||
25 | <name>Landmarks</name> | ||
26 | <type>3</type> | ||
27 | </folder> | ||
28 | <folder> | ||
29 | <name>Lost And Found</name> | ||
30 | <type>16</type> | ||
31 | </folder> | ||
32 | <folder> | ||
33 | <name>Notecards</name> | ||
34 | <type>7</type> | ||
35 | </folder> | ||
36 | <folder> | ||
37 | <name>Objects</name> | ||
38 | <type>6</type> | ||
39 | </folder> | ||
40 | <folder> | ||
41 | <name>Photo Album</name> | ||
42 | <type>15</type> | ||
43 | </folder> | ||
44 | <folder> | ||
45 | <name>Scripts</name> | ||
46 | <type>10</type> | ||
47 | </folder> | ||
48 | <folder> | ||
49 | <name>Sounds</name> | ||
50 | <type>1</type> | ||
51 | </folder> | ||
52 | <folder> | ||
53 | <name>Textures</name> | ||
54 | <type>0</type> | ||
55 | </folder> | ||
56 | <folder> | ||
57 | <name>Trash</name> | ||
58 | <type>14</type> | ||
59 | </folder> | ||
60 | </folders> | ||
61 | </folder> | ||
62 | </inventory> | ||
diff --git a/bin/inventory/attic/Inventory_Library.xml b/bin/inventory/attic/Inventory_Library.xml deleted file mode 100644 index b2b03b7..0000000 --- a/bin/inventory/attic/Inventory_Library.xml +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <inventory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
3 | <folder> | ||
4 | <name>Library</name> | ||
5 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
6 | <parentID UUID="00000000-0000-0000-0000-000000000000" /> | ||
7 | <folderID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
8 | <type>9</type> | ||
9 | <version>0</version> | ||
10 | <folders> | ||
11 | <folder> | ||
12 | <name>Animations</name> | ||
13 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
14 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
15 | <folderID UUID="d052e0a1-0bf7-4f2a-8982-472df8e4d226" /> | ||
16 | <type>20</type> | ||
17 | <version>0</version> | ||
18 | <folders /> | ||
19 | <items /> | ||
20 | </folder> | ||
21 | <folder> | ||
22 | <name>Body Parts</name> | ||
23 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
24 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
25 | <folderID UUID="52abdfa6-d50f-4743-b7db-b37f97857941" /> | ||
26 | <type>13</type> | ||
27 | <version>0</version> | ||
28 | <folders /> | ||
29 | <items /> | ||
30 | </folder> | ||
31 | <folder> | ||
32 | <name>Clothing</name> | ||
33 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
34 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
35 | <folderID UUID="5820e65c-eaa9-4404-a2bc-4c63fec47c83" /> | ||
36 | <type>5</type> | ||
37 | <version>0</version> | ||
38 | <folders /> | ||
39 | <items /> | ||
40 | </folder> | ||
41 | <folder> | ||
42 | <name>Gestures</name> | ||
43 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
44 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
45 | <folderID UUID="530e1f34-14fa-4129-a373-e4ee65249b78" /> | ||
46 | <type>21</type> | ||
47 | <version>0</version> | ||
48 | <folders /> | ||
49 | <items /> | ||
50 | </folder> | ||
51 | <folder> | ||
52 | <name>Landmarks</name> | ||
53 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
54 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
55 | <folderID UUID="a1419cef-d7d7-476e-a088-165c747532a2" /> | ||
56 | <type>3</type> | ||
57 | <version>0</version> | ||
58 | <folders /> | ||
59 | <items /> | ||
60 | </folder> | ||
61 | <folder> | ||
62 | <name>Notecards</name> | ||
63 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
64 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
65 | <folderID UUID="b61598ea-2312-49f9-9b1c-5214ba55facc" /> | ||
66 | <type>7</type> | ||
67 | <version>0</version> | ||
68 | <folders /> | ||
69 | <items /> | ||
70 | </folder> | ||
71 | <folder> | ||
72 | <name>Objects</name> | ||
73 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
74 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
75 | <folderID UUID="ff757447-ea4d-4769-8751-e3bb13cd570d" /> | ||
76 | <type>6</type> | ||
77 | <version>0</version> | ||
78 | <folders /> | ||
79 | <items /> | ||
80 | </folder> | ||
81 | <folder> | ||
82 | <name>Photo Album</name> | ||
83 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
84 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
85 | <folderID UUID="d6cadddd-68e1-4fc3-bd24-319cd593fdc0" /> | ||
86 | <type>15</type> | ||
87 | <version>0</version> | ||
88 | <folders /> | ||
89 | <items /> | ||
90 | </folder> | ||
91 | <folder> | ||
92 | <name>Scripts</name> | ||
93 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
94 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
95 | <folderID UUID="f0e2c3dc-3f44-4730-8b33-6a911994fea1" /> | ||
96 | <type>10</type> | ||
97 | <version>0</version> | ||
98 | <folders /> | ||
99 | <items /> | ||
100 | </folder> | ||
101 | <folder> | ||
102 | <name>Sounds</name> | ||
103 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
104 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
105 | <folderID UUID="b8815d3c-52b0-447c-adea-3a1a442dbb2b" /> | ||
106 | <type>1</type> | ||
107 | <version>0</version> | ||
108 | <folders /> | ||
109 | <items /> | ||
110 | </folder> | ||
111 | <folder> | ||
112 | <name>Textures</name> | ||
113 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
114 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
115 | <folderID UUID="23e487c5-43af-4fe6-b211-75cfc91845a6" /> | ||
116 | <type>0</type> | ||
117 | <version>0</version> | ||
118 | <folders /> | ||
119 | <items /> | ||
120 | </folder> | ||
121 | <folder> | ||
122 | <name>Accessories</name> | ||
123 | <agentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
124 | <parentID UUID="00000112-000f-0000-0000-000100bba000" /> | ||
125 | <folderID UUID="b4024e1c-9b1d-426e-a70e-55ae0078dc0b" /> | ||
126 | <type>8</type> | ||
127 | <version>0</version> | ||
128 | <folders /> | ||
129 | <items /> | ||
130 | </folder> | ||
131 | </folders> | ||
132 | <items /> | ||
133 | </folder> | ||
134 | </inventory> | ||