diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | 132 |
1 files changed, 33 insertions, 99 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index be89740..2f1e9dd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -145,10 +145,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
145 | { | 145 | { |
146 | ScenePresence presence = scene.GetScenePresence(agentId); | 146 | ScenePresence presence = scene.GetScenePresence(agentId); |
147 | if (presence != null) | 147 | if (presence != null) |
148 | { | 148 | return scene; |
149 | if (!presence.IsChildAgent) | ||
150 | return scene; | ||
151 | } | ||
152 | } | 149 | } |
153 | } | 150 | } |
154 | return null; | 151 | return null; |
@@ -156,19 +153,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
156 | 153 | ||
157 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | 154 | private void OnInstantMessage(IClientAPI client, GridInstantMessage im) |
158 | { | 155 | { |
159 | m_log.InfoFormat("OnInstantMessage {0}", im.dialog); | 156 | m_log.InfoFormat("[INVENTORY TRANSFER]: OnInstantMessage {0}", im.dialog); |
157 | |||
160 | Scene scene = FindClientScene(client.AgentId); | 158 | Scene scene = FindClientScene(client.AgentId); |
161 | 159 | ||
162 | if (scene == null) // Something seriously wrong here. | 160 | if (scene == null) // Something seriously wrong here. |
163 | return; | 161 | return; |
164 | 162 | ||
165 | 163 | ||
166 | |||
167 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) | 164 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) |
168 | { | 165 | { |
169 | //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); | 166 | //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0])); |
170 | 167 | ||
171 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 168 | if (im.binaryBucket.Length < 17) // Invalid |
169 | return; | ||
170 | |||
171 | UUID receipientID = new UUID(im.toAgentID); | ||
172 | ScenePresence user = scene.GetScenePresence(receipientID); | ||
172 | UUID copyID; | 173 | UUID copyID; |
173 | 174 | ||
174 | // First byte is the asset type | 175 | // First byte is the asset type |
@@ -183,7 +184,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
183 | folderID, new UUID(im.toAgentID)); | 184 | folderID, new UUID(im.toAgentID)); |
184 | 185 | ||
185 | InventoryFolderBase folderCopy | 186 | InventoryFolderBase folderCopy |
186 | = scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero); | 187 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); |
187 | 188 | ||
188 | if (folderCopy == null) | 189 | if (folderCopy == null) |
189 | { | 190 | { |
@@ -199,20 +200,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
199 | im.binaryBucket[0] = (byte)AssetType.Folder; | 200 | im.binaryBucket[0] = (byte)AssetType.Folder; |
200 | Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); | 201 | Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length); |
201 | 202 | ||
202 | if (user != null && !user.IsChildAgent) | 203 | if (user != null) |
203 | { | 204 | { |
204 | user.ControllingClient.SendBulkUpdateInventory(folderCopy); | 205 | user.ControllingClient.SendBulkUpdateInventory(folderCopy); |
205 | } | 206 | } |
207 | |||
208 | // HACK!! | ||
209 | im.imSessionID = folderID.Guid; | ||
206 | } | 210 | } |
207 | else | 211 | else |
208 | { | 212 | { |
209 | // First byte of the array is probably the item type | 213 | // First byte of the array is probably the item type |
210 | // Next 16 bytes are the UUID | 214 | // Next 16 bytes are the UUID |
211 | m_log.Info("OnInstantMessage - giving item"); | ||
212 | 215 | ||
213 | UUID itemID = new UUID(im.binaryBucket, 1); | 216 | UUID itemID = new UUID(im.binaryBucket, 1); |
214 | 217 | ||
215 | m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+ | 218 | m_log.DebugFormat("[AGENT INVENTORY]: (giving) Inserting item {0} "+ |
216 | "into agent {1}'s inventory", | 219 | "into agent {1}'s inventory", |
217 | itemID, new UUID(im.toAgentID)); | 220 | itemID, new UUID(im.toAgentID)); |
218 | 221 | ||
@@ -229,29 +232,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
229 | copyID = itemCopy.ID; | 232 | copyID = itemCopy.ID; |
230 | Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); | 233 | Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16); |
231 | 234 | ||
232 | if (user != null && !user.IsChildAgent) | 235 | if (user != null) |
233 | { | 236 | { |
234 | user.ControllingClient.SendBulkUpdateInventory(itemCopy); | 237 | user.ControllingClient.SendBulkUpdateInventory(itemCopy); |
235 | } | 238 | } |
239 | |||
240 | // HACK!! | ||
241 | im.imSessionID = itemID.Guid; | ||
236 | } | 242 | } |
237 | 243 | ||
238 | // Send the IM to the recipient. The item is already | 244 | // Send the IM to the recipient. The item is already |
239 | // in their inventory, so it will not be lost if | 245 | // in their inventory, so it will not be lost if |
240 | // they are offline. | 246 | // they are offline. |
241 | // | 247 | // |
242 | if (user != null && !user.IsChildAgent) | 248 | if (user != null) |
243 | { | 249 | { |
244 | // And notify. Transaction ID is the item ID. We get that | ||
245 | // same ID back on the reply so we know what to act on | ||
246 | // | ||
247 | user.ControllingClient.SendInstantMessage(im); | 250 | user.ControllingClient.SendInstantMessage(im); |
248 | |||
249 | return; | 251 | return; |
250 | } | 252 | } |
251 | else | 253 | else |
252 | { | 254 | { |
253 | if (m_TransferModule != null) | 255 | if (m_TransferModule != null) |
254 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); | 256 | m_TransferModule.SendInstantMessage(im, delegate(bool success) |
257 | { | ||
258 | if (!success) | ||
259 | client.SendAlertMessage("User not online. Inventory has been saved"); | ||
260 | }); | ||
255 | } | 261 | } |
256 | } | 262 | } |
257 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | 263 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) |
@@ -282,10 +288,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
282 | 288 | ||
283 | InventoryFolderBase trashFolder = | 289 | InventoryFolderBase trashFolder = |
284 | invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); | 290 | invService.GetFolderForType(client.AgentId, AssetType.TrashFolder); |
285 | |||
286 | UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | ||
287 | 291 | ||
288 | InventoryItemBase item = new InventoryItemBase(inventoryEntityID, client.AgentId); | 292 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip |
293 | |||
294 | InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); | ||
289 | item = invService.GetItem(item); | 295 | item = invService.GetItem(item); |
290 | InventoryFolderBase folder = null; | 296 | InventoryFolderBase folder = null; |
291 | 297 | ||
@@ -301,7 +307,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
301 | } | 307 | } |
302 | else | 308 | else |
303 | { | 309 | { |
304 | folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | 310 | folder = new InventoryFolderBase(inventoryID, client.AgentId); |
305 | folder = invService.GetFolder(folder); | 311 | folder = invService.GetFolder(folder); |
306 | 312 | ||
307 | if (folder != null & trashFolder != null) | 313 | if (folder != null & trashFolder != null) |
@@ -417,90 +423,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
417 | { | 423 | { |
418 | // Check if this is ours to handle | 424 | // Check if this is ours to handle |
419 | // | 425 | // |
420 | m_log.Info("OnFridInstantMessage"); | 426 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); |
421 | if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered) | ||
422 | return; | ||
423 | 427 | ||
424 | if (msg.binaryBucket.Length < 17) // Invalid | 428 | if (scene == null) |
425 | return; | 429 | return; |
426 | 430 | ||
427 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | ||
428 | |||
429 | // Find agent to deliver to | 431 | // Find agent to deliver to |
430 | // | 432 | // |
431 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 433 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); |
432 | 434 | ||
433 | if (user == null) // Shouldn't happen | 435 | // Just forward to local handling |
434 | { | 436 | OnInstantMessage(user.ControllingClient, msg); |
435 | m_log.Debug("[INVENTORY TRANSFER] Can't find recipient"); | ||
436 | return; | ||
437 | } | ||
438 | |||
439 | //CachedUserInfo userInfo = | ||
440 | // scene.CommsManager.UserProfileCacheService. | ||
441 | // GetUserDetails(user.ControllingClient.AgentId); | ||
442 | |||
443 | //if (userInfo == null) | ||
444 | //{ | ||
445 | // m_log.Debug("[INVENTORY TRANSFER] Can't find user info of recipient"); | ||
446 | // return; | ||
447 | //} | ||
448 | |||
449 | AssetType assetType = (AssetType)msg.binaryBucket[0]; | ||
450 | IInventoryService invService = scene.InventoryService; | ||
451 | 437 | ||
452 | if (AssetType.Folder == assetType) | ||
453 | { | ||
454 | UUID folderID = new UUID(msg.binaryBucket, 1); | ||
455 | InventoryFolderBase folder = new InventoryFolderBase(); | ||
456 | |||
457 | folder.ID = folderID; | ||
458 | folder.Owner = user.ControllingClient.AgentId; | ||
459 | |||
460 | // Fetch from service | ||
461 | // | ||
462 | folder = invService.GetFolder(folder); | ||
463 | if (folder == null) | ||
464 | { | ||
465 | m_log.Debug("[INVENTORY TRANSFER] Can't find folder to give"); | ||
466 | return; | ||
467 | } | ||
468 | |||
469 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
470 | |||
471 | //// This unelegant, slow kludge is to reload the folders and | ||
472 | //// items. Since a folder give can transfer subfolders and | ||
473 | //// items, this is the easiest way to pull that stuff in | ||
474 | //// | ||
475 | //userInfo.DropInventory(); | ||
476 | //userInfo.FetchInventory(); | ||
477 | |||
478 | // Deliver message | ||
479 | // | ||
480 | user.ControllingClient.SendInstantMessage(msg); | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | UUID itemID = new UUID(msg.binaryBucket, 1); | ||
485 | InventoryItemBase item = new InventoryItemBase(itemID, user.ControllingClient.AgentId); | ||
486 | |||
487 | // Fetch from service | ||
488 | // | ||
489 | item = invService.GetItem(item); | ||
490 | if (item == null) | ||
491 | { | ||
492 | m_log.Debug("[INVENTORY TRANSFER] Can't find item to give"); | ||
493 | return; | ||
494 | } | ||
495 | |||
496 | // Update item to viewer (makes it appear in proper folder) | ||
497 | // | ||
498 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
499 | |||
500 | // Deliver message | ||
501 | // | ||
502 | user.ControllingClient.SendInstantMessage(msg); | ||
503 | } | ||
504 | } | 438 | } |
505 | } | 439 | } |
506 | } | 440 | } |