aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-02-13 00:30:51 +0000
committerJustin Clarke Casey2008-02-13 00:30:51 +0000
commit365cf8e4555e5105d669f3ebf11d3fb5b563f9a8 (patch)
tree9638bc100d59257eba64735bb6ff08b511040e5d /OpenSim/Framework/Communications/Cache
parentRefactor: factor a method out of AgentAssetTransactionsManager (diff)
downloadopensim-SC_OLD-365cf8e4555e5105d669f3ebf11d3fb5b563f9a8.zip
opensim-SC_OLD-365cf8e4555e5105d669f3ebf11d3fb5b563f9a8.tar.gz
opensim-SC_OLD-365cf8e4555e5105d669f3ebf11d3fb5b563f9a8.tar.bz2
opensim-SC_OLD-365cf8e4555e5105d669f3ebf11d3fb5b563f9a8.tar.xz
* Refactor: Move last commit's refactor back to AgentAssetTransactionsManager
* Push asset update (invoked when clothing is altered) down into AgentAssetTransactions from Scene.Inventory.cs to join others * I've tested that clothing creation and update still works, but please let me know if it suddently breaks for you. * Add/correct comments
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs47
-rw-r--r--OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs116
2 files changed, 128 insertions, 35 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs
index e74a06b..92390b5 100644
--- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactions.cs
@@ -136,6 +136,15 @@ namespace OpenSim.Framework.Communications.Cache
136 wearableType, nextOwnerMask); 136 wearableType, nextOwnerMask);
137 } 137 }
138 } 138 }
139
140 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
141 InventoryItemBase item)
142 {
143 if (XferUploaders.ContainsKey(transactionID))
144 {
145 XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item);
146 }
147 }
139 148
140 /// <summary> 149 /// <summary>
141 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. 150 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
@@ -351,6 +360,44 @@ namespace OpenSim.Framework.Communications.Cache
351 } 360 }
352 } 361 }
353 } 362 }
363
364 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
365 InventoryItemBase item)
366 {
367 if (TransactionID == transactionID)
368 {
369 CachedUserInfo userInfo =
370 m_userTransactions.Manager.CommsManager.UserProfileCacheService.GetUserDetails(
371 remoteClient.AgentId);
372
373 if (userInfo != null)
374 {
375 LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId);
376
377 AssetBase asset
378 = m_userTransactions.Manager.CommsManager.AssetCache.GetAsset(
379 assetID, (item.assetType == (int) AssetType.Texture ? true : false));
380
381 if (asset == null)
382 {
383 asset = m_userTransactions.GetTransactionAsset(transactionID);
384 }
385
386 if (asset != null && asset.FullID == assetID)
387 {
388 asset.Name = item.inventoryName;
389 asset.Description = item.inventoryDescription;
390 asset.InvType = (sbyte) item.invType;
391 asset.Type = (sbyte) item.assetType;
392 item.assetID = asset.FullID;
393
394 m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(Asset);
395 }
396
397 userInfo.UpdateItem(remoteClient.AgentId, item);
398 }
399 }
400 }
354 401
355 private void DoCreateItem() 402 private void DoCreateItem()
356 { 403 {
diff --git a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
index c9c35d2..48b2563 100644
--- a/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
+++ b/OpenSim/Framework/Communications/Cache/AgentAssetTransactionsManager.cs
@@ -34,7 +34,8 @@ using libsecondlife;
34namespace OpenSim.Framework.Communications.Cache 34namespace OpenSim.Framework.Communications.Cache
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// Manage the collection of agent asset transaction collections. Each agent has its own transaction collection 37 /// Provider handlers for processing asset transactions originating from the agent. This encompasses
38 /// clothing creation and update as well as asset uploads.
38 /// </summary> 39 /// </summary>
39 public class AgentAssetTransactionsManager 40 public class AgentAssetTransactionsManager
40 { 41 {
@@ -62,34 +63,76 @@ namespace OpenSim.Framework.Communications.Cache
62 } 63 }
63 64
64 /// <summary> 65 /// <summary>
65 /// Add a collection of asset transactions for the given user 66 /// Get the collection of asset transactions for the given user. If one does not already exist, it
67 /// is created.
66 /// </summary> 68 /// </summary>
67 /// <param name="userID"></param> 69 /// <param name="userID"></param>
68 public void AddUser(LLUUID userID) 70 /// <returns></returns>
71 private AgentAssetTransactions GetUserTransactions(LLUUID userID)
69 { 72 {
70 lock (AgentTransactions) 73 lock (AgentTransactions)
71 { 74 {
72 if (!AgentTransactions.ContainsKey(userID)) 75 if (!AgentTransactions.ContainsKey(userID))
73 { 76 {
74 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); 77 AgentAssetTransactions transactions
75 AgentTransactions.Add(userID, transactions); 78 = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile);
79 AgentTransactions.Add(userID, transactions);
76 } 80 }
77 } 81 }
82
83 return AgentTransactions[userID];
78 } 84 }
79 85
80 /// <summary> 86 /// <summary>
81 /// Get the collection of asset transactions for the given user. 87 /// Create an inventory item from data that has been received through a transaction.
88 ///
89 /// This is called when new clothing or body parts are created. It may also be called in other
90 /// situations.
82 /// </summary> 91 /// </summary>
83 /// <param name="userID"></param> 92 /// <param name="remoteClient"></param>
84 /// <returns>null if this agent does not have an asset transactions collection</returns> 93 /// <param name="transactionID"></param>
85 public AgentAssetTransactions GetUserTransactions(LLUUID userID) 94 /// <param name="folderID"></param>
95 /// <param name="callbackID"></param>
96 /// <param name="description"></param>
97 /// <param name="name"></param>
98 /// <param name="invType"></param>
99 /// <param name="type"></param>
100 /// <param name="wearableType"></param>
101 /// <param name="nextOwnerMask"></param>
102 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
103 uint callbackID, string description, string name, sbyte invType,
104 sbyte type, byte wearableType, uint nextOwnerMask)
86 { 105 {
87 if (AgentTransactions.ContainsKey(userID)) 106 m_log.InfoFormat(
88 { 107 "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
89 return AgentTransactions[userID]; 108
90 } 109 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
91 110
92 return null; 111 transactions.RequestCreateInventoryItem(
112 remoteClient, transactionID, folderID, callbackID, description,
113 name, invType, type, wearableType, nextOwnerMask);
114 }
115
116 /// <summary>
117 /// Update an inventory item with data that has been received through a transaction.
118 ///
119 /// This is called when clothing or body parts are updated (for instance, with new textures or
120 /// colours). It may also be called in other situations.
121 /// </summary>
122 /// <param name="remoteClient"></param>
123 /// <param name="transactionID"></param>
124 /// <param name="item"></param>
125 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
126 InventoryItemBase item)
127 {
128 m_log.InfoFormat(
129 "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
130 item.inventoryName);
131
132 AgentAssetTransactions transactions
133 = CommsManager.TransactionsManager.GetUserTransactions(remoteClient.AgentId);
134
135 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
93 } 136 }
94 137
95 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, 138 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type,
@@ -97,36 +140,39 @@ namespace OpenSim.Framework.Communications.Cache
97 { 140 {
98 // Console.WriteLine("asset upload of " + assetID); 141 // Console.WriteLine("asset upload of " + assetID);
99 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 142 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
100 if (transactions != null) 143
144 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
145 if (uploader != null)
101 { 146 {
102 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); 147 // Upload has already compelted uploading...
103 if (uploader != null) 148
149 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
104 { 150 {
105 // Upload has already compelted uploading... 151 //[commenting out as this removal breaks uploads]
106 152 /*lock (transactions.XferUploaders)
107 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
108 { 153 {
109 //[commenting out as this removal breaks uploads] 154
110 /*lock (transactions.XferUploaders) 155 // XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary
111 { 156 transactions.XferUploaders.Remove(uploader.TransactionID);
112 157
113 // XXX Weak ass way of doing this by directly manipulating this public dictionary, purely temporary 158 //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count);
114 transactions.XferUploaders.Remove(uploader.TransactionID); 159 }*/
115
116 //m_log.InfoFormat("[ASSET TRANSACTIONS] Current uploaders: {0}", transactions.XferUploaders.Count);
117 }*/
118 }
119 } 160 }
120 } 161 }
121 } 162 }
122 163
164 /// <summary>
165 /// Conduct an asset transfer from the client.
166 /// </summary>
167 /// <param name="remoteClient"></param>
168 /// <param name="xferID"></param>
169 /// <param name="packetID"></param>
170 /// <param name="data"></param>
123 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) 171 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
124 { 172 {
125 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 173 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
126 if (transactions != null) 174
127 { 175 transactions.HandleXfer(xferID, packetID, data);
128 transactions.HandleXfer(xferID, packetID, data);
129 }
130 } 176 }
131 } 177 }
132} 178}