aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs79
1 files changed, 78 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 1370b1f..641a042 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Xml; 31using System.Xml;
32using System.Reflection; 32using System.Reflection;
33using System.Text;
33using System.Threading; 34using System.Threading;
34 35
35using OpenSim.Framework; 36using OpenSim.Framework;
@@ -128,7 +129,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
128 129
129 protected virtual void OnNewClient(IClientAPI client) 130 protected virtual void OnNewClient(IClientAPI client)
130 { 131 {
131 132 client.OnCreateNewInventoryItem += CreateNewInventoryItem;
132 } 133 }
133 134
134 public virtual void Close() 135 public virtual void Close()
@@ -157,6 +158,82 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
157 #region Inventory Access 158 #region Inventory Access
158 159
159 /// <summary> 160 /// <summary>
161 /// Create a new inventory item. Called when the client creates a new item directly within their
162 /// inventory (e.g. by selecting a context inventory menu option).
163 /// </summary>
164 /// <param name="remoteClient"></param>
165 /// <param name="transactionID"></param>
166 /// <param name="folderID"></param>
167 /// <param name="callbackID"></param>
168 /// <param name="description"></param>
169 /// <param name="name"></param>
170 /// <param name="invType"></param>
171 /// <param name="type"></param>
172 /// <param name="wearableType"></param>
173 /// <param name="nextOwnerMask"></param>
174 public void CreateNewInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID,
175 uint callbackID, string description, string name, sbyte invType,
176 sbyte assetType,
177 byte wearableType, uint nextOwnerMask, int creationDate)
178 {
179 m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID);
180
181 if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
182 return;
183
184 InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId);
185 InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f);
186
187 if (folder == null || folder.Owner != remoteClient.AgentId)
188 return;
189
190 if (transactionID == UUID.Zero)
191 {
192 ScenePresence presence;
193 if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence))
194 {
195 byte[] data = null;
196
197 if (invType == (sbyte)InventoryType.Landmark && presence != null)
198 {
199 string strdata = GenerateLandmark(presence);
200 data = Encoding.ASCII.GetBytes(strdata);
201 }
202
203 AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId);
204 m_Scene.AssetService.Store(asset);
205
206 m_Scene.CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
207 }
208 else
209 {
210 m_log.ErrorFormat(
211 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
212 remoteClient.AgentId);
213 }
214 }
215 else
216 {
217 IAgentAssetTransactions agentTransactions = m_Scene.RequestModuleInterface<IAgentAssetTransactions>();
218 if (agentTransactions != null)
219 {
220 agentTransactions.HandleItemCreationFromTransaction(
221 remoteClient, transactionID, folderID, callbackID, description,
222 name, invType, assetType, wearableType, nextOwnerMask);
223 }
224 }
225 }
226
227 protected virtual string GenerateLandmark(ScenePresence presence)
228 {
229 Vector3 pos = presence.AbsolutePosition;
230 return String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n",
231 presence.Scene.RegionInfo.RegionID,
232 pos.X, pos.Y, pos.Z,
233 presence.RegionHandle);
234 }
235
236 /// <summary>
160 /// Capability originating call to update the asset of an item in an agent's inventory 237 /// Capability originating call to update the asset of an item in an agent's inventory
161 /// </summary> 238 /// </summary>
162 /// <param name="remoteClient"></param> 239 /// <param name="remoteClient"></param>