aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-12-04 19:57:36 +0000
committerJustin Clarke Casey2008-12-04 19:57:36 +0000
commit38ca31b37a6ac8fe74b77e4488112eb77d612827 (patch)
tree01c75a28b9f34667910f0992d8f817a5c5a1e5b3 /OpenSim/Region/Environment/Modules
parentMinor formatting cleanup. (diff)
downloadopensim-SC_OLD-38ca31b37a6ac8fe74b77e4488112eb77d612827.zip
opensim-SC_OLD-38ca31b37a6ac8fe74b77e4488112eb77d612827.tar.gz
opensim-SC_OLD-38ca31b37a6ac8fe74b77e4488112eb77d612827.tar.bz2
opensim-SC_OLD-38ca31b37a6ac8fe74b77e4488112eb77d612827.tar.xz
* Put in the code necessary to allow inventory transfer of whole folders (and their contents) between agents, not just single items
* However, this is not currently activated since it's not absolutely fully tested and there's a bug lurking in there to do with the sending of the BulkInventoryUpdate packets
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs127
-rw-r--r--OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs3
2 files changed, 95 insertions, 35 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
index 73f1761..b41c36f 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
@@ -136,42 +136,85 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
136 136
137 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) 137 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
138 { 138 {
139 ScenePresence user = 139 m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));
140 scene.GetScenePresence(new UUID(im.toAgentID)); 140
141 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
142 UUID copyID;
141 143
142 // First byte of the array is probably the item type 144 // First byte is the asset type
143 // Next 16 bytes are the UUID 145 AssetType assetType = (AssetType)im.binaryBucket[0];
146
147 // Temporarily disabled pending test of complex transfers (folders within folders, lots of items,
148 // empty folders, etc.)
149 if (AssetType.Folder == assetType)
150 return;
151
152 if (AssetType.Folder == assetType)
153 {
154 UUID folderID = new UUID(im.binaryBucket, 1);
155
156 m_log.DebugFormat("[AGENT INVENTORY]: Inserting original folder {0} "+
157 "into agent {1}'s inventory",
158 folderID, new UUID(im.toAgentID));
159
160 InventoryFolderImpl folderCopy
161 = scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero);
162
163 if (folderCopy == null)
164 {
165 client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
166 return;
167 }
168
169 // The outgoing binary bucket should contain only the byte which signals an asset folder is
170 // being copied and the following bytes for the copied folder's UUID
171 copyID = folderCopy.ID;
172 byte[] copyIDBytes = copyID.GetBytes();
173 im.binaryBucket = new byte[1 + copyIDBytes.Length];
174 im.binaryBucket[0] = (byte)AssetType.Folder;
175 Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);
176
177 if (user != null && !user.IsChildAgent)
178 {
179 user.ControllingClient.SendBulkUpdateInventory(folderCopy);
180 }
181 }
182 else
183 {
184 // First byte of the array is probably the item type
185 // Next 16 bytes are the UUID
144 186
145 UUID itemID = new UUID(im.binaryBucket, 1); 187 UUID itemID = new UUID(im.binaryBucket, 1);
146 188
147 m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+ 189 m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+
148 "into agent {1}'s inventory", 190 "into agent {1}'s inventory",
149 itemID, new UUID(im.toAgentID)); 191 itemID, new UUID(im.toAgentID));
150 192
151 InventoryItemBase itemCopy = scene.GiveInventoryItem( 193 InventoryItemBase itemCopy = scene.GiveInventoryItem(
152 new UUID(im.toAgentID), 194 new UUID(im.toAgentID),
153 client.AgentId, itemID); 195 client.AgentId, itemID);
154 196
155 if (itemCopy == null) 197 if (itemCopy == null)
156 { 198 {
157 client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false); 199 client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
158 return; 200 return;
201 }
202
203 copyID = itemCopy.ID;
204 Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);
205
206 if (user != null && !user.IsChildAgent)
207 {
208 user.ControllingClient.SendBulkUpdateInventory(itemCopy);
209 }
159 } 210 }
160 211
161 byte[] itemCopyID = itemCopy.ID.GetBytes();
162
163 Array.Copy(itemCopyID, 0, im.binaryBucket, 1, 16);
164
165 // Send the IM to the recipient. The item is already 212 // Send the IM to the recipient. The item is already
166 // in their inventory, so it will not be lost if 213 // in their inventory, so it will not be lost if
167 // they are offline. 214 // they are offline.
168 // 215 //
169 if (user != null && !user.IsChildAgent) 216 if (user != null && !user.IsChildAgent)
170 { 217 {
171 // User is online. So, let's make the item visible
172 //
173 user.ControllingClient.SendBulkUpdateInventory(itemCopy);
174
175 // And notify. Transaction ID is the item ID. We get that 218 // And notify. Transaction ID is the item ID. We get that
176 // same ID back on the reply so we know what to act on 219 // same ID back on the reply so we know what to act on
177 // 220 //
@@ -179,7 +222,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
179 new UUID(im.fromAgentID), im.message, 222 new UUID(im.fromAgentID), im.message,
180 new UUID(im.toAgentID), 223 new UUID(im.toAgentID),
181 im.fromAgentName, im.dialog, im.timestamp, 224 im.fromAgentName, im.dialog, im.timestamp,
182 itemCopy.ID, false, im.binaryBucket); 225 copyID, false, im.binaryBucket);
183 226
184 return; 227 return;
185 } 228 }
@@ -208,9 +251,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
208 } 251 }
209 } 252 }
210 else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) 253 else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
211 { 254 {
212 UUID itemID = new UUID(im.imSessionID); // The item, back from it's trip
213
214 // Here, the recipient is local and we can assume that the 255 // Here, the recipient is local and we can assume that the
215 // inventory is loaded. Courtesy of the above bulk update, 256 // inventory is loaded. Courtesy of the above bulk update,
216 // It will have been pushed to the client, too 257 // It will have been pushed to the client, too
@@ -224,27 +265,43 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
224 { 265 {
225 InventoryFolderImpl trashFolder = 266 InventoryFolderImpl trashFolder =
226 userInfo.FindFolderForType((int)AssetType.TrashFolder); 267 userInfo.FindFolderForType((int)AssetType.TrashFolder);
227 268
228 InventoryItemBase item = 269 UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
229 userInfo.RootFolder.FindItem(itemID); 270
230 271 InventoryItemBase item = userInfo.RootFolder.FindItem(inventoryEntityID);
231 if (trashFolder != null && item != null) 272 InventoryFolderBase folder = null;
273
274 if (item != null && trashFolder != null)
232 { 275 {
233 item.Folder = trashFolder.ID; 276 item.Folder = trashFolder.ID;
234 277
235 userInfo.DeleteItem(itemID); 278 userInfo.DeleteItem(inventoryEntityID);
236 279
237 scene.AddInventoryItem(client, item); 280 scene.AddInventoryItem(client, item);
238 } 281 }
239 else 282 else
240 { 283 {
241 string reason = ""; 284 folder = userInfo.RootFolder.FindFolder(inventoryEntityID);
285
286 if (folder != null & trashFolder != null)
287 {
288 userInfo.MoveFolder(inventoryEntityID, trashFolder.ID);
289 }
290 }
291
292 if ((null == item && null == folder) | null == trashFolder)
293 {
294 string reason = String.Empty;
295
242 if (trashFolder == null) 296 if (trashFolder == null)
243 reason += " Trash folder not found."; 297 reason += " Trash folder not found.";
244 if (item == null) 298 if (item == null)
245 reason += " Item not found."; 299 reason += " Item not found.";
300 if (folder == null)
301 reason += " Folder not found.";
302
246 client.SendAgentAlertMessage("Unable to delete "+ 303 client.SendAgentAlertMessage("Unable to delete "+
247 "received item" + reason, false); 304 "received inventory" + reason, false);
248 } 305 }
249 } 306 }
250 307
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index b5a5123..fb1d1ff 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -624,6 +624,9 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
624 public virtual void SendBulkUpdateInventory(InventoryItemBase item) 624 public virtual void SendBulkUpdateInventory(InventoryItemBase item)
625 { 625 {
626 } 626 }
627
628 public virtual void SendBulkUpdateInventory(InventoryFolderBase folderBase)
629 {}
627 630
628 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls) 631 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
629 { 632 {