Modify CAPS inventory code. Currently this is not executed

remotes/origin/0.6.7-post-fixes
Melanie 2009-08-28 23:28:32 +01:00
parent 3d6edc04a3
commit 22a0dff226
4 changed files with 101 additions and 36 deletions

View File

@ -57,7 +57,7 @@ namespace OpenSim.Framework.Capabilities
public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID, public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID,
bool isScriptRunning, byte[] data); bool isScriptRunning, byte[] data);
public delegate List<InventoryItemBase> FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, public delegate InventoryCollection FetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder); bool fetchFolders, bool fetchItems, int sortOrder);
/// <summary> /// <summary>
@ -460,46 +460,51 @@ namespace OpenSim.Framework.Capabilities
contents.descendents = 0; contents.descendents = 0;
reply.folders.Array.Add(contents); reply.folders.Array.Add(contents);
List<InventoryItemBase> itemList = null; InventoryCollection inv = new InventoryCollection();
inv.Folders = new List<InventoryFolderBase>();
inv.Items = new List<InventoryItemBase>();
if (CAPSFetchInventoryDescendents != null) if (CAPSFetchInventoryDescendents != null)
{ {
itemList = CAPSFetchInventoryDescendents(m_agentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order); inv = CAPSFetchInventoryDescendents(m_agentID, invFetch.folder_id, invFetch.owner_id, invFetch.fetch_folders, invFetch.fetch_items, invFetch.sort_order);
} }
if (itemList != null) if (inv.Folders != null)
{ {
foreach (InventoryItemBase invItem in itemList) foreach (InventoryFolderBase invFolder in inv.Folders)
{
contents.categories.Array.Add(ConvertInventoryFolder(invFolder));
}
}
if (inv.Items != null)
{
foreach (InventoryItemBase invItem in inv.Items)
{ {
contents.items.Array.Add(ConvertInventoryItem(invItem)); contents.items.Array.Add(ConvertInventoryItem(invItem));
} }
} }
/* The following block is removed as it ALWAYS sends the error to the client because the RC 1.22.9 client tries to
find items that have become dissasociated with a paret folder and have parent of 00000000-0000-00000....
else
{
IClientAPI client = GetClient(m_agentID);
// We're going to both notify the client of inventory service failure and send back a 'no folder contents' response.
// If we don't send back the response,
// the client becomes unhappy (see Teravus' comment in FetchInventoryRequest())
if (client != null)
{
client.SendAgentAlertMessage(
"AGIN0001E: The inventory service has either failed or is not responding. Your inventory will not function properly for the rest of this session. Please clear your cache and relog.",
true);
}
else
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not lookup controlling client for {0} in order to notify them of the inventory service failure",
m_agentID);
}
}*/
contents.descendents = contents.items.Array.Count; contents.descendents = contents.items.Array.Count;
return reply; return reply;
} }
/// <summary>
/// Convert an internal inventory folder object into an LLSD object.
/// </summary>
/// <param name="invFolder"></param>
/// <returns></returns>
private LLSDInventoryFolder ConvertInventoryFolder(InventoryFolderBase invFolder)
{
LLSDInventoryFolder llsdFolder = new LLSDInventoryFolder();
llsdFolder.folder_id = invFolder.ID;
llsdFolder.parent_id = invFolder.ParentID;
llsdFolder.name = invFolder.Name;
llsdFolder.type = TaskInventoryItem.InvTypes[invFolder.Type];
llsdFolder.preferred_type = "-1";
return llsdFolder;
}
/// <summary> /// <summary>
/// Convert an internal inventory item object into an LLSD object. /// Convert an internal inventory item object into an LLSD object.
/// </summary> /// </summary>
@ -529,15 +534,29 @@ namespace OpenSim.Framework.Capabilities
llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid; llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions; llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions; llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
llsdItem.permissions.group_id = UUID.Zero; llsdItem.permissions.group_id = invItem.GroupID;
llsdItem.permissions.group_mask = 0; llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
llsdItem.permissions.is_owner_group = false; llsdItem.permissions.is_owner_group = invItem.GroupOwned;
llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions; llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
llsdItem.permissions.owner_id = m_agentID; // FixMe llsdItem.permissions.owner_id = m_agentID;
llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions; llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
llsdItem.sale_info = new LLSDSaleInfo(); llsdItem.sale_info = new LLSDSaleInfo();
llsdItem.sale_info.sale_price = 10; llsdItem.sale_info.sale_price = invItem.SalePrice;
switch (invItem.SaleType)
{
default:
llsdItem.sale_info.sale_type = "not"; llsdItem.sale_info.sale_type = "not";
break;
case 1:
llsdItem.sale_info.sale_type = "original";
break;
case 2:
llsdItem.sale_info.sale_type = "copy";
break;
case 3:
llsdItem.sale_info.sale_type = "contents";
break;
}
return llsdItem; return llsdItem;
} }

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using OpenMetaverse;
namespace OpenSim.Framework.Capabilities
{
[OSDMap]
public class LLSDInventoryFolder
{
public UUID folder_id;
public UUID parent_id;
public string name;
public string type;
public string preferred_type;
}
}

View File

@ -90,6 +90,7 @@ namespace OpenSim.Framework.Capabilities
public UUID agent_id; public UUID agent_id;
public int descendents; public int descendents;
public UUID folder_id; public UUID folder_id;
public OSDArray categories = new OSDArray();
public OSDArray items = new OSDArray(); public OSDArray items = new OSDArray();
public UUID owner_id; public UUID owner_id;
public int version; public int version;

View File

@ -472,7 +472,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="fetchItems"></param> /// <param name="fetchItems"></param>
/// <param name="sortOrder"></param> /// <param name="sortOrder"></param>
/// <returns>null if the inventory look up failed</returns> /// <returns>null if the inventory look up failed</returns>
public List<InventoryItemBase> HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID, public InventoryCollection HandleFetchInventoryDescendentsCAPS(UUID agentID, UUID folderID, UUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder) bool fetchFolders, bool fetchItems, int sortOrder)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
@ -487,11 +487,15 @@ namespace OpenSim.Region.Framework.Scenes
InventoryFolderImpl fold; InventoryFolderImpl fold;
if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null)
{ {
return fold.RequestListOfItems(); InventoryCollection ret = new InventoryCollection();
ret.Folders = new List<InventoryFolderBase>();
ret.Items = fold.RequestListOfItems();
return ret;
} }
InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID); InventoryCollection contents = InventoryService.GetFolderContent(agentID, folderID);
return contents.Items; return contents;
} }