diff options
More work on inventory, can now create other inventory types, like Clothes and body parts. [Note while you can edit these, at the moment your changes won't be saved between restarts. This will be fixed very soon.]
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/AssetTransactions.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetTransactions.cs | 114 |
1 files changed, 108 insertions, 6 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs index 8909bdf..cea6e6e 100644 --- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs +++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs | |||
@@ -35,6 +35,7 @@ using libsecondlife.Packets; | |||
35 | using OpenSim.Framework.Interfaces; | 35 | using OpenSim.Framework.Interfaces; |
36 | using OpenSim.Framework.Types; | 36 | using OpenSim.Framework.Types; |
37 | using OpenSim.Framework.Utilities; | 37 | using OpenSim.Framework.Utilities; |
38 | using OpenSim.Framework.Data; | ||
38 | using OpenSim.Region.Capabilities; | 39 | using OpenSim.Region.Capabilities; |
39 | using OpenSim.Framework.Servers; | 40 | using OpenSim.Framework.Servers; |
40 | 41 | ||
@@ -47,11 +48,13 @@ namespace OpenSim.Framework.Communications.Caches | |||
47 | public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>(); | 48 | public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>(); |
48 | public LLUUID UserID; | 49 | public LLUUID UserID; |
49 | public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); | 50 | public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); |
51 | public AssetTransactionManager Manager; | ||
50 | 52 | ||
51 | // Methods | 53 | // Methods |
52 | public AgentAssetTransactions(LLUUID agentID) | 54 | public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager) |
53 | { | 55 | { |
54 | this.UserID = agentID; | 56 | this.UserID = agentID; |
57 | Manager = manager; | ||
55 | } | 58 | } |
56 | 59 | ||
57 | public AssetCapsUploader RequestCapsUploader() | 60 | public AssetCapsUploader RequestCapsUploader() |
@@ -70,9 +73,34 @@ namespace OpenSim.Framework.Communications.Caches | |||
70 | 73 | ||
71 | public AssetXferUploader RequestXferUploader(LLUUID transactionID) | 74 | public AssetXferUploader RequestXferUploader(LLUUID transactionID) |
72 | { | 75 | { |
73 | AssetXferUploader uploader = new AssetXferUploader(); | 76 | if (!this.XferUploaders.ContainsKey(transactionID)) |
74 | this.XferUploaders.Add(transactionID, uploader); | 77 | { |
75 | return uploader; | 78 | AssetXferUploader uploader = new AssetXferUploader(this); |
79 | |||
80 | this.XferUploaders.Add(transactionID, uploader); | ||
81 | return uploader; | ||
82 | } | ||
83 | return null; | ||
84 | } | ||
85 | |||
86 | public void HandleXfer(ulong xferID, uint packetID, byte[] data) | ||
87 | { | ||
88 | foreach (AssetXferUploader uploader in this.XferUploaders.Values) | ||
89 | { | ||
90 | if (uploader.XferID == xferID) | ||
91 | { | ||
92 | uploader.HandleXferPacket(xferID, packetID, data); | ||
93 | break; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) | ||
99 | { | ||
100 | if (this.XferUploaders.ContainsKey(transactionID)) | ||
101 | { | ||
102 | this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); | ||
103 | } | ||
76 | } | 104 | } |
77 | 105 | ||
78 | // Nested Types | 106 | // Nested Types |
@@ -143,10 +171,23 @@ namespace OpenSim.Framework.Communications.Caches | |||
143 | private IClientAPI ourClient; | 171 | private IClientAPI ourClient; |
144 | public LLUUID TransactionID = LLUUID.Zero; | 172 | public LLUUID TransactionID = LLUUID.Zero; |
145 | public bool UploadComplete; | 173 | public bool UploadComplete; |
146 | public uint XferID; | 174 | public ulong XferID; |
175 | private string m_name = ""; | ||
176 | private string m_description = ""; | ||
177 | private sbyte type = 0; | ||
178 | private sbyte invType = 0; | ||
179 | private uint nextPerm = 0; | ||
180 | private bool m_finished = false; | ||
181 | private bool m_createItem = false; | ||
182 | private AgentAssetTransactions m_userTransactions; | ||
183 | |||
184 | public AssetXferUploader(AgentAssetTransactions transactions) | ||
185 | { | ||
186 | this.m_userTransactions = transactions; | ||
187 | } | ||
147 | 188 | ||
148 | // Methods | 189 | // Methods |
149 | public void HandleXferPacket(uint xferID, uint packetID, byte[] data) | 190 | public void HandleXferPacket(ulong xferID, uint packetID, byte[] data) |
150 | { | 191 | { |
151 | if (this.XferID == xferID) | 192 | if (this.XferID == xferID) |
152 | { | 193 | { |
@@ -216,6 +257,67 @@ namespace OpenSim.Framework.Communications.Caches | |||
216 | newPack.AssetBlock.Success = true; | 257 | newPack.AssetBlock.Success = true; |
217 | newPack.AssetBlock.UUID = this.Asset.FullID; | 258 | newPack.AssetBlock.UUID = this.Asset.FullID; |
218 | this.ourClient.OutPacket(newPack); | 259 | this.ourClient.OutPacket(newPack); |
260 | this.m_finished = true; | ||
261 | if (m_createItem) | ||
262 | { | ||
263 | DoCreateItem(); | ||
264 | } | ||
265 | Console.WriteLine("upload complete "+ this.TransactionID); | ||
266 | //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data); | ||
267 | } | ||
268 | private void SaveAssetToFile(string filename, byte[] data) | ||
269 | { | ||
270 | FileStream fs = File.Create(filename); | ||
271 | BinaryWriter bw = new BinaryWriter(fs); | ||
272 | bw.Write(data); | ||
273 | bw.Close(); | ||
274 | fs.Close(); | ||
275 | } | ||
276 | |||
277 | public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) | ||
278 | { | ||
279 | if (this.TransactionID == transactionID) | ||
280 | { | ||
281 | this.InventFolder = folderID; | ||
282 | this.m_name = name; | ||
283 | this.m_description = description; | ||
284 | this.type = type; | ||
285 | this.invType = invType; | ||
286 | this.nextPerm = nextOwnerMask; | ||
287 | this.Asset.Name = name; | ||
288 | this.Asset.Description = description; | ||
289 | this.Asset.Type = type; | ||
290 | this.Asset.InvType = invType; | ||
291 | m_createItem = true; | ||
292 | if (m_finished) | ||
293 | { | ||
294 | DoCreateItem(); | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | |||
299 | private void DoCreateItem() | ||
300 | { | ||
301 | this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset); | ||
302 | CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId); | ||
303 | if (userInfo != null) | ||
304 | { | ||
305 | InventoryItemBase item = new InventoryItemBase(); | ||
306 | item.avatarID = this.ourClient.AgentId; | ||
307 | item.creatorsID = ourClient.AgentId; | ||
308 | item.inventoryID = LLUUID.Random(); | ||
309 | item.assetID = Asset.FullID; | ||
310 | item.inventoryDescription = this.m_description; | ||
311 | item.inventoryName = m_name; | ||
312 | item.assetType = type; | ||
313 | item.invType = this.invType; | ||
314 | item.parentFolderID = this.InventFolder; | ||
315 | item.inventoryCurrentPermissions = 2147483647; | ||
316 | item.inventoryNextPermissions = this.nextPerm; | ||
317 | |||
318 | userInfo.AddItem(ourClient.AgentId, item); | ||
319 | ourClient.SendInventoryItemUpdate(item); | ||
320 | } | ||
219 | } | 321 | } |
220 | } | 322 | } |
221 | 323 | ||