Finish conversion if XInventoryService
parent
e76333555d
commit
1ae9bfc074
|
@ -77,6 +77,8 @@ namespace OpenSim.Data
|
||||||
bool DeleteFolders(string field, string val);
|
bool DeleteFolders(string field, string val);
|
||||||
bool DeleteItems(string field, string val);
|
bool DeleteItems(string field, string val);
|
||||||
|
|
||||||
bool MoveItem(string principalID, string id, string newParent);
|
bool MoveItem(string id, string newParent);
|
||||||
|
XInventoryItem[] GetActiveGestures(UUID principalID);
|
||||||
|
int GetAssetPermissions(UUID principalID, UUID assetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,19 @@ namespace OpenSim.Data.MySQL
|
||||||
return m_Items.Delete(field, val);
|
return m_Items.Delete(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MoveItem(string principalID, string id, string newParent)
|
public bool MoveItem(string id, string newParent)
|
||||||
{
|
{
|
||||||
return m_Items.MoveItem(principalID, id, newParent);
|
return m_Items.MoveItem(id, newParent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||||
|
{
|
||||||
|
return m_Items.GetActiveGestures(principalID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||||
|
{
|
||||||
|
return m_Items.GetAssetPermissions(principalID, assetID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,16 +108,49 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MoveItem(string principalID, string id, string newParent)
|
public bool MoveItem(string id, string newParent)
|
||||||
{
|
{
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
MySqlCommand cmd = new MySqlCommand();
|
||||||
|
|
||||||
cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where agentID = ?AgentID and folderID = ?FolderID");
|
cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
|
||||||
cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
|
cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
|
||||||
cmd.Parameters.AddWithValue("?FolderID", id);
|
cmd.Parameters.AddWithValue("?InventoryID", id);
|
||||||
cmd.Parameters.AddWithValue("?AgentID", principalID);
|
|
||||||
|
|
||||||
return ExecuteNonQuery(cmd) == 0 ? false : true;
|
return ExecuteNonQuery(cmd) == 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||||
|
{
|
||||||
|
MySqlCommand cmd = new MySqlCommand();
|
||||||
|
cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm);
|
||||||
|
|
||||||
|
cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
||||||
|
|
||||||
|
return DoQuery(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||||
|
{
|
||||||
|
MySqlCommand cmd = new MySqlCommand();
|
||||||
|
|
||||||
|
cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
|
||||||
|
cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
|
||||||
|
cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
|
||||||
|
|
||||||
|
IDataReader reader = ExecuteReader(cmd);
|
||||||
|
|
||||||
|
int perms = 0;
|
||||||
|
|
||||||
|
if (reader.Read())
|
||||||
|
{
|
||||||
|
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
reader.Close();
|
||||||
|
CloseReaderCommand(cmd);
|
||||||
|
|
||||||
|
return perms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,10 @@ namespace OpenSim.Services.InventoryService
|
||||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||||
|
|
||||||
foreach (XInventoryFolder x in allFolders)
|
foreach (XInventoryFolder x in allFolders)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INVENTORY]: Adding folder {0} to skeleton", x.folderName);
|
||||||
folders.Add(ConvertToOpenSim(x));
|
folders.Add(ConvertToOpenSim(x));
|
||||||
|
}
|
||||||
|
|
||||||
return folders;
|
return folders;
|
||||||
}
|
}
|
||||||
|
@ -214,35 +217,48 @@ namespace OpenSim.Services.InventoryService
|
||||||
|
|
||||||
public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
|
public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
|
||||||
{
|
{
|
||||||
|
// This method doesn't receive a valud principal id from the
|
||||||
|
// connector. So we disregard the principal and look
|
||||||
|
// by ID.
|
||||||
|
//
|
||||||
|
m_log.DebugFormat("[INVENTORY]: Fetch contents for folder {0}", folderID.ToString());
|
||||||
InventoryCollection inventory = new InventoryCollection();
|
InventoryCollection inventory = new InventoryCollection();
|
||||||
inventory.UserID = principalID;
|
inventory.UserID = principalID;
|
||||||
inventory.Folders = new List<InventoryFolderBase>();
|
inventory.Folders = new List<InventoryFolderBase>();
|
||||||
inventory.Items = new List<InventoryItemBase>();
|
inventory.Items = new List<InventoryItemBase>();
|
||||||
|
|
||||||
XInventoryFolder[] folders = m_Database.GetFolders(
|
XInventoryFolder[] folders = m_Database.GetFolders(
|
||||||
new string[] { "agentID", "parentFolderID"},
|
new string[] { "parentFolderID"},
|
||||||
new string[] { principalID.ToString(), UUID.Zero.ToString() });
|
new string[] { folderID.ToString() });
|
||||||
|
|
||||||
foreach (XInventoryFolder x in folders)
|
foreach (XInventoryFolder x in folders)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INVENTORY]: Adding folder {0} to response", x.folderName);
|
||||||
inventory.Folders.Add(ConvertToOpenSim(x));
|
inventory.Folders.Add(ConvertToOpenSim(x));
|
||||||
|
}
|
||||||
|
|
||||||
XInventoryItem[] items = m_Database.GetItems(
|
XInventoryItem[] items = m_Database.GetItems(
|
||||||
new string[] { "avatarID", "parentFolderID"},
|
new string[] { "parentFolderID"},
|
||||||
new string[] { principalID.ToString(), UUID.Zero.ToString() });
|
new string[] { folderID.ToString() });
|
||||||
|
|
||||||
foreach (XInventoryItem i in items)
|
foreach (XInventoryItem i in items)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[INVENTORY]: Adding item {0} to response", i.inventoryName);
|
||||||
inventory.Items.Add(ConvertToOpenSim(i));
|
inventory.Items.Add(ConvertToOpenSim(i));
|
||||||
|
}
|
||||||
|
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
|
public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
|
||||||
{
|
{
|
||||||
|
// Since we probably don't get a valid principal here, either ...
|
||||||
|
//
|
||||||
List<InventoryItemBase> invItems = new List<InventoryItemBase>();
|
List<InventoryItemBase> invItems = new List<InventoryItemBase>();
|
||||||
|
|
||||||
XInventoryItem[] items = m_Database.GetItems(
|
XInventoryItem[] items = m_Database.GetItems(
|
||||||
new string[] { "avatarID", "parentFolderID"},
|
new string[] { "parentFolderID"},
|
||||||
new string[] { principalID.ToString(), UUID.Zero.ToString() });
|
new string[] { UUID.Zero.ToString() });
|
||||||
|
|
||||||
foreach (XInventoryItem i in items)
|
foreach (XInventoryItem i in items)
|
||||||
invItems.Add(ConvertToOpenSim(i));
|
invItems.Add(ConvertToOpenSim(i));
|
||||||
|
@ -279,6 +295,8 @@ namespace OpenSim.Services.InventoryService
|
||||||
//
|
//
|
||||||
public bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
|
public bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
|
||||||
{
|
{
|
||||||
|
// Ignore principal ID, it's bogus at connector level
|
||||||
|
//
|
||||||
foreach (UUID id in folderIDs)
|
foreach (UUID id in folderIDs)
|
||||||
{
|
{
|
||||||
InventoryFolderBase f = new InventoryFolderBase();
|
InventoryFolderBase f = new InventoryFolderBase();
|
||||||
|
@ -297,7 +315,10 @@ namespace OpenSim.Services.InventoryService
|
||||||
new string[] { folder.ID.ToString() });
|
new string[] { folder.ID.ToString() });
|
||||||
|
|
||||||
foreach (XInventoryFolder x in subFolders)
|
foreach (XInventoryFolder x in subFolders)
|
||||||
|
{
|
||||||
PurgeFolder(ConvertToOpenSim(x));
|
PurgeFolder(ConvertToOpenSim(x));
|
||||||
|
m_Database.DeleteFolders("folderID", x.folderID.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
|
m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
|
||||||
|
|
||||||
|
@ -316,10 +337,11 @@ namespace OpenSim.Services.InventoryService
|
||||||
|
|
||||||
public bool MoveItems(UUID principalID, List<InventoryItemBase> items)
|
public bool MoveItems(UUID principalID, List<InventoryItemBase> items)
|
||||||
{
|
{
|
||||||
|
// Principal is b0rked. *sigh*
|
||||||
|
//
|
||||||
foreach (InventoryItemBase i in items)
|
foreach (InventoryItemBase i in items)
|
||||||
{
|
{
|
||||||
m_Database.MoveItem(principalID.ToString(), i.ID.ToString(),
|
m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString());
|
||||||
i.Folder.ToString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -327,6 +349,8 @@ namespace OpenSim.Services.InventoryService
|
||||||
|
|
||||||
public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
|
public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
|
// Just use the ID... *facepalms*
|
||||||
|
//
|
||||||
foreach (UUID id in itemIDs)
|
foreach (UUID id in itemIDs)
|
||||||
m_Database.DeleteItems("inventoryID", id.ToString());
|
m_Database.DeleteItems("inventoryID", id.ToString());
|
||||||
|
|
||||||
|
@ -357,14 +381,24 @@ namespace OpenSim.Services.InventoryService
|
||||||
return ConvertToOpenSim(folders[0]);
|
return ConvertToOpenSim(folders[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryItemBase> GetActiveGestures(UUID userId)
|
public List<InventoryItemBase> GetActiveGestures(UUID principalID)
|
||||||
{
|
{
|
||||||
|
XInventoryItem[] items = m_Database.GetActiveGestures(principalID);
|
||||||
|
|
||||||
|
if (items.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
List<InventoryItemBase> ret = new List<InventoryItemBase>();
|
||||||
|
|
||||||
|
foreach (XInventoryItem x in items)
|
||||||
|
ret.Add(ConvertToOpenSim(x));
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetAssetPermissions(UUID userID, UUID assetID)
|
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||||
{
|
{
|
||||||
return 0;
|
return m_Database.GetAssetPermissions(principalID, assetID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CM never needed those. Left unimplemented.
|
// CM never needed those. Left unimplemented.
|
||||||
|
|
Loading…
Reference in New Issue