diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs')
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | 618 |
1 files changed, 309 insertions, 309 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index 790759a..d32db1b 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs | |||
@@ -1,309 +1,309 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Data.MySQL | 33 | namespace OpenSim.Framework.Data.MySQL |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A MySQL interface for the inventory server | 36 | /// A MySQL interface for the inventory server |
37 | /// </summary> | 37 | /// </summary> |
38 | class MySQLInventoryData : IInventoryData | 38 | class MySQLInventoryData : IInventoryData |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// The database manager | 41 | /// The database manager |
42 | /// </summary> | 42 | /// </summary> |
43 | public MySQLManager database; | 43 | public MySQLManager database; |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Loads and initialises this database plugin | 46 | /// Loads and initialises this database plugin |
47 | /// </summary> | 47 | /// </summary> |
48 | public void Initialise() | 48 | public void Initialise() |
49 | { | 49 | { |
50 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | 50 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); |
51 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | 51 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); |
52 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | 52 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); |
53 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | 53 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); |
54 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | 54 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); |
55 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | 55 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); |
56 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | 56 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); |
57 | 57 | ||
58 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | 58 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); |
59 | } | 59 | } |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// The name of this DB provider | 62 | /// The name of this DB provider |
63 | /// </summary> | 63 | /// </summary> |
64 | /// <returns>Name of DB provider</returns> | 64 | /// <returns>Name of DB provider</returns> |
65 | public string getName() | 65 | public string getName() |
66 | { | 66 | { |
67 | return "MySQL Inventory Data Interface"; | 67 | return "MySQL Inventory Data Interface"; |
68 | } | 68 | } |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Closes this DB provider | 71 | /// Closes this DB provider |
72 | /// </summary> | 72 | /// </summary> |
73 | public void Close() | 73 | public void Close() |
74 | { | 74 | { |
75 | // Do nothing. | 75 | // Do nothing. |
76 | } | 76 | } |
77 | 77 | ||
78 | /// <summary> | 78 | /// <summary> |
79 | /// Returns the version of this DB provider | 79 | /// Returns the version of this DB provider |
80 | /// </summary> | 80 | /// </summary> |
81 | /// <returns>A string containing the DB provider</returns> | 81 | /// <returns>A string containing the DB provider</returns> |
82 | public string getVersion() | 82 | public string getVersion() |
83 | { | 83 | { |
84 | return "0.1"; | 84 | return "0.1"; |
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
88 | /// Returns a list of items in a specified folder | 88 | /// Returns a list of items in a specified folder |
89 | /// </summary> | 89 | /// </summary> |
90 | /// <param name="folderID">The folder to search</param> | 90 | /// <param name="folderID">The folder to search</param> |
91 | /// <returns>A list containing inventory items</returns> | 91 | /// <returns>A list containing inventory items</returns> |
92 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) | 92 | public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID) |
93 | { | 93 | { |
94 | try | 94 | try |
95 | { | 95 | { |
96 | lock (database) | 96 | lock (database) |
97 | { | 97 | { |
98 | Dictionary<string, string> param = new Dictionary<string, string>(); | 98 | Dictionary<string, string> param = new Dictionary<string, string>(); |
99 | param["?uuid"] = folderID.ToStringHyphenated(); | 99 | param["?uuid"] = folderID.ToStringHyphenated(); |
100 | 100 | ||
101 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param); | 101 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid", param); |
102 | IDataReader reader = result.ExecuteReader(); | 102 | IDataReader reader = result.ExecuteReader(); |
103 | 103 | ||
104 | List<InventoryItemBase> items = database.readInventoryItems(reader); | 104 | List<InventoryItemBase> items = database.readInventoryItems(reader); |
105 | 105 | ||
106 | reader.Close(); | 106 | reader.Close(); |
107 | result.Dispose(); | 107 | result.Dispose(); |
108 | 108 | ||
109 | return items; | 109 | return items; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | catch (Exception e) | 112 | catch (Exception e) |
113 | { | 113 | { |
114 | database.Reconnect(); | 114 | database.Reconnect(); |
115 | Console.WriteLine(e.ToString()); | 115 | Console.WriteLine(e.ToString()); |
116 | return null; | 116 | return null; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | /// <summary> | 120 | /// <summary> |
121 | /// Returns a list of the root folders within a users inventory | 121 | /// Returns a list of the root folders within a users inventory |
122 | /// </summary> | 122 | /// </summary> |
123 | /// <param name="user">The user whos inventory is to be searched</param> | 123 | /// <param name="user">The user whos inventory is to be searched</param> |
124 | /// <returns>A list of folder objects</returns> | 124 | /// <returns>A list of folder objects</returns> |
125 | public List<InventoryFolderBase> getUserRootFolders(LLUUID user) | 125 | public List<InventoryFolderBase> getUserRootFolders(LLUUID user) |
126 | { | 126 | { |
127 | try | 127 | try |
128 | { | 128 | { |
129 | lock (database) | 129 | lock (database) |
130 | { | 130 | { |
131 | Dictionary<string, string> param = new Dictionary<string, string>(); | 131 | Dictionary<string, string> param = new Dictionary<string, string>(); |
132 | param["?uuid"] = user.ToStringHyphenated(); | 132 | param["?uuid"] = user.ToStringHyphenated(); |
133 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); | 133 | param["?zero"] = LLUUID.Zero.ToStringHyphenated(); |
134 | 134 | ||
135 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); | 135 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid", param); |
136 | IDataReader reader = result.ExecuteReader(); | 136 | IDataReader reader = result.ExecuteReader(); |
137 | 137 | ||
138 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 138 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
139 | 139 | ||
140 | reader.Close(); | 140 | reader.Close(); |
141 | result.Dispose(); | 141 | result.Dispose(); |
142 | 142 | ||
143 | return items; | 143 | return items; |
144 | } | 144 | } |
145 | } | 145 | } |
146 | catch (Exception e) | 146 | catch (Exception e) |
147 | { | 147 | { |
148 | database.Reconnect(); | 148 | database.Reconnect(); |
149 | Console.WriteLine(e.ToString()); | 149 | Console.WriteLine(e.ToString()); |
150 | return null; | 150 | return null; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | /// <summary> | 154 | /// <summary> |
155 | /// Returns a list of folders in a users inventory contained within the specified folder | 155 | /// Returns a list of folders in a users inventory contained within the specified folder |
156 | /// </summary> | 156 | /// </summary> |
157 | /// <param name="parentID">The folder to search</param> | 157 | /// <param name="parentID">The folder to search</param> |
158 | /// <returns>A list of inventory folders</returns> | 158 | /// <returns>A list of inventory folders</returns> |
159 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) | 159 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) |
160 | { | 160 | { |
161 | try | 161 | try |
162 | { | 162 | { |
163 | lock (database) | 163 | lock (database) |
164 | { | 164 | { |
165 | Dictionary<string, string> param = new Dictionary<string, string>(); | 165 | Dictionary<string, string> param = new Dictionary<string, string>(); |
166 | param["?uuid"] = parentID.ToStringHyphenated(); | 166 | param["?uuid"] = parentID.ToStringHyphenated(); |
167 | 167 | ||
168 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param); | 168 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid", param); |
169 | IDataReader reader = result.ExecuteReader(); | 169 | IDataReader reader = result.ExecuteReader(); |
170 | 170 | ||
171 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 171 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
172 | 172 | ||
173 | reader.Close(); | 173 | reader.Close(); |
174 | result.Dispose(); | 174 | result.Dispose(); |
175 | 175 | ||
176 | return items; | 176 | return items; |
177 | } | 177 | } |
178 | } | 178 | } |
179 | catch (Exception e) | 179 | catch (Exception e) |
180 | { | 180 | { |
181 | database.Reconnect(); | 181 | database.Reconnect(); |
182 | Console.WriteLine(e.ToString()); | 182 | Console.WriteLine(e.ToString()); |
183 | return null; | 183 | return null; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /// <summary> | 187 | /// <summary> |
188 | /// Returns a specified inventory item | 188 | /// Returns a specified inventory item |
189 | /// </summary> | 189 | /// </summary> |
190 | /// <param name="item">The item to return</param> | 190 | /// <param name="item">The item to return</param> |
191 | /// <returns>An inventory item</returns> | 191 | /// <returns>An inventory item</returns> |
192 | public InventoryItemBase getInventoryItem(LLUUID item) | 192 | public InventoryItemBase getInventoryItem(LLUUID item) |
193 | { | 193 | { |
194 | try | 194 | try |
195 | { | 195 | { |
196 | lock (database) | 196 | lock (database) |
197 | { | 197 | { |
198 | Dictionary<string, string> param = new Dictionary<string, string>(); | 198 | Dictionary<string, string> param = new Dictionary<string, string>(); |
199 | param["?uuid"] = item.ToStringHyphenated(); | 199 | param["?uuid"] = item.ToStringHyphenated(); |
200 | 200 | ||
201 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param); | 201 | IDbCommand result = database.Query("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", param); |
202 | IDataReader reader = result.ExecuteReader(); | 202 | IDataReader reader = result.ExecuteReader(); |
203 | 203 | ||
204 | List<InventoryItemBase> items = database.readInventoryItems(reader); | 204 | List<InventoryItemBase> items = database.readInventoryItems(reader); |
205 | 205 | ||
206 | reader.Close(); | 206 | reader.Close(); |
207 | result.Dispose(); | 207 | result.Dispose(); |
208 | 208 | ||
209 | if (items.Count > 0) | 209 | if (items.Count > 0) |
210 | { | 210 | { |
211 | return items[0]; | 211 | return items[0]; |
212 | } | 212 | } |
213 | else | 213 | else |
214 | { | 214 | { |
215 | return null; | 215 | return null; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | catch (Exception e) | 219 | catch (Exception e) |
220 | { | 220 | { |
221 | database.Reconnect(); | 221 | database.Reconnect(); |
222 | Console.WriteLine(e.ToString()); | 222 | Console.WriteLine(e.ToString()); |
223 | return null; | 223 | return null; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | /// <summary> | 227 | /// <summary> |
228 | /// Returns a specified inventory folder | 228 | /// Returns a specified inventory folder |
229 | /// </summary> | 229 | /// </summary> |
230 | /// <param name="folder">The folder to return</param> | 230 | /// <param name="folder">The folder to return</param> |
231 | /// <returns>A folder class</returns> | 231 | /// <returns>A folder class</returns> |
232 | public InventoryFolderBase getInventoryFolder(LLUUID folder) | 232 | public InventoryFolderBase getInventoryFolder(LLUUID folder) |
233 | { | 233 | { |
234 | try | 234 | try |
235 | { | 235 | { |
236 | lock (database) | 236 | lock (database) |
237 | { | 237 | { |
238 | Dictionary<string, string> param = new Dictionary<string, string>(); | 238 | Dictionary<string, string> param = new Dictionary<string, string>(); |
239 | param["?uuid"] = folder.ToStringHyphenated(); | 239 | param["?uuid"] = folder.ToStringHyphenated(); |
240 | 240 | ||
241 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param); | 241 | IDbCommand result = database.Query("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", param); |
242 | IDataReader reader = result.ExecuteReader(); | 242 | IDataReader reader = result.ExecuteReader(); |
243 | 243 | ||
244 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); | 244 | List<InventoryFolderBase> items = database.readInventoryFolders(reader); |
245 | 245 | ||
246 | reader.Close(); | 246 | reader.Close(); |
247 | result.Dispose(); | 247 | result.Dispose(); |
248 | 248 | ||
249 | if (items.Count > 0) | 249 | if (items.Count > 0) |
250 | { | 250 | { |
251 | return items[0]; | 251 | return items[0]; |
252 | } | 252 | } |
253 | else | 253 | else |
254 | { | 254 | { |
255 | return null; | 255 | return null; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | catch (Exception e) | 259 | catch (Exception e) |
260 | { | 260 | { |
261 | database.Reconnect(); | 261 | database.Reconnect(); |
262 | Console.WriteLine(e.ToString()); | 262 | Console.WriteLine(e.ToString()); |
263 | return null; | 263 | return null; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | /// <summary> | 267 | /// <summary> |
268 | /// Adds a specified item to the database | 268 | /// Adds a specified item to the database |
269 | /// </summary> | 269 | /// </summary> |
270 | /// <param name="item">The inventory item</param> | 270 | /// <param name="item">The inventory item</param> |
271 | public void addInventoryItem(InventoryItemBase item) | 271 | public void addInventoryItem(InventoryItemBase item) |
272 | { | 272 | { |
273 | lock (database) | 273 | lock (database) |
274 | { | 274 | { |
275 | database.insertItem(item); | 275 | database.insertItem(item); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | /// <summary> | 279 | /// <summary> |
280 | /// Updates the specified inventory item | 280 | /// Updates the specified inventory item |
281 | /// </summary> | 281 | /// </summary> |
282 | /// <param name="item">Inventory item to update</param> | 282 | /// <param name="item">Inventory item to update</param> |
283 | public void updateInventoryItem(InventoryItemBase item) | 283 | public void updateInventoryItem(InventoryItemBase item) |
284 | { | 284 | { |
285 | addInventoryItem(item); | 285 | addInventoryItem(item); |
286 | } | 286 | } |
287 | 287 | ||
288 | /// <summary> | 288 | /// <summary> |
289 | /// Creates a new inventory folder | 289 | /// Creates a new inventory folder |
290 | /// </summary> | 290 | /// </summary> |
291 | /// <param name="folder">Folder to create</param> | 291 | /// <param name="folder">Folder to create</param> |
292 | public void addInventoryFolder(InventoryFolderBase folder) | 292 | public void addInventoryFolder(InventoryFolderBase folder) |
293 | { | 293 | { |
294 | lock (database) | 294 | lock (database) |
295 | { | 295 | { |
296 | database.insertFolder(folder); | 296 | database.insertFolder(folder); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | /// <summary> | 300 | /// <summary> |
301 | /// Updates an inventory folder | 301 | /// Updates an inventory folder |
302 | /// </summary> | 302 | /// </summary> |
303 | /// <param name="folder">Folder to update</param> | 303 | /// <param name="folder">Folder to update</param> |
304 | public void updateInventoryFolder(InventoryFolderBase folder) | 304 | public void updateInventoryFolder(InventoryFolderBase folder) |
305 | { | 305 | { |
306 | addInventoryFolder(folder); | 306 | addInventoryFolder(folder); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |