30 using System.Reflection;
31 using System.Collections.Generic;
33 using Community.CsharpSqlite.Sqlite;
35 using Mono.Data.Sqlite;
39 using OpenSim.Framework;
41 namespace OpenSim.Data.SQLite
56 Util.LoadArchSpecificWindowsDll(
"sqlite3.dll");
59 conn,
"inventoryfolders",
"XInventoryStore");
61 conn,
"inventoryitems", String.Empty);
66 return m_Folders.Get(fields, vals);
71 return m_Items.Get(fields, vals);
77 folder.folderName = folder.folderName.Substring(0, 64);
79 return m_Folders.Store(folder);
85 item.inventoryName = item.inventoryName.Substring(0, 64);
87 item.inventoryDescription = item.inventoryDescription.Substring(0, 128);
89 return m_Items.Store(item);
94 return m_Folders.Delete(field, val);
99 return m_Folders.Delete(fields, vals);
104 return m_Items.Delete(field, val);
109 return m_Items.Delete(fields, vals);
114 return m_Items.MoveItem(id, newParent);
119 return m_Folders.MoveFolder(id, newParent);
124 return m_Items.GetActiveGestures(principalID);
129 return m_Items.GetAssetPermissions(principalID, assetID);
142 if (!base.Store(item))
150 public override bool Delete(
string field,
string val)
152 XInventoryItem[] retrievedItems = Get(
new string[] { field },
new string[] { val });
153 if (retrievedItems.Length == 0)
156 if (!base.Delete(field, val))
165 public override bool Delete(
string[] fields,
string[] vals)
168 if (retrievedItems.Length == 0)
171 if (!base.Delete(fields, vals))
174 HashSet<UUID> deletedItemFolderUUIDs =
new HashSet<UUID>();
176 Array.ForEach<
XInventoryItem>(retrievedItems, i => deletedItemFolderUUIDs.Add(i.parentFolderID));
178 foreach (UUID deletedItemFolderUUID
in deletedItemFolderUUIDs)
179 IncrementFolderVersion(deletedItemFolderUUID);
186 XInventoryItem[] retrievedItems = Get(
new string[] {
"inventoryID" },
new string[] {
id });
187 if (retrievedItems.Length == 0)
190 UUID oldParent = retrievedItems[0].parentFolderID;
192 using (SqliteCommand cmd =
new SqliteCommand())
194 cmd.CommandText = String.Format(
"update {0} set parentFolderID = :ParentFolderID where inventoryID = :InventoryID", m_Realm);
195 cmd.Parameters.Add(
new SqliteParameter(
":ParentFolderID", newParent));
196 cmd.Parameters.Add(
new SqliteParameter(
":InventoryID",
id));
198 if (ExecuteNonQuery(cmd, m_Connection) == 0)
202 IncrementFolderVersion(oldParent);
203 IncrementFolderVersion(newParent);
210 using (SqliteCommand cmd =
new SqliteCommand())
212 cmd.CommandText = String.Format(
"select * from inventoryitems where avatarId = :uuid and assetType = :type and flags = 1", m_Realm);
214 cmd.Parameters.Add(
new SqliteParameter(
":uuid", principalID.ToString()));
215 cmd.Parameters.Add(
new SqliteParameter(
":type", (
int)AssetType.Gesture));
225 using (SqliteCommand cmd =
new SqliteCommand())
227 cmd.CommandText = String.Format(
"select inventoryCurrentPermissions from inventoryitems where avatarID = :PrincipalID and assetID = :AssetID", m_Realm);
228 cmd.Parameters.Add(
new SqliteParameter(
":PrincipalID", principalID.ToString()));
229 cmd.Parameters.Add(
new SqliteParameter(
":AssetID", assetID.ToString()));
231 reader = ExecuteReader(cmd, m_Connection);
236 while (reader.Read())
238 perms |= Convert.ToInt32(reader[
"inventoryCurrentPermissions"]);
257 if (!base.Store(folder))
267 XInventoryFolder[] folders = Get(
new string[] {
"folderID" },
new string[] {
id });
269 if (folders.Length == 0)
272 UUID oldParentFolderUUID = folders[0].parentFolderID;
274 using (SqliteCommand cmd =
new SqliteCommand())
276 cmd.CommandText = String.Format(
"update {0} set parentFolderID = :ParentFolderID where folderID = :FolderID", m_Realm);
277 cmd.Parameters.Add(
new SqliteParameter(
":ParentFolderID", newParentFolderID));
278 cmd.Parameters.Add(
new SqliteParameter(
":FolderID",
id));
280 if (ExecuteNonQuery(cmd, m_Connection) == 0)
284 IncrementFolderVersion(oldParentFolderUUID);
285 IncrementFolderVersion(newParentFolderID);
292 public class SqliteInventoryHandler<T> : SQLiteGenericTableHandler<T> where T: class, new()
298 return IncrementFolderVersion(folderID.ToString());
306 using (SqliteCommand cmd =
new SqliteCommand())
308 cmd.CommandText =
"update inventoryfolders set version=version+1 where folderID = ?folderID";
309 cmd.Parameters.Add(
new SqliteParameter(
":folderID", folderID));
313 cmd.ExecuteNonQuery();
bool IncrementFolderVersion(UUID folderID)
bool MoveFolder(string id, string newParent)
Move a folder to another folder.
int GetAssetPermissions(UUID principalID, UUID assetID)
override bool Delete(string[] fields, string[] vals)
bool DeleteItems(string[] fields, string[] vals)
Delete items where field1 == val1, field2 == val2...
bool StoreFolder(XInventoryFolder folder)
XInventoryFolder[] GetFolders(string[] fields, string[] vals)
int GetAssetPermissions(UUID principalID, UUID assetID)
XInventoryItem[] GetActiveGestures(UUID principalID)
bool MoveItem(string id, string newParent)
Move an item to another folder.
SqliteItemHandler(string c, string t, string m)
SQLiteXInventoryData(string conn, string realm)
bool MoveFolder(string id, string newParentFolderID)
XInventoryItem[] GetItems(string[] fields, string[] vals)
bool DeleteItems(string field, string val)
Delete items where field == val
bool DeleteFolders(string[] fields, string[] vals)
Delete folders where field1 == val1, field2 == val2...
string inventoryDescription
override bool Store(XInventoryItem item)
XInventoryItem[] GetActiveGestures(UUID principalID)
override bool Store(XInventoryFolder folder)
SqliteFolderHandler(string c, string t, string m)
bool MoveItem(string id, string newParent)
bool IncrementFolderVersion(string folderID)
bool StoreItem(XInventoryItem item)
A SQLite Interface for the Asset Server
SqliteInventoryHandler(string c, string t, string m)
override bool Delete(string field, string val)
bool DeleteFolders(string field, string val)
Delete folders where field == val