aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2011-06-03 08:27:01 -0700
committerDiva Canto2011-06-03 08:27:01 -0700
commit76c60f1f99ca8aa7c1a336918aa0ef5f83b1ae04 (patch)
treeb5bcc10a80d6cd0515f1aa980563a0ce0cb0d70b
parentHG IM: increase the timeout value (diff)
downloadopensim-SC-76c60f1f99ca8aa7c1a336918aa0ef5f83b1ae04.zip
opensim-SC-76c60f1f99ca8aa7c1a336918aa0ef5f83b1ae04.tar.gz
opensim-SC-76c60f1f99ca8aa7c1a336918aa0ef5f83b1ae04.tar.bz2
opensim-SC-76c60f1f99ca8aa7c1a336918aa0ef5f83b1ae04.tar.xz
Moved CreateNewInventoryItem to the InventoryAccessModule in preparation for supporting HG landmarks.
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs79
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs74
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
3 files changed, 81 insertions, 76 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>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 3c47873..b70e1c3 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -778,7 +778,7 @@ namespace OpenSim.Region.Framework.Scenes
778 /// <param name="asset"></param> 778 /// <param name="asset"></param>
779 /// <param name="invType"></param> 779 /// <param name="invType"></param>
780 /// <param name="nextOwnerMask"></param> 780 /// <param name="nextOwnerMask"></param>
781 private void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, 781 public void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID,
782 AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) 782 AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate)
783 { 783 {
784 CreateNewInventoryItem( 784 CreateNewInventoryItem(
@@ -833,78 +833,6 @@ namespace OpenSim.Region.Framework.Scenes
833 } 833 }
834 834
835 /// <summary> 835 /// <summary>
836 /// Create a new inventory item. Called when the client creates a new item directly within their
837 /// inventory (e.g. by selecting a context inventory menu option).
838 /// </summary>
839 /// <param name="remoteClient"></param>
840 /// <param name="transactionID"></param>
841 /// <param name="folderID"></param>
842 /// <param name="callbackID"></param>
843 /// <param name="description"></param>
844 /// <param name="name"></param>
845 /// <param name="invType"></param>
846 /// <param name="type"></param>
847 /// <param name="wearableType"></param>
848 /// <param name="nextOwnerMask"></param>
849 public void CreateNewInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID,
850 uint callbackID, string description, string name, sbyte invType,
851 sbyte assetType,
852 byte wearableType, uint nextOwnerMask, int creationDate)
853 {
854 m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item {0} in folder {1}", name, folderID);
855
856 if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
857 return;
858
859 InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId);
860 InventoryFolderBase folder = InventoryService.GetFolder(f);
861
862 if (folder == null || folder.Owner != remoteClient.AgentId)
863 return;
864
865 if (transactionID == UUID.Zero)
866 {
867 ScenePresence presence;
868 if (TryGetScenePresence(remoteClient.AgentId, out presence))
869 {
870 byte[] data = null;
871
872 if (invType == (sbyte)InventoryType.Landmark && presence != null)
873 {
874 Vector3 pos = presence.AbsolutePosition;
875 string strdata = String.Format(
876 "Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n",
877 presence.Scene.RegionInfo.RegionID,
878 pos.X, pos.Y, pos.Z,
879 presence.RegionHandle);
880 data = Encoding.ASCII.GetBytes(strdata);
881 }
882
883 AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId);
884 AssetService.Store(asset);
885
886 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
887 }
888 else
889 {
890 m_log.ErrorFormat(
891 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
892 remoteClient.AgentId);
893 }
894 }
895 else
896 {
897 IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
898 if (agentTransactions != null)
899 {
900 agentTransactions.HandleItemCreationFromTransaction(
901 remoteClient, transactionID, folderID, callbackID, description,
902 name, invType, assetType, wearableType, nextOwnerMask);
903 }
904 }
905 }
906
907 /// <summary>
908 /// Link an inventory item to an existing item. 836 /// Link an inventory item to an existing item.
909 /// </summary> 837 /// </summary>
910 /// <remarks> 838 /// <remarks>
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1d562fd..b179683 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2726,7 +2726,7 @@ namespace OpenSim.Region.Framework.Scenes
2726 2726
2727 public virtual void SubscribeToClientInventoryEvents(IClientAPI client) 2727 public virtual void SubscribeToClientInventoryEvents(IClientAPI client)
2728 { 2728 {
2729 client.OnCreateNewInventoryItem += CreateNewInventoryItem; 2729
2730 client.OnLinkInventoryItem += HandleLinkInventoryItem; 2730 client.OnLinkInventoryItem += HandleLinkInventoryItem;
2731 client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder; 2731 client.OnCreateNewInventoryFolder += HandleCreateInventoryFolder;
2732 client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder; 2732 client.OnUpdateInventoryFolder += HandleUpdateInventoryFolder;
@@ -2853,7 +2853,7 @@ namespace OpenSim.Region.Framework.Scenes
2853 2853
2854 public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) 2854 public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client)
2855 { 2855 {
2856 client.OnCreateNewInventoryItem -= CreateNewInventoryItem; 2856
2857 client.OnCreateNewInventoryFolder -= HandleCreateInventoryFolder; 2857 client.OnCreateNewInventoryFolder -= HandleCreateInventoryFolder;
2858 client.OnUpdateInventoryFolder -= HandleUpdateInventoryFolder; 2858 client.OnUpdateInventoryFolder -= HandleUpdateInventoryFolder;
2859 client.OnMoveInventoryFolder -= HandleMoveInventoryFolder; // 2; //!! 2859 client.OnMoveInventoryFolder -= HandleMoveInventoryFolder; // 2; //!!