Restarting to work on HGSuitcaseInventoryService: added the ability for the outside world to retrieve appearance items. Not ACLed yet.

connector_plugin
Diva Canto 2012-09-13 10:00:29 -07:00
parent 81fda6f947
commit 190f9c258b
2 changed files with 58 additions and 4 deletions

View File

@ -308,6 +308,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
protected override InventoryItemBase GetItem(UUID agentID, UUID itemID) protected override InventoryItemBase GetItem(UUID agentID, UUID itemID)
{ {
InventoryItemBase item = base.GetItem(agentID, itemID); InventoryItemBase item = base.GetItem(agentID, itemID);
if (item == null)
return null;
string userAssetServer = string.Empty; string userAssetServer = string.Empty;
if (IsForeignUser(agentID, out userAssetServer)) if (IsForeignUser(agentID, out userAssetServer))

View File

@ -56,10 +56,12 @@ namespace OpenSim.Services.HypergridService
private string m_HomeURL; private string m_HomeURL;
private IUserAccountService m_UserAccountService; private IUserAccountService m_UserAccountService;
private IAvatarService m_AvatarService;
// private UserAccountCache m_Cache; // private UserAccountCache m_Cache;
private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>(); private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID, List<XInventoryFolder>>();
private ExpiringCache<UUID, AvatarAppearance> m_Appearances = new ExpiringCache<UUID, AvatarAppearance>();
public HGSuitcaseInventoryService(IConfigSource config, string configName) public HGSuitcaseInventoryService(IConfigSource config, string configName)
: base(config, configName) : base(config, configName)
@ -77,7 +79,6 @@ namespace OpenSim.Services.HypergridService
IConfig invConfig = config.Configs[m_ConfigName]; IConfig invConfig = config.Configs[m_ConfigName];
if (invConfig != null) if (invConfig != null)
{ {
// realm = authConfig.GetString("Realm", realm);
string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
if (userAccountsDll == string.Empty) if (userAccountsDll == string.Empty)
throw new Exception("Please specify UserAccountsService in HGInventoryService configuration"); throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
@ -87,8 +88,14 @@ namespace OpenSim.Services.HypergridService
if (m_UserAccountService == null) if (m_UserAccountService == null)
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
// legacy configuration [obsolete] string avatarDll = invConfig.GetString("AvatarService", string.Empty);
m_HomeURL = invConfig.GetString("ProfileServerURI", string.Empty); if (avatarDll == string.Empty)
throw new Exception("Please specify AvatarService in HGInventoryService configuration");
m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarDll, args);
if (m_AvatarService == null)
throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
// Preferred // Preferred
m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL); m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL);
@ -394,7 +401,7 @@ namespace OpenSim.Services.HypergridService
return null; return null;
} }
if (!IsWithinSuitcaseTree(it.Owner, it.Folder)) if (!IsWithinSuitcaseTree(it.Owner, it.Folder) && !IsPartOfAppearance(it.Owner, it.ID))
{ {
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
it.Name, it.Folder); it.Name, it.Folder);
@ -549,6 +556,51 @@ namespace OpenSim.Services.HypergridService
else return true; else return true;
} }
#endregion #endregion
#region Avatar Appearance
private AvatarAppearance GetAppearance(UUID principalID)
{
AvatarAppearance a = null;
if (m_Appearances.TryGetValue(principalID, out a))
return a;
a = m_AvatarService.GetAppearance(principalID);
m_Appearances.AddOrUpdate(principalID, a, 5 * 60); // 5minutes
return a;
}
private bool IsPartOfAppearance(UUID principalID, UUID itemID)
{
AvatarAppearance a = GetAppearance(principalID);
if (a == null)
return false;
// Check wearables (body parts and clothes)
for (int i = 0; i < a.Wearables.Length; i++)
{
for (int j = 0; j < a.Wearables[i].Count; j++)
{
if (a.Wearables[i][j].ItemID == itemID)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is a wearable", itemID);
return true;
}
}
}
// Check attachments
if (a.GetAttachmentForItem(itemID) != null)
{
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: item {0} is an attachment", itemID);
return true;
}
return false;
}
#endregion
} }
} }