aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-04-30 20:05:57 +0100
committerJustin Clark-Casey (justincc)2010-04-30 20:05:57 +0100
commit0b8b302aa0f2ee25be5cbdfefe232459e6e5b778 (patch)
tree8108a73ddf306c5f011e7bf91fb8ead5b6a678aa /OpenSim/Data
parenttake out some debug logging in the sqlite db adaptor (diff)
downloadopensim-SC_OLD-0b8b302aa0f2ee25be5cbdfefe232459e6e5b778.zip
opensim-SC_OLD-0b8b302aa0f2ee25be5cbdfefe232459e6e5b778.tar.gz
opensim-SC_OLD-0b8b302aa0f2ee25be5cbdfefe232459e6e5b778.tar.bz2
opensim-SC_OLD-0b8b302aa0f2ee25be5cbdfefe232459e6e5b778.tar.xz
Fix a bunch of issues that crop up after the naive porting of the new sqlite db from master to 0.6.9
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/SQLite/SQLiteAuthenticationData.cs257
-rw-r--r--OpenSim/Data/SQLite/SQLiteEstateData.cs65
-rw-r--r--OpenSim/Data/SQLite/SQLiteFramework.cs27
-rw-r--r--OpenSim/Data/SQLite/SQLiteFriendsData.cs70
-rw-r--r--OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs13
-rw-r--r--OpenSim/Data/SQLite/SQLiteInventoryStore.cs18
-rw-r--r--OpenSim/Data/SQLite/SQLiteManager.cs8
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserAccountData.cs81
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserData.cs2
-rw-r--r--OpenSim/Data/SQLite/SQLiteXInventoryData.cs6
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs3
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs74
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs12
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs70
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs11
-rw-r--r--OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs81
16 files changed, 24 insertions, 774 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs b/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
deleted file mode 100644
index 086ac0a..0000000
--- a/OpenSim/Data/SQLite/SQLiteAuthenticationData.cs
+++ /dev/null
@@ -1,257 +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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using Mono.Data.Sqlite;
35
36namespace OpenSim.Data.SQLite
37{
38 public class SQLiteAuthenticationData : SQLiteFramework, IAuthenticationData
39 {
40 private string m_Realm;
41 private List<string> m_ColumnNames;
42 private int m_LastExpire;
43 private string m_connectionString;
44
45 protected static SqliteConnection m_Connection;
46 private static bool m_initialized = false;
47
48 public SQLiteAuthenticationData(string connectionString, string realm)
49 : base(connectionString)
50 {
51 m_Realm = realm;
52 m_connectionString = connectionString;
53
54 if (!m_initialized)
55 {
56 m_Connection = new SqliteConnection(connectionString);
57 m_Connection.Open();
58
59 Migration m = new Migration(m_Connection, GetType().Assembly, "AuthStore");
60 m.Update();
61
62 m_initialized = true;
63 }
64 }
65
66 public AuthenticationData Get(UUID principalID)
67 {
68 AuthenticationData ret = new AuthenticationData();
69 ret.Data = new Dictionary<string, object>();
70
71 SqliteCommand cmd = new SqliteCommand("select * from `" + m_Realm + "` where UUID = :PrincipalID");
72 cmd.Parameters.Add(new SqliteParameter(":PrincipalID", principalID.ToString()));
73
74 IDataReader result = ExecuteReader(cmd, m_Connection);
75
76 try
77 {
78 if (result.Read())
79 {
80 ret.PrincipalID = principalID;
81
82 if (m_ColumnNames == null)
83 {
84 m_ColumnNames = new List<string>();
85
86 DataTable schemaTable = result.GetSchemaTable();
87 foreach (DataRow row in schemaTable.Rows)
88 m_ColumnNames.Add(row["ColumnName"].ToString());
89 }
90
91 foreach (string s in m_ColumnNames)
92 {
93 if (s == "UUID")
94 continue;
95
96 ret.Data[s] = result[s].ToString();
97 }
98
99 return ret;
100 }
101 else
102 {
103 return null;
104 }
105 }
106 catch
107 {
108 }
109 finally
110 {
111 //CloseCommand(cmd);
112 }
113
114 return null;
115 }
116
117 public bool Store(AuthenticationData data)
118 {
119 if (data.Data.ContainsKey("UUID"))
120 data.Data.Remove("UUID");
121
122 string[] fields = new List<string>(data.Data.Keys).ToArray();
123 string[] values = new string[data.Data.Count];
124 int i = 0;
125 foreach (object o in data.Data.Values)
126 values[i++] = o.ToString();
127
128 SqliteCommand cmd = new SqliteCommand();
129
130 if (Get(data.PrincipalID) != null)
131 {
132
133
134 string update = "update `" + m_Realm + "` set ";
135 bool first = true;
136 foreach (string field in fields)
137 {
138 if (!first)
139 update += ", ";
140 update += "`" + field + "` = :" + field;
141 cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
142
143 first = false;
144 }
145
146 update += " where UUID = :UUID";
147 cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
148
149 cmd.CommandText = update;
150 try
151 {
152 if (ExecuteNonQuery(cmd, m_Connection) < 1)
153 {
154 //CloseCommand(cmd);
155 return false;
156 }
157 }
158 catch (Exception e)
159 {
160 Console.WriteLine(e.ToString());
161 //CloseCommand(cmd);
162 return false;
163 }
164 }
165
166 else
167 {
168 string insert = "insert into `" + m_Realm + "` (`UUID`, `" +
169 String.Join("`, `", fields) +
170 "`) values (:UUID, :" + String.Join(", :", fields) + ")";
171
172 cmd.Parameters.Add(new SqliteParameter(":UUID", data.PrincipalID.ToString()));
173 foreach (string field in fields)
174 cmd.Parameters.Add(new SqliteParameter(":" + field, data.Data[field]));
175
176 cmd.CommandText = insert;
177
178 try
179 {
180 if (ExecuteNonQuery(cmd, m_Connection) < 1)
181 {
182 //CloseCommand(cmd);
183 return false;
184 }
185 }
186 catch (Exception e)
187 {
188 Console.WriteLine(e.ToString());
189 //CloseCommand(cmd);
190 return false;
191 }
192 }
193
194 //CloseCommand(cmd);
195
196 return true;
197 }
198
199 public bool SetDataItem(UUID principalID, string item, string value)
200 {
201 SqliteCommand cmd = new SqliteCommand("update `" + m_Realm +
202 "` set `" + item + "` = " + value + " where UUID = '" + principalID.ToString() + "'");
203
204 if (ExecuteNonQuery(cmd, m_Connection) > 0)
205 return true;
206
207 return false;
208 }
209
210 public bool SetToken(UUID principalID, string token, int lifetime)
211 {
212 if (System.Environment.TickCount - m_LastExpire > 30000)
213 DoExpire();
214
215 SqliteCommand cmd = new SqliteCommand("insert into tokens (UUID, token, validity) values ('" + principalID.ToString() +
216 "', '" + token + "', datetime('now', 'localtime', '+" + lifetime.ToString() + " minutes'))");
217
218 if (ExecuteNonQuery(cmd, m_Connection) > 0)
219 {
220 cmd.Dispose();
221 return true;
222 }
223
224 cmd.Dispose();
225 return false;
226 }
227
228 public bool CheckToken(UUID principalID, string token, int lifetime)
229 {
230 if (System.Environment.TickCount - m_LastExpire > 30000)
231 DoExpire();
232
233 SqliteCommand cmd = new SqliteCommand("update tokens set validity = datetime('now', 'localtime', '+" + lifetime.ToString() +
234 " minutes') where UUID = '" + principalID.ToString() + "' and token = '" + token + "' and validity > datetime('now', 'localtime')");
235
236 if (ExecuteNonQuery(cmd, m_Connection) > 0)
237 {
238 cmd.Dispose();
239 return true;
240 }
241
242 cmd.Dispose();
243
244 return false;
245 }
246
247 private void DoExpire()
248 {
249 SqliteCommand cmd = new SqliteCommand("delete from tokens where validity < datetime('now', 'localtime')");
250 ExecuteNonQuery(cmd, m_Connection);
251
252 cmd.Dispose();
253
254 m_LastExpire = System.Environment.TickCount;
255 }
256 }
257}
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs
index ad4e2a2..643e55d 100644
--- a/OpenSim/Data/SQLite/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs
@@ -180,7 +180,7 @@ namespace OpenSim.Data.SQLite
180 // 180 //
181 cmd.Parameters.Clear(); 181 cmd.Parameters.Clear();
182 cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID"; 182 cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID";
183 cmd.Parameters.Add(":UUID", regionID.ToString()); 183 cmd.Parameters.AddWithValue(":UUID", regionID.ToString());
184 184
185 try 185 try
186 { 186 {
@@ -336,66 +336,5 @@ namespace OpenSim.Data.SQLite
336 336
337 return uuids.ToArray(); 337 return uuids.ToArray();
338 } 338 }
339<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteEstateData.cs
340=======
341
342 public EstateSettings LoadEstateSettings(int estateID)
343 {
344 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID";
345
346 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
347
348 cmd.CommandText = sql;
349 cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
350
351 return DoLoad(cmd, UUID.Zero, false);
352 }
353
354 public List<int> GetEstates(string search)
355 {
356 List<int> result = new List<int>();
357
358 string sql = "select EstateID from estate_settings where estate_settings.EstateName :EstateName";
359
360 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
361
362 cmd.CommandText = sql;
363 cmd.Parameters.AddWithValue(":EstateName", search);
364
365 IDataReader r = cmd.ExecuteReader();
366
367 while (r.Read())
368 {
369 result.Add(Convert.ToInt32(r["EstateID"]));
370 }
371 r.Close();
372
373 return result;
374 }
375
376 public bool LinkRegion(UUID regionID, int estateID)
377 {
378 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
379
380 cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
381 cmd.Parameters.AddWithValue(":RegionID", regionID.ToString());
382 cmd.Parameters.AddWithValue(":EstateID", estateID.ToString());
383
384 if (cmd.ExecuteNonQuery() == 0)
385 return false;
386
387 return true;
388 }
389
390 public List<UUID> GetRegions(int estateID)
391 {
392 return new List<UUID>();
393 }
394
395 public bool DeleteEstate(int estateID)
396 {
397 return false;
398 }
399>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteEstateData.cs
400 } 339 }
401} 340} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteFramework.cs b/OpenSim/Data/SQLite/SQLiteFramework.cs
index 79eaab3..9567727 100644
--- a/OpenSim/Data/SQLite/SQLiteFramework.cs
+++ b/OpenSim/Data/SQLite/SQLiteFramework.cs
@@ -57,19 +57,7 @@ namespace OpenSim.Data.SQLite
57 { 57 {
58 lock (m_Connection) 58 lock (m_Connection)
59 { 59 {
60<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteFramework.cs
61 cmd.Connection = m_Connection; 60 cmd.Connection = m_Connection;
62=======
63/*
64 SqliteConnection newConnection =
65 (SqliteConnection)((ICloneable)connection).Clone();
66 newConnection.Open();
67
68 cmd.Connection = newConnection;
69*/
70 cmd.Connection = connection;
71 //Console.WriteLine("XXX " + cmd.CommandText);
72>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteFramework.cs
73 61
74 return cmd.ExecuteNonQuery(); 62 return cmd.ExecuteNonQuery();
75 } 63 }
@@ -77,27 +65,18 @@ namespace OpenSim.Data.SQLite
77 65
78 protected IDataReader ExecuteReader(SqliteCommand cmd) 66 protected IDataReader ExecuteReader(SqliteCommand cmd)
79 { 67 {
80<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteFramework.cs 68 lock (m_Connection)
81 SqliteConnection newConnection =
82 (SqliteConnection)((ICloneable)m_Connection).Clone();
83 newConnection.Open();
84
85 cmd.Connection = newConnection;
86 return cmd.ExecuteReader();
87=======
88 lock (connection)
89 { 69 {
90 //SqliteConnection newConnection = 70 //SqliteConnection newConnection =
91 // (SqliteConnection)((ICloneable)connection).Clone(); 71 // (SqliteConnection)((ICloneable)connection).Clone();
92 //newConnection.Open(); 72 //newConnection.Open();
93 73
94 //cmd.Connection = newConnection; 74 //cmd.Connection = newConnection;
95 cmd.Connection = connection; 75 cmd.Connection = m_Connection;
96 //Console.WriteLine("XXX " + cmd.CommandText); 76 //Console.WriteLine("XXX " + cmd.CommandText);
97 77
98 return cmd.ExecuteReader(); 78 return cmd.ExecuteReader();
99 } 79 }
100>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteFramework.cs
101 } 80 }
102 81
103 protected void CloseReaderCommand(SqliteCommand cmd) 82 protected void CloseReaderCommand(SqliteCommand cmd)
@@ -107,4 +86,4 @@ namespace OpenSim.Data.SQLite
107 cmd.Dispose(); 86 cmd.Dispose();
108 } 87 }
109 } 88 }
110} 89} \ No newline at end of file
diff --git a/OpenSim/Data/SQLite/SQLiteFriendsData.cs b/OpenSim/Data/SQLite/SQLiteFriendsData.cs
deleted file mode 100644
index b06853c..0000000
--- a/OpenSim/Data/SQLite/SQLiteFriendsData.cs
+++ /dev/null
@@ -1,70 +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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using Mono.Data.Sqlite;
35
36namespace OpenSim.Data.SQLite
37{
38 public class SQLiteFriendsData : SQLiteGenericTableHandler<FriendsData>, IFriendsData
39 {
40 public SQLiteFriendsData(string connectionString, string realm)
41 : base(connectionString, realm, "FriendsStore")
42 {
43 }
44
45 public FriendsData[] GetFriends(UUID userID)
46 {
47 SqliteCommand cmd = new SqliteCommand();
48
49 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
50 cmd.Parameters.AddWithValue(":PrincipalID", userID.ToString());
51
52 return DoQuery(cmd);
53
54 }
55
56 public bool Delete(UUID principalID, string friend)
57 {
58 SqliteCommand cmd = new SqliteCommand();
59
60 cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
61 cmd.Parameters.AddWithValue(":PrincipalID", principalID.ToString());
62 cmd.Parameters.AddWithValue(":Friend", friend);
63
64 ExecuteNonQuery(cmd, cmd.Connection);
65
66 return true;
67 }
68
69 }
70}
diff --git a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
index 918cb3d..86eaca1 100644
--- a/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
+++ b/OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
@@ -54,11 +54,8 @@ namespace OpenSim.Data.SQLite
54 m_Realm = realm; 54 m_Realm = realm;
55 if (storeName != String.Empty) 55 if (storeName != String.Empty)
56 { 56 {
57<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
58 Assembly assem = GetType().Assembly;
59=======
60 m_Connection = new SqliteConnection(connectionString); 57 m_Connection = new SqliteConnection(connectionString);
61 Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString)); 58 //Console.WriteLine(string.Format("OPENING CONNECTION FOR {0} USING {1}", storeName, connectionString));
62 m_Connection.Open(); 59 m_Connection.Open();
63 60
64 if (storeName != String.Empty) 61 if (storeName != String.Empty)
@@ -74,10 +71,6 @@ namespace OpenSim.Data.SQLite
74 //newConnection.Close(); 71 //newConnection.Close();
75 //newConnection.Dispose(); 72 //newConnection.Dispose();
76 } 73 }
77>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
78
79 Migration m = new Migration(m_Connection, assem, storeName);
80 m.Update();
81 } 74 }
82 75
83 Type t = typeof(T); 76 Type t = typeof(T);
@@ -200,11 +193,7 @@ namespace OpenSim.Data.SQLite
200 result.Add(row); 193 result.Add(row);
201 } 194 }
202 195
203<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
204 CloseReaderCommand(cmd);
205=======
206 //CloseCommand(cmd); 196 //CloseCommand(cmd);
207>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteGenericTableHandler.cs
208 197
209 return result.ToArray(); 198 return result.ToArray();
210 } 199 }
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 0149838..9ce21b1 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -88,30 +88,18 @@ namespace OpenSim.Data.SQLite
88 invFoldersDa = new SqliteDataAdapter(foldersSelectCmd); 88 invFoldersDa = new SqliteDataAdapter(foldersSelectCmd);
89 89
90 ds = new DataSet(); 90 ds = new DataSet();
91 91
92<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteInventoryStore.cs
93 ds.Tables.Add(createInventoryFoldersTable()); 92 ds.Tables.Add(createInventoryFoldersTable());
94 invFoldersDa.Fill(ds.Tables["inventoryfolders"]); 93 invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
95 setupFoldersCommands(invFoldersDa, conn); 94 setupFoldersCommands(invFoldersDa, conn);
95 CreateDataSetMapping(invFoldersDa, "inventoryfolders");
96 m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions"); 96 m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
97 97
98 ds.Tables.Add(createInventoryItemsTable()); 98 ds.Tables.Add(createInventoryItemsTable());
99 invItemsDa.Fill(ds.Tables["inventoryitems"]); 99 invItemsDa.Fill(ds.Tables["inventoryitems"]);
100 setupItemsCommands(invItemsDa, conn); 100 setupItemsCommands(invItemsDa, conn);
101 CreateDataSetMapping(invItemsDa, "inventoryitems");
101 m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions"); 102 m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
102=======
103 ds.Tables.Add(createInventoryFoldersTable());
104 invFoldersDa.Fill(ds.Tables["inventoryfolders"]);
105 setupFoldersCommands(invFoldersDa, conn);
106 CreateDataSetMapping(invFoldersDa, "inventoryfolders");
107 m_log.Info("[INVENTORY DB]: Populated Inventory Folders Definitions");
108
109 ds.Tables.Add(createInventoryItemsTable());
110 invItemsDa.Fill(ds.Tables["inventoryitems"]);
111 setupItemsCommands(invItemsDa, conn);
112 CreateDataSetMapping(invItemsDa, "inventoryitems");
113 m_log.Info("[INVENTORY DB]: Populated Inventory Items Definitions");
114>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteInventoryStore.cs
115 103
116 ds.AcceptChanges(); 104 ds.AcceptChanges();
117 } 105 }
diff --git a/OpenSim/Data/SQLite/SQLiteManager.cs b/OpenSim/Data/SQLite/SQLiteManager.cs
index b6d4a1c..7dcd323 100644
--- a/OpenSim/Data/SQLite/SQLiteManager.cs
+++ b/OpenSim/Data/SQLite/SQLiteManager.cs
@@ -28,9 +28,9 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Data.SQLite;
32using System.Reflection; 31using System.Reflection;
33using log4net; 32using log4net;
33using Mono.Data.Sqlite;
34using OpenMetaverse; 34using OpenMetaverse;
35 35
36namespace OpenSim.Data.SQLite 36namespace OpenSim.Data.SQLite
@@ -66,7 +66,7 @@ namespace OpenSim.Data.SQLite
66 connectionString = "URI=file:GridServerSqlite.db;"; 66 connectionString = "URI=file:GridServerSqlite.db;";
67 } 67 }
68 68
69 dbcon = new SQLiteConnection(connectionString); 69 dbcon = new SqliteConnection(connectionString);
70 70
71 dbcon.Open(); 71 dbcon.Open();
72 } 72 }
@@ -93,11 +93,11 @@ namespace OpenSim.Data.SQLite
93 /// <returns>A SQLite DB Command</returns> 93 /// <returns>A SQLite DB Command</returns>
94 public IDbCommand Query(string sql, Dictionary<string, string> parameters) 94 public IDbCommand Query(string sql, Dictionary<string, string> parameters)
95 { 95 {
96 SQLiteCommand dbcommand = (SQLiteCommand) dbcon.CreateCommand(); 96 SqliteCommand dbcommand = (SqliteCommand) dbcon.CreateCommand();
97 dbcommand.CommandText = sql; 97 dbcommand.CommandText = sql;
98 foreach (KeyValuePair<string, string> param in parameters) 98 foreach (KeyValuePair<string, string> param in parameters)
99 { 99 {
100 SQLiteParameter paramx = new SQLiteParameter(param.Key, param.Value); 100 SqliteParameter paramx = new SqliteParameter(param.Key, param.Value);
101 dbcommand.Parameters.Add(paramx); 101 dbcommand.Parameters.Add(paramx);
102 } 102 }
103 103
diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
deleted file mode 100644
index 893f105..0000000
--- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs
+++ /dev/null
@@ -1,81 +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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using Mono.Data.Sqlite;
35
36namespace OpenSim.Data.SQLite
37{
38 public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
39 {
40 public SQLiteUserAccountData(string connectionString, string realm)
41 : base(connectionString, realm, "UserAccount")
42 {
43 }
44
45 public UserAccountData[] GetUsers(UUID scopeID, string query)
46 {
47 string[] words = query.Split(new char[] {' '});
48
49 for (int i = 0 ; i < words.Length ; i++)
50 {
51 if (words[i].Length < 3)
52 {
53 if (i != words.Length - 1)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
55 Array.Resize(ref words, words.Length - 1);
56 }
57 }
58
59 if (words.Length == 0)
60 return new UserAccountData[0];
61
62 if (words.Length > 2)
63 return new UserAccountData[0];
64
65 SqliteCommand cmd = new SqliteCommand();
66
67 if (words.Length == 1)
68 {
69 cmd.CommandText = String.Format("select * from {0} where ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
70 m_Realm, scopeID.ToString(), words[0]);
71 }
72 else
73 {
74 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
75 m_Realm, scopeID.ToString(), words[0], words[1]);
76 }
77
78 return DoQuery(cmd);
79 }
80 }
81}
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs
index caddcf8..12db403 100644
--- a/OpenSim/Data/SQLite/SQLiteUserData.cs
+++ b/OpenSim/Data/SQLite/SQLiteUserData.cs
@@ -30,7 +30,7 @@ using System.Collections.Generic;
30using System.Data; 30using System.Data;
31using System.Reflection; 31using System.Reflection;
32using log4net; 32using log4net;
33using Mono.Data.SqliteClient; 33using Mono.Data.Sqlite;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36 36
diff --git a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
index 0650a86..0d211b6 100644
--- a/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
+++ b/OpenSim/Data/SQLite/SQLiteXInventoryData.cs
@@ -147,12 +147,8 @@ namespace OpenSim.Data.SQLite
147 } 147 }
148 148
149 reader.Close(); 149 reader.Close();
150<<<<<<< HEAD:OpenSim/Data/SQLite/SQLiteXInventoryData.cs 150
151 CloseReaderCommand(cmd);
152=======
153 //CloseCommand(cmd); 151 //CloseCommand(cmd);
154>>>>>>> cc67de5... rename SQLiteNG to SQLite and SQLite to SQLiteLegacy:OpenSim/Data/SQLite/SQLiteXInventoryData.cs
155
156 return perms; 152 return perms;
157 } 153 }
158 } 154 }
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs
index 0d63dea..23cdfd4 100644
--- a/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs
+++ b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs
@@ -234,8 +234,7 @@ namespace OpenSim.Data.SQLiteLegacy
234 AssetBase asset = new AssetBase( 234 AssetBase asset = new AssetBase(
235 new UUID((String)row["UUID"]), 235 new UUID((String)row["UUID"]),
236 (String)row["Name"], 236 (String)row["Name"],
237 Convert.ToSByte(row["Type"]), 237 Convert.ToSByte(row["Type"])
238 UUID.Zero.ToString()
239 ); 238 );
240 239
241 asset.Description = (String) row["Description"]; 240 asset.Description = (String) row["Description"];
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs
deleted file mode 100644
index 660632c..0000000
--- a/OpenSim/Data/SQLiteLegacy/SQLiteAvatarData.cs
+++ /dev/null
@@ -1,74 +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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using Mono.Data.SqliteClient;
37
38namespace OpenSim.Data.SQLiteLegacy
39{
40 /// <summary>
41 /// A SQLite Interface for Avatar Data
42 /// </summary>
43 public class SQLiteAvatarData : SQLiteGenericTableHandler<AvatarBaseData>,
44 IAvatarData
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 public SQLiteAvatarData(string connectionString, string realm) :
49 base(connectionString, realm, "Avatar")
50 {
51 }
52
53 public bool Delete(UUID principalID, string name)
54 {
55 SqliteCommand cmd = new SqliteCommand();
56
57 cmd.CommandText = String.Format("delete from {0} where `PrincipalID` = :PrincipalID and `Name` = :Name", m_Realm);
58 cmd.Parameters.Add(":PrincipalID", principalID.ToString());
59 cmd.Parameters.Add(":Name", name);
60
61 try
62 {
63 if (ExecuteNonQuery(cmd, m_Connection) > 0)
64 return true;
65
66 return false;
67 }
68 finally
69 {
70 CloseCommand(cmd);
71 }
72 }
73 }
74}
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs
index e135eaa..5a7fbd7 100644
--- a/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLiteLegacy/SQLiteEstateData.cs
@@ -80,7 +80,7 @@ namespace OpenSim.Data.SQLiteLegacy
80 get { return new List<string>(m_FieldMap.Keys).ToArray(); } 80 get { return new List<string>(m_FieldMap.Keys).ToArray(); }
81 } 81 }
82 82
83 public EstateSettings LoadEstateSettings(UUID regionID, bool create) 83 public EstateSettings LoadEstateSettings(UUID regionID)
84 { 84 {
85 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; 85 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID";
86 86
@@ -89,10 +89,10 @@ namespace OpenSim.Data.SQLiteLegacy
89 cmd.CommandText = sql; 89 cmd.CommandText = sql;
90 cmd.Parameters.Add(":RegionID", regionID.ToString()); 90 cmd.Parameters.Add(":RegionID", regionID.ToString());
91 91
92 return DoLoad(cmd, regionID, create); 92 return DoLoad(cmd, regionID);
93 } 93 }
94 94
95 private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create) 95 private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID)
96 { 96 {
97 EstateSettings es = new EstateSettings(); 97 EstateSettings es = new EstateSettings();
98 es.OnSave += StoreEstateSettings; 98 es.OnSave += StoreEstateSettings;
@@ -125,8 +125,10 @@ namespace OpenSim.Data.SQLiteLegacy
125 } 125 }
126 r.Close(); 126 r.Close();
127 } 127 }
128 else if (create) 128 else
129 { 129 {
130 // Migration case
131 //
130 r.Close(); 132 r.Close();
131 133
132 List<string> names = new List<string>(FieldList); 134 List<string> names = new List<string>(FieldList);
@@ -335,7 +337,7 @@ namespace OpenSim.Data.SQLiteLegacy
335 cmd.CommandText = sql; 337 cmd.CommandText = sql;
336 cmd.Parameters.Add(":EstateID", estateID.ToString()); 338 cmd.Parameters.Add(":EstateID", estateID.ToString());
337 339
338 return DoLoad(cmd, UUID.Zero, false); 340 return DoLoad(cmd, UUID.Zero);
339 } 341 }
340 342
341 public List<int> GetEstates(string search) 343 public List<int> GetEstates(string search)
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs
deleted file mode 100644
index d529d4d..0000000
--- a/OpenSim/Data/SQLiteLegacy/SQLiteFriendsData.cs
+++ /dev/null
@@ -1,70 +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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using Mono.Data.SqliteClient;
35
36namespace OpenSim.Data.SQLiteLegacy
37{
38 public class SQLiteFriendsData : SQLiteGenericTableHandler<FriendsData>, IFriendsData
39 {
40 public SQLiteFriendsData(string connectionString, string realm)
41 : base(connectionString, realm, "FriendsStore")
42 {
43 }
44
45 public FriendsData[] GetFriends(UUID userID)
46 {
47 SqliteCommand cmd = new SqliteCommand();
48
49 cmd.CommandText = String.Format("select a.*,case when b.Flags is null then -1 else b.Flags end as TheirFlags from {0} as a left join {0} as b on a.PrincipalID = b.Friend and a.Friend = b.PrincipalID where a.PrincipalID = :PrincipalID", m_Realm);
50 cmd.Parameters.Add(":PrincipalID", userID.ToString());
51
52 return DoQuery(cmd);
53
54 }
55
56 public bool Delete(UUID principalID, string friend)
57 {
58 SqliteCommand cmd = new SqliteCommand();
59
60 cmd.CommandText = String.Format("delete from {0} where PrincipalID = :PrincipalID and Friend = :Friend", m_Realm);
61 cmd.Parameters.Add(":PrincipalID", principalID.ToString());
62 cmd.Parameters.Add(":Friend", friend);
63
64 ExecuteNonQuery(cmd, cmd.Connection);
65
66 return true;
67 }
68
69 }
70}
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs
index eb78037..f8660c7 100644
--- a/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLiteLegacy/SQLiteRegionData.cs
@@ -272,16 +272,7 @@ namespace OpenSim.Data.SQLiteLegacy
272 Commit(); 272 Commit();
273 } 273 }
274 } 274 }
275 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 275
276 {
277 //This connector doesn't support the windlight module yet
278 //Return default LL windlight settings
279 return new RegionLightShareData();
280 }
281 public void StoreRegionWindlightSettings(RegionLightShareData wl)
282 {
283 //This connector doesn't support the windlight module yet
284 }
285 public RegionSettings LoadRegionSettings(UUID regionUUID) 276 public RegionSettings LoadRegionSettings(UUID regionUUID)
286 { 277 {
287 lock (ds) 278 lock (ds)
diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs
deleted file mode 100644
index 27553c6..0000000
--- a/OpenSim/Data/SQLiteLegacy/SQLiteUserAccountData.cs
+++ /dev/null
@@ -1,81 +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 OpenSimulator 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Data;
32using OpenMetaverse;
33using OpenSim.Framework;
34using Mono.Data.SqliteClient;
35
36namespace OpenSim.Data.SQLiteLegacy
37{
38 public class SQLiteUserAccountData : SQLiteGenericTableHandler<UserAccountData>, IUserAccountData
39 {
40 public SQLiteUserAccountData(string connectionString, string realm)
41 : base(connectionString, realm, "UserAccount")
42 {
43 }
44
45 public UserAccountData[] GetUsers(UUID scopeID, string query)
46 {
47 string[] words = query.Split(new char[] {' '});
48
49 for (int i = 0 ; i < words.Length ; i++)
50 {
51 if (words[i].Length < 3)
52 {
53 if (i != words.Length - 1)
54 Array.Copy(words, i + 1, words, i, words.Length - i - 1);
55 Array.Resize(ref words, words.Length - 1);
56 }
57 }
58
59 if (words.Length == 0)
60 return new UserAccountData[0];
61
62 if (words.Length > 2)
63 return new UserAccountData[0];
64
65 SqliteCommand cmd = new SqliteCommand();
66
67 if (words.Length == 1)
68 {
69 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{2}%')",
70 m_Realm, scopeID.ToString(), words[0]);
71 }
72 else
73 {
74 cmd.CommandText = String.Format("select * from {0} where (ScopeID='{1}' or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like '{2}%' or LastName like '{3}%')",
75 m_Realm, scopeID.ToString(), words[0], words[1]);
76 }
77
78 return DoQuery(cmd);
79 }
80 }
81}