aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorSean Dague2007-12-03 20:06:01 +0000
committerSean Dague2007-12-03 20:06:01 +0000
commit8f58a9a107047bf9d9aff4d8c25171acaa8e9805 (patch)
treebde9e5b6c29792d19c487549f99f198709e61bc8
parent* Now using interpolation to expand the 256x256 heightfield data to 512x512 b... (diff)
downloadopensim-SC_OLD-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.zip
opensim-SC_OLD-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.tar.gz
opensim-SC_OLD-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.tar.bz2
opensim-SC_OLD-8f58a9a107047bf9d9aff4d8c25171acaa8e9805.tar.xz
From Justin Casey (IBM)
While exploring what it would take to get the 'new script' button working, I encountered the fact, some way down in the rabbit hole, that if a user renamed an item in their inventory and logged out (without a restart of the simulator), on log in the new name was not preserved. As far as I can see, this was because any updates which didn't occur inside a transaction were ignored by opensim. This patch pays attention to those changes. It generates a new asset when an item is updated and changes the user's inventory properties appropriately. I believe this behaviour is in line with the copy-on-write semantics used in the Second Life protocol - perhaps it could be optimized if we knew for sure that the only copy of the object was in the user's inventory. This also means that if you rename an item (e.g. a script) before you drag it into an object's inventory, the inventory will receive the item's most recent name and description.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IClientAPI.cs11
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs32
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs119
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs7
5 files changed, 120 insertions, 51 deletions
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index a3177f7..68a0591 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -310,8 +310,9 @@ namespace OpenSim.Framework
310 310
311 public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID); 311 public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
312 312
313 public delegate void UpdateInventoryItemTransaction( 313 public delegate void UpdateInventoryItem(
314 IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID); 314 IClientAPI remoteClient, LLUUID transactionID, LLUUID itemID, string name, string description,
315 uint nextOwnerMask);
315 316
316 public delegate void CopyInventoryItem( 317 public delegate void CopyInventoryItem(
317 IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName); 318 IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName);
@@ -392,7 +393,7 @@ namespace OpenSim.Framework
392 event FetchInventoryDescendents OnFetchInventoryDescendents; 393 event FetchInventoryDescendents OnFetchInventoryDescendents;
393 event FetchInventory OnFetchInventory; 394 event FetchInventory OnFetchInventory;
394 event RequestTaskInventory OnRequestTaskInventory; 395 event RequestTaskInventory OnRequestTaskInventory;
395 event UpdateInventoryItemTransaction OnUpdateInventoryItem; 396 event UpdateInventoryItem OnUpdateInventoryItem;
396 event CopyInventoryItem OnCopyInventoryItem; 397 event CopyInventoryItem OnCopyInventoryItem;
397 event UDPAssetUploadRequest OnAssetUploadRequest; 398 event UDPAssetUploadRequest OnAssetUploadRequest;
398 event XferReceive OnXferReceive; 399 event XferReceive OnXferReceive;
@@ -417,6 +418,8 @@ namespace OpenSim.Framework
417 LLUUID AgentId { get; } 418 LLUUID AgentId { get; }
418 419
419 LLUUID SessionId { get; } 420 LLUUID SessionId { get; }
421
422 LLUUID SecureSessionId { get; }
420 423
421 string FirstName { get; } 424 string FirstName { get; }
422 425
@@ -481,7 +484,7 @@ namespace OpenSim.Framework
481 /// <summary> 484 /// <summary>
482 /// Tell the client that we have created the item it requested. 485 /// Tell the client that we have created the item it requested.
483 /// </summary> 486 /// </summary>
484 /// <param name="Item"></param> 487 /// <param name="Item"></param>
485 void SendInventoryItemCreateUpdate(InventoryItemBase Item); 488 void SendInventoryItemCreateUpdate(InventoryItemBase Item);
486 489
487 void SendRemoveInventoryItem(LLUUID itemID); 490 void SendRemoveInventoryItem(LLUUID itemID);
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index f04a70a..1c16a95 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -59,7 +59,14 @@ namespace OpenSim.Region.ClientStack
59 //local handlers for this instance 59 //local handlers for this instance
60 60
61 private LLUUID m_sessionId; 61 private LLUUID m_sessionId;
62 public LLUUID SecureSessionID = LLUUID.Zero; 62
63 private LLUUID m_secureSessionId = LLUUID.Zero;
64
65 public LLUUID SecureSessionId
66 {
67 get { return m_secureSessionId; }
68 }
69
63 public string firstName; 70 public string firstName;
64 public string lastName; 71 public string lastName;
65 private UseCircuitCodePacket cirpack; 72 private UseCircuitCodePacket cirpack;
@@ -540,7 +547,7 @@ namespace OpenSim.Region.ClientStack
540 547
541 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) 548 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
542 { 549 {
543 SecureSessionID = sessionInfo.LoginInfo.SecureSession; 550 m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
544 } 551 }
545 InitNewClient(); 552 InitNewClient();
546 553
@@ -615,7 +622,7 @@ namespace OpenSim.Region.ClientStack
615 public event FetchInventoryDescendents OnFetchInventoryDescendents; 622 public event FetchInventoryDescendents OnFetchInventoryDescendents;
616 public event FetchInventory OnFetchInventory; 623 public event FetchInventory OnFetchInventory;
617 public event RequestTaskInventory OnRequestTaskInventory; 624 public event RequestTaskInventory OnRequestTaskInventory;
618 public event UpdateInventoryItemTransaction OnUpdateInventoryItem; 625 public event UpdateInventoryItem OnUpdateInventoryItem;
619 public event CopyInventoryItem OnCopyInventoryItem; 626 public event CopyInventoryItem OnCopyInventoryItem;
620 public event UDPAssetUploadRequest OnAssetUploadRequest; 627 public event UDPAssetUploadRequest OnAssetUploadRequest;
621 public event XferReceive OnXferReceive; 628 public event XferReceive OnXferReceive;
@@ -888,7 +895,7 @@ namespace OpenSim.Region.ClientStack
888 AgentCircuitData agentData = new AgentCircuitData(); 895 AgentCircuitData agentData = new AgentCircuitData();
889 agentData.AgentID = AgentId; 896 agentData.AgentID = AgentId;
890 agentData.SessionID = m_sessionId; 897 agentData.SessionID = m_sessionId;
891 agentData.SecureSessionID = SecureSessionID; 898 agentData.SecureSessionID = SecureSessionId;
892 agentData.circuitcode = m_circuitCode; 899 agentData.circuitcode = m_circuitCode;
893 agentData.child = false; 900 agentData.child = false;
894 agentData.firstname = firstName; 901 agentData.firstname = firstName;
@@ -2953,10 +2960,10 @@ namespace OpenSim.Region.ClientStack
2953 case PacketType.AssetUploadRequest: 2960 case PacketType.AssetUploadRequest:
2954 AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack; 2961 AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack;
2955 // Console.WriteLine("upload request " + Pack.ToString()); 2962 // Console.WriteLine("upload request " + Pack.ToString());
2956 // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated()); 2963 // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToStringHyphenated());
2957 if (OnAssetUploadRequest != null) 2964 if (OnAssetUploadRequest != null)
2958 { 2965 {
2959 OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID), 2966 OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionId),
2960 request.AssetBlock.TransactionID, request.AssetBlock.Type, 2967 request.AssetBlock.TransactionID, request.AssetBlock.Type,
2961 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); 2968 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal);
2962 } 2969 }
@@ -3033,12 +3040,11 @@ namespace OpenSim.Region.ClientStack
3033 { 3040 {
3034 for (int i = 0; i < update.InventoryData.Length; i++) 3041 for (int i = 0; i < update.InventoryData.Length; i++)
3035 { 3042 {
3036 if (update.InventoryData[i].TransactionID != LLUUID.Zero) 3043 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
3037 { 3044 update.InventoryData[i].ItemID,
3038 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, 3045 Util.FieldToString(update.InventoryData[i].Name),
3039 update.InventoryData[i].TransactionID.Combine(SecureSessionID), 3046 Util.FieldToString(update.InventoryData[i].Description),
3040 update.InventoryData[i].ItemID); 3047 update.InventoryData[i].NextOwnerMask);
3041 }
3042 } 3048 }
3043 } 3049 }
3044 //Console.WriteLine(Pack.ToString()); 3050 //Console.WriteLine(Pack.ToString());
@@ -3046,7 +3052,7 @@ namespace OpenSim.Region.ClientStack
3046 { 3052 {
3047 if (update.InventoryData[i].TransactionID != LLUUID.Zero) 3053 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
3048 { 3054 {
3049 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); 3055 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionId));
3050 if (asset != null) 3056 if (asset != null)
3051 { 3057 {
3052 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); 3058 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 1ea8d5a..5976fdc 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -106,53 +106,108 @@ namespace OpenSim.Region.Environment.Scenes
106 return LLUUID.Zero; 106 return LLUUID.Zero;
107 } 107 }
108 108
109 public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, 109 /// <summary>
110 LLUUID itemID) 110 /// Update an item which is either already in the client's inventory or is within
111 { 111 /// a transaction
112 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 112 /// </summary>
113 if (userInfo != null) 113 /// <param name="remoteClient"></param>
114 /// <param name="transactionID">The transaction ID. If this is LLUUID.Zero we will
115 /// assume that we are not in a transaction</param>
116 /// <param name="itemID">The ID of the updated item</param>
117 /// <param name="name">The name of the updated item</param>
118 /// <param name="description">The description of the updated item</param>
119 /// <param name="nextOwnerMask">The permissions of the updated item</param>
120 public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID,
121 LLUUID itemID, string name, string description,
122 uint nextOwnerMask)
123 {
124 CachedUserInfo userInfo
125 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
126
127 if (userInfo != null && userInfo.RootFolder != null)
114 { 128 {
115 if (userInfo.RootFolder != null) 129 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
130 if (item != null)
116 { 131 {
117 InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); 132 AssetBase asset = null;
118 if (item != null) 133 bool addAsset = false;
134
135 // If we're not inside a transaction and an existing asset is attached
136 // to the update item, then we need to create a new asset for the new details
137 if (LLUUID.Zero == transactionID)
138 {
139 asset = AssetCache.GetAsset(item.assetID);
140
141 if (asset != null)
142 {
143 // to update an item we need to create a new asset
144 // it's possible that this could be optimized to an update if we knew
145 // that the owner's inventory had the only copy of the item (I believe
146 // we're using copy on write semantics).
147 item.inventoryName = asset.Name = name;
148 item.inventoryDescription = asset.Description = description;
149 item.inventoryNextPermissions = nextOwnerMask;
150 item.assetID = asset.FullID = LLUUID.Random();
151
152 addAsset = true;
153 }
154 else
155 {
156 OpenSim.Framework.Console.MainLog.Instance.Warn(
157 "Asset ID " + item.assetID + " not found for item ID " + itemID
158 + " named " + item.inventoryName + " for an inventory item update.");
159 return;
160 }
161 }
162 else
119 { 163 {
120 AgentAssetTransactions transactions = 164 AgentAssetTransactions transactions
121 CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId); 165 = CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
166
122 if (transactions != null) 167 if (transactions != null)
123 { 168 {
124 AssetBase asset = null; 169 LLUUID assetID = transactionID.Combine(remoteClient.SecureSessionId);
125 bool addToCache = false;
126
127 asset = AssetCache.GetAsset(assetID); 170 asset = AssetCache.GetAsset(assetID);
171
128 if (asset == null) 172 if (asset == null)
129 { 173 {
130 asset = transactions.GetTransactionAsset(transactionID); 174 asset = transactions.GetTransactionAsset(transactionID);
131 addToCache = true;
132 } 175 }
133 176
134 if (asset != null) 177 if (asset != null && asset.FullID == assetID)
135 { 178 {
136 if (asset.FullID == assetID) 179 asset.Name = item.inventoryName;
137 { 180 asset.Description = item.inventoryDescription;
138 asset.Name = item.inventoryName; 181 asset.InvType = (sbyte) item.invType;
139 asset.Description = item.inventoryDescription; 182 asset.Type = (sbyte) item.assetType;
140 asset.InvType = (sbyte) item.invType; 183 item.assetID = asset.FullID;
141 asset.Type = (sbyte) item.assetType; 184
142 item.assetID = asset.FullID; 185 addAsset = true;
143
144 if (addToCache)
145 {
146 AssetCache.AddAsset(asset);
147 }
148
149 userInfo.UpdateItem(remoteClient.AgentId, item);
150 }
151 } 186 }
152 } 187 }
153 } 188 }
189
190 if (asset != null)
191 {
192 if (addAsset)
193 {
194 AssetCache.AddAsset(asset);
195 }
196
197 userInfo.UpdateItem(remoteClient.AgentId, item);
198 }
199 }
200 else
201 {
202 OpenSim.Framework.Console.MainLog.Instance.Warn(
203 "Item ID " + itemID + " not found for an inventory item update.");
154 } 204 }
155 } 205 }
206 else
207 {
208 OpenSim.Framework.Console.MainLog.Instance.Warn(
209 "Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
210 }
156 } 211 }
157 212
158 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) 213 public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName)
@@ -507,4 +562,4 @@ namespace OpenSim.Region.Environment.Scenes
507 rootPart.ScheduleFullUpdate(); 562 rootPart.ScheduleFullUpdate();
508 } 563 }
509 } 564 }
510} \ No newline at end of file 565}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 09ecae0..8fc04c4 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -989,7 +989,7 @@ namespace OpenSim.Region.Environment.Scenes
989 client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents; 989 client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents;
990 client.OnRequestTaskInventory += RequestTaskInventory; 990 client.OnRequestTaskInventory += RequestTaskInventory;
991 client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory; 991 client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory;
992 client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; 992 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
993 client.OnCopyInventoryItem += CopyInventoryItem; 993 client.OnCopyInventoryItem += CopyInventoryItem;
994 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; 994 client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
995 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; 995 client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 6887deb..69cf7b3 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -108,7 +108,7 @@ namespace SimpleApp
108 public event FetchInventoryDescendents OnFetchInventoryDescendents; 108 public event FetchInventoryDescendents OnFetchInventoryDescendents;
109 public event FetchInventory OnFetchInventory; 109 public event FetchInventory OnFetchInventory;
110 public event RequestTaskInventory OnRequestTaskInventory; 110 public event RequestTaskInventory OnRequestTaskInventory;
111 public event UpdateInventoryItemTransaction OnUpdateInventoryItem; 111 public event UpdateInventoryItem OnUpdateInventoryItem;
112 public event CopyInventoryItem OnCopyInventoryItem; 112 public event CopyInventoryItem OnCopyInventoryItem;
113 public event UDPAssetUploadRequest OnAssetUploadRequest; 113 public event UDPAssetUploadRequest OnAssetUploadRequest;
114 public event XferReceive OnXferReceive; 114 public event XferReceive OnXferReceive;
@@ -157,6 +157,11 @@ namespace SimpleApp
157 { 157 {
158 get { return LLUUID.Zero; } 158 get { return LLUUID.Zero; }
159 } 159 }
160
161 public LLUUID SecureSessionId
162 {
163 get { return LLUUID.Zero; }
164 }
160 165
161 public virtual string FirstName 166 public virtual string FirstName
162 { 167 {