Redirected all calls to CachedUserProfile methods to the inventory service. Redirection of the RootFolder property is still todo. This compiles but probably inventory will be inconsistent.

arthursv
Diva Canto 2009-08-12 20:39:48 -07:00
parent 41ad610f3e
commit 7aa54593e0
11 changed files with 614 additions and 893 deletions

View File

@ -355,6 +355,15 @@ namespace OpenSim.Framework
}
protected int m_creationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
public InventoryItemBase()
{
}
public InventoryItemBase(UUID id)
{
ID = id;
}
public object Clone()
{
return MemberwiseClone();

View File

@ -192,40 +192,29 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{
if (XferUploaders.ContainsKey(transactionID))
{
CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
remoteClient.AgentId);
UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId);
if (userInfo != null)
AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString());
if (asset == null)
{
UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId);
AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString());
if (asset == null)
{
asset = GetTransactionAsset(transactionID);
}
if (asset != null && asset.FullID == assetID)
{
// Assets never get updated, new ones get created
asset.FullID = UUID.Random();
asset.Name = item.Name;
asset.Description = item.Description;
asset.Type = (sbyte)item.AssetType;
item.AssetID = asset.FullID;
Manager.MyScene.AssetService.Store(asset);
}
userInfo.UpdateItem(item);
asset = GetTransactionAsset(transactionID);
}
else
if (asset != null && asset.FullID == assetID)
{
m_log.ErrorFormat(
"[ASSET TRANSACTIONS]: Could not find user {0} for inventory item update",
remoteClient.AgentId);
// Assets never get updated, new ones get created
asset.FullID = UUID.Random();
asset.Name = item.Name;
asset.Description = item.Description;
asset.Type = (sbyte)item.AssetType;
item.AssetID = asset.FullID;
Manager.MyScene.AssetService.Store(asset);
}
IInventoryService invService = Manager.MyScene.InventoryService;
invService.UpdateItem(item);
}
}
}

View File

@ -32,6 +32,7 @@ using log4net;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
{
@ -214,39 +215,31 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
private void DoCreateItem(uint callbackID)
{
m_userTransactions.Manager.MyScene.AssetService.Store(m_asset);
CachedUserInfo userInfo =
m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
ourClient.AgentId);
if (userInfo != null)
{
InventoryItemBase item = new InventoryItemBase();
item.Owner = ourClient.AgentId;
item.CreatorId = ourClient.AgentId.ToString();
item.ID = UUID.Random();
item.AssetID = m_asset.FullID;
item.Description = m_description;
item.Name = m_name;
item.AssetType = type;
item.InvType = invType;
item.Folder = InventFolder;
item.BasePermissions = 0x7fffffff;
item.CurrentPermissions = 0x7fffffff;
item.GroupPermissions=0;
item.EveryOnePermissions=0;
item.NextPermissions = nextPerm;
item.Flags = (uint) wearableType;
item.CreationDate = Util.UnixTimeSinceEpoch();
IInventoryService invService = m_userTransactions.Manager.MyScene.InventoryService;
userInfo.AddItem(item);
InventoryItemBase item = new InventoryItemBase();
item.Owner = ourClient.AgentId;
item.CreatorId = ourClient.AgentId.ToString();
item.ID = UUID.Random();
item.AssetID = m_asset.FullID;
item.Description = m_description;
item.Name = m_name;
item.AssetType = type;
item.InvType = invType;
item.Folder = InventFolder;
item.BasePermissions = 0x7fffffff;
item.CurrentPermissions = 0x7fffffff;
item.GroupPermissions=0;
item.EveryOnePermissions=0;
item.NextPermissions = nextPerm;
item.Flags = (uint) wearableType;
item.CreationDate = Util.UnixTimeSinceEpoch();
if (invService.AddItem(item))
ourClient.SendInventoryItemCreateUpdate(item, callbackID);
}
else
{
m_log.ErrorFormat(
"[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation",
ourClient.AgentId);
}
ourClient.SendAlertMessage("Unable to create inventory item");
}
/// <summary>

View File

@ -39,6 +39,7 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Friends
{
@ -654,8 +655,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
initiator.ControllingClient.SendAgentOnline(new UUID[] { fromAgentID });
// find the folder for the friend...
InventoryFolderImpl folder =
initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard);
//InventoryFolderImpl folder =
// initiator.Scene.CommsManager.UserProfileCacheService.GetUserDetails(toAgentID).FindFolderForType((int)InventoryType.CallingCard);
IInventoryService invService = initiator.Scene.InventoryService;
InventoryFolderBase folder = invService.GetFolderForType(toAgentID, AssetType.CallingCard);
if (folder != null)
{
// ... and add the calling card

View File

@ -33,6 +33,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Gestures
{
@ -62,42 +63,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Gestures
public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId)
{
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
IInventoryService invService = m_scene.InventoryService;
if (userInfo != null)
InventoryItemBase item = invService.QueryItem(new InventoryItemBase(gestureId));
if (item != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId);
if (item != null)
{
item.Flags = 1;
userInfo.UpdateItem(item);
}
else
m_log.ErrorFormat(
"[GESTURES]: Unable to find gesture to activate {0} for {1}", gestureId, client.Name);
item.Flags = 1;
invService.UpdateItem(item);
}
else
m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name);
m_log.WarnFormat(
"[GESTURES]: Unable to find gesture {0} to activate for {1}", gestureId, client.Name);
}
public virtual void DeactivateGesture(IClientAPI client, UUID gestureId)
{
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId);
IInventoryService invService = m_scene.InventoryService;
if (userInfo != null)
InventoryItemBase item = invService.QueryItem(new InventoryItemBase(gestureId));
if (item != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId);
if (item != null)
{
item.Flags = 0;
userInfo.UpdateItem(item);
}
else
m_log.ErrorFormat(
"[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name);
item.Flags = 0;
invService.UpdateItem(item);
}
else
m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name);
m_log.ErrorFormat(
"[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name);
}
}
}

View File

@ -35,6 +35,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
@ -154,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
"into agent {1}'s inventory",
folderID, new UUID(im.toAgentID));
InventoryFolderImpl folderCopy
InventoryFolderBase folderCopy
= scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero);
if (folderCopy == null)
@ -247,52 +248,51 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// It will have been pushed to the client, too
//
CachedUserInfo userInfo =
scene.CommsManager.UserProfileCacheService.
GetUserDetails(client.AgentId);
//CachedUserInfo userInfo =
// scene.CommsManager.UserProfileCacheService.
// GetUserDetails(client.AgentId);
IInventoryService invService = scene.InventoryService;
if (userInfo != null)
InventoryFolderBase trashFolder =
invService.GetFolderForType(client.AgentId, AssetType.TrashFolder);
UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
InventoryItemBase item = invService.QueryItem(new InventoryItemBase(inventoryEntityID));
InventoryFolderBase folder = null;
if (item != null && trashFolder != null)
{
InventoryFolderImpl trashFolder =
userInfo.FindFolderForType((int)AssetType.TrashFolder);
item.Folder = trashFolder.ID;
UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
// Diva comment: can't we just update this item???
invService.DeleteItem(item);
scene.AddInventoryItem(client, item);
}
else
{
folder = invService.QueryFolder(new InventoryFolderBase(inventoryEntityID));
InventoryItemBase item = userInfo.RootFolder.FindItem(inventoryEntityID);
InventoryFolderBase folder = null;
if (item != null && trashFolder != null)
if (folder != null & trashFolder != null)
{
item.Folder = trashFolder.ID;
userInfo.DeleteItem(inventoryEntityID);
scene.AddInventoryItem(client, item);
folder.ParentID = trashFolder.ID;
invService.MoveFolder(folder);
}
else
{
folder = userInfo.RootFolder.FindFolder(inventoryEntityID);
}
if (folder != null & trashFolder != null)
{
userInfo.MoveFolder(inventoryEntityID, trashFolder.ID);
}
}
if ((null == item && null == folder) | null == trashFolder)
{
string reason = String.Empty;
if ((null == item && null == folder) | null == trashFolder)
{
string reason = String.Empty;
if (trashFolder == null)
reason += " Trash folder not found.";
if (item == null)
reason += " Item not found.";
if (folder == null)
reason += " Folder not found.";
if (trashFolder == null)
reason += " Trash folder not found.";
if (item == null)
reason += " Item not found.";
if (folder == null)
reason += " Folder not found.";
client.SendAgentAlertMessage("Unable to delete "+
"received inventory" + reason, false);
}
client.SendAgentAlertMessage("Unable to delete "+
"received inventory" + reason, false);
}
ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
@ -405,17 +405,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
return;
}
CachedUserInfo userInfo =
scene.CommsManager.UserProfileCacheService.
GetUserDetails(user.ControllingClient.AgentId);
//CachedUserInfo userInfo =
// scene.CommsManager.UserProfileCacheService.
// GetUserDetails(user.ControllingClient.AgentId);
if (userInfo == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient");
return;
}
//if (userInfo == null)
//{
// m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient");
// return;
//}
AssetType assetType = (AssetType)msg.binaryBucket[0];
IInventoryService invService = scene.InventoryService;
if (AssetType.Folder == assetType)
{
@ -425,31 +426,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
folder.ID = folderID;
folder.Owner = user.ControllingClient.AgentId;
// Fetch from database
// Fetch from service
//
if (!userInfo.QueryFolder(folder))
folder = invService.QueryFolder(folder);
if (folder == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't find folder to give");
return;
}
// Get folder info
//
InventoryFolderImpl folderInfo = userInfo.RootFolder.FindFolder(folder.ID);
if (folderInfo == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't retrieve folder to give");
return;
}
user.ControllingClient.SendBulkUpdateInventory(folder);
user.ControllingClient.SendBulkUpdateInventory(folderInfo);
// This unelegant, slow kludge is to reload the folders and
// items. Since a folder give can transfer subfolders and
// items, this is the easiest way to pull that stuff in
//
userInfo.DropInventory();
userInfo.FetchInventory();
//// This unelegant, slow kludge is to reload the folders and
//// items. Since a folder give can transfer subfolders and
//// items, this is the easiest way to pull that stuff in
////
//userInfo.DropInventory();
//userInfo.FetchInventory();
// Deliver message
//
@ -463,20 +456,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
item.ID = itemID;
item.Owner = user.ControllingClient.AgentId;
// Fetch from database
// Fetch from service
//
if (!userInfo.QueryItem(item))
{
m_log.Debug("[INVENTORY TRANSFER] Can't find item to give");
return;
}
// Get item info
//
item = userInfo.RootFolder.FindItem(item.ID);
item = invService.QueryItem(item);
if (item == null)
{
m_log.Debug("[INVENTORY TRANSFER] Can't retrieve item to give");
m_log.Debug("[INVENTORY TRANSFER] Can't find item to give");
return;
}

View File

@ -64,6 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
Dictionary<AssetType, InventoryFolderBase> folders = m_Connector.GetSystemFolders(presence.UUID);
m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent in {0}, fetched system folders for {1} {2}: count {3}",
presence.Scene.RegionInfo.RegionName, presence.Firstname, presence.Lastname, folders.Count);
if (folders.Count > 0)
lock (m_InventoryCache)
m_InventoryCache.Add(presence.UUID, folders);

File diff suppressed because it is too large Load Diff

View File

@ -435,17 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (null == userProfile)
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
remoteClient.Name, remoteClient.AgentId);
return;
}
userProfile.SendInventoryDecendents(remoteClient, folderID, fetchFolders, fetchItems);
SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems);
}
/// <summary>
@ -543,19 +533,10 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType,
string folderName, UUID parentID)
{
CachedUserInfo userProfile = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (null == userProfile)
InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, remoteClient.AgentId, (short)folderType, parentID, 1);
if (!InventoryService.AddFolder(folder))
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
remoteClient.Name, remoteClient.AgentId);
return;
}
if (!userProfile.CreateFolder(folderName, folderID, folderType, parentID))
{
m_log.ErrorFormat(
m_log.WarnFormat(
"[AGENT INVENTORY]: Failed to move create folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
}

View File

@ -3510,59 +3510,53 @@ namespace OpenSim.Region.Framework.Scenes
case 2: // Sell a copy
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
CachedUserInfo userInfo =
CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
uint perms=group.GetEffectivePermissions();
if (userInfo != null)
if ((perms & (uint)PermissionMask.Transfer) == 0)
{
uint perms=group.GetEffectivePermissions();
if ((perms & (uint)PermissionMask.Transfer) == 0)
{
m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
return false;
}
AssetBase asset = CreateAsset(
group.GetPartName(localID),
group.GetPartDescription(localID),
(sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml));
AssetService.Store(asset);
InventoryItemBase item = new InventoryItemBase();
item.CreatorId = part.CreatorID.ToString();
item.ID = UUID.Random();
item.Owner = remoteClient.AgentId;
item.AssetID = asset.FullID;
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
uint nextPerms=(perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
item.BasePermissions = perms & part.NextOwnerMask;
item.CurrentPermissions = perms & part.NextOwnerMask;
item.NextPermissions = part.NextOwnerMask;
item.EveryOnePermissions = part.EveryoneMask &
part.NextOwnerMask;
item.GroupPermissions = part.GroupMask &
part.NextOwnerMask;
item.CurrentPermissions |= 8; // Slam!
item.CreationDate = Util.UnixTimeSinceEpoch();
userInfo.AddItem(item);
remoteClient.SendInventoryItemCreateUpdate(item, 0);
m_dialogModule.SendAlertToUser(remoteClient, "This item doesn't appear to be for sale");
return false;
}
AssetBase asset = CreateAsset(
group.GetPartName(localID),
group.GetPartDescription(localID),
(sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml));
AssetService.Store(asset);
InventoryItemBase item = new InventoryItemBase();
item.CreatorId = part.CreatorID.ToString();
item.ID = UUID.Random();
item.Owner = remoteClient.AgentId;
item.AssetID = asset.FullID;
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
item.Folder = categoryID;
uint nextPerms=(perms & 7) << 13;
if ((nextPerms & (uint)PermissionMask.Copy) == 0)
perms &= ~(uint)PermissionMask.Copy;
if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
perms &= ~(uint)PermissionMask.Transfer;
if ((nextPerms & (uint)PermissionMask.Modify) == 0)
perms &= ~(uint)PermissionMask.Modify;
item.BasePermissions = perms & part.NextOwnerMask;
item.CurrentPermissions = perms & part.NextOwnerMask;
item.NextPermissions = part.NextOwnerMask;
item.EveryOnePermissions = part.EveryoneMask &
part.NextOwnerMask;
item.GroupPermissions = part.GroupMask &
part.NextOwnerMask;
item.CurrentPermissions |= 8; // Slam!
item.CreationDate = Util.UnixTimeSinceEpoch();
if (InventoryService.AddItem(item))
remoteClient.SendInventoryItemCreateUpdate(item, 0);
else
{
m_dialogModule.SendAlertToUser(remoteClient, "Cannot buy now. Your inventory is unavailable");
@ -3577,8 +3571,8 @@ namespace OpenSim.Region.Framework.Scenes
foreach (UUID invID in invList)
{
TaskInventoryItem item = part.Inventory.GetInventoryItem(invID);
if ((item.CurrentPermissions &
TaskInventoryItem item1 = part.Inventory.GetInventoryItem(invID);
if ((item1.CurrentPermissions &
(uint)PermissionMask.Transfer) == 0)
{
okToSell = false;

View File

@ -542,7 +542,7 @@ namespace OpenSim.Region.Framework.Scenes
group.DetachToInventoryPrep();
m_log.Debug("[DETACH]: Saving attachpoint: " +
((uint)group.GetAttachmentPoint()).ToString());
m_parentScene.updateKnownAsset(remoteClient, group,
m_parentScene.UpdateKnownItem(remoteClient, group,
group.GetFromAssetID(), group.OwnerID);
m_parentScene.DeleteSceneObject(group, false);
return;
@ -1307,7 +1307,7 @@ namespace OpenSim.Region.Framework.Scenes
group.UpdateGroupPosition(pos);
group.RootPart.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(), group.OwnerID);
m_parentScene.UpdateKnownItem(remoteClient, group, group.GetFromAssetID(), group.OwnerID);
group.SetAttachmentPoint(attachmentPoint);
}