diff options
author | Jeff Ames | 2007-11-18 13:50:46 +0000 |
---|---|---|
committer | Jeff Ames | 2007-11-18 13:50:46 +0000 |
commit | d10c79d4216436fd2a5056dbf853f317967202af (patch) | |
tree | 2474bfe5d0f56f624a19ff112807233e5e335f08 /OpenSim/Region/Environment | |
parent | * Found several cases where prim set physical were not subscribing to physics... (diff) | |
download | opensim-SC_OLD-d10c79d4216436fd2a5056dbf853f317967202af.zip opensim-SC_OLD-d10c79d4216436fd2a5056dbf853f317967202af.tar.gz opensim-SC_OLD-d10c79d4216436fd2a5056dbf853f317967202af.tar.bz2 opensim-SC_OLD-d10c79d4216436fd2a5056dbf853f317967202af.tar.xz |
first stab at implementation of CopyInventoryItem
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 127 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 1 |
2 files changed, 85 insertions, 43 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index b06fa2f..bc0ccb3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -31,6 +31,7 @@ using libsecondlife; | |||
31 | using libsecondlife.Packets; | 31 | using libsecondlife.Packets; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Communications.Cache; | 33 | using OpenSim.Framework.Communications.Cache; |
34 | using OpenSim.Framework.Console; | ||
34 | using OpenSim.Region.Physics.Manager; | 35 | using OpenSim.Region.Physics.Manager; |
35 | 36 | ||
36 | namespace OpenSim.Region.Environment.Scenes | 37 | namespace OpenSim.Region.Environment.Scenes |
@@ -82,24 +83,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
82 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); | 83 | InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); |
83 | if (item != null) | 84 | if (item != null) |
84 | { | 85 | { |
85 | AssetBase asset; | 86 | AssetBase asset = CreateAsset(item.inventoryName, item.inventoryDescription, (sbyte) item.invType, (sbyte) item.assetType, data); |
86 | asset = new AssetBase(); | ||
87 | asset.FullID = LLUUID.Random(); | ||
88 | asset.Type = (sbyte) item.assetType; | ||
89 | asset.InvType = (sbyte) item.invType; | ||
90 | asset.Name = item.inventoryName; | ||
91 | asset.Data = data; | ||
92 | AssetCache.AddAsset(asset); | 87 | AssetCache.AddAsset(asset); |
93 | 88 | ||
94 | item.assetID = asset.FullID; | 89 | item.assetID = asset.FullID; |
95 | userInfo.UpdateItem(remoteClient.AgentId, item); | 90 | userInfo.UpdateItem(remoteClient.AgentId, item); |
96 | 91 | ||
97 | // remoteClient.SendInventoryItemUpdate(item); | 92 | // remoteClient.SendInventoryItemUpdate(item); |
98 | if (item.invType == 7) | 93 | if ((InventoryType) item.invType == InventoryType.Notecard) |
99 | { | 94 | { |
100 | //do we want to know about updated note cards? | 95 | //do we want to know about updated note cards? |
101 | } | 96 | } |
102 | else if (item.invType == 10) | 97 | else if ((InventoryType) item.invType == InventoryType.LSL) |
103 | { | 98 | { |
104 | // do we want to know about updated scripts | 99 | // do we want to know about updated scripts |
105 | } | 100 | } |
@@ -160,6 +155,75 @@ namespace OpenSim.Region.Environment.Scenes | |||
160 | } | 155 | } |
161 | } | 156 | } |
162 | 157 | ||
158 | public void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName) | ||
159 | { | ||
160 | InventoryItemBase item = CommsManager.UserProfileCache.libraryRoot.HasItem(oldItemID); | ||
161 | if (item == null) | ||
162 | { | ||
163 | CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(oldAgentID); | ||
164 | if (userInfo == null) | ||
165 | { | ||
166 | MainLog.Instance.Warn("INVENTORY", "Failed to find user " + oldAgentID.ToString()); | ||
167 | return; | ||
168 | } | ||
169 | |||
170 | item = userInfo.RootFolder.HasItem(oldItemID); | ||
171 | if (item == null) | ||
172 | { | ||
173 | MainLog.Instance.Warn("INVENTORY", "Failed to find item " + oldItemID.ToString()); | ||
174 | return; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | AssetBase asset = AssetCache.CopyAsset(item.assetID); | ||
179 | if (asset == null) | ||
180 | { | ||
181 | MainLog.Instance.Warn("INVENTORY", "Failed to find asset " + item.assetID.ToString()); | ||
182 | return; | ||
183 | } | ||
184 | |||
185 | asset.Name = (newName.Length == 0) ? item.inventoryName : newName; | ||
186 | |||
187 | // TODO: preserve current permissions? | ||
188 | CreateNewInventoryItem(remoteClient, newFolderID, callbackID, asset, item.inventoryNextPermissions); | ||
189 | } | ||
190 | |||
191 | private AssetBase CreateAsset(string name, string description, sbyte invType, sbyte assetType, byte[] data) | ||
192 | { | ||
193 | AssetBase asset = new AssetBase(); | ||
194 | asset.Name = name; | ||
195 | asset.Description = description; | ||
196 | asset.InvType = invType; | ||
197 | asset.Type = assetType; | ||
198 | asset.FullID = LLUUID.Random(); // TODO: check for conflicts | ||
199 | asset.Data = (data == null) ? new byte[1] : data; | ||
200 | return asset; | ||
201 | } | ||
202 | |||
203 | private void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID folderID, uint callbackID, | ||
204 | AssetBase asset, uint nextOwnerMask) | ||
205 | { | ||
206 | CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); | ||
207 | if (userInfo != null) | ||
208 | { | ||
209 | InventoryItemBase item = new InventoryItemBase(); | ||
210 | item.avatarID = remoteClient.AgentId; | ||
211 | item.creatorsID = remoteClient.AgentId; | ||
212 | item.inventoryID = LLUUID.Random(); | ||
213 | item.assetID = asset.FullID; | ||
214 | item.inventoryDescription = asset.Description; | ||
215 | item.inventoryName = asset.Name; | ||
216 | item.assetType = asset.Type; | ||
217 | item.invType = asset.InvType; | ||
218 | item.parentFolderID = folderID; | ||
219 | item.inventoryCurrentPermissions = 2147483647; | ||
220 | item.inventoryNextPermissions = nextOwnerMask; | ||
221 | |||
222 | userInfo.AddItem(remoteClient.AgentId, item); | ||
223 | remoteClient.SendInventoryItemUpdate(item); | ||
224 | } | ||
225 | } | ||
226 | |||
163 | /// <summary> | 227 | /// <summary> |
164 | /// temporary method to test out creating new inventory items | 228 | /// temporary method to test out creating new inventory items |
165 | /// </summary> | 229 | /// </summary> |
@@ -174,7 +238,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
174 | /// <param name="wearableType"></param> | 238 | /// <param name="wearableType"></param> |
175 | /// <param name="nextOwnerMask"></param> | 239 | /// <param name="nextOwnerMask"></param> |
176 | public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, | 240 | public void CreateNewInventoryItem(IClientAPI remoteClient, LLUUID transActionID, LLUUID folderID, |
177 | uint callbackID, string description, string name, sbyte invType, sbyte type, | 241 | uint callbackID, string description, string name, sbyte invType, sbyte assetType, |
178 | byte wearableType, uint nextOwnerMask) | 242 | byte wearableType, uint nextOwnerMask) |
179 | { | 243 | { |
180 | if (transActionID == LLUUID.Zero) | 244 | if (transActionID == LLUUID.Zero) |
@@ -182,37 +246,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
182 | CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); | 246 | CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); |
183 | if (userInfo != null) | 247 | if (userInfo != null) |
184 | { | 248 | { |
185 | AssetBase asset = new AssetBase(); | 249 | AssetBase asset = CreateAsset(name, description, invType, assetType, null); |
186 | asset.Name = name; | ||
187 | asset.Description = description; | ||
188 | asset.InvType = invType; | ||
189 | asset.Type = type; | ||
190 | asset.FullID = LLUUID.Random(); | ||
191 | asset.Data = new byte[1]; | ||
192 | AssetCache.AddAsset(asset); | 250 | AssetCache.AddAsset(asset); |
193 | 251 | ||
194 | InventoryItemBase item = new InventoryItemBase(); | 252 | CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask); |
195 | item.avatarID = remoteClient.AgentId; | ||
196 | item.creatorsID = remoteClient.AgentId; | ||
197 | item.inventoryID = LLUUID.Random(); | ||
198 | item.assetID = asset.FullID; | ||
199 | item.inventoryDescription = description; | ||
200 | item.inventoryName = name; | ||
201 | item.assetType = invType; | ||
202 | item.invType = invType; | ||
203 | item.parentFolderID = folderID; | ||
204 | item.inventoryCurrentPermissions = 2147483647; | ||
205 | item.inventoryNextPermissions = nextOwnerMask; | ||
206 | |||
207 | userInfo.AddItem(remoteClient.AgentId, item); | ||
208 | remoteClient.SendInventoryItemUpdate(item); | ||
209 | } | 253 | } |
210 | } | 254 | } |
211 | else | 255 | else |
212 | { | 256 | { |
213 | CommsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, | 257 | CommsManager.TransactionsManager.HandleInventoryFromTransaction(remoteClient, transActionID, folderID, |
214 | callbackID, description, name, invType, | 258 | callbackID, description, name, invType, |
215 | type, wearableType, nextOwnerMask); | 259 | assetType, wearableType, nextOwnerMask); |
216 | //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); | 260 | //System.Console.WriteLine("request to create inventory item from transaction " + transActionID); |
217 | } | 261 | } |
218 | } | 262 | } |
@@ -348,21 +392,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
348 | CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); | 392 | CachedUserInfo userInfo = CommsManager.UserProfileCache.GetUserDetails(remoteClient.AgentId); |
349 | if (userInfo != null) | 393 | if (userInfo != null) |
350 | { | 394 | { |
351 | AssetBase asset = new AssetBase(); | 395 | AssetBase asset = CreateAsset( |
352 | asset.Name = ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId); | 396 | ((SceneObjectGroup) selectedEnt).GetPartName(selectedEnt.LocalId), |
353 | asset.Description = | 397 | ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId), |
354 | ((SceneObjectGroup) selectedEnt).GetPartDescription(selectedEnt.LocalId); | 398 | (sbyte) InventoryType.Object, |
355 | asset.InvType = 6; | 399 | (sbyte) AssetType.Object, // TODO: after libSL r1357, this becomes AssetType.Primitive |
356 | asset.Type = 6; | 400 | Helpers.StringToField(sceneObjectXml)); |
357 | asset.FullID = LLUUID.Random(); | ||
358 | asset.Data = Helpers.StringToField(sceneObjectXml); | ||
359 | AssetCache.AddAsset(asset); | 401 | AssetCache.AddAsset(asset); |
360 | 402 | ||
361 | |||
362 | InventoryItemBase item = new InventoryItemBase(); | 403 | InventoryItemBase item = new InventoryItemBase(); |
363 | item.avatarID = remoteClient.AgentId; | 404 | item.avatarID = remoteClient.AgentId; |
364 | item.creatorsID = remoteClient.AgentId; | 405 | item.creatorsID = remoteClient.AgentId; |
365 | item.inventoryID = LLUUID.Random(); | 406 | item.inventoryID = LLUUID.Random(); // TODO: check for conflicts |
366 | item.assetID = asset.FullID; | 407 | item.assetID = asset.FullID; |
367 | item.inventoryDescription = asset.Description; | 408 | item.inventoryDescription = asset.Description; |
368 | item.inventoryName = asset.Name; | 409 | item.inventoryName = asset.Name; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 0b9d218..87bd0c1 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -789,6 +789,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
789 | client.OnRequestTaskInventory += RequestTaskInventory; | 789 | client.OnRequestTaskInventory += RequestTaskInventory; |
790 | client.OnFetchInventory += CommsManager.UserProfileCache.HandleFetchInventory; | 790 | client.OnFetchInventory += CommsManager.UserProfileCache.HandleFetchInventory; |
791 | client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; | 791 | client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; |
792 | client.OnCopyInventoryItem += CopyInventoryItem; | ||
792 | client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; | 793 | client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest; |
793 | client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; | 794 | client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer; |
794 | client.OnRezScript += RezScript; | 795 | client.OnRezScript += RezScript; |