aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
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/ClientStack
parentMinor formatting cleanup. (diff)
downloadopensim-SC-38ca31b37a6ac8fe74b77e4488112eb77d612827.zip
opensim-SC-38ca31b37a6ac8fe74b77e4488112eb77d612827.tar.gz
opensim-SC-38ca31b37a6ac8fe74b77e4488112eb77d612827.tar.bz2
opensim-SC-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 '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs148
1 files changed, 148 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 74bf7e5..42f190f 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1144,6 +1144,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1144 msg.MessageBlock.Message = Utils.StringToBytes(message); 1144 msg.MessageBlock.Message = Utils.StringToBytes(message);
1145 msg.MessageBlock.BinaryBucket = binaryBucket; 1145 msg.MessageBlock.BinaryBucket = binaryBucket;
1146 1146
1147 System.Console.WriteLine("SendInstantMessage: " + msg);
1147 OutPacket(msg, ThrottleOutPacketType.Task); 1148 OutPacket(msg, ThrottleOutPacketType.Task);
1148 } 1149 }
1149 } 1150 }
@@ -1763,6 +1764,153 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1763 inventoryReply.Header.Zerocoded = true; 1764 inventoryReply.Header.Zerocoded = true;
1764 OutPacket(inventoryReply, ThrottleOutPacketType.Asset); 1765 OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
1765 } 1766 }
1767
1768 /// <see>IClientAPI.SendBulkUpdateInventory(InventoryFolderBase)</see>
1769 public void SendBulkUpdateInventory(InventoryFolderBase folderBase)
1770 {
1771 // XXX: Nasty temporary move that will be resolved shortly
1772 InventoryFolderImpl folder = (InventoryFolderImpl)folderBase;
1773
1774 // We will use the same transaction id for all the separate packets to be sent out in this update.
1775 UUID transactionId = UUID.Random();
1776
1777 List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
1778 = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
1779
1780 SendBulkUpdateInventoryRecursive(folder, ref folderDataBlocks, transactionId);
1781
1782 if (folderDataBlocks.Count > 0)
1783 {
1784 // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
1785 // Send these now
1786 BulkUpdateInventoryPacket bulkUpdate
1787 = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
1788 bulkUpdate.Header.Zerocoded = true;
1789
1790 bulkUpdate.AgentData.AgentID = AgentId;
1791 bulkUpdate.AgentData.TransactionID = transactionId;
1792 bulkUpdate.FolderData = folderDataBlocks.ToArray();
1793
1794 Console.WriteLine("SendBulkUpdateInventory :" + bulkUpdate);
1795 OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
1796 }
1797 }
1798
1799 /// <summary>
1800 /// Recursively construct bulk update packets to send folders and items
1801 /// </summary>
1802 /// <param name="folder"></param>
1803 /// <param name="folderDataBlocks"></param>
1804 /// <param name="transactionId"></param>
1805 private void SendBulkUpdateInventoryRecursive(
1806 InventoryFolderImpl folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
1807 UUID transactionId)
1808 {
1809 folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
1810
1811 const int MAX_ITEMS_PER_PACKET = 5;
1812
1813 // If there are any items then we have to start sending them off in this packet - the next folder will have
1814 // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
1815 // being used on the Linden grid at 20081203).
1816 List<InventoryItemBase> items = folder.RequestListOfItems();
1817 while (items.Count > 0)
1818 {
1819 BulkUpdateInventoryPacket bulkUpdate
1820 = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
1821 bulkUpdate.Header.Zerocoded = true;
1822
1823 bulkUpdate.AgentData.AgentID = AgentId;
1824 bulkUpdate.AgentData.TransactionID = transactionId;
1825 bulkUpdate.FolderData = folderDataBlocks.ToArray();
1826
1827 int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
1828 bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
1829
1830 for (int i = 0; i < itemsToSend; i++)
1831 {
1832 // Remove from the end of the list so that we don't incur a performance penalty
1833 bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
1834 items.RemoveAt(items.Count - 1);
1835 }
1836
1837 Console.WriteLine("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
1838 OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
1839
1840 folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
1841
1842 // If we're going to be sending another items packet then it needs to contain just the folder to which those
1843 // items belong.
1844 if (items.Count > 0)
1845 folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
1846 }
1847
1848 List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls();
1849 foreach (InventoryFolderImpl subFolder in subFolders)
1850 {
1851 SendBulkUpdateInventoryRecursive(subFolder, ref folderDataBlocks, transactionId);
1852 }
1853 }
1854
1855 /// <summary>
1856 /// Generate a bulk update inventory data block for the given folder
1857 /// </summary>
1858 /// <param name="folder"></param>
1859 /// <returns></returns>
1860 private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
1861 {
1862 BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
1863
1864 folderBlock.FolderID = folder.ID;
1865 folderBlock.ParentID = folder.ParentID;
1866 folderBlock.Type = -1;
1867 folderBlock.Name = Utils.StringToBytes(folder.Name);
1868
1869 return folderBlock;
1870 }
1871
1872 /// <summary>
1873 /// Generate a bulk update inventory data block for the given item
1874 /// </summary>
1875 /// <param name="item"></param>
1876 /// <returns></returns>
1877 private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
1878 {
1879 BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
1880
1881 itemBlock.ItemID = item.ID;
1882 itemBlock.AssetID = item.AssetID;
1883 itemBlock.CreatorID = item.Creator;
1884 itemBlock.BaseMask = item.BasePermissions;
1885 itemBlock.Description = Utils.StringToBytes(item.Description);
1886 itemBlock.EveryoneMask = item.EveryOnePermissions;
1887 itemBlock.FolderID = item.Folder;
1888 itemBlock.InvType = (sbyte)item.InvType;
1889 itemBlock.Name = Utils.StringToBytes(item.Name);
1890 itemBlock.NextOwnerMask = item.NextPermissions;
1891 itemBlock.OwnerID = item.Owner;
1892 itemBlock.OwnerMask = item.CurrentPermissions;
1893 itemBlock.Type = (sbyte)item.AssetType;
1894 itemBlock.GroupID = item.GroupID;
1895 itemBlock.GroupOwned = item.GroupOwned;
1896 itemBlock.GroupMask = item.GroupPermissions;
1897 itemBlock.Flags = item.Flags;
1898 itemBlock.SalePrice = item.SalePrice;
1899 itemBlock.SaleType = item.SaleType;
1900 itemBlock.CreationDate = item.CreationDate;
1901
1902 itemBlock.CRC =
1903 Helpers.InventoryCRC(
1904 1000, 0, itemBlock.InvType,
1905 itemBlock.Type, itemBlock.AssetID,
1906 itemBlock.GroupID, 100,
1907 itemBlock.OwnerID, itemBlock.CreatorID,
1908 itemBlock.ItemID, itemBlock.FolderID,
1909 (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
1910 (uint)PermissionMask.All);
1911
1912 return itemBlock;
1913 }
1766 1914
1767 /// <see>IClientAPI.SendBulkUpdateInventory(InventoryItemBase)</see> 1915 /// <see>IClientAPI.SendBulkUpdateInventory(InventoryItemBase)</see>
1768 public void SendBulkUpdateInventory(InventoryItemBase item) 1916 public void SendBulkUpdateInventory(InventoryItemBase item)