mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 03:45:35 +08:00
Added MoveItems, which is most useful upon viewer-delete inventory operation. Moving a batch of items is a 1-time operation. Made it async anyway, so that the viewer doesn't wait in case the DB layer is dumb (which is the case currently).
This commit is contained in:
@@ -253,6 +253,19 @@ namespace OpenSim.Services.Connectors.Inventory
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool MoveItems(string id, List<InventoryItemBase> items, UUID sessionID)
|
||||
{
|
||||
string url = string.Empty;
|
||||
string userID = string.Empty;
|
||||
|
||||
if (StringToUrlAndUserID(id, out url, out userID))
|
||||
{
|
||||
ISessionAuthInventoryService connector = GetConnector(url);
|
||||
return connector.MoveItems(userID, items, sessionID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID)
|
||||
{
|
||||
string url = string.Empty;
|
||||
|
||||
@@ -116,6 +116,8 @@ namespace OpenSim.Services.Connectors
|
||||
/// <returns>true if the item was successfully updated</returns>
|
||||
bool UpdateItem(string userID, InventoryItemBase item, UUID session_id);
|
||||
|
||||
bool MoveItems(string userID, List<InventoryItemBase> items, UUID session_id);
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item from the user's inventory
|
||||
/// </summary>
|
||||
|
||||
@@ -383,6 +383,48 @@ namespace OpenSim.Services.Connectors
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* MoveItems Async group
|
||||
*/
|
||||
|
||||
delegate void MoveItemsDelegate(string userID, List<InventoryItemBase> items, UUID sessionID);
|
||||
|
||||
private void MoveItemsAsync(string userID, List<InventoryItemBase> items, UUID sessionID)
|
||||
{
|
||||
try
|
||||
{
|
||||
SynchronousRestSessionObjectPoster<List<InventoryItemBase>, bool>.BeginPostObject(
|
||||
"POST", m_ServerURI + "/MoveItems/", items, sessionID.ToString(), userID.ToString());
|
||||
|
||||
// Success
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory items operation failed, {0} {1} (old server?). Trying slow way.",
|
||||
e.Source, e.Message);
|
||||
}
|
||||
|
||||
foreach (InventoryItemBase item in items)
|
||||
{
|
||||
InventoryItemBase itm = this.QueryItem(userID, item, sessionID);
|
||||
itm.Name = item.Name;
|
||||
itm.Folder = item.Folder;
|
||||
this.UpdateItem(userID, itm, sessionID);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveItemsCompleted(IAsyncResult iar)
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveItems(string userID, List<InventoryItemBase> items, UUID sessionID)
|
||||
{
|
||||
MoveItemsDelegate d = MoveItemsAsync;
|
||||
d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeleteItems(string userID, List<UUID> items, UUID sessionID)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -151,6 +151,11 @@ namespace OpenSim.Services.Connectors
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteItems(UUID owner, List<UUID> itemIDs)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -142,6 +142,8 @@ namespace OpenSim.Services.Interfaces
|
||||
/// <returns>true if the item was successfully updated</returns>
|
||||
bool UpdateItem(InventoryItemBase item);
|
||||
|
||||
bool MoveItems(UUID ownerID, List<InventoryItemBase> items);
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item from the user's inventory
|
||||
/// </summary>
|
||||
|
||||
@@ -386,6 +386,24 @@ namespace OpenSim.Services.InventoryService
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[INVENTORY SERVICE]: Moving {0} items from user {1}", items.Count, ownerID);
|
||||
|
||||
InventoryItemBase itm = null;
|
||||
foreach (InventoryItemBase item in items)
|
||||
{
|
||||
itm = GetInventoryItem(item.ID);
|
||||
itm.Folder = item.Folder;
|
||||
if ((item.Name != null) && !item.Name.Equals(string.Empty))
|
||||
itm.Name = item.Name;
|
||||
m_Database.updateInventoryItem(itm);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// See IInventoryServices
|
||||
public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user