aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJonathan Freedman2010-12-05 11:49:15 -0800
committerJonathan Freedman2010-12-05 11:49:15 -0800
commit45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a (patch)
tree0351fb2c756a46d522fe41798c3969e020a3258d /OpenSim
parentMerge branch 'master-core' into mantis5110 (diff)
parentMerge branch 'master' of /var/git/opensim/ (diff)
downloadopensim-SC_OLD-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.zip
opensim-SC_OLD-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.tar.gz
opensim-SC_OLD-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.tar.bz2
opensim-SC_OLD-45cd2e3ef93cc8ab880cb5b1742e33d441e7d01a.tar.xz
Merge branch 'master-core' into mantis5110
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs4
-rw-r--r--OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs100
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs17
-rw-r--r--OpenSim/Data/Tests/InventoryTests.cs4
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs35
-rw-r--r--OpenSim/Framework/AssetLandmark.cs12
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs36
-rw-r--r--OpenSim/Framework/Capabilities/Caps.cs4
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs10
-rw-r--r--OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs104
-rw-r--r--OpenSim/Framework/IScene.cs2
-rw-r--r--OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs99
-rw-r--r--OpenSim/Framework/Serialization/External/OspResolver.cs (renamed from OpenSim/Framework/Communications/Osp/OspResolver.cs)8
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs225
-rw-r--r--OpenSim/Framework/Util.cs81
-rw-r--r--OpenSim/Region/Application/OpenSim.cs6
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs4
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs32
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs15
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs22
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs130
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs166
-rw-r--r--OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs43
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs125
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs13
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs28
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs16
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs83
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs30
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs26
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RestartModule.cs263
-rw-r--r--OpenSim/Region/Examples/SimpleModule/RegionModule.cs11
-rw-r--r--OpenSim/Region/Framework/Interfaces/IRestartModule.cs39
-rw-r--r--OpenSim/Region/Framework/Interfaces/IUserManagement.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs84
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs20
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs275
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs164
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs40
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs18
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs9
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs86
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs91
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs11
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs86
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs24
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs5
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs6
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs73
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs3
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs145
-rw-r--r--OpenSim/Services/HypergridService/HGInventoryService.cs (renamed from OpenSim/Services/InventoryService/HGInventoryService.cs)54
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs105
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs16
68 files changed, 2318 insertions, 987 deletions
diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
index b16f46c..7ef0f5f 100644
--- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
+++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs
@@ -106,8 +106,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
106 m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule()); 106 m_openSim.ModuleLoader.LoadDefaultSharedModule(new LoadImageURLModule());
107 m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule..."); 107 m_log.Info("[LOADREGIONSPLUGIN]: XMLRPCModule...");
108 m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule()); 108 m_openSim.ModuleLoader.LoadDefaultSharedModule(new XMLRPCModule());
109 m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule..."); 109// m_log.Info("[LOADREGIONSPLUGIN]: AssetTransactionModule...");
110 m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule()); 110// m_openSim.ModuleLoader.LoadDefaultSharedModule(new AssetTransactionModule());
111 m_log.Info("[LOADREGIONSPLUGIN]: Done."); 111 m_log.Info("[LOADREGIONSPLUGIN]: Done.");
112 112
113 if (!CheckRegionsForSanity(regionsToLoad)) 113 if (!CheckRegionsForSanity(regionsToLoad))
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
index 9d79b3a..49bd911 100644
--- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
@@ -62,7 +62,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
62 new List<ISharedRegionModule>(); 62 new List<ISharedRegionModule>();
63 63
64#region IApplicationPlugin implementation 64#region IApplicationPlugin implementation
65 65
66 public void Initialise (OpenSimBase openSim) 66 public void Initialise (OpenSimBase openSim)
67 { 67 {
68 m_openSim = openSim; 68 m_openSim = openSim;
@@ -91,66 +91,24 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
91 { 91 {
92 if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null) 92 if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
93 { 93 {
94 // Get the config string 94 if (CheckModuleEnabled(node, modulesConfig))
95 string moduleString =
96 modulesConfig.GetString("Setup_" + node.Id, String.Empty);
97
98 // We have a selector
99 if (moduleString != String.Empty)
100 { 95 {
101 // Allow disabling modules even if they don't have 96 m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
102 // support for it 97 m_sharedModules.Add(node);
103 if (moduleString == "disabled")
104 continue;
105
106 // Split off port, if present
107 string[] moduleParts = moduleString.Split(new char[] { '/' }, 2);
108 // Format is [port/][class]
109 string className = moduleParts[0];
110 if (moduleParts.Length > 1)
111 className = moduleParts[1];
112
113 // Match the class name if given
114 if (className != String.Empty &&
115 node.Type.ToString() != className)
116 continue;
117 } 98 }
118
119 m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
120 m_sharedModules.Add(node);
121 } 99 }
122 else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null) 100 else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
123 { 101 {
124 // Get the config string 102 if (CheckModuleEnabled(node, modulesConfig))
125 string moduleString =
126 modulesConfig.GetString("Setup_" + node.Id, String.Empty);
127
128 // We have a selector
129 if (moduleString != String.Empty)
130 { 103 {
131 // Allow disabling modules even if they don't have 104 m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
132 // support for it 105 m_nonSharedModules.Add(node);
133 if (moduleString == "disabled")
134 continue;
135
136 // Split off port, if present
137 string[] moduleParts = moduleString.Split(new char[] { '/' }, 2);
138 // Format is [port/][class]
139 string className = moduleParts[0];
140 if (moduleParts.Length > 1)
141 className = moduleParts[1];
142
143 // Match the class name if given
144 if (className != String.Empty &&
145 node.Type.ToString() != className)
146 continue;
147 } 106 }
148
149 m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
150 m_nonSharedModules.Add(node);
151 } 107 }
152 else 108 else
109 {
153 m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type); 110 m_log.DebugFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
111 }
154 } 112 }
155 113
156 // Load and init the module. We try a constructor with a port 114 // Load and init the module. We try a constructor with a port
@@ -197,8 +155,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
197 m_sharedInstances.Add(module); 155 m_sharedInstances.Add(module);
198 module.Initialise(m_openSim.ConfigSource.Source); 156 module.Initialise(m_openSim.ConfigSource.Source);
199 } 157 }
200
201
202 } 158 }
203 159
204 public void PostInitialise () 160 public void PostInitialise ()
@@ -210,7 +166,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
210 { 166 {
211 module.PostInitialise(); 167 module.PostInitialise();
212 } 168 }
213
214 } 169 }
215 170
216#endregion 171#endregion
@@ -244,7 +199,6 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
244 199
245#endregion 200#endregion
246 201
247
248 public string Version 202 public string Version
249 { 203 {
250 get 204 get
@@ -262,6 +216,42 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
262 } 216 }
263 217
264#region IRegionModulesController implementation 218#region IRegionModulesController implementation
219
220 /// <summary>
221 /// Check that the given module is no disabled in the [Modules] section of the config files.
222 /// </summary>
223 /// <param name="node"></param>
224 /// <param name="modulesConfig">The config section</param>
225 /// <returns>true if the module is enabled, false if it is disabled</returns>
226 protected bool CheckModuleEnabled(TypeExtensionNode node, IConfig modulesConfig)
227 {
228 // Get the config string
229 string moduleString =
230 modulesConfig.GetString("Setup_" + node.Id, String.Empty);
231
232 // We have a selector
233 if (moduleString != String.Empty)
234 {
235 // Allow disabling modules even if they don't have
236 // support for it
237 if (moduleString == "disabled")
238 return false;
239
240 // Split off port, if present
241 string[] moduleParts = moduleString.Split(new char[] { '/' }, 2);
242 // Format is [port/][class]
243 string className = moduleParts[0];
244 if (moduleParts.Length > 1)
245 className = moduleParts[1];
246
247 // Match the class name if given
248 if (className != String.Empty &&
249 node.Type.ToString() != className)
250 return false;
251 }
252
253 return true;
254 }
265 255
266 // The root of all evil. 256 // The root of all evil.
267 // This is where we handle adding the modules to scenes when they 257 // This is where we handle adding the modules to scenes when they
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index c09252a..1b4d1ea 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -208,18 +208,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController
208 208
209 UUID regionID = new UUID((string) requestData["regionID"]); 209 UUID regionID = new UUID((string) requestData["regionID"]);
210 210
211 responseData["accepted"] = true;
212 responseData["success"] = true;
213 response.Value = responseData;
214
215 Scene rebootedScene; 211 Scene rebootedScene;
216 212
213 responseData["success"] = false;
214 responseData["accepted"] = true;
217 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene)) 215 if (!m_application.SceneManager.TryGetScene(regionID, out rebootedScene))
218 throw new Exception("region not found"); 216 throw new Exception("region not found");
219 217
220 responseData["rebooting"] = true; 218 responseData["rebooting"] = true;
219
220 IRestartModule restartModule = rebootedScene.RequestModuleInterface<IRestartModule>();
221 if (restartModule != null)
222 {
223 List<int> times = new List<int> { 30, 15 };
224
225 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
226 responseData["success"] = true;
227 }
221 response.Value = responseData; 228 response.Value = responseData;
222 rebootedScene.Restart(30); 229
223 } 230 }
224 catch (Exception e) 231 catch (Exception e)
225 { 232 {
diff --git a/OpenSim/Data/Tests/InventoryTests.cs b/OpenSim/Data/Tests/InventoryTests.cs
index dc03259..9c2a2d6 100644
--- a/OpenSim/Data/Tests/InventoryTests.cs
+++ b/OpenSim/Data/Tests/InventoryTests.cs
@@ -323,7 +323,7 @@ namespace OpenSim.Data.Tests
323 .IgnoreProperty(x => x.InvType) 323 .IgnoreProperty(x => x.InvType)
324 .IgnoreProperty(x => x.CreatorIdAsUuid) 324 .IgnoreProperty(x => x.CreatorIdAsUuid)
325 .IgnoreProperty(x => x.Description) 325 .IgnoreProperty(x => x.Description)
326 .IgnoreProperty(x => x.CreatorId) 326 .IgnoreProperty(x => x.CreatorIdentification)
327 .IgnoreProperty(x => x.CreatorData)); 327 .IgnoreProperty(x => x.CreatorData));
328 328
329 inventoryScrambler.Scramble(expected); 329 inventoryScrambler.Scramble(expected);
@@ -334,7 +334,7 @@ namespace OpenSim.Data.Tests
334 .IgnoreProperty(x => x.InvType) 334 .IgnoreProperty(x => x.InvType)
335 .IgnoreProperty(x => x.CreatorIdAsUuid) 335 .IgnoreProperty(x => x.CreatorIdAsUuid)
336 .IgnoreProperty(x => x.Description) 336 .IgnoreProperty(x => x.Description)
337 .IgnoreProperty(x => x.CreatorId) 337 .IgnoreProperty(x => x.CreatorIdentification)
338 .IgnoreProperty(x => x.CreatorData)); 338 .IgnoreProperty(x => x.CreatorData));
339 } 339 }
340 340
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index cc9fcea..1600bdc 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -302,31 +302,26 @@ namespace OpenSim.Framework
302 if (args["start_pos"] != null) 302 if (args["start_pos"] != null)
303 Vector3.TryParse(args["start_pos"].AsString(), out startpos); 303 Vector3.TryParse(args["start_pos"].AsString(), out startpos);
304 304
305// DEBUG ON 305 m_log.InfoFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}",AgentID,child,startpos.ToString());
306 m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}",AgentID,child,startpos.ToString());
307// DEBUG OFF
308 306
309 try { 307 try {
310 // Unpack various appearance elements 308 // Unpack various appearance elements
311 Appearance = new AvatarAppearance(AgentID); 309 Appearance = new AvatarAppearance(AgentID);
312 310
313 // Eventually this code should be deprecated, use full appearance 311 // Eventually this code should be deprecated, use full appearance
314 // packing in packed_appearance 312 // packing in packed_appearance
315 if (args["appearance_serial"] != null) 313 if (args["appearance_serial"] != null)
316 Appearance.Serial = args["appearance_serial"].AsInteger(); 314 Appearance.Serial = args["appearance_serial"].AsInteger();
317 315
318 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map)) 316 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
319 { 317 {
320 Appearance.Unpack((OSDMap)args["packed_appearance"]); 318 Appearance.Unpack((OSDMap)args["packed_appearance"]);
321// DEBUG ON 319 m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance");
322 m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance"); 320 }
323// DEBUG OFF 321 else
322 m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
324 } 323 }
325// DEBUG ON 324 catch (Exception e)
326 else
327 m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
328// DEBUG OFF
329 } catch (Exception e)
330 { 325 {
331 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message); 326 m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
332 } 327 }
diff --git a/OpenSim/Framework/AssetLandmark.cs b/OpenSim/Framework/AssetLandmark.cs
index 7806c1f..f433235 100644
--- a/OpenSim/Framework/AssetLandmark.cs
+++ b/OpenSim/Framework/AssetLandmark.cs
@@ -51,8 +51,16 @@ namespace OpenSim.Framework
51 string[] parts = temp.Split('\n'); 51 string[] parts = temp.Split('\n');
52 int.TryParse(parts[0].Substring(17, 1), out Version); 52 int.TryParse(parts[0].Substring(17, 1), out Version);
53 UUID.TryParse(parts[1].Substring(10, 36), out RegionID); 53 UUID.TryParse(parts[1].Substring(10, 36), out RegionID);
54 // the vector is stored with spaces as separators, not with commas ("10.3 32.5 43" instead of "10.3, 32.5, 43") 54 // The position is a vector with spaces as separators ("10.3 32.5 43").
55 Vector3.TryParse(parts[2].Substring(10, parts[2].Length - 10).Replace(" ", ","), out Position); 55 // Parse each scalar separately to take into account the system's culture setting.
56 string[] scalars = parts[2].Substring(10, parts[2].Length - 10).Split(' ');
57 if (scalars.Length > 0)
58 System.Single.TryParse(scalars[0], out Position.X);
59 if (scalars.Length > 1)
60 System.Single.TryParse(scalars[1], out Position.Y);
61 if (scalars.Length > 2)
62 System.Single.TryParse(scalars[2], out Position.Z);
63
56 ulong.TryParse(parts[3].Substring(14, parts[3].Length - 14), out RegionHandle); 64 ulong.TryParse(parts[3].Substring(14, parts[3].Length - 14), out RegionHandle);
57 } 65 }
58 } 66 }
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 2906af8..18a5733 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Framework
48 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; 48 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
49 49
50 protected UUID m_owner; 50 protected UUID m_owner;
51 protected int m_serial = 1; 51 protected int m_serial = 0;
52 protected byte[] m_visualparams; 52 protected byte[] m_visualparams;
53 protected Primitive.TextureEntry m_texture; 53 protected Primitive.TextureEntry m_texture;
54 protected AvatarWearable[] m_wearables; 54 protected AvatarWearable[] m_wearables;
@@ -103,7 +103,7 @@ namespace OpenSim.Framework
103 { 103 {
104// m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance for {0}",owner); 104// m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance for {0}",owner);
105 105
106 m_serial = 1; 106 m_serial = 0;
107 m_owner = owner; 107 m_owner = owner;
108 108
109 SetDefaultWearables(); 109 SetDefaultWearables();
@@ -127,7 +127,7 @@ namespace OpenSim.Framework
127 { 127 {
128// m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID); 128// m_log.WarnFormat("[AVATAR APPEARANCE] create initialized appearance for {0}",avatarID);
129 129
130 m_serial = 1; 130 m_serial = 0;
131 m_owner = avatarID; 131 m_owner = avatarID;
132 132
133 if (wearables != null) 133 if (wearables != null)
@@ -160,7 +160,7 @@ namespace OpenSim.Framework
160 160
161 if (appearance == null) 161 if (appearance == null)
162 { 162 {
163 m_serial = 1; 163 m_serial = 0;
164 m_owner = UUID.Zero; 164 m_owner = UUID.Zero;
165 165
166 SetDefaultWearables(); 166 SetDefaultWearables();
@@ -229,6 +229,24 @@ namespace OpenSim.Framework
229 m_wearables = AvatarWearable.DefaultWearables; 229 m_wearables = AvatarWearable.DefaultWearables;
230 } 230 }
231 231
232 /// <summary>
233 /// Invalidate all of the baked textures in the appearance, useful
234 /// if you know that none are valid
235 /// </summary>
236 public virtual void ResetAppearance()
237 {
238 m_serial = 0;
239
240 SetDefaultParams();
241 SetDefaultTexture();
242
243 //for (int i = 0; i < BAKE_INDICES.Length; i++)
244 // {
245 // int idx = BAKE_INDICES[i];
246 // m_texture.FaceTextures[idx].TextureID = UUID.Zero;
247 // }
248 }
249
232 protected virtual void SetDefaultParams() 250 protected virtual void SetDefaultParams()
233 { 251 {
234 m_visualparams = new byte[] { 33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 }; 252 m_visualparams = new byte[] { 33,61,85,23,58,127,63,85,63,42,0,85,63,36,85,95,153,63,34,0,63,109,88,132,63,136,81,85,103,136,127,0,150,150,150,127,0,0,0,0,0,127,0,0,255,127,114,127,99,63,127,140,127,127,0,0,0,191,0,104,0,0,0,0,0,0,0,0,0,145,216,133,0,127,0,127,170,0,0,127,127,109,85,127,127,63,85,42,150,150,150,150,150,150,150,25,150,150,150,0,127,0,0,144,85,127,132,127,85,0,127,127,127,127,127,127,59,127,85,127,127,106,47,79,127,127,204,2,141,66,0,0,127,127,0,0,0,0,127,0,159,0,0,178,127,36,85,131,127,127,127,153,95,0,140,75,27,127,127,0,150,150,198,0,0,63,30,127,165,209,198,127,127,153,204,51,51,255,255,255,204,0,255,150,150,150,150,150,150,150,150,150,150,0,150,150,150,150,150,0,127,127,150,150,150,150,150,150,150,150,0,0,150,51,132,150,150,150 };
@@ -240,9 +258,10 @@ namespace OpenSim.Framework
240 258
241 protected virtual void SetDefaultTexture() 259 protected virtual void SetDefaultTexture()
242 { 260 {
243 m_texture = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97")); 261 m_texture = new Primitive.TextureEntry(new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
244 for (uint i = 0; i < TEXTURE_COUNT; i++) 262
245 m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE); 263 // for (uint i = 0; i < TEXTURE_COUNT; i++)
264 // m_texture.CreateFace(i).TextureID = new UUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE);
246 } 265 }
247 266
248 /// <summary> 267 /// <summary>
@@ -274,9 +293,6 @@ namespace OpenSim.Framework
274 } 293 }
275 294
276 changed = true; 295 changed = true;
277
278// if (newface != null)
279// m_log.WarnFormat("[AVATAR APPEARANCE]: index {0}, new texture id {1}",i,newface.TextureID);
280 } 296 }
281 297
282 m_texture = textureEntry; 298 m_texture = textureEntry;
diff --git a/OpenSim/Framework/Capabilities/Caps.cs b/OpenSim/Framework/Capabilities/Caps.cs
index e7f2e13..63e1e34 100644
--- a/OpenSim/Framework/Capabilities/Caps.cs
+++ b/OpenSim/Framework/Capabilities/Caps.cs
@@ -990,6 +990,7 @@ namespace OpenSim.Framework.Capabilities
990 public void BakedTextureUploaded(UUID assetID, byte[] data) 990 public void BakedTextureUploaded(UUID assetID, byte[] data)
991 { 991 {
992// m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString()); 992// m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
993
993 AssetBase asset; 994 AssetBase asset;
994 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString()); 995 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
995 asset.Data = data; 996 asset.Data = data;
@@ -1331,6 +1332,7 @@ namespace OpenSim.Framework.Capabilities
1331 newAssetID = UUID.Random(); 1332 newAssetID = UUID.Random();
1332 uploaderPath = path; 1333 uploaderPath = path;
1333 httpListener = httpServer; 1334 httpListener = httpServer;
1335 m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
1334 } 1336 }
1335 1337
1336 /// <summary> 1338 /// <summary>
@@ -1358,6 +1360,8 @@ namespace OpenSim.Framework.Capabilities
1358 handlerUpLoad(newAssetID, data); 1360 handlerUpLoad(newAssetID, data);
1359 } 1361 }
1360 1362
1363 m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
1364
1361 return res; 1365 return res;
1362 } 1366 }
1363 } 1367 }
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index a227338..ce0b2fb 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -331,9 +331,7 @@ namespace OpenSim.Framework
331 331
332 public virtual OSDMap Pack() 332 public virtual OSDMap Pack()
333 { 333 {
334// DEBUG ON 334 m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
335 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Pack data");
336// DEBUG OFF
337 335
338 OSDMap args = new OSDMap(); 336 OSDMap args = new OSDMap();
339 args["message_type"] = OSD.FromString("AgentData"); 337 args["message_type"] = OSD.FromString("AgentData");
@@ -454,9 +452,7 @@ namespace OpenSim.Framework
454 /// <param name="hash"></param> 452 /// <param name="hash"></param>
455 public virtual void Unpack(OSDMap args) 453 public virtual void Unpack(OSDMap args)
456 { 454 {
457// DEBUG ON 455 m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
458 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data");
459// DEBUG OFF
460 456
461 if (args.ContainsKey("region_id")) 457 if (args.ContainsKey("region_id"))
462 UUID.TryParse(args["region_id"].AsString(), out RegionID); 458 UUID.TryParse(args["region_id"].AsString(), out RegionID);
@@ -613,10 +609,8 @@ namespace OpenSim.Framework
613 609
614 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) 610 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
615 Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]); 611 Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]);
616// DEBUG ON
617 else 612 else
618 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); 613 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
619// DEBUG OFF
620 614
621 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 615 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
622 { 616 {
diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
deleted file mode 100644
index bcd1eee..0000000
--- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
+++ /dev/null
@@ -1,104 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Collections.Generic;
29using OpenSim.Data;
30using OpenMetaverse;
31using OpenSim.Services.Interfaces;
32
33namespace OpenSim.Framework.Communications.Osp
34{
35 /// <summary>
36 /// Wrap other inventory data plugins so that we can perform OSP related post processing for items
37 /// </summary>
38 public class OspInventoryWrapperPlugin : IInventoryDataPlugin
39 {
40 protected IInventoryDataPlugin m_wrappedPlugin;
41 //protected CommunicationsManager m_commsManager;
42 protected IUserAccountService m_userAccountService;
43
44 public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService)
45 {
46 m_wrappedPlugin = wrappedPlugin;
47 m_userAccountService = userService;
48 }
49
50 public string Name { get { return "OspInventoryWrapperPlugin"; } }
51 public string Version { get { return "0.1"; } }
52 public void Initialise() {}
53 public void Initialise(string connect) {}
54 public void Dispose() {}
55
56 public InventoryItemBase getInventoryItem(UUID item)
57 {
58 return PostProcessItem(m_wrappedPlugin.getInventoryItem(item));
59 }
60
61 // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem?
62 public InventoryItemBase queryInventoryItem(UUID item)
63 {
64 return PostProcessItem(m_wrappedPlugin.queryInventoryItem(item));
65 }
66
67 public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
68 {
69 List<InventoryItemBase> items = m_wrappedPlugin.getInventoryInFolder(folderID);
70
71 foreach (InventoryItemBase item in items)
72 PostProcessItem(item);
73
74 return items;
75 }
76
77 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
78 {
79 return m_wrappedPlugin.fetchActiveGestures(avatarID);
80
81 // Presuming that no post processing is needed here as gestures don't refer to creator information (?)
82 }
83
84 protected InventoryItemBase PostProcessItem(InventoryItemBase item)
85 {
86 item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService);
87 return item;
88 }
89
90 public List<InventoryFolderBase> getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); }
91 public List<InventoryFolderBase> getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); }
92 public InventoryFolderBase getUserRootFolder(UUID user) { return m_wrappedPlugin.getUserRootFolder(user); }
93 public List<InventoryFolderBase> getInventoryFolders(UUID parentID) { return m_wrappedPlugin.getInventoryFolders(parentID); }
94 public InventoryFolderBase getInventoryFolder(UUID folder) { return m_wrappedPlugin.getInventoryFolder(folder); }
95 public void addInventoryItem(InventoryItemBase item) { m_wrappedPlugin.addInventoryItem(item); }
96 public void updateInventoryItem(InventoryItemBase item) { m_wrappedPlugin.updateInventoryItem(item); }
97 public void deleteInventoryItem(UUID item) { m_wrappedPlugin.deleteInventoryItem(item); }
98 public InventoryFolderBase queryInventoryFolder(UUID folder) { return m_wrappedPlugin.queryInventoryFolder(folder); }
99 public void addInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.addInventoryFolder(folder); }
100 public void updateInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.updateInventoryFolder(folder); }
101 public void moveInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.moveInventoryFolder(folder); }
102 public void deleteInventoryFolder(UUID folder) { m_wrappedPlugin.deleteInventoryFolder(folder); }
103 }
104}
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index 6798b7b..1298f26 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Framework
73 void AddNewClient(IClientAPI client); 73 void AddNewClient(IClientAPI client);
74 void RemoveClient(UUID agentID); 74 void RemoveClient(UUID agentID);
75 75
76 void Restart(int seconds); 76 void Restart();
77 //RegionInfo OtherRegionUp(RegionInfo thisRegion); 77 //RegionInfo OtherRegionUp(RegionInfo thisRegion);
78 78
79 string GetSimulatorVersion(); 79 string GetSimulatorVersion();
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
new file mode 100644
index 0000000..6e8c2ee
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -0,0 +1,99 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Xml;
31
32using OpenMetaverse;
33using OpenSim.Services.Interfaces;
34
35namespace OpenSim.Framework.Serialization.External
36{
37 /// <summary>
38 /// Utilities for manipulating external representations of data structures in OpenSim
39 /// </summary>
40 public class ExternalRepresentationUtils
41 {
42 /// <summary>
43 /// Takes a XML representation of a SceneObjectPart and returns another XML representation
44 /// with creator data added to it.
45 /// </summary>
46 /// <param name="xml">The SceneObjectPart represented in XML2</param>
47 /// <param name="profileURL">The URL of the profile service for the creator</param>
48 /// <param name="userService">The service for retrieving user account information</param>
49 /// <param name="scopeID">The scope of the user account information (Grid ID)</param>
50 /// <returns>The SceneObjectPart represented in XML2</returns>
51 public static string RewriteSOP(string xml, string profileURL, IUserAccountService userService, UUID scopeID)
52 {
53 if (xml == string.Empty || profileURL == string.Empty || userService == null)
54 return xml;
55
56 XmlDocument doc = new XmlDocument();
57 doc.LoadXml(xml);
58 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
59
60 foreach (XmlNode sop in sops)
61 {
62 UserAccount creator = null;
63 bool hasCreatorData = false;
64 XmlNodeList nodes = sop.ChildNodes;
65 foreach (XmlNode node in nodes)
66 {
67 if (node.Name == "CreatorID")
68 {
69 UUID uuid = UUID.Zero;
70 UUID.TryParse(node.InnerText, out uuid);
71 creator = userService.GetUserAccount(scopeID, uuid);
72 }
73 if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
74 hasCreatorData = true;
75
76 //if (node.Name == "OwnerID")
77 //{
78 // UserAccount owner = GetUser(node.InnerText);
79 // if (owner != null)
80 // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
81 //}
82 }
83 if (!hasCreatorData && creator != null)
84 {
85 XmlElement creatorData = doc.CreateElement("CreatorData");
86 creatorData.InnerText = profileURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
87 sop.AppendChild(creatorData);
88 }
89 }
90
91 using (StringWriter wr = new StringWriter())
92 {
93 doc.Save(wr);
94 return wr.ToString();
95 }
96
97 }
98 }
99}
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
index 24ea64d..7e3dd1b 100644
--- a/OpenSim/Framework/Communications/Osp/OspResolver.cs
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34 34
35namespace OpenSim.Framework.Communications.Osp 35namespace OpenSim.Framework.Serialization
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for 38 /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for
@@ -57,6 +57,12 @@ namespace OpenSim.Framework.Communications.Osp
57 /// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns> 57 /// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns>
58 public static string MakeOspa(UUID userId, IUserAccountService userService) 58 public static string MakeOspa(UUID userId, IUserAccountService userService)
59 { 59 {
60 if (userService == null)
61 {
62 m_log.Warn("[OSP RESOLVER]: UserService is null");
63 return userId.ToString();
64 }
65
60 UserAccount account = userService.GetUserAccount(UUID.Zero, userId); 66 UserAccount account = userService.GetUserAccount(UUID.Zero, userId);
61 if (account != null) 67 if (account != null)
62 return MakeOspa(account.FirstName, account.LastName); 68 return MakeOspa(account.FirstName, account.LastName);
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index 862cc72..d5e84c7 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -26,11 +26,16 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.IO; 30using System.IO;
31using System.Reflection;
30using System.Text; 32using System.Text;
31using System.Xml; 33using System.Xml;
34
35using log4net;
32using OpenMetaverse; 36using OpenMetaverse;
33using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Services.Interfaces;
34 39
35namespace OpenSim.Framework.Serialization.External 40namespace OpenSim.Framework.Serialization.External
36{ 41{
@@ -40,6 +45,141 @@ namespace OpenSim.Framework.Serialization.External
40 /// XXX: Please do not use yet. 45 /// XXX: Please do not use yet.
41 public class UserInventoryItemSerializer 46 public class UserInventoryItemSerializer
42 { 47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader);
51 private static Dictionary<string, InventoryItemXmlProcessor> m_InventoryItemXmlProcessors = new Dictionary<string, InventoryItemXmlProcessor>();
52
53 #region InventoryItemBase Processor initialization
54 static UserInventoryItemSerializer()
55 {
56 m_InventoryItemXmlProcessors.Add("Name", ProcessName);
57 m_InventoryItemXmlProcessors.Add("ID", ProcessID);
58 m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType);
59 m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID);
60 m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID);
61 m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData);
62 m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate);
63 m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner);
64 m_InventoryItemXmlProcessors.Add("Description", ProcessDescription);
65 m_InventoryItemXmlProcessors.Add("AssetType", ProcessAssetType);
66 m_InventoryItemXmlProcessors.Add("AssetID", ProcessAssetID);
67 m_InventoryItemXmlProcessors.Add("SaleType", ProcessSaleType);
68 m_InventoryItemXmlProcessors.Add("SalePrice", ProcessSalePrice);
69 m_InventoryItemXmlProcessors.Add("BasePermissions", ProcessBasePermissions);
70 m_InventoryItemXmlProcessors.Add("CurrentPermissions", ProcessCurrentPermissions);
71 m_InventoryItemXmlProcessors.Add("EveryOnePermissions", ProcessEveryOnePermissions);
72 m_InventoryItemXmlProcessors.Add("NextPermissions", ProcessNextPermissions);
73 m_InventoryItemXmlProcessors.Add("Flags", ProcessFlags);
74 m_InventoryItemXmlProcessors.Add("GroupID", ProcessGroupID);
75 m_InventoryItemXmlProcessors.Add("GroupOwned", ProcessGroupOwned);
76 }
77 #endregion
78
79 #region InventoryItemBase Processors
80 private static void ProcessName(InventoryItemBase item, XmlTextReader reader)
81 {
82 item.Name = reader.ReadElementContentAsString("Name", String.Empty);
83 }
84
85 private static void ProcessID(InventoryItemBase item, XmlTextReader reader)
86 {
87 item.ID = Util.ReadUUID(reader, "ID");
88 }
89
90 private static void ProcessInvType(InventoryItemBase item, XmlTextReader reader)
91 {
92 item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty);
93 }
94
95 private static void ProcessCreatorUUID(InventoryItemBase item, XmlTextReader reader)
96 {
97 item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty);
98 }
99
100 private static void ProcessCreatorID(InventoryItemBase item, XmlTextReader reader)
101 {
102 // when it exists, this overrides the previous
103 item.CreatorId = reader.ReadElementContentAsString("CreatorID", String.Empty);
104 }
105
106 private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader)
107 {
108 item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
109 }
110
111 private static void ProcessOwner(InventoryItemBase item, XmlTextReader reader)
112 {
113 item.Owner = Util.ReadUUID(reader, "Owner");
114 }
115
116 private static void ProcessDescription(InventoryItemBase item, XmlTextReader reader)
117 {
118 item.Description = reader.ReadElementContentAsString("Description", String.Empty);
119 }
120
121 private static void ProcessAssetType(InventoryItemBase item, XmlTextReader reader)
122 {
123 item.AssetType = reader.ReadElementContentAsInt("AssetType", String.Empty);
124 }
125
126 private static void ProcessAssetID(InventoryItemBase item, XmlTextReader reader)
127 {
128 item.AssetID = Util.ReadUUID(reader, "AssetID");
129 }
130
131 private static void ProcessSaleType(InventoryItemBase item, XmlTextReader reader)
132 {
133 item.SaleType = (byte)reader.ReadElementContentAsInt("SaleType", String.Empty);
134 }
135
136 private static void ProcessSalePrice(InventoryItemBase item, XmlTextReader reader)
137 {
138 item.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
139 }
140
141 private static void ProcessBasePermissions(InventoryItemBase item, XmlTextReader reader)
142 {
143 item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
144 }
145
146 private static void ProcessCurrentPermissions(InventoryItemBase item, XmlTextReader reader)
147 {
148 item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
149 }
150
151 private static void ProcessEveryOnePermissions(InventoryItemBase item, XmlTextReader reader)
152 {
153 item.EveryOnePermissions = (uint)reader.ReadElementContentAsInt("EveryOnePermissions", String.Empty);
154 }
155
156 private static void ProcessNextPermissions(InventoryItemBase item, XmlTextReader reader)
157 {
158 item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
159 }
160
161 private static void ProcessFlags(InventoryItemBase item, XmlTextReader reader)
162 {
163 item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty);
164 }
165
166 private static void ProcessGroupID(InventoryItemBase item, XmlTextReader reader)
167 {
168 item.GroupID = Util.ReadUUID(reader, "GroupID");
169 }
170
171 private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader)
172 {
173 item.GroupOwned = Util.ReadBoolean(reader);
174 }
175
176 private static void ProcessCreatorData(InventoryItemBase item, XmlTextReader reader)
177 {
178 item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty);
179 }
180
181 #endregion
182
43 /// <summary> 183 /// <summary>
44 /// Deserialize item 184 /// Deserialize item
45 /// </summary> 185 /// </summary>
@@ -60,40 +200,47 @@ namespace OpenSim.Framework.Serialization.External
60 public static InventoryItemBase Deserialize(string serialization) 200 public static InventoryItemBase Deserialize(string serialization)
61 { 201 {
62 InventoryItemBase item = new InventoryItemBase(); 202 InventoryItemBase item = new InventoryItemBase();
63 203
64 StringReader sr = new StringReader(serialization); 204 using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization)))
65 XmlTextReader xtr = new XmlTextReader(sr); 205 {
66 206 reader.ReadStartElement("InventoryItem");
67 xtr.ReadStartElement("InventoryItem"); 207
68 208 string nodeName = string.Empty;
69 item.Name = xtr.ReadElementString("Name"); 209 while (reader.NodeType != XmlNodeType.EndElement)
70 item.ID = UUID.Parse( xtr.ReadElementString("ID")); 210 {
71 item.InvType = Convert.ToInt32( xtr.ReadElementString("InvType")); 211 nodeName = reader.Name;
72 item.CreatorId = xtr.ReadElementString("CreatorUUID"); 212 InventoryItemXmlProcessor p = null;
73 item.CreationDate = Convert.ToInt32( xtr.ReadElementString("CreationDate")); 213 if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p))
74 item.Owner = UUID.Parse( xtr.ReadElementString("Owner")); 214 {
75 item.Description = xtr.ReadElementString("Description"); 215 //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name);
76 item.AssetType = Convert.ToInt32( xtr.ReadElementString("AssetType")); 216 try
77 item.AssetID = UUID.Parse( xtr.ReadElementString("AssetID")); 217 {
78 item.SaleType = Convert.ToByte( xtr.ReadElementString("SaleType")); 218 p(item, reader);
79 item.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice")); 219 }
80 item.BasePermissions = Convert.ToUInt32( xtr.ReadElementString("BasePermissions")); 220 catch (Exception e)
81 item.CurrentPermissions = Convert.ToUInt32( xtr.ReadElementString("CurrentPermissions")); 221 {
82 item.EveryOnePermissions = Convert.ToUInt32( xtr.ReadElementString("EveryOnePermissions")); 222 m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e);
83 item.NextPermissions = Convert.ToUInt32( xtr.ReadElementString("NextPermissions")); 223 if (reader.NodeType == XmlNodeType.EndElement)
84 item.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags")); 224 reader.Read();
85 item.GroupID = UUID.Parse( xtr.ReadElementString("GroupID")); 225 }
86 item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned")); 226 }
87 227 else
88 xtr.ReadEndElement(); 228 {
89 229 // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName);
90 xtr.Close(); 230 reader.ReadOuterXml(); // ignore
91 sr.Close(); 231 }
92 232
233 }
234
235 reader.ReadEndElement(); // InventoryItem
236 }
237
238 //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID);
93 return item; 239 return item;
240
94 } 241 }
95 242
96 public static string Serialize(InventoryItemBase inventoryItem) 243 public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService)
97 { 244 {
98 StringWriter sw = new StringWriter(); 245 StringWriter sw = new StringWriter();
99 XmlTextWriter writer = new XmlTextWriter(sw); 246 XmlTextWriter writer = new XmlTextWriter(sw);
@@ -112,7 +259,7 @@ namespace OpenSim.Framework.Serialization.External
112 writer.WriteString(inventoryItem.InvType.ToString()); 259 writer.WriteString(inventoryItem.InvType.ToString());
113 writer.WriteEndElement(); 260 writer.WriteEndElement();
114 writer.WriteStartElement("CreatorUUID"); 261 writer.WriteStartElement("CreatorUUID");
115 writer.WriteString(inventoryItem.CreatorId); 262 writer.WriteString(OspResolver.MakeOspa(inventoryItem.CreatorIdAsUuid, userAccountService));
116 writer.WriteEndElement(); 263 writer.WriteEndElement();
117 writer.WriteStartElement("CreationDate"); 264 writer.WriteStartElement("CreationDate");
118 writer.WriteString(inventoryItem.CreationDate.ToString()); 265 writer.WriteString(inventoryItem.CreationDate.ToString());
@@ -156,6 +303,20 @@ namespace OpenSim.Framework.Serialization.External
156 writer.WriteStartElement("GroupOwned"); 303 writer.WriteStartElement("GroupOwned");
157 writer.WriteString(inventoryItem.GroupOwned.ToString()); 304 writer.WriteString(inventoryItem.GroupOwned.ToString());
158 writer.WriteEndElement(); 305 writer.WriteEndElement();
306 if (inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty)
307 writer.WriteElementString("CreatorData", inventoryItem.CreatorData);
308 else if (options.ContainsKey("profile"))
309 {
310 if (userAccountService != null)
311 {
312 UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid);
313 if (account != null)
314 {
315 writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName);
316 }
317 writer.WriteElementString("CreatorID", inventoryItem.CreatorId);
318 }
319 }
159 320
160 writer.WriteEndElement(); 321 writer.WriteEndElement();
161 322
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e8f8e01..8d1671a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1558,5 +1558,86 @@ namespace OpenSim.Framework
1558 return string.Empty; 1558 return string.Empty;
1559 } 1559 }
1560 1560
1561 #region Xml Serialization Utilities
1562 public static bool ReadBoolean(XmlTextReader reader)
1563 {
1564 reader.ReadStartElement();
1565 bool result = Boolean.Parse(reader.ReadContentAsString().ToLower());
1566 reader.ReadEndElement();
1567
1568 return result;
1569 }
1570
1571 public static UUID ReadUUID(XmlTextReader reader, string name)
1572 {
1573 UUID id;
1574 string idStr;
1575
1576 reader.ReadStartElement(name);
1577
1578 if (reader.Name == "Guid")
1579 idStr = reader.ReadElementString("Guid");
1580 else if (reader.Name == "UUID")
1581 idStr = reader.ReadElementString("UUID");
1582 else // no leading tag
1583 idStr = reader.ReadContentAsString();
1584 UUID.TryParse(idStr, out id);
1585 reader.ReadEndElement();
1586
1587 return id;
1588 }
1589
1590 public static Vector3 ReadVector(XmlTextReader reader, string name)
1591 {
1592 Vector3 vec;
1593
1594 reader.ReadStartElement(name);
1595 vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
1596 vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
1597 vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
1598 reader.ReadEndElement();
1599
1600 return vec;
1601 }
1602
1603 public static Quaternion ReadQuaternion(XmlTextReader reader, string name)
1604 {
1605 Quaternion quat = new Quaternion();
1606
1607 reader.ReadStartElement(name);
1608 while (reader.NodeType != XmlNodeType.EndElement)
1609 {
1610 switch (reader.Name.ToLower())
1611 {
1612 case "x":
1613 quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1614 break;
1615 case "y":
1616 quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1617 break;
1618 case "z":
1619 quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1620 break;
1621 case "w":
1622 quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1623 break;
1624 }
1625 }
1626
1627 reader.ReadEndElement();
1628
1629 return quat;
1630 }
1631
1632 public static T ReadEnum<T>(XmlTextReader reader, string name)
1633 {
1634 string value = reader.ReadElementContentAsString(name, String.Empty);
1635 // !!!!! to deal with flags without commas
1636 if (value.Contains(" ") && !value.Contains(","))
1637 value = value.Replace(" ", ", ");
1638
1639 return (T)Enum.Parse(typeof(T), value); ;
1640 }
1641 #endregion
1561 } 1642 }
1562} 1643}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 6127c2d..ae2d836 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -265,10 +265,10 @@ namespace OpenSim
265 LoadOar); 265 LoadOar);
266 266
267 m_console.Commands.AddCommand("region", false, "save oar", 267 m_console.Commands.AddCommand("region", false, "save oar",
268 "save oar [-v|--version=N] [-p|--profile=url] [<OAR path>]", 268 "save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]",
269 "Save a region's data to an OAR archive.", 269 "Save a region's data to an OAR archive.",
270 "-v|--version=N generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine 270 "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
271 + "-p|--profile=url adds the url of the profile service to the saved user information" + Environment.NewLine 271 + "-p|--profile=<url> adds the url of the profile service to the saved user information" + Environment.NewLine
272 + "The OAR path must be a filesystem path." 272 + "The OAR path must be a filesystem path."
273 + " If this is not given then the oar is saved to region.oar in the current directory.", 273 + " If this is not given then the oar is saved to region.oar in the current directory.",
274 SaveOar); 274 SaveOar);
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 904a50c..1652b82 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -352,13 +352,13 @@ namespace OpenSim
352 m_moduleLoader.InitialiseSharedModules(scene); 352 m_moduleLoader.InitialiseSharedModules(scene);
353 353
354 // Use this in the future, the line above will be deprecated soon 354 // Use this in the future, the line above will be deprecated soon
355 m_log.Info("[MODULES]: Loading Region's modules (new style)"); 355 m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)");
356 IRegionModulesController controller; 356 IRegionModulesController controller;
357 if (ApplicationRegistry.TryGet(out controller)) 357 if (ApplicationRegistry.TryGet(out controller))
358 { 358 {
359 controller.AddRegionToModules(scene); 359 controller.AddRegionToModules(scene);
360 } 360 }
361 else m_log.Error("[MODULES]: The new RegionModulesController is missing..."); 361 else m_log.Error("[REGIONMODULES]: The new RegionModulesController is missing...");
362 362
363 scene.SetModuleInterfaces(); 363 scene.SetModuleInterfaces();
364 364
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 7851c4d..f125822 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3562,24 +3562,28 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3562 EntityUpdate update; 3562 EntityUpdate update;
3563 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update)) 3563 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update))
3564 { 3564 {
3565 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
3566 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
3567 // safety measure.
3568 //
3569 // Receiving updates after kills results in undeleteable prims that persist until relog and
3570 // currently occurs because prims can be deleted before all queued updates are sent.
3571 if (m_killRecord.Contains(update.Entity.LocalId))
3572 {
3573// m_log.WarnFormat(
3574// "[CLIENT]: Preventing full update for prim with local id {0} after client for user {1} told it was deleted",
3575// update.Entity.LocalId, Name);
3576 continue;
3577 }
3578
3579 if (update.Entity is SceneObjectPart) 3565 if (update.Entity is SceneObjectPart)
3580 { 3566 {
3581 SceneObjectPart part = (SceneObjectPart)update.Entity; 3567 SceneObjectPart part = (SceneObjectPart)update.Entity;
3582 3568
3569 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client
3570 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good
3571 // safety measure.
3572 //
3573 // If a Linden Lab 1.23.5 client (and possibly later and earlier) receives an object update
3574 // after a kill, it will keep displaying the deleted object until relog. OpenSim currently performs
3575 // updates and kills on different threads with different scheduling strategies, hence this protection.
3576 //
3577 // This doesn't appear to apply to child prims - a client will happily ignore these updates
3578 // after the root prim has been deleted.
3579 if (m_killRecord.Contains(part.LocalId))
3580 {
3581 // m_log.WarnFormat(
3582 // "[CLIENT]: Preventing update for prim with local id {0} after client for user {1} told it was deleted",
3583 // part.LocalId, Name);
3584 continue;
3585 }
3586
3583 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3587 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3584 { 3588 {
3585 if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand && 3589 if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index c4db5da..e02783a 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -399,7 +399,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
399 return data; 399 return data;
400 } 400 }
401 401
402 public bool EnqueueOutgoing(OutgoingPacket packet) 402 /// <summary>
403 /// Queue an outgoing packet if appropriate.
404 /// </summary>
405 /// <param name="packet"></param>
406 /// <param name="forceQueue">Always queue the packet if at all possible.</param>
407 /// <returns>
408 /// true if the packet has been queued,
409 /// false if the packet has not been queued and should be sent immediately.
410 /// </returns>
411 public bool EnqueueOutgoing(OutgoingPacket packet, bool forceQueue)
403 { 412 {
404 int category = (int)packet.Category; 413 int category = (int)packet.Category;
405 414
@@ -408,14 +417,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
408 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; 417 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
409 TokenBucket bucket = m_throttleCategories[category]; 418 TokenBucket bucket = m_throttleCategories[category];
410 419
411 if (bucket.RemoveTokens(packet.Buffer.DataLength)) 420 if (!forceQueue && bucket.RemoveTokens(packet.Buffer.DataLength))
412 { 421 {
413 // Enough tokens were removed from the bucket, the packet will not be queued 422 // Enough tokens were removed from the bucket, the packet will not be queued
414 return false; 423 return false;
415 } 424 }
416 else 425 else
417 { 426 {
418 // Not enough tokens in the bucket, queue this packet 427 // Force queue specified or not enough tokens in the bucket, queue this packet
419 queue.Enqueue(packet); 428 queue.Enqueue(packet);
420 return true; 429 return true;
421 } 430 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index dcfe615..149ae9e 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -312,6 +312,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
312 } 312 }
313 } 313 }
314 314
315 /// <summary>
316 /// Start the process of sending a packet to the client.
317 /// </summary>
318 /// <param name="udpClient"></param>
319 /// <param name="packet"></param>
320 /// <param name="category"></param>
321 /// <param name="allowSplitting"></param>
315 public void SendPacket(LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting) 322 public void SendPacket(LLUDPClient udpClient, Packet packet, ThrottleOutPacketType category, bool allowSplitting)
316 { 323 {
317 // CoarseLocationUpdate packets cannot be split in an automated way 324 // CoarseLocationUpdate packets cannot be split in an automated way
@@ -339,6 +346,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
339 } 346 }
340 } 347 }
341 348
349 /// <summary>
350 /// Start the process of sending a packet to the client.
351 /// </summary>
352 /// <param name="udpClient"></param>
353 /// <param name="data"></param>
354 /// <param name="type"></param>
355 /// <param name="category"></param>
342 public void SendPacketData(LLUDPClient udpClient, byte[] data, PacketType type, ThrottleOutPacketType category) 356 public void SendPacketData(LLUDPClient udpClient, byte[] data, PacketType type, ThrottleOutPacketType category)
343 { 357 {
344 int dataLength = data.Length; 358 int dataLength = data.Length;
@@ -396,7 +410,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
396 410
397 OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category); 411 OutgoingPacket outgoingPacket = new OutgoingPacket(udpClient, buffer, category);
398 412
399 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) 413 // If a Linden Lab 1.23.5 client receives an update packet after a kill packet for an object, it will
414 // continue to display the deleted object until relog. Therefore, we need to always queue a kill object
415 // packet so that it isn't sent before a queued update packet.
416 bool requestQueue = type == PacketType.KillObject;
417 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, requestQueue))
400 SendPacketFinal(outgoingPacket); 418 SendPacketFinal(outgoingPacket);
401 419
402 #endregion Queue or Send 420 #endregion Queue or Send
@@ -489,7 +507,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
489 //Interlocked.Increment(ref Stats.ResentPackets); 507 //Interlocked.Increment(ref Stats.ResentPackets);
490 508
491 // Requeue or resend the packet 509 // Requeue or resend the packet
492 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket)) 510 if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket, false))
493 SendPacketFinal(outgoingPacket); 511 SendPacketFinal(outgoingPacket);
494 } 512 }
495 } 513 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 3d6e7f3..c66a4ea 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -41,19 +41,22 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
41 /// </summary> 41 /// </summary>
42 public class AgentAssetTransactions 42 public class AgentAssetTransactions
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(
45 MethodBase.GetCurrentMethod().DeclaringType);
45 46
46 // Fields 47 // Fields
47 private bool m_dumpAssetsToFile; 48 private bool m_dumpAssetsToFile;
48 public AssetTransactionModule Manager; 49 private Scene m_Scene;
49 public UUID UserID; 50 public UUID UserID;
50 public Dictionary<UUID, AssetXferUploader> XferUploaders = new Dictionary<UUID, AssetXferUploader>(); 51 public Dictionary<UUID, AssetXferUploader> XferUploaders =
52 new Dictionary<UUID, AssetXferUploader>();
51 53
52 // Methods 54 // Methods
53 public AgentAssetTransactions(UUID agentID, AssetTransactionModule manager, bool dumpAssetsToFile) 55 public AgentAssetTransactions(UUID agentID, Scene scene,
56 bool dumpAssetsToFile)
54 { 57 {
58 m_Scene = scene;
55 UserID = agentID; 59 UserID = agentID;
56 Manager = manager;
57 m_dumpAssetsToFile = dumpAssetsToFile; 60 m_dumpAssetsToFile = dumpAssetsToFile;
58 } 61 }
59 62
@@ -61,7 +64,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
61 { 64 {
62 if (!XferUploaders.ContainsKey(transactionID)) 65 if (!XferUploaders.ContainsKey(transactionID))
63 { 66 {
64 AssetXferUploader uploader = new AssetXferUploader(this, m_dumpAssetsToFile); 67 AssetXferUploader uploader = new AssetXferUploader(m_Scene,
68 m_dumpAssetsToFile);
65 69
66 lock (XferUploaders) 70 lock (XferUploaders)
67 { 71 {
@@ -88,22 +92,25 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
88 } 92 }
89 } 93 }
90 94
91 public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, 95 public void RequestCreateInventoryItem(IClientAPI remoteClient,
92 uint callbackID, string description, string name, sbyte invType, 96 UUID transactionID, UUID folderID, uint callbackID,
93 sbyte type, byte wearableType, uint nextOwnerMask) 97 string description, string name, sbyte invType,
98 sbyte type, byte wearableType, uint nextOwnerMask)
94 { 99 {
95 if (XferUploaders.ContainsKey(transactionID)) 100 if (XferUploaders.ContainsKey(transactionID))
96 { 101 {
97 XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, 102 XferUploaders[transactionID].RequestCreateInventoryItem(
98 callbackID, description, name, invType, type, 103 remoteClient, transactionID, folderID,
99 wearableType, nextOwnerMask); 104 callbackID, description, name, invType, type,
105 wearableType, nextOwnerMask);
100 } 106 }
101 } 107 }
102 108
103 109
104 110
105 /// <summary> 111 /// <summary>
106 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. 112 /// Get an uploaded asset. If the data is successfully retrieved,
113 /// the transaction will be removed.
107 /// </summary> 114 /// </summary>
108 /// <param name="transactionID"></param> 115 /// <param name="transactionID"></param>
109 /// <returns>The asset if the upload has completed, null if it has not.</returns> 116 /// <returns>The asset if the upload has completed, null if it has not.</returns>
@@ -125,105 +132,56 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
125 return null; 132 return null;
126 } 133 }
127 134
128 //private void CreateItemFromUpload(AssetBase asset, IClientAPI ourClient, UUID inventoryFolderID, uint nextPerms, uint wearableType) 135 public void RequestUpdateTaskInventoryItem(IClientAPI remoteClient,
129 //{ 136 SceneObjectPart part, UUID transactionID,
130 // Manager.MyScene.CommsManager.AssetCache.AddAsset(asset); 137 TaskInventoryItem item)
131 // CachedUserInfo userInfo = Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
132 // ourClient.AgentId);
133
134 // if (userInfo != null)
135 // {
136 // InventoryItemBase item = new InventoryItemBase();
137 // item.Owner = ourClient.AgentId;
138 // item.Creator = ourClient.AgentId;
139 // item.ID = UUID.Random();
140 // item.AssetID = asset.FullID;
141 // item.Description = asset.Description;
142 // item.Name = asset.Name;
143 // item.AssetType = asset.Type;
144 // item.InvType = asset.Type;
145 // item.Folder = inventoryFolderID;
146 // item.BasePermissions = 0x7fffffff;
147 // item.CurrentPermissions = 0x7fffffff;
148 // item.EveryOnePermissions = 0;
149 // item.NextPermissions = nextPerms;
150 // item.Flags = wearableType;
151 // item.CreationDate = Util.UnixTimeSinceEpoch();
152
153 // userInfo.AddItem(item);
154 // ourClient.SendInventoryItemCreateUpdate(item);
155 // }
156 // else
157 // {
158 // m_log.ErrorFormat(
159 // "[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation",
160 // ourClient.AgentId);
161 // }
162 //}
163
164 public void RequestUpdateTaskInventoryItem(
165 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
166 { 138 {
167 if (XferUploaders.ContainsKey(transactionID)) 139 if (XferUploaders.ContainsKey(transactionID))
168 { 140 {
169 AssetBase asset = XferUploaders[transactionID].GetAssetData(); 141 AssetBase asset = GetTransactionAsset(transactionID);
142
143 // Only legacy viewers use this, and they prefer CAPS, which
144 // we have, so this really never runs.
145 // Allow it, but only for "safe" types.
146 if ((InventoryType)item.InvType != InventoryType.Notecard &&
147 (InventoryType)item.InvType != InventoryType.LSL)
148 return;
149
170 if (asset != null) 150 if (asset != null)
171 { 151 {
172 m_log.DebugFormat( 152 asset.FullID = UUID.Random();
173 "[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}",
174 item.Name, part.Name, transactionID);
175
176 asset.Name = item.Name; 153 asset.Name = item.Name;
177 asset.Description = item.Description; 154 asset.Description = item.Description;
178 asset.Type = (sbyte)item.Type; 155 asset.Type = (sbyte)item.Type;
179 item.AssetID = asset.FullID; 156 item.AssetID = asset.FullID;
180 157
181 Manager.MyScene.AssetService.Store(asset); 158 m_Scene.AssetService.Store(asset);
182 159
183 if (part.Inventory.UpdateInventoryItem(item)) 160 part.Inventory.UpdateInventoryItem(item);
184 {
185 if ((InventoryType)item.InvType == InventoryType.Notecard)
186 remoteClient.SendAgentAlertMessage("Notecard saved", false);
187 else if ((InventoryType)item.InvType == InventoryType.LSL)
188 remoteClient.SendAgentAlertMessage("Script saved", false);
189 else
190 remoteClient.SendAgentAlertMessage("Item saved", false);
191
192 part.GetProperties(remoteClient);
193 }
194 } 161 }
195 } 162 }
196 } 163 }
197 164
198 165 public void RequestUpdateInventoryItem(IClientAPI remoteClient,
199 public void RequestUpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, 166 UUID transactionID, InventoryItemBase item)
200 InventoryItemBase item)
201 { 167 {
202 if (XferUploaders.ContainsKey(transactionID)) 168 if (XferUploaders.ContainsKey(transactionID))
203 { 169 {
204 UUID assetID = UUID.Combine(transactionID, remoteClient.SecureSessionId); 170 AssetBase asset = GetTransactionAsset(transactionID);
205 171
206 AssetBase asset = Manager.MyScene.AssetService.Get(assetID.ToString()); 172 if (asset != null)
207
208 if (asset == null)
209 {
210 asset = GetTransactionAsset(transactionID);
211 }
212
213 if (asset != null && asset.FullID == assetID)
214 { 173 {
215 // Assets never get updated, new ones get created
216 asset.FullID = UUID.Random(); 174 asset.FullID = UUID.Random();
217 asset.Name = item.Name; 175 asset.Name = item.Name;
218 asset.Description = item.Description; 176 asset.Description = item.Description;
219 asset.Type = (sbyte)item.AssetType; 177 asset.Type = (sbyte)item.AssetType;
220 item.AssetID = asset.FullID; 178 item.AssetID = asset.FullID;
221 179
222 Manager.MyScene.AssetService.Store(asset); 180 m_Scene.AssetService.Store(asset);
223 }
224 181
225 IInventoryService invService = Manager.MyScene.InventoryService; 182 IInventoryService invService = m_Scene.InventoryService;
226 invService.UpdateItem(item); 183 invService.UpdateItem(item);
184 }
227 } 185 }
228 } 186 }
229 } 187 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
index ae31050..82558de 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -34,22 +34,19 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
37using Mono.Addins;
37 38
38namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 39namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
39{ 40{
40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions 41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetTransactionModule")]
42 public class AssetTransactionModule : INonSharedRegionModule,
43 IAgentAssetTransactions
41 { 44 {
42// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45// private static readonly ILog m_log = LogManager.GetLogger(
46// MethodBase.GetCurrentMethod().DeclaringType);
43 47
44 private readonly Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); 48 protected Scene m_Scene;
45 private bool m_dumpAssetsToFile = false; 49 private bool m_dumpAssetsToFile = false;
46 private Scene m_scene = null;
47
48 [Obsolete]
49 public Scene MyScene
50 {
51 get{ return m_scene;}
52 }
53 50
54 /// <summary> 51 /// <summary>
55 /// Each agent has its own singleton collection of transactions 52 /// Each agent has its own singleton collection of transactions
@@ -57,33 +54,24 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
57 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = 54 private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
58 new Dictionary<UUID, AgentAssetTransactions>(); 55 new Dictionary<UUID, AgentAssetTransactions>();
59 56
57 #region IRegionModule Members
60 58
61 public AssetTransactionModule() 59 public void Initialise(IConfigSource config)
62 { 60 {
63 //m_log.Debug("creating AgentAssetTransactionModule");
64 } 61 }
65 62
66 #region IRegionModule Members 63 public void AddRegion(Scene scene)
67
68 public void Initialise(Scene scene, IConfigSource config)
69 { 64 {
70 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 65 m_Scene = scene;
71 { 66 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
72 // m_log.Debug("initialising AgentAssetTransactionModule"); 67 scene.EventManager.OnNewClient += NewClient;
73 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); 68 }
74 scene.RegisterModuleInterface<IAgentAssetTransactions>(this);
75
76 scene.EventManager.OnNewClient += NewClient;
77 }
78 69
79 // EVIL HACK! 70 public void RegionLoaded(Scene scene)
80 // This needs killing! 71 {
81 //
82 if (m_scene == null)
83 m_scene = scene;
84 } 72 }
85 73
86 public void PostInitialise() 74 public void RemoveRegion(Scene scene)
87 { 75 {
88 } 76 }
89 77
@@ -96,9 +84,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
96 get { return "AgentTransactionModule"; } 84 get { return "AgentTransactionModule"; }
97 } 85 }
98 86
99 public bool IsSharedModule 87 public Type ReplaceableInterface
100 { 88 {
101 get { return true; } 89 get { return typeof(IAgentAssetTransactions); }
102 } 90 }
103 91
104 #endregion 92 #endregion
@@ -111,8 +99,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
111 99
112 #region AgentAssetTransactions 100 #region AgentAssetTransactions
113 /// <summary> 101 /// <summary>
114 /// Get the collection of asset transactions for the given user. If one does not already exist, it 102 /// Get the collection of asset transactions for the given user.
115 /// is created. 103 /// If one does not already exist, it is created.
116 /// </summary> 104 /// </summary>
117 /// <param name="userID"></param> 105 /// <param name="userID"></param>
118 /// <returns></returns> 106 /// <returns></returns>
@@ -122,7 +110,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
122 { 110 {
123 if (!AgentTransactions.ContainsKey(userID)) 111 if (!AgentTransactions.ContainsKey(userID))
124 { 112 {
125 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this, m_dumpAssetsToFile); 113 AgentAssetTransactions transactions =
114 new AgentAssetTransactions(userID, m_Scene,
115 m_dumpAssetsToFile);
116
126 AgentTransactions.Add(userID, transactions); 117 AgentTransactions.Add(userID, transactions);
127 } 118 }
128 119
@@ -131,8 +122,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
131 } 122 }
132 123
133 /// <summary> 124 /// <summary>
134 /// Remove the given agent asset transactions. This should be called when a client is departing 125 /// Remove the given agent asset transactions. This should be called
135 /// from a scene (and hence won't be making any more transactions here). 126 /// when a client is departing from a scene (and hence won't be making
127 /// any more transactions here).
136 /// </summary> 128 /// </summary>
137 /// <param name="userID"></param> 129 /// <param name="userID"></param>
138 public void RemoveAgentAssetTransactions(UUID userID) 130 public void RemoveAgentAssetTransactions(UUID userID)
@@ -146,10 +138,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
146 } 138 }
147 139
148 /// <summary> 140 /// <summary>
149 /// Create an inventory item from data that has been received through a transaction. 141 /// Create an inventory item from data that has been received through
150 /// 142 /// a transaction.
151 /// This is called when new clothing or body parts are created. It may also be called in other 143 /// This is called when new clothing or body parts are created.
152 /// situations. 144 /// It may also be called in other situations.
153 /// </summary> 145 /// </summary>
154 /// <param name="remoteClient"></param> 146 /// <param name="remoteClient"></param>
155 /// <param name="transactionID"></param> 147 /// <param name="transactionID"></param>
@@ -161,61 +153,72 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
161 /// <param name="type"></param> 153 /// <param name="type"></param>
162 /// <param name="wearableType"></param> 154 /// <param name="wearableType"></param>
163 /// <param name="nextOwnerMask"></param> 155 /// <param name="nextOwnerMask"></param>
164 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, 156 public void HandleItemCreationFromTransaction(IClientAPI remoteClient,
165 uint callbackID, string description, string name, sbyte invType, 157 UUID transactionID, UUID folderID, uint callbackID,
166 sbyte type, byte wearableType, uint nextOwnerMask) 158 string description, string name, sbyte invType,
159 sbyte type, byte wearableType, uint nextOwnerMask)
167 { 160 {
168 // m_log.DebugFormat( 161// m_log.DebugFormat(
169 // "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name); 162// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
170 163
171 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 164 AgentAssetTransactions transactions =
165 GetUserTransactions(remoteClient.AgentId);
172 166
173 transactions.RequestCreateInventoryItem( 167 transactions.RequestCreateInventoryItem(remoteClient, transactionID,
174 remoteClient, transactionID, folderID, callbackID, description, 168 folderID, callbackID, description, name, invType, type,
175 name, invType, type, wearableType, nextOwnerMask); 169 wearableType, nextOwnerMask);
176 } 170 }
177 171
178 /// <summary> 172 /// <summary>
179 /// Update an inventory item with data that has been received through a transaction. 173 /// Update an inventory item with data that has been received through a
174 /// transaction.
180 /// 175 ///
181 /// This is called when clothing or body parts are updated (for instance, with new textures or 176 /// This is called when clothing or body parts are updated (for
182 /// colours). It may also be called in other situations. 177 /// instance, with new textures or colours). It may also be called in
178 /// other situations.
183 /// </summary> 179 /// </summary>
184 /// <param name="remoteClient"></param> 180 /// <param name="remoteClient"></param>
185 /// <param name="transactionID"></param> 181 /// <param name="transactionID"></param>
186 /// <param name="item"></param> 182 /// <param name="item"></param>
187 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, 183 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient,
188 InventoryItemBase item) 184 UUID transactionID, InventoryItemBase item)
189 { 185 {
190 // m_log.DebugFormat( 186// m_log.DebugFormat(
191 // "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}", 187// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
192 // item.Name); 188// item.Name);
193 189
194 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 190 AgentAssetTransactions transactions =
191 GetUserTransactions(remoteClient.AgentId);
195 192
196 transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item); 193 transactions.RequestUpdateInventoryItem(remoteClient,
194 transactionID, item);
197 } 195 }
198 196
199 /// <summary> 197 /// <summary>
200 /// Update a task inventory item with data that has been received through a transaction. 198 /// Update a task inventory item with data that has been received
199 /// through a transaction.
201 /// 200 ///
202 /// This is currently called when, for instance, a notecard in a prim is saved. The data is sent 201 /// This is currently called when, for instance, a notecard in a prim
203 /// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction 202 /// is saved. The data is sent up through a single AssetUploadRequest.
203 /// A subsequent UpdateTaskInventory then references the transaction
204 /// and comes through this method. 204 /// and comes through this method.
205 /// </summary> 205 /// </summary>
206 /// <param name="remoteClient"></param> 206 /// <param name="remoteClient"></param>
207 /// <param name="transactionID"></param> 207 /// <param name="transactionID"></param>
208 /// <param name="item"></param> 208 /// <param name="item"></param>
209 public void HandleTaskItemUpdateFromTransaction( 209 public void HandleTaskItemUpdateFromTransaction(IClientAPI remoteClient,
210 IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item) 210 SceneObjectPart part, UUID transactionID,
211 TaskInventoryItem item)
211 { 212 {
212 // m_log.DebugFormat( 213// m_log.DebugFormat(
213 // "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}", 214// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
214 // item.Name); 215// item.Name);
215 216
216 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 217 AgentAssetTransactions transactions =
218 GetUserTransactions(remoteClient.AgentId);
217 219
218 transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item); 220 transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
221 transactionID, item);
219 } 222 }
220 223
221 /// <summary> 224 /// <summary>
@@ -227,8 +230,9 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
227 /// <param name="type"></param> 230 /// <param name="type"></param>
228 /// <param name="data"></param></param> 231 /// <param name="data"></param></param>
229 /// <param name="tempFile"></param> 232 /// <param name="tempFile"></param>
230 public void HandleUDPUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, 233 public void HandleUDPUploadRequest(IClientAPI remoteClient,
231 byte[] data, bool storeLocal, bool tempFile) 234 UUID assetID, UUID transaction, sbyte type, byte[] data,
235 bool storeLocal, bool tempFile)
232 { 236 {
233// m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile); 237// m_log.Debug("HandleUDPUploadRequest - assetID: " + assetID.ToString() + " transaction: " + transaction.ToString() + " type: " + type.ToString() + " storelocal: " + storeLocal + " tempFile: " + tempFile);
234 238
@@ -251,27 +255,33 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
251 } 255 }
252 } 256 }
253 257
254 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 258 AgentAssetTransactions transactions =
259 GetUserTransactions(remoteClient.AgentId);
260
261 AssetXferUploader uploader =
262 transactions.RequestXferUploader(transaction);
255 263
256 AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
257 if (uploader != null) 264 if (uploader != null)
258 { 265 {
259 uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile); 266 uploader.Initialise(remoteClient, assetID, transaction, type,
267 data, storeLocal, tempFile);
260 } 268 }
261 } 269 }
262 270
263 /// <summary> 271 /// <summary>
264 /// Handle asset transfer data packets received in response to the asset upload request in 272 /// Handle asset transfer data packets received in response to the
265 /// HandleUDPUploadRequest() 273 /// asset upload request in HandleUDPUploadRequest()
266 /// </summary> 274 /// </summary>
267 /// <param name="remoteClient"></param> 275 /// <param name="remoteClient"></param>
268 /// <param name="xferID"></param> 276 /// <param name="xferID"></param>
269 /// <param name="packetID"></param> 277 /// <param name="packetID"></param>
270 /// <param name="data"></param> 278 /// <param name="data"></param>
271 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data) 279 public void HandleXfer(IClientAPI remoteClient, ulong xferID,
280 uint packetID, byte[] data)
272 { 281 {
273 //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!"); 282 //m_log.Debug("xferID: " + xferID + " packetID: " + packetID + " data!");
274 AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); 283 AgentAssetTransactions transactions =
284 GetUserTransactions(remoteClient.AgentId);
275 285
276 transactions.HandleXfer(xferID, packetID, data); 286 transactions.HandleXfer(xferID, packetID, data);
277 } 287 }
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
index 4609738..a7929ba 100644
--- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
+++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs
@@ -31,7 +31,7 @@ using System.Reflection;
31using log4net; 31using log4net;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction 37namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
@@ -50,17 +50,17 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
50 private bool m_finished = false; 50 private bool m_finished = false;
51 private string m_name = String.Empty; 51 private string m_name = String.Empty;
52 private bool m_storeLocal; 52 private bool m_storeLocal;
53 private AgentAssetTransactions m_userTransactions;
54 private uint nextPerm = 0; 53 private uint nextPerm = 0;
55 private IClientAPI ourClient; 54 private IClientAPI ourClient;
56 private UUID TransactionID = UUID.Zero; 55 private UUID TransactionID = UUID.Zero;
57 private sbyte type = 0; 56 private sbyte type = 0;
58 private byte wearableType = 0; 57 private byte wearableType = 0;
59 public ulong XferID; 58 public ulong XferID;
59 private Scene m_Scene;
60 60
61 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 61 public AssetXferUploader(Scene scene, bool dumpAssetToFile)
62 { 62 {
63 m_userTransactions = transactions; 63 m_Scene = scene;
64 m_dumpAssetToFile = dumpAssetToFile; 64 m_dumpAssetToFile = dumpAssetToFile;
65 } 65 }
66 66
@@ -108,11 +108,13 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
108 /// <param name="packetID"></param> 108 /// <param name="packetID"></param>
109 /// <param name="data"></param> 109 /// <param name="data"></param>
110 /// <returns>True if the transfer is complete, false otherwise</returns> 110 /// <returns>True if the transfer is complete, false otherwise</returns>
111 public bool Initialise(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, 111 public bool Initialise(IClientAPI remoteClient, UUID assetID,
112 bool storeLocal, bool tempFile) 112 UUID transaction, sbyte type, byte[] data, bool storeLocal,
113 bool tempFile)
113 { 114 {
114 ourClient = remoteClient; 115 ourClient = remoteClient;
115 m_asset = new AssetBase(assetID, "blank", type, remoteClient.AgentId.ToString()); 116 m_asset = new AssetBase(assetID, "blank", type,
117 remoteClient.AgentId.ToString());
116 m_asset.Data = data; 118 m_asset.Data = data;
117 m_asset.Description = "empty"; 119 m_asset.Description = "empty";
118 m_asset.Local = storeLocal; 120 m_asset.Local = storeLocal;
@@ -137,12 +139,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
137 protected void RequestStartXfer() 139 protected void RequestStartXfer()
138 { 140 {
139 XferID = Util.GetNextXferID(); 141 XferID = Util.GetNextXferID();
140 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID, 0, new byte[0]); 142 ourClient.SendXferRequest(XferID, m_asset.Type, m_asset.FullID,
143 0, new byte[0]);
141 } 144 }
142 145
143 protected void SendCompleteMessage() 146 protected void SendCompleteMessage()
144 { 147 {
145 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true, m_asset.FullID); 148 ourClient.SendAssetUploadCompleteMessage(m_asset.Type, true,
149 m_asset.FullID);
146 150
147 m_finished = true; 151 m_finished = true;
148 if (m_createItem) 152 if (m_createItem)
@@ -151,18 +155,20 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
151 } 155 }
152 else if (m_storeLocal) 156 else if (m_storeLocal)
153 { 157 {
154 m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); 158 m_Scene.AssetService.Store(m_asset);
155 } 159 }
156 160
157 m_log.DebugFormat( 161 m_log.DebugFormat(
158 "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}", m_asset.FullID, TransactionID); 162 "[ASSET TRANSACTIONS]: Uploaded asset {0} for transaction {1}",
163 m_asset.FullID, TransactionID);
159 164
160 if (m_dumpAssetToFile) 165 if (m_dumpAssetToFile)
161 { 166 {
162 DateTime now = DateTime.Now; 167 DateTime now = DateTime.Now;
163 string filename = 168 string filename =
164 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat", now.Year, now.Month, now.Day, 169 String.Format("{6}_{7}_{0:d2}{1:d2}{2:d2}_{3:d2}{4:d2}{5:d2}.dat",
165 now.Hour, now.Minute, now.Second, m_asset.Name, m_asset.Type); 170 now.Year, now.Month, now.Day, now.Hour, now.Minute,
171 now.Second, m_asset.Name, m_asset.Type);
166 SaveAssetToFile(filename, m_asset.Data); 172 SaveAssetToFile(filename, m_asset.Data);
167 } 173 }
168 } 174 }
@@ -181,9 +187,10 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
181 fs.Close(); 187 fs.Close();
182 } 188 }
183 189
184 public void RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, 190 public void RequestCreateInventoryItem(IClientAPI remoteClient,
185 uint callbackID, string description, string name, sbyte invType, 191 UUID transactionID, UUID folderID, uint callbackID,
186 sbyte type, byte wearableType, uint nextOwnerMask) 192 string description, string name, sbyte invType,
193 sbyte type, byte wearableType, uint nextOwnerMask)
187 { 194 {
188 if (TransactionID == transactionID) 195 if (TransactionID == transactionID)
189 { 196 {
@@ -212,7 +219,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
212 219
213 private void DoCreateItem(uint callbackID) 220 private void DoCreateItem(uint callbackID)
214 { 221 {
215 m_userTransactions.Manager.MyScene.AssetService.Store(m_asset); 222 m_Scene.AssetService.Store(m_asset);
216 223
217 InventoryItemBase item = new InventoryItemBase(); 224 InventoryItemBase item = new InventoryItemBase();
218 item.Owner = ourClient.AgentId; 225 item.Owner = ourClient.AgentId;
@@ -232,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
232 item.Flags = (uint) wearableType; 239 item.Flags = (uint) wearableType;
233 item.CreationDate = Util.UnixTimeSinceEpoch(); 240 item.CreationDate = Util.UnixTimeSinceEpoch();
234 241
235 if (m_userTransactions.Manager.MyScene.AddInventoryItem(item)) 242 if (m_Scene.AddInventoryItem(item))
236 ourClient.SendInventoryItemCreateUpdate(item, callbackID); 243 ourClient.SendInventoryItemCreateUpdate(item, callbackID);
237 else 244 else
238 ourClient.SendAlertMessage("Unable to create inventory item"); 245 ourClient.SendAlertMessage("Unable to create inventory item");
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 0df4585..7d6d191 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -115,8 +115,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
115 115
116 #endregion 116 #endregion
117 117
118 /// <summary>
119 /// Check for the existence of the baked texture assets. Request a rebake
120 /// unless checkonly is true.
121 /// </summary>
122 /// <param name="client"></param>
123 /// <param name="checkonly"></param>
118 public bool ValidateBakedTextureCache(IClientAPI client) 124 public bool ValidateBakedTextureCache(IClientAPI client)
119 { 125 {
126 return ValidateBakedTextureCache(client, true);
127 }
128
129 private bool ValidateBakedTextureCache(IClientAPI client, bool checkonly)
130 {
120 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 131 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
121 if (sp == null) 132 if (sp == null)
122 { 133 {
@@ -131,15 +142,33 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
131 { 142 {
132 int idx = AvatarAppearance.BAKE_INDICES[i]; 143 int idx = AvatarAppearance.BAKE_INDICES[i];
133 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; 144 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
134 if (face == null || face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) 145
146 // if there is no texture entry, skip it
147 if (face == null)
135 continue; 148 continue;
136 149
150 // if the texture is one of the "defaults" then skip it
151 // this should probably be more intelligent (skirt texture doesnt matter
152 // if the avatar isnt wearing a skirt) but if any of the main baked
153 // textures is default then the rest should be as well
154 if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
155 continue;
156
137 defonly = false; // found a non-default texture reference 157 defonly = false; // found a non-default texture reference
138 158
139 if (! CheckBakedTextureAsset(client,face.TextureID,idx)) 159 if (! CheckBakedTextureAsset(client,face.TextureID,idx))
140 return false; 160 {
161 // the asset didn't exist if we are only checking, then we found a bad
162 // one and we're done otherwise, ask for a rebake
163 if (checkonly) return false;
164
165 m_log.InfoFormat("[AVFACTORY] missing baked texture {0}, request rebake",face.TextureID);
166 client.SendRebakeAvatarTextures(face.TextureID);
167 }
141 } 168 }
142 169
170 m_log.InfoFormat("[AVFACTORY]: complete texture check for {0}",client.AgentId);
171
143 // If we only found default textures, then the appearance is not cached 172 // If we only found default textures, then the appearance is not cached
144 return (defonly ? false : true); 173 return (defonly ? false : true);
145 } 174 }
@@ -158,61 +187,43 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
158 return; 187 return;
159 } 188 }
160 189
161 // m_log.WarnFormat("[AVFACTORY]: Start SetAppearance for {0}",client.AgentId); 190 m_log.InfoFormat("[AVFACTORY]: start SetAppearance for {0}",client.AgentId);
162 191
192 // TODO: This is probably not necessary any longer, just assume the
193 // textureEntry set implies that the appearance transaction is complete
163 bool changed = false; 194 bool changed = false;
164 195
165 // Process the texture entry transactionally, this doesn't guarantee that Appearance is 196 // Process the texture entry transactionally, this doesn't guarantee that Appearance is
166 // going to be handled correctly but it does serialize the updates to the appearance 197 // going to be handled correctly but it does serialize the updates to the appearance
167 lock (m_setAppearanceLock) 198 lock (m_setAppearanceLock)
168 { 199 {
169 if (textureEntry != null)
170 {
171 changed = sp.Appearance.SetTextureEntries(textureEntry);
172
173 // m_log.WarnFormat("[AVFACTORY]: Prepare to check textures for {0}",client.AgentId);
174
175 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
176 {
177 int idx = AvatarAppearance.BAKE_INDICES[i];
178 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
179 if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
180 Util.FireAndForget(delegate(object o) {
181 if (! CheckBakedTextureAsset(client,face.TextureID,idx))
182 client.SendRebakeAvatarTextures(face.TextureID);
183 });
184 }
185
186 // m_log.WarnFormat("[AVFACTORY]: Complete texture check for {0}",client.AgentId);
187 }
188
189 // Process the visual params, this may change height as well 200 // Process the visual params, this may change height as well
190 if (visualParams != null) 201 if (visualParams != null)
191 { 202 {
192 if (sp.Appearance.SetVisualParams(visualParams)) 203 changed = sp.Appearance.SetVisualParams(visualParams);
193 { 204 if (sp.Appearance.AvatarHeight > 0)
194 changed = true; 205 sp.SetHeight(sp.Appearance.AvatarHeight);
195 if (sp.Appearance.AvatarHeight > 0)
196 sp.SetHeight(sp.Appearance.AvatarHeight);
197 }
198 } 206 }
199 207
200 // Send the appearance back to the avatar, not clear that this is needed 208 // Process the baked texture array
201 sp.ControllingClient.SendAvatarDataImmediate(sp); 209 if (textureEntry != null)
202 // AvatarAppearance avp = sp.Appearance; 210 {
203 // sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes()); 211 changed = sp.Appearance.SetTextureEntries(textureEntry) || changed;
212
213 m_log.InfoFormat("[AVFACTORY]: received texture update for {0}",client.AgentId);
214 Util.FireAndForget(delegate(object o) { ValidateBakedTextureCache(client,false); });
204 215
205 } 216 // This appears to be set only in the final stage of the appearance
206 217 // update transaction. In theory, we should be able to do an immediate
218 // appearance send and save here.
207 219
208 // If something changed in the appearance then queue an appearance save 220 QueueAppearanceSave(client.AgentId);
209 if (changed) 221 QueueAppearanceSend(client.AgentId);
210 QueueAppearanceSave(client.AgentId); 222 }
211 223
212 // And always queue up an appearance update to send out 224 }
213 QueueAppearanceSend(client.AgentId);
214 225
215 // m_log.WarnFormat("[AVFACTORY]: Complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString()); 226 // m_log.WarnFormat("[AVFACTORY]: complete SetAppearance for {0}:\n{1}",client.AgentId,sp.Appearance.ToString());
216 } 227 }
217 228
218 /// <summary> 229 /// <summary>
@@ -235,6 +246,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
235 246
236 #region UpdateAppearanceTimer 247 #region UpdateAppearanceTimer
237 248
249 /// <summary>
250 /// Queue up a request to send appearance, makes it possible to
251 /// accumulate changes without sending out each one separately.
252 /// </summary>
238 public void QueueAppearanceSend(UUID agentid) 253 public void QueueAppearanceSend(UUID agentid)
239 { 254 {
240 // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); 255 // m_log.WarnFormat("[AVFACTORY]: Queue appearance send for {0}", agentid);
@@ -274,21 +289,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
274 289
275 // Send the appearance to everyone in the scene 290 // Send the appearance to everyone in the scene
276 sp.SendAppearanceToAllOtherAgents(); 291 sp.SendAppearanceToAllOtherAgents();
277 // sp.ControllingClient.SendAvatarDataImmediate(sp);
278
279 // Send the appearance back to the avatar
280 // AvatarAppearance avp = sp.Appearance;
281 // sp.ControllingClient.SendAppearance(avp.Owner, avp.VisualParams, avp.Texture.GetBytes());
282 292
283/* 293 // Send animations back to the avatar as well
284// this needs to be fixed, the flag should be on scene presence not the region module 294 sp.Animator.SendAnimPack();
285 // Start the animations if necessary
286 if (!m_startAnimationSet)
287 {
288 sp.Animator.UpdateMovementAnimations();
289 m_startAnimationSet = true;
290 }
291*/
292 } 295 }
293 296
294 private void HandleAppearanceSave(UUID agentid) 297 private void HandleAppearanceSave(UUID agentid)
@@ -374,8 +377,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
374 377
375 // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId); 378 // m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}", client.AgentId);
376 379
377 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false); 380 // we need to clean out the existing textures
381 sp.Appearance.ResetAppearance();
378 382
383 // operate on a copy of the appearance so we don't have to lock anything
384 AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance, false);
385
379 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) 386 foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
380 { 387 {
381 if (wear.Type < AvatarWearable.MAX_WEARABLES) 388 if (wear.Type < AvatarWearable.MAX_WEARABLES)
@@ -388,9 +395,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
388 SetAppearanceAssets(sp.UUID, ref avatAppearance); 395 SetAppearanceAssets(sp.UUID, ref avatAppearance);
389 396
390 // could get fancier with the locks here, but in the spirit of "last write wins" 397 // could get fancier with the locks here, but in the spirit of "last write wins"
391 // this should work correctly 398 // this should work correctly, also, we don't need to send the appearance here
399 // since the "iswearing" will trigger a new set of visual param and baked texture changes
400 // when those complete, the new appearance will be sent
392 sp.Appearance = avatAppearance; 401 sp.Appearance = avatAppearance;
393 m_scene.AvatarService.SetAppearance(client.AgentId, sp.Appearance); 402 QueueAppearanceSave(client.AgentId);
394 } 403 }
395 404
396 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance) 405 private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 046b05f..acf2c3e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -37,12 +37,11 @@ using System.Xml.Linq;
37using log4net; 37using log4net;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Osp;
42using OpenSim.Framework.Serialization; 40using OpenSim.Framework.Serialization;
43using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
44using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
45using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
47 46
48namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 47namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
@@ -398,20 +397,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
398 // Don't use the item ID that's in the file 397 // Don't use the item ID that's in the file
399 item.ID = UUID.Random(); 398 item.ID = UUID.Random();
400 399
401 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
402 if (UUID.Zero != ospResolvedId) 401 if (UUID.Zero != ospResolvedId) // The user exists in this grid
403 { 402 {
404 item.CreatorIdAsUuid = ospResolvedId; 403 item.CreatorIdAsUuid = ospResolvedId;
405 404
406 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
407 // database). Instead, replace with the UUID that we found. 406 // database). Instead, replace with the UUID that we found.
408 item.CreatorId = ospResolvedId.ToString(); 407 item.CreatorId = ospResolvedId.ToString();
408
409 item.CreatorData = string.Empty;
409 } 410 }
410 else 411 else if (item.CreatorData == null || item.CreatorData == String.Empty)
411 { 412 {
412 item.CreatorIdAsUuid = m_userInfo.PrincipalID; 413 item.CreatorIdAsUuid = m_userInfo.PrincipalID;
413 } 414 }
414 415
415 item.Owner = m_userInfo.PrincipalID; 416 item.Owner = m_userInfo.PrincipalID;
416 417
417 // Reset folder ID to the one in which we want to load it 418 // Reset folder ID to the one in which we want to load it
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index d81703a..cab341d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -36,8 +36,6 @@ using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Serialization; 37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External; 38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Osp;
41using OpenSim.Region.CoreModules.World.Archiver; 39using OpenSim.Region.CoreModules.World.Archiver;
42using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
43using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -139,20 +137,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
139 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); 137 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
140 } 138 }
141 139
142 protected void SaveInvItem(InventoryItemBase inventoryItem, string path) 140 protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService)
143 { 141 {
144 string filename = path + CreateArchiveItemName(inventoryItem); 142 string filename = path + CreateArchiveItemName(inventoryItem);
145 143
146 // Record the creator of this item for user record purposes (which might go away soon) 144 // Record the creator of this item for user record purposes (which might go away soon)
147 m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; 145 m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
148 146
149 InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); 147 string serialization = UserInventoryItemSerializer.Serialize(inventoryItem, options, userAccountService);
150 saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService);
151
152 string serialization = UserInventoryItemSerializer.Serialize(saveItem);
153 m_archiveWriter.WriteFile(filename, serialization); 148 m_archiveWriter.WriteFile(filename, serialization);
154 149
155 m_assetGatherer.GatherAssetUuids(saveItem.AssetID, (AssetType)saveItem.AssetType, m_assetUuids); 150 m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids);
156 } 151 }
157 152
158 /// <summary> 153 /// <summary>
@@ -161,7 +156,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
161 /// <param name="inventoryFolder">The inventory folder to save</param> 156 /// <param name="inventoryFolder">The inventory folder to save</param>
162 /// <param name="path">The path to which the folder should be saved</param> 157 /// <param name="path">The path to which the folder should be saved</param>
163 /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> 158 /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param>
164 protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself) 159 protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, Dictionary<string, object> options, IUserAccountService userAccountService)
165 { 160 {
166 if (saveThisFolderItself) 161 if (saveThisFolderItself)
167 { 162 {
@@ -176,19 +171,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
176 171
177 foreach (InventoryFolderBase childFolder in contents.Folders) 172 foreach (InventoryFolderBase childFolder in contents.Folders)
178 { 173 {
179 SaveInvFolder(childFolder, path, true); 174 SaveInvFolder(childFolder, path, true, options, userAccountService);
180 } 175 }
181 176
182 foreach (InventoryItemBase item in contents.Items) 177 foreach (InventoryItemBase item in contents.Items)
183 { 178 {
184 SaveInvItem(item, path); 179 SaveInvItem(item, path, options, userAccountService);
185 } 180 }
186 } 181 }
187 182
188 /// <summary> 183 /// <summary>
189 /// Execute the inventory write request 184 /// Execute the inventory write request
190 /// </summary> 185 /// </summary>
191 public void Execute() 186 public void Execute(Dictionary<string, object> options, IUserAccountService userAccountService)
192 { 187 {
193 try 188 try
194 { 189 {
@@ -266,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
266 m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); 261 m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath);
267 262
268 //recurse through all dirs getting dirs and files 263 //recurse through all dirs getting dirs and files
269 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly); 264 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService);
270 } 265 }
271 else if (inventoryItem != null) 266 else if (inventoryItem != null)
272 { 267 {
@@ -274,14 +269,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
274 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", 269 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
275 inventoryItem.Name, inventoryItem.ID, m_invPath); 270 inventoryItem.Name, inventoryItem.ID, m_invPath);
276 271
277 SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); 272 SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService);
278 } 273 }
279 274
280 // Don't put all this profile information into the archive right now. 275 // Don't put all this profile information into the archive right now.
281 //SaveUsers(); 276 //SaveUsers();
282 277
283 new AssetsRequest( 278 new AssetsRequest(
284 new AssetsArchiver(m_archiveWriter), m_assetUuids, m_scene.AssetService, ReceivedAllAssets).Execute(); 279 new AssetsArchiver(m_archiveWriter),
280 m_assetUuids, m_scene.AssetService,
281 m_scene.UserAccountService, m_scene.RegionInfo.ScopeID,
282 options, ReceivedAllAssets).Execute();
285 } 283 }
286 catch (Exception) 284 catch (Exception)
287 { 285 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 2eaca49..b33c2b1 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -75,6 +75,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 75 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
76 private Scene m_aScene; 76 private Scene m_aScene;
77 77
78 private IUserAccountService m_UserAccountService;
79 protected IUserAccountService UserAccountService
80 {
81 get
82 {
83 if (m_UserAccountService == null)
84 // What a strange thing to do...
85 foreach (Scene s in m_scenes.Values)
86 {
87 m_UserAccountService = s.RequestModuleInterface<IUserAccountService>();
88 break;
89 }
90
91 return m_UserAccountService;
92 }
93 }
94
95
78 public InventoryArchiverModule() {} 96 public InventoryArchiverModule() {}
79 97
80 public InventoryArchiverModule(bool disablePresenceChecks) 98 public InventoryArchiverModule(bool disablePresenceChecks)
@@ -106,11 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
106 124
107 scene.AddCommand( 125 scene.AddCommand(
108 this, "save iar", 126 this, "save iar",
109 "save iar <first> <last> <inventory path> <password> [<IAR path>]", 127 "save iar <first> <last> <inventory path> <password> [--p|-profile=<url>] [<IAR path>]",
110 "Save user inventory archive (IAR).", 128 "Save user inventory archive (IAR).",
111 "<first> is the user's first name." + Environment.NewLine 129 "<first> is the user's first name." + Environment.NewLine
112 + "<last> is the user's last name." + Environment.NewLine 130 + "<last> is the user's last name." + Environment.NewLine
113 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 131 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
132 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
114 + "<IAR path> is the filesystem path at which to save the IAR." 133 + "<IAR path> is the filesystem path at which to save the IAR."
115 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 134 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
116 HandleSaveInvConsoleCommand); 135 HandleSaveInvConsoleCommand);
@@ -157,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
157 { 176 {
158 try 177 try
159 { 178 {
160 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); 179 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(options, UserAccountService);
161 } 180 }
162 catch (EntryPointNotFoundException e) 181 catch (EntryPointNotFoundException e)
163 { 182 {
@@ -197,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
197 { 216 {
198 try 217 try
199 { 218 {
200 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); 219 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(options, UserAccountService);
201 } 220 }
202 catch (EntryPointNotFoundException e) 221 catch (EntryPointNotFoundException e)
203 { 222 {
@@ -235,14 +254,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
235 if (m_scenes.Count > 0) 254 if (m_scenes.Count > 0)
236 { 255 {
237 UserAccount userInfo = GetUserInfo(firstName, lastName, pass); 256 UserAccount userInfo = GetUserInfo(firstName, lastName, pass);
238 257
239 if (userInfo != null) 258 if (userInfo != null)
240 { 259 {
241 if (CheckPresence(userInfo.PrincipalID)) 260 if (CheckPresence(userInfo.PrincipalID))
242 { 261 {
262
243 InventoryArchiveReadRequest request; 263 InventoryArchiveReadRequest request;
244 bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); 264 bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false);
245 265
246 try 266 try
247 { 267 {
248 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); 268 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge);
@@ -256,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
256 276
257 return false; 277 return false;
258 } 278 }
259 279
260 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 280 UpdateClientWithLoadedNodes(userInfo, request.Execute());
261 281
262 return true; 282 return true;
@@ -268,6 +288,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
268 userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); 288 userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID);
269 } 289 }
270 } 290 }
291 else
292 m_log.ErrorFormat("[INVENTORY ARCHIVER]: User {0} {1} not found",
293 firstName, lastName);
271 } 294 }
272 295
273 return false; 296 return false;
@@ -368,10 +391,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
368 protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) 391 protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
369 { 392 {
370 Guid id = Guid.NewGuid(); 393 Guid id = Guid.NewGuid();
371 394
395 Dictionary<string, object> options = new Dictionary<string, object>();
396
397 OptionSet ops = new OptionSet();
398 //ops.Add("v|version=", delegate(string v) { options["version"] = v; });
399 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
400
401 List<string> mainParams = ops.Parse(cmdparams);
402
372 try 403 try
373 { 404 {
374 if (cmdparams.Length < 6) 405 if (mainParams.Count < 6)
375 { 406 {
376 m_log.Error( 407 m_log.Error(
377 "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); 408 "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]");
@@ -379,18 +410,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
379 } 410 }
380 411
381 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); 412 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
382 413 if (options.ContainsKey("profile"))
383 string firstName = cmdparams[2]; 414 m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -profile option if you want to produce a compatible IAR");
384 string lastName = cmdparams[3]; 415
385 string invPath = cmdparams[4]; 416 string firstName = mainParams[2];
386 string pass = cmdparams[5]; 417 string lastName = mainParams[3];
387 string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); 418 string invPath = mainParams[4];
419 string pass = mainParams[5];
420 string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
388 421
389 m_log.InfoFormat( 422 m_log.InfoFormat(
390 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", 423 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
391 savePath, invPath, firstName, lastName); 424 savePath, invPath, firstName, lastName);
392 425
393 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>()); 426 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
394 } 427 }
395 catch (InventoryArchiverException e) 428 catch (InventoryArchiverException e)
396 { 429 {
@@ -518,5 +551,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
518 551
519 return false; 552 return false;
520 } 553 }
554
521 } 555 }
522} 556}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 938886b2..2747e15 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -38,7 +38,6 @@ using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 39using OpenSim.Framework.Serialization.External;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Osp;
42using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 41using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
43using OpenSim.Region.CoreModules.World.Serialiser; 42using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
@@ -96,14 +95,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
96 item1.Name = m_item1Name; 95 item1.Name = m_item1Name;
97 item1.AssetID = UUID.Random(); 96 item1.AssetID = UUID.Random();
98 item1.GroupID = UUID.Random(); 97 item1.GroupID = UUID.Random();
99 item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); 98 //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName);
100 //item1.CreatorId = userUuid.ToString(); 99 //item1.CreatorId = userUuid.ToString();
101 //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; 100 item1.CreatorId = m_ua2.PrincipalID.ToString();
102 item1.Owner = UUID.Zero; 101 item1.Owner = UUID.Zero;
103 102
103 Scene scene = SceneSetupHelpers.SetupScene("Inventory");
104 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
105
104 string item1FileName 106 string item1FileName
105 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 107 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
106 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 108 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService));
107 tar.Close(); 109 tar.Close();
108 m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); 110 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
109 } 111 }
@@ -386,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
386 Scene scene = SceneSetupHelpers.SetupScene("inventory"); 388 Scene scene = SceneSetupHelpers.SetupScene("inventory");
387 389
388 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); 390 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
389 391
390 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); 392 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood");
391 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); 393 UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire");
392 394
@@ -551,7 +553,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
551 553
552 string item1FileName 554 string item1FileName
553 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 555 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
554 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 556 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
555 tar.Close(); 557 tar.Close();
556 558
557 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 559 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 56aefa5..47548c7 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -876,8 +876,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
876 } 876 }
877 877
878 agent.MakeChildAgent(); 878 agent.MakeChildAgent();
879
879 // now we have a child agent in this region. Request all interesting data about other (root) agents 880 // now we have a child agent in this region. Request all interesting data about other (root) agents
880 agent.SendInitialFullUpdateToAllClients(); 881 agent.SendOtherAgentsAvatarDataToMe();
882 agent.SendOtherAgentsAppearanceToMe();
881 883
882 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); 884 CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
883 885
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
index ccb892e..81b65c5 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -27,8 +27,11 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Threading; 32using System.Threading;
33using System.Xml;
34
32using log4net; 35using log4net;
33using OpenMetaverse; 36using OpenMetaverse;
34using OpenSim.Framework; 37using OpenSim.Framework;
@@ -52,14 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); 55// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53 56
54 private Scene m_scene; 57 private Scene m_scene;
58 private string m_ProfileServerURI;
55 59
56 #endregion 60 #endregion
57 61
58 #region Constructor 62 #region Constructor
59 63
60 public HGAssetMapper(Scene scene) 64 public HGAssetMapper(Scene scene, string profileURL)
61 { 65 {
62 m_scene = scene; 66 m_scene = scene;
67 m_ProfileServerURI = profileURL;
63 } 68 }
64 69
65 #endregion 70 #endregion
@@ -95,16 +100,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
95 try 100 try
96 { 101 {
97 asset1.ID = url + "/" + asset.ID; 102 asset1.ID = url + "/" + asset.ID;
98// UUID temp = UUID.Zero;
99 // TODO: if the creator is local, stick this grid's URL in front
100 //if (UUID.TryParse(asset.Metadata.CreatorID, out temp))
101 // asset1.Metadata.CreatorID = ??? + "/" + asset.Metadata.CreatorID;
102 } 103 }
103 catch 104 catch
104 { 105 {
105 m_log.Warn("[HG ASSET MAPPER]: Oops."); 106 m_log.Warn("[HG ASSET MAPPER]: Oops.");
106 } 107 }
107 108
109 AdjustIdentifiers(asset1.Metadata);
110 if (asset1.Metadata.Type == (sbyte)AssetType.Object)
111 asset1.Data = AdjustIdentifiers(asset.Data);
112 else
113 asset1.Data = asset.Data;
114
108 m_scene.AssetService.Store(asset1); 115 m_scene.AssetService.Store(asset1);
109 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); 116 m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
110 } 117 }
@@ -118,7 +125,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
118 125
119 private void Copy(AssetBase from, AssetBase to) 126 private void Copy(AssetBase from, AssetBase to)
120 { 127 {
121 to.Data = from.Data; 128 //to.Data = from.Data; // don't copy this, it's copied elsewhere
122 to.Description = from.Description; 129 to.Description = from.Description;
123 to.FullID = from.FullID; 130 to.FullID = from.FullID;
124 to.ID = from.ID; 131 to.ID = from.ID;
@@ -129,6 +136,70 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
129 136
130 } 137 }
131 138
139 private void AdjustIdentifiers(AssetMetadata meta)
140 {
141 if (meta.CreatorID != null && meta.CreatorID != string.Empty)
142 {
143 UUID uuid = UUID.Zero;
144 UUID.TryParse(meta.CreatorID, out uuid);
145 UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
146 if (creator != null)
147 meta.CreatorID = m_ProfileServerURI + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
148 }
149 }
150
151 protected byte[] AdjustIdentifiers(byte[] data)
152 {
153 string xml = Utils.BytesToString(data);
154 return Utils.StringToBytes(RewriteSOP(xml));
155 }
156
157 protected string RewriteSOP(string xml)
158 {
159 XmlDocument doc = new XmlDocument();
160 doc.LoadXml(xml);
161 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
162
163 foreach (XmlNode sop in sops)
164 {
165 UserAccount creator = null;
166 bool hasCreatorData = false;
167 XmlNodeList nodes = sop.ChildNodes;
168 foreach (XmlNode node in nodes)
169 {
170 if (node.Name == "CreatorID")
171 {
172 UUID uuid = UUID.Zero;
173 UUID.TryParse(node.InnerText, out uuid);
174 creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
175 }
176 if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
177 hasCreatorData = true;
178
179 //if (node.Name == "OwnerID")
180 //{
181 // UserAccount owner = GetUser(node.InnerText);
182 // if (owner != null)
183 // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
184 //}
185 }
186
187 if (!hasCreatorData && creator != null)
188 {
189 XmlElement creatorData = doc.CreateElement("CreatorData");
190 creatorData.InnerText = m_ProfileServerURI + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
191 sop.AppendChild(creatorData);
192 }
193 }
194
195 using (StringWriter wr = new StringWriter())
196 {
197 doc.Save(wr);
198 return wr.ToString();
199 }
200
201 }
202
132 // TODO: unused 203 // TODO: unused
133 // private void Dump(Dictionary<UUID, bool> lst) 204 // private void Dump(Dictionary<UUID, bool> lst)
134 // { 205 // {
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 125a397..34b8114 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
54 get { return m_assMapper; } 54 get { return m_assMapper; }
55 } 55 }
56 56
57 private string m_ProfileServerURI;
58
57// private bool m_Initialized = false; 59// private bool m_Initialized = false;
58 60
59 #region INonSharedRegionModule 61 #region INonSharedRegionModule
@@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
73 { 75 {
74 m_Enabled = true; 76 m_Enabled = true;
75 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); 77 m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name);
78
79 IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"];
80 if (thisModuleConfig != null)
81 m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty);
82 else
83 m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!");
76 } 84 }
77 } 85 }
78 } 86 }
@@ -83,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
83 return; 91 return;
84 92
85 base.AddRegion(scene); 93 base.AddRegion(scene);
86 m_assMapper = new HGAssetMapper(scene); 94 m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI);
87 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; 95 scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
88 96
89 } 97 }
@@ -97,7 +105,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
97 string userAssetServer = string.Empty; 105 string userAssetServer = string.Empty;
98 if (IsForeignUser(avatarID, out userAssetServer)) 106 if (IsForeignUser(avatarID, out userAssetServer))
99 { 107 {
100 m_assMapper.Post(assetID, avatarID, userAssetServer); 108 Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); });
101 } 109 }
102 } 110 }
103 111
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 67732ff..1ebccd1 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -53,6 +53,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
53 53
54 protected bool m_Enabled = false; 54 protected bool m_Enabled = false;
55 protected Scene m_Scene; 55 protected Scene m_Scene;
56 protected IUserManagement m_UserManagement;
57 protected IUserManagement UserManagementModule
58 {
59 get
60 {
61 if (m_UserManagement == null)
62 m_UserManagement = m_Scene.RequestModuleInterface<IUserManagement>();
63 return m_UserManagement;
64 }
65 }
66
56 67
57 #region INonSharedRegionModule 68 #region INonSharedRegionModule
58 69
@@ -542,6 +553,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
542 SceneObjectGroup group 553 SceneObjectGroup group
543 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); 554 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
544 555
556 Util.FireAndForget(delegate { AddUserData(group); });
557
545 group.RootPart.FromFolderID = item.Folder; 558 group.RootPart.FromFolderID = item.Folder;
546 559
547 // If it's rezzed in world, select it. Much easier to 560 // If it's rezzed in world, select it. Much easier to
@@ -699,6 +712,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
699 return null; 712 return null;
700 } 713 }
701 714
715 protected void AddUserData(SceneObjectGroup sog)
716 {
717 UserManagementModule.AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData);
718 foreach (SceneObjectPart sop in sog.Parts)
719 UserManagementModule.AddUser(sop.CreatorID, sop.CreatorData);
720 }
721
702 public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) 722 public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
703 { 723 {
704 } 724 }
@@ -779,9 +799,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
779 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) 799 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
780 { 800 {
781 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); 801 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>();
782 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID); 802 InventoryItemBase item = new InventoryItemBase(itemID, agentID);
783 assetRequestItem = invService.GetItem(assetRequestItem); 803 item = invService.GetItem(item);
784 return assetRequestItem; 804
805 if (item.CreatorData != null && item.CreatorData != string.Empty)
806 UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData);
807
808 return item;
785 } 809 }
786 810
787 #endregion 811 #endregion
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 0d94baa..bf84100 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -275,6 +275,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
275 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); 275 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
276 } 276 }
277 277
278 public void AddUser(UUID uuid, string first, string last, string profileURL)
279 {
280 AddUser(uuid, profileURL + ";" + first + " " + last);
281 }
282
278 //public void AddUser(UUID uuid, string userData) 283 //public void AddUser(UUID uuid, string userData)
279 //{ 284 //{
280 // if (m_UserCache.ContainsKey(uuid)) 285 // if (m_UserCache.ContainsKey(uuid))
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
index 2324380..e25700d 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs
@@ -91,9 +91,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset
91 { 91 {
92 m_Registered = true; 92 m_Registered = true;
93 93
94 m_log.Info("[RegionAssetService]: Starting..."); 94 m_log.Info("[HGAssetService]: Starting...");
95 95
96 Object[] args = new Object[] { m_Config, MainServer.Instance, string.Empty }; 96
97 Object[] args = new Object[] { m_Config, MainServer.Instance, "HGAssetService" };
97 98
98 ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); 99 ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args);
99 } 100 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index b987b5a..0699407 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -190,7 +190,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
190 190
191 new AssetsRequest( 191 new AssetsRequest(
192 new AssetsArchiver(archiveWriter), assetUuids, 192 new AssetsArchiver(archiveWriter), assetUuids,
193 m_scene.AssetService, awre.ReceivedAllAssets).Execute(); 193 m_scene.AssetService, m_scene.UserAccountService,
194 m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute();
194 } 195 }
195 catch (Exception) 196 catch (Exception)
196 { 197 {
@@ -238,10 +239,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
238 } 239 }
239 240
240 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); 241 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
241 if (majorVersion == 1) 242 //if (majorVersion == 1)
242 { 243 //{
243 m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); 244 // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
244 } 245 //}
245 246
246 StringWriter sw = new StringWriter(); 247 StringWriter sw = new StringWriter();
247 XmlTextWriter xtw = new XmlTextWriter(sw); 248 XmlTextWriter xtw = new XmlTextWriter(sw);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index d4a09b4..5da1656 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -34,6 +34,7 @@ using log4net;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Serialization; 36using OpenSim.Framework.Serialization;
37using OpenSim.Framework.Serialization.External;
37using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
38 39
39namespace OpenSim.Region.CoreModules.World.Archiver 40namespace OpenSim.Region.CoreModules.World.Archiver
@@ -100,17 +101,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
100 /// Asset service used to request the assets 101 /// Asset service used to request the assets
101 /// </value> 102 /// </value>
102 protected IAssetService m_assetService; 103 protected IAssetService m_assetService;
104 protected IUserAccountService m_userAccountService;
105 protected UUID m_scopeID; // the grid ID
103 106
104 protected AssetsArchiver m_assetsArchiver; 107 protected AssetsArchiver m_assetsArchiver;
105 108
109 protected Dictionary<string, object> m_options;
110
106 protected internal AssetsRequest( 111 protected internal AssetsRequest(
107 AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids, 112 AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids,
108 IAssetService assetService, AssetsRequestCallback assetsRequestCallback) 113 IAssetService assetService, IUserAccountService userService,
114 UUID scope, Dictionary<string, object> options,
115 AssetsRequestCallback assetsRequestCallback)
109 { 116 {
110 m_assetsArchiver = assetsArchiver; 117 m_assetsArchiver = assetsArchiver;
111 m_uuids = uuids; 118 m_uuids = uuids;
112 m_assetsRequestCallback = assetsRequestCallback; 119 m_assetsRequestCallback = assetsRequestCallback;
113 m_assetService = assetService; 120 m_assetService = assetService;
121 m_userAccountService = userService;
122 m_scopeID = scope;
123 m_options = options;
114 m_repliesRequired = uuids.Count; 124 m_repliesRequired = uuids.Count;
115 125
116 m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT); 126 m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT);
@@ -241,7 +251,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
241 { 251 {
242// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id); 252// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
243 m_foundAssetUuids.Add(asset.FullID); 253 m_foundAssetUuids.Add(asset.FullID);
244 m_assetsArchiver.WriteAsset(asset); 254
255 m_assetsArchiver.WriteAsset(PostProcess(asset));
245 } 256 }
246 else 257 else
247 { 258 {
@@ -288,5 +299,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
288 "[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e); 299 "[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e);
289 } 300 }
290 } 301 }
302
303 protected AssetBase PostProcess(AssetBase asset)
304 {
305 if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("profile"))
306 {
307 //m_log.DebugFormat("[ARCHIVER]: Rewriting object data for {0}", asset.ID);
308 string xml = ExternalRepresentationUtils.RewriteSOP(Utils.BytesToString(asset.Data), m_options["profile"].ToString(), m_userAccountService, m_scopeID);
309 asset.Data = Utils.StringToBytes(xml);
310 }
311 return asset;
312 }
291 } 313 }
292} 314}
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 622fc08..ddae20f 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -231,7 +231,23 @@ namespace OpenSim.Region.CoreModules.World.Estate
231 231
232 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) 232 private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds)
233 { 233 {
234 m_scene.Restart(timeInSeconds); 234 IRestartModule restartModule = m_scene.RequestModuleInterface<IRestartModule>();
235 if (restartModule != null)
236 {
237 List<int> times = new List<int>();
238 while (timeInSeconds > 0)
239 {
240 times.Add(timeInSeconds);
241 if (timeInSeconds > 300)
242 timeInSeconds -= 120;
243 else if (timeInSeconds > 30)
244 timeInSeconds -= 30;
245 else
246 timeInSeconds -= 15;
247 }
248
249 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
250 }
235 } 251 }
236 252
237 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID) 253 private void handleChangeEstateCovenantRequest(IClientAPI remoteClient, UUID estateCovenantID)
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
new file mode 100644
index 0000000..c65aa6a
--- /dev/null
+++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs
@@ -0,0 +1,263 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Timers;
31using System.Threading;
32using System.Collections.Generic;
33using log4net;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Console;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using Timer=System.Timers.Timer;
41using Mono.Addins;
42
43namespace OpenSim.Region.CoreModules.World.Region
44{
45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RestartModule")]
46 public class RestartModule : INonSharedRegionModule, IRestartModule
47 {
48 private static readonly ILog m_log =
49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 protected Scene m_Scene;
52 protected Timer m_CountdownTimer = null;
53 protected DateTime m_RestartBegin;
54 protected List<int> m_Alerts;
55 protected string m_Message;
56 protected UUID m_Initiator;
57 protected bool m_Notice = false;
58 protected IDialogModule m_DialogModule = null;
59
60 public void Initialise(IConfigSource config)
61 {
62 }
63
64 public void AddRegion(Scene scene)
65 {
66 m_Scene = scene;
67 scene.RegisterModuleInterface<IRestartModule>(this);
68 MainConsole.Instance.Commands.AddCommand("RestartModule",
69 false, "region restart bluebox",
70 "region restart bluebox <message> <time> ...",
71 "Restart the region", HandleRegionRestart);
72 MainConsole.Instance.Commands.AddCommand("RestartModule",
73 false, "region restart notice",
74 "region restart notice <message> <time> ...",
75 "Restart the region", HandleRegionRestart);
76 MainConsole.Instance.Commands.AddCommand("RestartModule",
77 false, "region restart abort",
78 "region restart abort [<message>]",
79 "Restart the region", HandleRegionRestart);
80 }
81
82 public void RegionLoaded(Scene scene)
83 {
84 m_DialogModule = m_Scene.RequestModuleInterface<IDialogModule>();
85 }
86
87 public void RemoveRegion(Scene scene)
88 {
89 }
90
91 public void Close()
92 {
93 }
94
95 public string Name
96 {
97 get { return "RestartModule"; }
98 }
99
100 public Type ReplaceableInterface
101 {
102 get { return typeof(IRestartModule); }
103 }
104
105 public TimeSpan TimeUntilRestart
106 {
107 get { return DateTime.Now - m_RestartBegin; }
108 }
109
110 public void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice)
111 {
112 if (m_CountdownTimer != null)
113 return;
114
115 if (alerts == null)
116 {
117 m_Scene.RestartNow();
118 return;
119 }
120
121 m_Message = message;
122 m_Initiator = initiator;
123 m_Notice = notice;
124 m_Alerts = new List<int>(alerts);
125 m_Alerts.Sort();
126 m_Alerts.Reverse();
127
128 if (m_Alerts[0] == 0)
129 {
130 m_Scene.RestartNow();
131 return;
132 }
133
134 int nextInterval = DoOneNotice();
135
136 SetTimer(nextInterval);
137 }
138
139 public int DoOneNotice()
140 {
141 if (m_Alerts.Count == 0 || m_Alerts[0] == 0)
142 {
143 m_Scene.RestartNow();
144 return 0;
145 }
146
147 int nextAlert = 0;
148 while (m_Alerts.Count > 1)
149 {
150 if (m_Alerts[1] == m_Alerts[0])
151 {
152 m_Alerts.RemoveAt(0);
153 continue;
154 }
155 nextAlert = m_Alerts[1];
156 break;
157 }
158
159 int currentAlert = m_Alerts[0];
160
161 m_Alerts.RemoveAt(0);
162
163 int minutes = currentAlert / 60;
164 string currentAlertString = String.Empty;
165 if (minutes > 0)
166 {
167 if (minutes == 1)
168 currentAlertString += "1 minute";
169 else
170 currentAlertString += String.Format("{0} minutes", minutes);
171 if ((currentAlert % 60) != 0)
172 currentAlertString += " and ";
173 }
174 if ((currentAlert % 60) != 0)
175 {
176 int seconds = currentAlert % 60;
177 if (seconds == 1)
178 currentAlertString += "1 second";
179 else
180 currentAlertString += String.Format("{0} seconds", seconds);
181 }
182
183 string msg = String.Format(m_Message, currentAlertString);
184
185 if (m_DialogModule != null && msg != String.Empty)
186 {
187 if (m_Notice)
188 m_DialogModule.SendGeneralAlert(msg);
189 else
190 m_DialogModule.SendNotificationToUsersInRegion(m_Initiator, "System", msg);
191 }
192
193 return currentAlert - nextAlert;
194 }
195
196 public void SetTimer(int intervalSeconds)
197 {
198 m_CountdownTimer = new Timer();
199 m_CountdownTimer.AutoReset = false;
200 m_CountdownTimer.Interval = intervalSeconds * 1000;
201 m_CountdownTimer.Elapsed += OnTimer;
202 m_CountdownTimer.Start();
203 }
204
205 private void OnTimer(object source, ElapsedEventArgs e)
206 {
207 int nextInterval = DoOneNotice();
208
209 SetTimer(nextInterval);
210 }
211
212 public void AbortRestart(string message)
213 {
214 if (m_CountdownTimer != null)
215 {
216 m_CountdownTimer.Stop();
217 m_CountdownTimer = null;
218 if (m_DialogModule != null && message != String.Empty)
219 m_DialogModule.SendGeneralAlert(message);
220 }
221 }
222
223 private void HandleRegionRestart(string module, string[] args)
224 {
225 if (!(MainConsole.Instance.ConsoleScene is Scene))
226 return;
227
228 if (MainConsole.Instance.ConsoleScene != m_Scene)
229 return;
230
231 if (args.Length < 5)
232 {
233 if (args.Length > 2)
234 {
235 if (args[2] == "abort")
236 {
237 string msg = String.Empty;
238 if (args.Length > 3)
239 msg = args[3];
240
241 AbortRestart(msg);
242
243 MainConsole.Instance.Output("Region restart aborted");
244 return;
245 }
246 }
247
248 MainConsole.Instance.Output("Error: restart region <mode> <name> <time> ...");
249 return;
250 }
251
252 bool notice = false;
253 if (args[2] == "notice")
254 notice = true;
255
256 List<int> times = new List<int>();
257 for (int i = 4 ; i < args.Length ; i++)
258 times.Add(Convert.ToInt32(args[i]));
259
260 ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice);
261 }
262 }
263}
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
index 6da41db..088b818 100644
--- a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
+++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs
@@ -34,6 +34,17 @@ using OpenSim.Region.Framework.Scenes;
34 34
35namespace OpenSim.Region.Examples.SimpleModule 35namespace OpenSim.Region.Examples.SimpleModule
36{ 36{
37 /// <summary>
38 /// Example region module.
39 /// </summary>
40 /// <remarks>
41 /// This is an old and unmaintained region module which uses the old style module interface. It is not loaded into
42 /// OpenSim by default. If you want to try enabling it, look in the bin folder of this project.
43 /// Please see the README.txt in this project on the filesystem for some more information.
44 /// Nonetheless, it may contain some useful example code so has been left here for now.
45 ///
46 /// You can see bare bones examples of the more modern region module system in OpenSim/Region/OptionalModules/Example
47 /// </remarks>
37 public class RegionModule : IRegionModule 48 public class RegionModule : IRegionModule
38 { 49 {
39 #region IRegionModule Members 50 #region IRegionModule Members
diff --git a/OpenSim/Region/Framework/Interfaces/IRestartModule.cs b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs
new file mode 100644
index 0000000..c68550f
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs
@@ -0,0 +1,39 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30
31namespace OpenSim.Region.Framework.Interfaces
32{
33 public interface IRestartModule
34 {
35 TimeSpan TimeUntilRestart { get; }
36 void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice);
37 void AbortRestart(string message);
38 }
39}
diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
index 1a5cb7e..2904ee8 100644
--- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
+++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs
@@ -9,5 +9,6 @@ namespace OpenSim.Region.Framework.Interfaces
9 { 9 {
10 string GetUserName(UUID uuid); 10 string GetUserName(UUID uuid);
11 void AddUser(UUID uuid, string userData); 11 void AddUser(UUID uuid, string userData);
12 void AddUser(UUID uuid, string firstName, string lastName, string profileURL);
12 } 13 }
13} 14}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 06f8ac1..2cf0ced 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -416,6 +416,10 @@ namespace OpenSim.Region.Framework.Scenes
416 416
417 if ((item != null) && (item.Owner == senderId)) 417 if ((item != null) && (item.Owner == senderId))
418 { 418 {
419 IUserManagement uman = RequestModuleInterface<IUserManagement>();
420 if (uman != null)
421 uman.AddUser(item.CreatorIdAsUuid, item.CreatorData);
422
419 if (!Permissions.BypassPermissions()) 423 if (!Permissions.BypassPermissions())
420 { 424 {
421 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) 425 if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 55fca9b..fcfb4d7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -893,60 +893,6 @@ namespace OpenSim.Region.Framework.Scenes
893 return new GridRegion(RegionInfo); 893 return new GridRegion(RegionInfo);
894 } 894 }
895 895
896 /// <summary>
897 /// Given float seconds, this will restart the region.
898 /// </summary>
899 /// <param name="seconds">float indicating duration before restart.</param>
900 public virtual void Restart(float seconds)
901 {
902 // notifications are done in 15 second increments
903 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request
904 // It's a 'Cancel restart' request.
905
906 // RestartNow() does immediate restarting.
907 if (seconds < 15)
908 {
909 m_restartTimer.Stop();
910 m_dialogModule.SendGeneralAlert("Restart Aborted");
911 }
912 else
913 {
914 // Now we figure out what to set the timer to that does the notifications and calls, RestartNow()
915 m_restartTimer.Interval = 15000;
916 m_incrementsof15seconds = (int)seconds / 15;
917 m_RestartTimerCounter = 0;
918 m_restartTimer.AutoReset = true;
919 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
920 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
921 m_restartTimer.Start();
922 m_dialogModule.SendNotificationToUsersInRegion(
923 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0)));
924 }
925 }
926
927 // The Restart timer has occured.
928 // We have to figure out if this is a notification or if the number of seconds specified in Restart
929 // have elapsed.
930 // If they have elapsed, call RestartNow()
931 public void RestartTimer_Elapsed(object sender, ElapsedEventArgs e)
932 {
933 m_RestartTimerCounter++;
934 if (m_RestartTimerCounter <= m_incrementsof15seconds)
935 {
936 if (m_RestartTimerCounter == 4 || m_RestartTimerCounter == 6 || m_RestartTimerCounter == 7)
937 m_dialogModule.SendNotificationToUsersInRegion(
938 UUID.Random(),
939 String.Empty,
940 RegionInfo.RegionName + ": Restarting in " + ((8 - m_RestartTimerCounter) * 15) + " seconds");
941 }
942 else
943 {
944 m_restartTimer.Stop();
945 m_restartTimer.AutoReset = false;
946 RestartNow();
947 }
948 }
949
950 // This causes the region to restart immediatley. 896 // This causes the region to restart immediatley.
951 public void RestartNow() 897 public void RestartNow()
952 { 898 {
@@ -969,7 +915,8 @@ namespace OpenSim.Region.Framework.Scenes
969 Close(); 915 Close();
970 916
971 m_log.Error("[REGION]: Firing Region Restart Message"); 917 m_log.Error("[REGION]: Firing Region Restart Message");
972 base.Restart(0); 918
919 base.Restart();
973 } 920 }
974 921
975 // This is a helper function that notifies root agents in this region that a new sim near them has come up 922 // This is a helper function that notifies root agents in this region that a new sim near them has come up
@@ -2050,7 +1997,7 @@ namespace OpenSim.Region.Framework.Scenes
2050 /// <param name="group">Object Id</param> 1997 /// <param name="group">Object Id</param>
2051 /// <param name="silent">Suppress broadcasting changes to other clients.</param> 1998 /// <param name="silent">Suppress broadcasting changes to other clients.</param>
2052 public void DeleteSceneObject(SceneObjectGroup group, bool silent) 1999 public void DeleteSceneObject(SceneObjectGroup group, bool silent)
2053 { 2000 {
2054// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID); 2001// m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);
2055 2002
2056 //SceneObjectPart rootPart = group.GetChildPart(group.UUID); 2003 //SceneObjectPart rootPart = group.GetChildPart(group.UUID);
@@ -2091,7 +2038,7 @@ namespace OpenSim.Region.Framework.Scenes
2091 2038
2092 group.DeleteGroupFromScene(silent); 2039 group.DeleteGroupFromScene(silent);
2093 2040
2094// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2041// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2095 } 2042 }
2096 2043
2097 /// <summary> 2044 /// <summary>
@@ -2110,9 +2057,12 @@ namespace OpenSim.Region.Framework.Scenes
2110 // Force a database update so that the scene object group ID is accurate. It's possible that the 2057 // Force a database update so that the scene object group ID is accurate. It's possible that the
2111 // group has recently been delinked from another group but that this change has not been persisted 2058 // group has recently been delinked from another group but that this change has not been persisted
2112 // to the DB. 2059 // to the DB.
2113 ForceSceneObjectBackup(so); 2060 // This is an expensive thing to do so only do it if absolutely necessary.
2061 if (so.HasGroupChangedDueToDelink)
2062 ForceSceneObjectBackup(so);
2063
2114 so.DetachFromBackup(); 2064 so.DetachFromBackup();
2115 SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID); 2065 SimulationDataService.RemoveObject(so.UUID, m_regInfo.RegionID);
2116 } 2066 }
2117 2067
2118 // We need to keep track of this state in case this group is still queued for further backup. 2068 // We need to keep track of this state in case this group is still queued for further backup.
@@ -2377,16 +2327,14 @@ namespace OpenSim.Region.Framework.Scenes
2377 m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); 2327 m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
2378 return false; 2328 return false;
2379 } 2329 }
2380 2330
2381 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 2); 2331 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject));
2382 2332
2383 newObject.ResumeScripts(); 2333 newObject.ResumeScripts();
2384 2334
2385 // Do this as late as possible so that listeners have full access to the incoming object 2335 // Do this as late as possible so that listeners have full access to the incoming object
2386 EventManager.TriggerOnIncomingSceneObject(newObject); 2336 EventManager.TriggerOnIncomingSceneObject(newObject);
2387 2337
2388 TriggerChangedTeleport(newObject);
2389
2390 return true; 2338 return true;
2391 } 2339 }
2392 2340
@@ -2494,7 +2442,7 @@ namespace OpenSim.Region.Framework.Scenes
2494 return true; 2442 return true;
2495 } 2443 }
2496 2444
2497 private void TriggerChangedTeleport(SceneObjectGroup sog) 2445 private int GetStateSource(SceneObjectGroup sog)
2498 { 2446 {
2499 ScenePresence sp = GetScenePresence(sog.OwnerID); 2447 ScenePresence sp = GetScenePresence(sog.OwnerID);
2500 2448
@@ -2505,13 +2453,12 @@ namespace OpenSim.Region.Framework.Scenes
2505 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default)) 2453 if (aCircuit != null && (aCircuit.teleportFlags != (uint)TeleportFlags.Default))
2506 { 2454 {
2507 // This will get your attention 2455 // This will get your attention
2508 //m_log.Error("[XXX] Triggering "); 2456 //m_log.Error("[XXX] Triggering CHANGED_TELEPORT");
2509 2457
2510 // Trigger CHANGED_TELEPORT 2458 return 5; // StateSource.Teleporting
2511 sp.Scene.EventManager.TriggerOnScriptChangedEvent(sog.LocalId, (uint)Changed.TELEPORT);
2512 } 2459 }
2513
2514 } 2460 }
2461 return 2; // StateSource.PrimCrossing
2515 } 2462 }
2516 2463
2517 #endregion 2464 #endregion
@@ -2616,6 +2563,7 @@ namespace OpenSim.Region.Framework.Scenes
2616 } 2563 }
2617 else 2564 else
2618 m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); 2565 m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2566
2619 } 2567 }
2620 } 2568 }
2621 2569
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index c71aefa..f343bc8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -218,18 +218,6 @@ namespace OpenSim.Region.Framework.Scenes
218 218
219 #region admin stuff 219 #region admin stuff
220 220
221 /// <summary>
222 /// Region Restart - Seconds till restart.
223 /// </summary>
224 /// <param name="seconds"></param>
225 public virtual void Restart(int seconds)
226 {
227 m_log.Error("[REGION]: passing Restart Message up the namespace");
228 restart handlerPhysicsCrash = OnRestart;
229 if (handlerPhysicsCrash != null)
230 handlerPhysicsCrash(RegionInfo);
231 }
232
233 public virtual bool PresenceChildStatus(UUID avatarID) 221 public virtual bool PresenceChildStatus(UUID avatarID)
234 { 222 {
235 return false; 223 return false;
@@ -562,6 +550,14 @@ namespace OpenSim.Region.Framework.Scenes
562 get { return false; } 550 get { return false; }
563 } 551 }
564 552
553 public void Restart()
554 {
555 // This has to be here to fire the event
556 restart handlerPhysicsCrash = OnRestart;
557 if (handlerPhysicsCrash != null)
558 handlerPhysicsCrash(RegionInfo);
559 }
560
565 public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); 561 public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep);
566 } 562 }
567} 563}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 4ec530e..f17fb28 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -119,10 +119,19 @@ namespace OpenSim.Region.Framework.Scenes
119 timeFirstChanged = DateTime.Now.Ticks; 119 timeFirstChanged = DateTime.Now.Ticks;
120 } 120 }
121 m_hasGroupChanged = value; 121 m_hasGroupChanged = value;
122
123// m_log.DebugFormat(
124// "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId);
122 } 125 }
123 126
124 get { return m_hasGroupChanged; } 127 get { return m_hasGroupChanged; }
125 } 128 }
129
130 /// <summary>
131 /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since
132 /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation.
133 /// </summary>
134 public bool HasGroupChangedDueToDelink { get; private set; }
126 135
127 private bool isTimeToPersist() 136 private bool isTimeToPersist()
128 { 137 {
@@ -1330,6 +1339,7 @@ namespace OpenSim.Region.Framework.Scenes
1330 backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity; 1339 backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
1331 backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem; 1340 backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
1332 HasGroupChanged = false; 1341 HasGroupChanged = false;
1342 HasGroupChangedDueToDelink = false;
1333 1343
1334 m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); 1344 m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this);
1335 datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); 1345 datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);
@@ -2208,8 +2218,9 @@ namespace OpenSim.Region.Framework.Scenes
2208 2218
2209 linkPart.Rezzed = RootPart.Rezzed; 2219 linkPart.Rezzed = RootPart.Rezzed;
2210 2220
2211 //HasGroupChanged = true; 2221 // When we delete a group, we currently have to force persist to the database if the object id has changed
2212 //ScheduleGroupForFullUpdate(); 2222 // (since delete works by deleting all rows which have a given object id)
2223 objectGroup.HasGroupChangedDueToDelink = true;
2213 2224
2214 return objectGroup; 2225 return objectGroup;
2215 } 2226 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index ba592c4..f87056e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -449,7 +449,10 @@ namespace OpenSim.Region.Framework.Scenes
449 } 449 }
450 } 450 }
451 451
452 public string CreatorData // = <profile url>;<name> 452 /// <summary>
453 /// Data about the creator in the form profile_url;name
454 /// </summary>
455 public string CreatorData
453 { 456 {
454 get { return m_creatorData; } 457 get { return m_creatorData; }
455 set { m_creatorData = value; } 458 set { m_creatorData = value; }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4526a59..d88526f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -445,8 +445,36 @@ namespace OpenSim.Region.Framework.Scenes
445 PhysicsActor actor = m_physicsActor; 445 PhysicsActor actor = m_physicsActor;
446 if (actor != null) 446 if (actor != null)
447 m_pos = actor.Position; 447 m_pos = actor.Position;
448 else
449 {
450 // Obtain the correct position of a seated avatar.
451 // In addition to providing the correct position while
452 // the avatar is seated, this value will also
453 // be used as the location to unsit to.
454 //
455 // If m_parentID is not 0, assume we are a seated avatar
456 // and we should return the position based on the sittarget
457 // offset and rotation of the prim we are seated on.
458 //
459 // Generally, m_pos will contain the position of the avatar
460 // in the sim unless the avatar is on a sit target. While
461 // on a sit target, m_pos will contain the desired offset
462 // without the parent rotation applied.
463 if (m_parentID != 0)
464 {
465 SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
466 if (part != null)
467 {
468 return m_parentPosition + (m_pos * part.GetWorldRotation());
469 }
470 else
471 {
472 return m_parentPosition + m_pos;
473 }
474 }
475 }
448 476
449 return m_parentPosition + m_pos; 477 return m_pos;
450 } 478 }
451 set 479 set
452 { 480 {
@@ -703,7 +731,9 @@ namespace OpenSim.Region.Framework.Scenes
703 // Note: This won't send data *to* other clients in that region (children don't send) 731 // Note: This won't send data *to* other clients in that region (children don't send)
704 732
705// MIC: This gets called again in CompleteMovement 733// MIC: This gets called again in CompleteMovement
706 SendInitialFullUpdateToAllClients(); 734 // SendInitialFullUpdateToAllClients();
735 SendOtherAgentsAvatarDataToMe();
736 SendOtherAgentsAppearanceToMe();
707 737
708 RegisterToEvents(); 738 RegisterToEvents();
709 SetDirectionVectors(); 739 SetDirectionVectors();
@@ -1613,7 +1643,7 @@ namespace OpenSim.Region.Framework.Scenes
1613 { 1643 {
1614 AbsolutePosition = part.AbsolutePosition; 1644 AbsolutePosition = part.AbsolutePosition;
1615 Velocity = Vector3.Zero; 1645 Velocity = Vector3.Zero;
1616 SendFullUpdateToAllClients(); 1646 SendAvatarDataToAllAgents();
1617 1647
1618 //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); 1648 //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID);
1619 } 1649 }
@@ -1688,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes
1688 m_parentPosition = Vector3.Zero; 1718 m_parentPosition = Vector3.Zero;
1689 1719
1690 m_parentID = 0; 1720 m_parentID = 0;
1691 SendFullUpdateToAllClients(); 1721 SendAvatarDataToAllAgents();
1692 m_requestedSitTargetID = 0; 1722 m_requestedSitTargetID = 0;
1693 if (m_physicsActor != null && m_appearance != null) 1723 if (m_physicsActor != null && m_appearance != null)
1694 { 1724 {
@@ -2154,7 +2184,7 @@ namespace OpenSim.Region.Framework.Scenes
2154 RemoveFromPhysicalScene(); 2184 RemoveFromPhysicalScene();
2155 2185
2156 Animator.TrySetMovementAnimation(sitAnimation); 2186 Animator.TrySetMovementAnimation(sitAnimation);
2157 SendFullUpdateToAllClients(); 2187 SendAvatarDataToAllAgents();
2158 // This may seem stupid, but Our Full updates don't send avatar rotation :P 2188 // This may seem stupid, but Our Full updates don't send avatar rotation :P
2159 // So we're also sending a terse update (which has avatar rotation) 2189 // So we're also sending a terse update (which has avatar rotation)
2160 // [Update] We do now. 2190 // [Update] We do now.
@@ -2379,165 +2409,183 @@ namespace OpenSim.Region.Framework.Scenes
2379 } 2409 }
2380 2410
2381 /// <summary> 2411 /// <summary>
2382 /// Tell other client about this avatar (The client previously didn't know or had outdated details about this avatar) 2412 /// Do everything required once a client completes its movement into a region and becomes
2413 /// a root agent.
2383 /// </summary> 2414 /// </summary>
2384 /// <param name="remoteAvatar"></param> 2415 private void SendInitialData()
2385 public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
2386 { 2416 {
2387 // 2 stage check is needed. 2417 // Moved this into CompleteMovement to ensure that m_appearance is initialized before
2388 if (remoteAvatar == null) 2418 // the inventory arrives
2389 return; 2419 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2390
2391 IClientAPI cl = remoteAvatar.ControllingClient;
2392 if (cl == null)
2393 return;
2394
2395 if (m_appearance.Texture == null)
2396 return;
2397 2420
2398// MT: This is needed for sit. It's legal to send it to oneself, and the name 2421 bool cachedappearance = false;
2399// of the method is a misnomer
2400//
2401// if (LocalId == remoteAvatar.LocalId)
2402// {
2403// m_log.WarnFormat("[SCENEPRESENCE]: An agent is attempting to send avatar data to itself; {0}", UUID);
2404// return;
2405// }
2406 2422
2407 if (IsChildAgent) 2423 // We have an appearance but we may not have the baked textures. Check the asset cache
2424 // to see if all the baked textures are already here.
2425 if (m_scene.AvatarFactory != null)
2408 { 2426 {
2409 m_log.WarnFormat("[SCENEPRESENCE]: A child agent is attempting to send out avatar data; {0}", UUID); 2427 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient);
2410 return; 2428 }
2429 else
2430 {
2431 m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name);
2411 } 2432 }
2412 2433
2413 remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this); 2434 // If we aren't using a cached appearance, then clear out the baked textures
2414 m_scene.StatsReporter.AddAgentUpdates(1); 2435 if (! cachedappearance)
2436 {
2437 m_appearance.ResetAppearance();
2438 if (m_scene.AvatarFactory != null)
2439 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
2440 }
2441
2442 // This agent just became root. We are going to tell everyone about it. The process of
2443 // getting other avatars information was initiated in the constructor... don't do it
2444 // again here... this comes after the cached appearance check because the avatars
2445 // appearance goes into the avatar update packet
2446 SendAvatarDataToAllAgents();
2447 SendAppearanceToAgent(this);
2448
2449 // If we are using the the cached appearance then send it out to everyone
2450 if (cachedappearance)
2451 {
2452 m_log.InfoFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name);
2453
2454 // If the avatars baked textures are all in the cache, then we have a
2455 // complete appearance... send it out, if not, then we'll send it when
2456 // the avatar finishes updating its appearance
2457 SendAppearanceToAllOtherAgents();
2458 }
2415 } 2459 }
2416 2460
2417 /// <summary> 2461 /// <summary>
2418 /// Tell *ALL* agents about this agent 2462 /// Send this agent's avatar data to all other root and child agents in the scene
2463 /// This agent must be root. This avatar will receive its own update.
2419 /// </summary> 2464 /// </summary>
2420 public void SendInitialFullUpdateToAllClients() 2465 public void SendAvatarDataToAllAgents()
2421 { 2466 {
2422 m_perfMonMS = Util.EnvironmentTickCount(); 2467 // only send update from root agents to other clients; children are only "listening posts"
2423 int avUpdates = 0; 2468 if (IsChildAgent)
2424 m_scene.ForEachScenePresence(delegate(ScenePresence avatar)
2425 { 2469 {
2426 ++avUpdates; 2470 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
2427 2471 return;
2428 // Don't update ourselves 2472 }
2429 if (avatar.LocalId == LocalId) 2473
2430 return; 2474 m_perfMonMS = Util.EnvironmentTickCount();
2431
2432 // If this is a root agent, then get info about the avatar
2433 if (!IsChildAgent)
2434 {
2435 SendFullUpdateToOtherClient(avatar);
2436 }
2437 2475
2438 // If the other avatar is a root 2476 int count = 0;
2439 if (!avatar.IsChildAgent) 2477 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2440 { 2478 {
2441 avatar.SendFullUpdateToOtherClient(this); 2479 SendAvatarDataToAgent(scenePresence);
2442 avatar.SendAppearanceToOtherAgent(this); 2480 count++;
2443 avatar.Animator.SendAnimPackToClient(ControllingClient); 2481 });
2444 }
2445 });
2446 2482
2447 m_scene.StatsReporter.AddAgentUpdates(avUpdates); 2483 m_scene.StatsReporter.AddAgentUpdates(count);
2448 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2484 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2449
2450 //Animator.SendAnimPack();
2451 } 2485 }
2452 2486
2453 public void SendFullUpdateToAllClients() 2487 /// <summary>
2488 /// Send avatar data for all other root agents to this agent, this agent
2489 /// can be either a child or root
2490 /// </summary>
2491 public void SendOtherAgentsAvatarDataToMe()
2454 { 2492 {
2455 m_perfMonMS = Util.EnvironmentTickCount(); 2493 m_perfMonMS = Util.EnvironmentTickCount();
2456 2494
2457 // only send update from root agents to other clients; children are only "listening posts"
2458 if (IsChildAgent)
2459 {
2460 m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
2461 return;
2462 }
2463
2464 int count = 0; 2495 int count = 0;
2465 m_scene.ForEachScenePresence(delegate(ScenePresence sp) 2496 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2466 { 2497 {
2467 if (sp.IsChildAgent) 2498 // only send information about root agents
2468 return; 2499 if (scenePresence.IsChildAgent)
2469 SendFullUpdateToOtherClient(sp); 2500 return;
2470 ++count; 2501
2471 }); 2502 // only send information about other root agents
2503 if (scenePresence.UUID == UUID)
2504 return;
2505
2506 scenePresence.SendAvatarDataToAgent(this);
2507 count++;
2508 });
2509
2472 m_scene.StatsReporter.AddAgentUpdates(count); 2510 m_scene.StatsReporter.AddAgentUpdates(count);
2473 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2511 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2474
2475 Animator.SendAnimPack();
2476 } 2512 }
2477 2513
2478 /// <summary> 2514 /// <summary>
2479 /// Do everything required once a client completes its movement into a region 2515 /// Send avatar data to an agent.
2480 /// </summary> 2516 /// </summary>
2481 public void SendInitialData() 2517 /// <param name="avatar"></param>
2518 public void SendAvatarDataToAgent(ScenePresence avatar)
2482 { 2519 {
2483 // Moved this into CompleteMovement to ensure that m_appearance is initialized before 2520// m_log.WarnFormat("[SP] Send avatar data from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2484 // the inventory arrives
2485 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2486 2521
2487 m_controllingClient.SendAvatarDataImmediate(this); 2522 avatar.ControllingClient.SendAvatarDataImmediate(this);
2488 if (m_scene.AvatarFactory != null) 2523 Animator.SendAnimPackToClient(avatar.ControllingClient);
2489 { 2524 }
2490 if (m_scene.AvatarFactory.ValidateBakedTextureCache(m_controllingClient)) 2525
2491 { 2526 /// <summary>
2492// m_log.WarnFormat("[SCENEPRESENCE]: baked textures are in the cache for {0}", Name); 2527 /// Send this agent's appearance to all other root and child agents in the scene
2493 m_controllingClient.SendAppearance( 2528 /// This agent must be root.
2494 m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes()); 2529 /// </summary>
2495 } 2530 public void SendAppearanceToAllOtherAgents()
2496 } 2531 {
2497 else 2532 // only send update from root agents to other clients; children are only "listening posts"
2533 if (IsChildAgent)
2498 { 2534 {
2499 m_log.WarnFormat("[SCENEPRESENCE]: AvatarFactory not set for {0}", Name); 2535 m_log.Warn("[SCENEPRESENCE] attempt to send avatar data from a child agent");
2536 return;
2500 } 2537 }
2538
2539 m_perfMonMS = Util.EnvironmentTickCount();
2501 2540
2502 SendInitialFullUpdateToAllClients(); 2541 int count = 0;
2542 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2543 {
2544 if (scenePresence.UUID == UUID)
2545 return;
2546
2547 SendAppearanceToAgent(scenePresence);
2548 count++;
2549 });
2550
2551 m_scene.StatsReporter.AddAgentUpdates(count);
2552 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2503 } 2553 }
2504 2554
2505 /// <summary> 2555 /// <summary>
2506 /// 2556 /// Send appearance from all other root agents to this agent. this agent
2557 /// can be either root or child
2507 /// </summary> 2558 /// </summary>
2508 public void SendAppearanceToAllOtherAgents() 2559 public void SendOtherAgentsAppearanceToMe()
2509 { 2560 {
2510// DEBUG ON
2511// m_log.WarnFormat("[SCENEPRESENCE]: Send appearance from {0} to all other agents", m_uuid);
2512// DEBUG OFF
2513 m_perfMonMS = Util.EnvironmentTickCount(); 2561 m_perfMonMS = Util.EnvironmentTickCount();
2514 2562
2563 int count = 0;
2515 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2564 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2516 { 2565 {
2517 if (scenePresence.UUID != UUID) 2566 // only send information about root agents
2518 { 2567 if (scenePresence.IsChildAgent)
2519 SendAppearanceToOtherAgent(scenePresence); 2568 return;
2520 } 2569
2570 // only send information about other root agents
2571 if (scenePresence.UUID == UUID)
2572 return;
2573
2574 scenePresence.SendAppearanceToAgent(this);
2575 count++;
2521 }); 2576 });
2522 2577
2578 m_scene.StatsReporter.AddAgentUpdates(count);
2523 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); 2579 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2524 } 2580 }
2525 2581
2526 /// <summary> 2582 /// <summary>
2527 /// Send appearance data to an agent that isn't this one. 2583 /// Send appearance data to an agent.
2528 /// </summary> 2584 /// </summary>
2529 /// <param name="avatar"></param> 2585 /// <param name="avatar"></param>
2530 public void SendAppearanceToOtherAgent(ScenePresence avatar) 2586 public void SendAppearanceToAgent(ScenePresence avatar)
2531 { 2587 {
2532 if (LocalId == avatar.LocalId)
2533 {
2534 m_log.WarnFormat("[SCENE PRESENCE]: An agent is attempting to send appearance data to itself; {0}", UUID);
2535 return;
2536 }
2537
2538// DEBUG ON
2539// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); 2588// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
2540// DEBUG OFF
2541 2589
2542 avatar.ControllingClient.SendAppearance( 2590 avatar.ControllingClient.SendAppearance(
2543 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); 2591 m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
@@ -3050,9 +3098,6 @@ namespace OpenSim.Region.Framework.Scenes
3050 3098
3051 public void CopyFrom(AgentData cAgent) 3099 public void CopyFrom(AgentData cAgent)
3052 { 3100 {
3053// DEBUG ON
3054 m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
3055// DEBUG OFF
3056 m_originRegionID = cAgent.RegionID; 3101 m_originRegionID = cAgent.RegionID;
3057 3102
3058 m_callbackURI = cAgent.CallbackURI; 3103 m_callbackURI = cAgent.CallbackURI;
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 9cf5a39..6c9826f 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -409,12 +409,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
409 #region SOPXmlProcessors 409 #region SOPXmlProcessors
410 private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader) 410 private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader)
411 { 411 {
412 obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); 412 obj.AllowedDrop = Util.ReadBoolean(reader);
413 } 413 }
414 414
415 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader) 415 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader)
416 { 416 {
417 obj.CreatorID = ReadUUID(reader, "CreatorID"); 417 obj.CreatorID = Util.ReadUUID(reader, "CreatorID");
418 } 418 }
419 419
420 private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader) 420 private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader)
@@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
424 424
425 private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) 425 private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader)
426 { 426 {
427 obj.FolderID = ReadUUID(reader, "FolderID"); 427 obj.FolderID = Util.ReadUUID(reader, "FolderID");
428 } 428 }
429 429
430 private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader) 430 private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader)
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
439 439
440 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) 440 private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader)
441 { 441 {
442 obj.UUID = ReadUUID(reader, "UUID"); 442 obj.UUID = Util.ReadUUID(reader, "UUID");
443 } 443 }
444 444
445 private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader) 445 private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader)
@@ -459,7 +459,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
459 459
460 private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader) 460 private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader)
461 { 461 {
462 obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); 462 obj.PassTouches = Util.ReadBoolean(reader);
463 } 463 }
464 464
465 private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader) 465 private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader)
@@ -474,32 +474,32 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
474 474
475 private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader) 475 private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader)
476 { 476 {
477 obj.GroupPosition = ReadVector(reader, "GroupPosition"); 477 obj.GroupPosition = Util.ReadVector(reader, "GroupPosition");
478 } 478 }
479 479
480 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader) 480 private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader)
481 { 481 {
482 obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ; 482 obj.OffsetPosition = Util.ReadVector(reader, "OffsetPosition"); ;
483 } 483 }
484 484
485 private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader) 485 private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader)
486 { 486 {
487 obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); 487 obj.RotationOffset = Util.ReadQuaternion(reader, "RotationOffset");
488 } 488 }
489 489
490 private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader) 490 private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader)
491 { 491 {
492 obj.Velocity = ReadVector(reader, "Velocity"); 492 obj.Velocity = Util.ReadVector(reader, "Velocity");
493 } 493 }
494 494
495 private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader) 495 private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader)
496 { 496 {
497 obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); 497 obj.AngularVelocity = Util.ReadVector(reader, "AngularVelocity");
498 } 498 }
499 499
500 private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader) 500 private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader)
501 { 501 {
502 obj.Acceleration = ReadVector(reader, "Acceleration"); 502 obj.Acceleration = Util.ReadVector(reader, "Acceleration");
503 } 503 }
504 504
505 private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader) 505 private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader)
@@ -553,7 +553,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
553 553
554 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) 554 private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader)
555 { 555 {
556 obj.Scale = ReadVector(reader, "Scale"); 556 obj.Scale = Util.ReadVector(reader, "Scale");
557 } 557 }
558 558
559 private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader) 559 private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader)
@@ -563,22 +563,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
563 563
564 private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader) 564 private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader)
565 { 565 {
566 obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); 566 obj.SitTargetOrientation = Util.ReadQuaternion(reader, "SitTargetOrientation");
567 } 567 }
568 568
569 private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader) 569 private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader)
570 { 570 {
571 obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); 571 obj.SitTargetPosition = Util.ReadVector(reader, "SitTargetPosition");
572 } 572 }
573 573
574 private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader) 574 private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader)
575 { 575 {
576 obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); 576 obj.SitTargetPositionLL = Util.ReadVector(reader, "SitTargetPositionLL");
577 } 577 }
578 578
579 private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader) 579 private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader)
580 { 580 {
581 obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); 581 obj.SitTargetOrientationLL = Util.ReadQuaternion(reader, "SitTargetOrientationLL");
582 } 582 }
583 583
584 private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader) 584 private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader)
@@ -614,17 +614,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
614 614
615 private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader) 615 private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader)
616 { 616 {
617 obj.GroupID = ReadUUID(reader, "GroupID"); 617 obj.GroupID = Util.ReadUUID(reader, "GroupID");
618 } 618 }
619 619
620 private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader) 620 private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader)
621 { 621 {
622 obj.OwnerID = ReadUUID(reader, "OwnerID"); 622 obj.OwnerID = Util.ReadUUID(reader, "OwnerID");
623 } 623 }
624 624
625 private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader) 625 private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader)
626 { 626 {
627 obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); 627 obj.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID");
628 } 628 }
629 629
630 private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader) 630 private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader)
@@ -654,16 +654,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
654 654
655 private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader) 655 private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader)
656 { 656 {
657 string value = reader.ReadElementContentAsString("Flags", String.Empty); 657 obj.Flags = Util.ReadEnum<PrimFlags>(reader, "Flags");
658 // !!!!! to deal with flags without commas
659 if (value.Contains(" ") && !value.Contains(","))
660 value = value.Replace(" ", ", ");
661 obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value);
662 } 658 }
663 659
664 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader) 660 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader)
665 { 661 {
666 obj.CollisionSound = ReadUUID(reader, "CollisionSound"); 662 obj.CollisionSound = Util.ReadUUID(reader, "CollisionSound");
667 } 663 }
668 664
669 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader) 665 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader)
@@ -690,7 +686,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
690 #region TaskInventoryXmlProcessors 686 #region TaskInventoryXmlProcessors
691 private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) 687 private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader)
692 { 688 {
693 item.AssetID = ReadUUID(reader, "AssetID"); 689 item.AssetID = Util.ReadUUID(reader, "AssetID");
694 } 690 }
695 691
696 private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader) 692 private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader)
@@ -705,7 +701,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
705 701
706 private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) 702 private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader)
707 { 703 {
708 item.CreatorID = ReadUUID(reader, "CreatorID"); 704 item.CreatorID = Util.ReadUUID(reader, "CreatorID");
709 } 705 }
710 706
711 private static void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader) 707 private static void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader)
@@ -730,7 +726,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
730 726
731 private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) 727 private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader)
732 { 728 {
733 item.GroupID = ReadUUID(reader, "GroupID"); 729 item.GroupID = Util.ReadUUID(reader, "GroupID");
734 } 730 }
735 731
736 private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader) 732 private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader)
@@ -745,20 +741,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
745 741
746 private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader) 742 private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader)
747 { 743 {
748 item.ItemID = ReadUUID(reader, "ItemID"); 744 item.ItemID = Util.ReadUUID(reader, "ItemID");
749 } 745 }
750 746
751 private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) 747 private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
752 { 748 {
753 ReadUUID(reader, "OldItemID"); 749 Util.ReadUUID(reader, "OldItemID");
754 // On deserialization, the old item id MUST BE UUID.Zero!!!!! 750 // On deserialization, the old item id MUST BE UUID.Zero!!!!!
755 // Setting this to the saved value will BREAK script persistence! 751 // Setting this to the saved value will BREAK script persistence!
756 // item.OldItemID = ReadUUID(reader, "OldItemID"); 752 // item.OldItemID = Util.ReadUUID(reader, "OldItemID");
757 } 753 }
758 754
759 private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) 755 private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
760 { 756 {
761 item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); 757 item.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID");
762 } 758 }
763 759
764 private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) 760 private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader)
@@ -773,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
773 769
774 private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) 770 private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader)
775 { 771 {
776 item.OwnerID = ReadUUID(reader, "OwnerID"); 772 item.OwnerID = Util.ReadUUID(reader, "OwnerID");
777 } 773 }
778 774
779 private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) 775 private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader)
@@ -783,17 +779,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
783 779
784 private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader) 780 private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader)
785 { 781 {
786 item.ParentID = ReadUUID(reader, "ParentID"); 782 item.ParentID = Util.ReadUUID(reader, "ParentID");
787 } 783 }
788 784
789 private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) 785 private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader)
790 { 786 {
791 item.ParentPartID = ReadUUID(reader, "ParentPartID"); 787 item.ParentPartID = Util.ReadUUID(reader, "ParentPartID");
792 } 788 }
793 789
794 private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) 790 private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader)
795 { 791 {
796 item.PermsGranter = ReadUUID(reader, "PermsGranter"); 792 item.PermsGranter = Util.ReadUUID(reader, "PermsGranter");
797 } 793 }
798 794
799 private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader) 795 private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader)
@@ -808,7 +804,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
808 804
809 private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader) 805 private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader)
810 { 806 {
811 item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty); 807 item.OwnerChanged = Util.ReadBoolean(reader);
812 } 808 }
813 809
814 #endregion 810 #endregion
@@ -922,7 +918,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
922 918
923 private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader) 919 private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader)
924 { 920 {
925 shp.Scale = ReadVector(reader, "Scale"); 921 shp.Scale = Util.ReadVector(reader, "Scale");
926 } 922 }
927 923
928 private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader) 924 private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -932,25 +928,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
932 928
933 private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader) 929 private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader)
934 { 930 {
935 string value = reader.ReadElementContentAsString("ProfileShape", String.Empty); 931 shp.ProfileShape = Util.ReadEnum<ProfileShape>(reader, "ProfileShape");
936 // !!!!! to deal with flags without commas
937 if (value.Contains(" ") && !value.Contains(","))
938 value = value.Replace(" ", ", ");
939 shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value);
940 } 932 }
941 933
942 private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader) 934 private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader)
943 { 935 {
944 string value = reader.ReadElementContentAsString("HollowShape", String.Empty); 936 shp.HollowShape = Util.ReadEnum<HollowShape>(reader, "HollowShape");
945 // !!!!! to deal with flags without commas
946 if (value.Contains(" ") && !value.Contains(","))
947 value = value.Replace(" ", ", ");
948 shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value);
949 } 937 }
950 938
951 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader) 939 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader)
952 { 940 {
953 shp.SculptTexture = ReadUUID(reader, "SculptTexture"); 941 shp.SculptTexture = Util.ReadUUID(reader, "SculptTexture");
954 } 942 }
955 943
956 private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader) 944 private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1045,17 +1033,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1045 1033
1046 private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader) 1034 private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1047 { 1035 {
1048 shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); 1036 shp.FlexiEntry = Util.ReadBoolean(reader);
1049 } 1037 }
1050 1038
1051 private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader) 1039 private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1052 { 1040 {
1053 shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); 1041 shp.LightEntry = Util.ReadBoolean(reader);
1054 } 1042 }
1055 1043
1056 private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader) 1044 private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1057 { 1045 {
1058 shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty); 1046 shp.SculptEntry = Util.ReadBoolean(reader);
1059 } 1047 }
1060 1048
1061 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader) 1049 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1220,16 +1208,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1220 1208
1221 static void WriteFlags(XmlTextWriter writer, string name, string flagsStr, Dictionary<string, object> options) 1209 static void WriteFlags(XmlTextWriter writer, string name, string flagsStr, Dictionary<string, object> options)
1222 { 1210 {
1223 // Older versions of serialization can't cope with commas 1211 // Older versions of serialization can't cope with commas, so we eliminate the commas
1224 if (options.ContainsKey("version")) 1212 writer.WriteElementString(name, flagsStr.Replace(",", ""));
1225 {
1226 float version = 0.5F;
1227 float.TryParse(options["version"].ToString(), out version);
1228 if (version < 0.5)
1229 flagsStr = flagsStr.Replace(",", "");
1230 }
1231
1232 writer.WriteElementString(name, flagsStr);
1233 } 1213 }
1234 1214
1235 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options, Scene scene) 1215 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options, Scene scene)
@@ -1459,66 +1439,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1459 return obj; 1439 return obj;
1460 } 1440 }
1461 1441
1462 static UUID ReadUUID(XmlTextReader reader, string name)
1463 {
1464 UUID id;
1465 string idStr;
1466
1467 reader.ReadStartElement(name);
1468
1469 if (reader.Name == "Guid")
1470 idStr = reader.ReadElementString("Guid");
1471 else // UUID
1472 idStr = reader.ReadElementString("UUID");
1473
1474 UUID.TryParse(idStr, out id);
1475 reader.ReadEndElement();
1476
1477 return id;
1478 }
1479
1480 static Vector3 ReadVector(XmlTextReader reader, string name)
1481 {
1482 Vector3 vec;
1483
1484 reader.ReadStartElement(name);
1485 vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
1486 vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
1487 vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
1488 reader.ReadEndElement();
1489
1490 return vec;
1491 }
1492
1493 static Quaternion ReadQuaternion(XmlTextReader reader, string name)
1494 {
1495 Quaternion quat = new Quaternion();
1496
1497 reader.ReadStartElement(name);
1498 while (reader.NodeType != XmlNodeType.EndElement)
1499 {
1500 switch (reader.Name.ToLower())
1501 {
1502 case "x":
1503 quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1504 break;
1505 case "y":
1506 quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1507 break;
1508 case "z":
1509 quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1510 break;
1511 case "w":
1512 quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
1513 break;
1514 }
1515 }
1516
1517 reader.ReadEndElement();
1518
1519 return quat;
1520 }
1521
1522 static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) 1442 static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name)
1523 { 1443 {
1524 TaskInventoryDictionary tinv = new TaskInventoryDictionary(); 1444 TaskInventoryDictionary tinv = new TaskInventoryDictionary();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index f57cf98..b84298f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -121,13 +121,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests
121 "Not exactly sure what this is asserting..."); 121 "Not exactly sure what this is asserting...");
122 122
123 // Delink part 2 123 // Delink part 2
124 grp1.DelinkFromGroup(part2.LocalId); 124 SceneObjectGroup grp3 = grp1.DelinkFromGroup(part2.LocalId);
125 125
126 if (debugtest) 126 if (debugtest)
127 m_log.Debug("Group2: Prim2: OffsetPosition:" + part2.AbsolutePosition + ", OffsetRotation:" + part2.RotationOffset); 127 m_log.Debug("Group2: Prim2: OffsetPosition:" + part2.AbsolutePosition + ", OffsetRotation:" + part2.RotationOffset);
128 128
129 Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink."); 129 Assert.That(grp1.Parts.Length, Is.EqualTo(1), "Group 1 still contained part2 after delink.");
130 Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero"); 130 Assert.That(part2.AbsolutePosition == Vector3.Zero, "The absolute position should be zero");
131 Assert.That(grp3.HasGroupChangedDueToDelink, Is.True);
131 } 132 }
132 133
133 [Test] 134 [Test]
@@ -325,7 +326,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
325 326
326 SceneObjectGroup sog = new SceneObjectGroup(rootPart); 327 SceneObjectGroup sog = new SceneObjectGroup(rootPart);
327 sog.AddPart(linkPart); 328 sog.AddPart(linkPart);
328 scene.AddNewSceneObject(sog, true); 329 scene.AddNewSceneObject(sog, true);
329 330
330 // In a test, we have to crank the backup handle manually. Normally this would be done by the timer invoked 331 // In a test, we have to crank the backup handle manually. Normally this would be done by the timer invoked
331 // scene backup thread. 332 // scene backup thread.
@@ -333,7 +334,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
333 334
334 // These changes should occur immediately without waiting for a backup pass 335 // These changes should occur immediately without waiting for a backup pass
335 SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false); 336 SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false);
337
338 Assert.That(groupToDelete.HasGroupChangedDueToDelink, Is.True);
336 scene.DeleteSceneObject(groupToDelete, false); 339 scene.DeleteSceneObject(groupToDelete, false);
340 Assert.That(groupToDelete.HasGroupChangedDueToDelink, Is.False);
337 341
338 List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID); 342 List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID);
339 343
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index aee2d10..3978a7d 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -86,23 +86,33 @@ namespace OpenSim.Region.Framework.Scenes
86 /// <param name="assetUuids">The assets gathered</param> 86 /// <param name="assetUuids">The assets gathered</param>
87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) 87 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids)
88 { 88 {
89 assetUuids[assetUuid] = assetType; 89 try
90 90 {
91 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) 91 assetUuids[assetUuid] = assetType;
92 { 92
93 GetWearableAssetUuids(assetUuid, assetUuids); 93 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType)
94 } 94 {
95 else if (AssetType.Gesture == assetType) 95 GetWearableAssetUuids(assetUuid, assetUuids);
96 { 96 }
97 GetGestureAssetUuids(assetUuid, assetUuids); 97 else if (AssetType.Gesture == assetType)
98 } 98 {
99 else if (AssetType.LSLText == assetType) 99 GetGestureAssetUuids(assetUuid, assetUuids);
100 { 100 }
101 GetScriptAssetUuids(assetUuid, assetUuids); 101 else if (AssetType.LSLText == assetType)
102 {
103 GetScriptAssetUuids(assetUuid, assetUuids);
104 }
105 else if (AssetType.Object == assetType)
106 {
107 GetSceneObjectAssetUuids(assetUuid, assetUuids);
108 }
102 } 109 }
103 else if (AssetType.Object == assetType) 110 catch (Exception)
104 { 111 {
105 GetSceneObjectAssetUuids(assetUuid, assetUuids); 112 m_log.ErrorFormat(
113 "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}",
114 assetUuid, assetType);
115 throw;
106 } 116 }
107 } 117 }
108 118
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index a583cca..e9c5453 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
132 m_FreeswitchService = ServerUtils.LoadPlugin<IFreeswitchService>(serviceDll, args); 132 m_FreeswitchService = ServerUtils.LoadPlugin<IFreeswitchService>(serviceDll, args);
133 133
134 string jsonConfig = m_FreeswitchService.GetJsonConfig(); 134 string jsonConfig = m_FreeswitchService.GetJsonConfig();
135 m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig); 135 //m_log.Debug("[FreeSwitchVoice]: Configuration string: " + jsonConfig);
136 OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig); 136 OSDMap map = (OSDMap)OSDParser.DeserializeJson(jsonConfig);
137 137
138 m_freeSwitchAPIPrefix = map["APIPrefix"].AsString(); 138 m_freeSwitchAPIPrefix = map["APIPrefix"].AsString();
@@ -363,8 +363,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
363 363
364 try 364 try
365 { 365 {
366 m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", 366 //m_log.DebugFormat("[FreeSwitchVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
367 request, path, param); 367 // request, path, param);
368 368
369 //XmlElement resp; 369 //XmlElement resp;
370 string agentname = "x" + Convert.ToBase64String(agentID.GetBytes()); 370 string agentname = "x" + Convert.ToBase64String(agentID.GetBytes());
@@ -445,8 +445,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
445 // voice channel 445 // voice channel
446 LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 446 LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
447 447
448 m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", 448 //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}",
449 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); 449 // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param);
450 450
451 // TODO: EstateSettings don't seem to get propagated... 451 // TODO: EstateSettings don't seem to get propagated...
452 // if (!scene.RegionInfo.EstateSettings.AllowVoice) 452 // if (!scene.RegionInfo.EstateSettings.AllowVoice)
@@ -592,7 +592,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
592 592
593 response["int_response_code"] = 200; 593 response["int_response_code"] = 200;
594 594
595 m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]); 595 //m_log.DebugFormat("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler return {0}",response["str_response_string"]);
596 return response; 596 return response;
597 } 597 }
598 598
@@ -664,7 +664,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
664 response["str_response_string"] = resp.ToString(); 664 response["str_response_string"] = resp.ToString();
665 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 665 Regex normalizeEndLines = new Regex(@"\r\n", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
666 666
667 m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],"")); 667 //m_log.DebugFormat("[FREESWITCH]: {0}", normalizeEndLines.Replace((string)response["str_response_string"],""));
668 return response; 668 return response;
669 } 669 }
670 670
@@ -696,8 +696,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
696 } 696 }
697 } 697 }
698 698
699 m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype, 699 //m_log.DebugFormat("[FreeSwitchVoice]: AUTH, URI: {0}, Content-Type:{1}, Body{2}", uri, contenttype,
700 requestbody); 700 // requestbody);
701 Hashtable response = new Hashtable(); 701 Hashtable response = new Hashtable();
702 response["str_response_string"] = string.Format(@"<response xsi:schemaLocation=""/xsd/signin.xsd""> 702 response["str_response_string"] = string.Format(@"<response xsi:schemaLocation=""/xsd/signin.xsd"">
703 <level0> 703 <level0>
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 0c8113e..ccf5289 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -1173,10 +1173,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1173 presence = scene.GetScenePresence(AgentID); 1173 presence = scene.GetScenePresence(AgentID);
1174 if (presence != null) 1174 if (presence != null)
1175 { 1175 {
1176 presence.Grouptitle = Title; 1176 if (presence.Grouptitle != Title)
1177 {
1178 presence.Grouptitle = Title;
1177 1179
1178 // FixMe: Ter suggests a "Schedule" method that I can't find. 1180 if (! presence.IsChildAgent)
1179 presence.SendFullUpdateToAllClients(); 1181 presence.SendAvatarDataToAllAgents();
1182 }
1180 } 1183 }
1181 } 1184 }
1182 } 1185 }
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
new file mode 100644
index 0000000..7d37135
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
@@ -0,0 +1,86 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using log4net;
31using Mono.Addins;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared
37{
38 /// <summary>
39 /// Simplest possible example of a non-shared region module.
40 /// </summary>
41 /// <remarks>
42 /// This module is the simplest possible example of a non-shared region module (a module where each scene/region
43 /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then
44 /// please create a separate class.
45 ///
46 /// This module is not active by default. If you want to see it in action,
47 /// then just uncomment the line below starting with [Extension(Path...
48 ///
49 /// When the module is enabled it will print messages when it receives certain events to the screen and the log
50 /// file.
51 /// </remarks>
52 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesNonSharedModule")]
53 public class BareBonesNonSharedModule : INonSharedRegionModule
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 public string Name { get { return "Bare Bones Non Shared Module"; } }
58
59 public Type ReplaceableInterface { get { return null; } }
60
61 public void Initialise(IConfigSource source)
62 {
63 m_log.DebugFormat("[BARE BONES NON SHARED]: INITIALIZED MODULE");
64 }
65
66 public void Close()
67 {
68 m_log.DebugFormat("[BARE BONES NON SHARED]: CLOSED MODULE");
69 }
70
71 public void AddRegion(Scene scene)
72 {
73 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName);
74 }
75
76 public void RemoveRegion(Scene scene)
77 {
78 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
79 }
80
81 public void RegionLoaded(Scene scene)
82 {
83 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName);
84 }
85 }
86} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
new file mode 100644
index 0000000..781fe95
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
@@ -0,0 +1,91 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using log4net;
31using Mono.Addins;
32using Nini.Config;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.OptionalModules.Example.BareBonesShared
37{
38 /// <summary>
39 /// Simplest possible example of a shared region module.
40 /// </summary>
41 /// <remarks>
42 /// This module is the simplest possible example of a shared region module (a module which is shared by every
43 /// scene/region running on the simulator). If anybody wants to create a more complex example in the future then
44 /// please create a separate class.
45 ///
46 /// This module is not active by default. If you want to see it in action,
47 /// then just uncomment the line below starting with [Extension(Path...
48 ///
49 /// When the module is enabled it will print messages when it receives certain events to the screen and the log
50 /// file.
51 /// </remarks>
52 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")]
53 public class BareBonesSharedModule : ISharedRegionModule
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 public string Name { get { return "Bare Bones Shared Module"; } }
58
59 public Type ReplaceableInterface { get { return null; } }
60
61 public void Initialise(IConfigSource source)
62 {
63 m_log.DebugFormat("[BARE BONES SHARED]: INITIALIZED MODULE");
64 }
65
66 public void PostInitialise()
67 {
68 m_log.DebugFormat("[BARE BONES SHARED]: POST INITIALIZED MODULE");
69 }
70
71 public void Close()
72 {
73 m_log.DebugFormat("[BARE BONES SHARED]: CLOSED MODULE");
74 }
75
76 public void AddRegion(Scene scene)
77 {
78 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName);
79 }
80
81 public void RemoveRegion(Scene scene)
82 {
83 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
84 }
85
86 public void RegionLoaded(Scene scene)
87 {
88 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName);
89 }
90 }
91} \ No newline at end of file
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index d770ad1..3386e72 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -276,7 +276,7 @@ namespace OpenSim.Region.Physics.Meshing
276 276
277 m_log.Debug("[MESH]: experimental mesh proxy generation"); 277 m_log.Debug("[MESH]: experimental mesh proxy generation");
278 278
279 OSD meshOsd; 279 OSD meshOsd = null;
280 280
281 if (primShape.SculptData.Length <= 0) 281 if (primShape.SculptData.Length <= 0)
282 { 282 {
@@ -287,7 +287,14 @@ namespace OpenSim.Region.Physics.Meshing
287 long start = 0; 287 long start = 0;
288 using (MemoryStream data = new MemoryStream(primShape.SculptData)) 288 using (MemoryStream data = new MemoryStream(primShape.SculptData))
289 { 289 {
290 meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data); 290 try
291 {
292 meshOsd = (OSDMap)OSDParser.DeserializeLLSDBinary(data);
293 }
294 catch (Exception e)
295 {
296 m_log.Error("[MESH]: Exception deserializing mesh asset header:" + e.ToString());
297 }
291 start = data.Position; 298 start = data.Position;
292 } 299 }
293 300
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
index 0c99d8c..8b7871b 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs
@@ -42,7 +42,8 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
42 NewRez = 1, 42 NewRez = 1,
43 PrimCrossing = 2, 43 PrimCrossing = 2,
44 ScriptedRez = 3, 44 ScriptedRez = 3,
45 AttachedRez = 4 45 AttachedRez = 4,
46 Teleporting = 5
46 } 47 }
47 48
48 public interface IScriptWorkItem 49 public interface IScriptWorkItem
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d06b134..3c5f2d0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7759,24 +7759,59 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7759 break; 7759 break;
7760 7760
7761 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 7761 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7762 // TODO--------------
7763 if (remain < 1) 7762 if (remain < 1)
7764 return res; 7763 return res;
7765 7764
7766 face=(int)rules.GetLSLIntegerItem(idx++); 7765 face=(int)rules.GetLSLIntegerItem(idx++);
7767 7766
7768 res.Add(new LSL_Integer(0)); 7767 tex = part.Shape.Textures;
7769 res.Add(new LSL_Integer(0)); 7768 if (face == ScriptBaseClass.ALL_SIDES)
7769 {
7770 for (face = 0; face < GetNumberOfSides(part); face++)
7771 {
7772 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7773 // Convert Shininess to PRIM_SHINY_*
7774 res.Add(new LSL_Integer((uint)texface.Shiny >> 6));
7775 // PRIM_BUMP_*
7776 res.Add(new LSL_Integer((int)texface.Bump));
7777 }
7778 }
7779 else
7780 {
7781 if (face >= 0 && face < GetNumberOfSides(part))
7782 {
7783 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7784 // Convert Shininess to PRIM_SHINY_*
7785 res.Add(new LSL_Integer((uint)texface.Shiny >> 6));
7786 // PRIM_BUMP_*
7787 res.Add(new LSL_Integer((int)texface.Bump));
7788 }
7789 }
7770 break; 7790 break;
7771 7791
7772 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 7792 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7773 // TODO--------------
7774 if (remain < 1) 7793 if (remain < 1)
7775 return res; 7794 return res;
7776 7795
7777 face=(int)rules.GetLSLIntegerItem(idx++); 7796 face=(int)rules.GetLSLIntegerItem(idx++);
7778 7797
7779 res.Add(new LSL_Integer(0)); 7798 tex = part.Shape.Textures;
7799 if (face == ScriptBaseClass.ALL_SIDES)
7800 {
7801 for (face = 0; face < GetNumberOfSides(part); face++)
7802 {
7803 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7804 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0));
7805 }
7806 }
7807 else
7808 {
7809 if (face >= 0 && face < GetNumberOfSides(part))
7810 {
7811 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7812 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0));
7813 }
7814 }
7780 break; 7815 break;
7781 7816
7782 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 7817 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
@@ -7797,14 +7832,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7797 break; 7832 break;
7798 7833
7799 case (int)ScriptBaseClass.PRIM_TEXGEN: 7834 case (int)ScriptBaseClass.PRIM_TEXGEN:
7800 // TODO--------------
7801 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7802 if (remain < 1) 7835 if (remain < 1)
7803 return res; 7836 return res;
7804 7837
7805 face=(int)rules.GetLSLIntegerItem(idx++); 7838 face=(int)rules.GetLSLIntegerItem(idx++);
7806 7839
7807 res.Add(new LSL_Integer(0)); 7840 tex = part.Shape.Textures;
7841 if (face == ScriptBaseClass.ALL_SIDES)
7842 {
7843 for (face = 0; face < GetNumberOfSides(part); face++)
7844 {
7845 MappingType texgen = tex.GetFace((uint)face).TexMapType;
7846 // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc.
7847 res.Add(new LSL_Integer((uint)texgen >> 1));
7848 }
7849 }
7850 else
7851 {
7852 if (face >= 0 && face < GetNumberOfSides(part))
7853 {
7854 MappingType texgen = tex.GetFace((uint)face).TexMapType;
7855 res.Add(new LSL_Integer((uint)texgen >> 1));
7856 }
7857 }
7808 break; 7858 break;
7809 7859
7810 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 7860 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
@@ -7823,14 +7873,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7823 break; 7873 break;
7824 7874
7825 case (int)ScriptBaseClass.PRIM_GLOW: 7875 case (int)ScriptBaseClass.PRIM_GLOW:
7826 // TODO--------------
7827 if (remain < 1) 7876 if (remain < 1)
7828 return res; 7877 return res;
7829 7878
7830 face=(int)rules.GetLSLIntegerItem(idx++); 7879 face=(int)rules.GetLSLIntegerItem(idx++);
7831 7880
7832 res.Add(new LSL_Float(0)); 7881 tex = part.Shape.Textures;
7882 if (face == ScriptBaseClass.ALL_SIDES)
7883 {
7884 for (face = 0; face < GetNumberOfSides(part); face++)
7885 {
7886 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7887 res.Add(new LSL_Float(texface.Glow));
7888 }
7889 }
7890 else
7891 {
7892 if (face >= 0 && face < GetNumberOfSides(part))
7893 {
7894 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7895 res.Add(new LSL_Float(texface.Glow));
7896 }
7897 }
7833 break; 7898 break;
7899
7834 case (int)ScriptBaseClass.PRIM_TEXT: 7900 case (int)ScriptBaseClass.PRIM_TEXT:
7835 Color4 textColor = part.GetTextColor(); 7901 Color4 textColor = part.GetTextColor();
7836 res.Add(part.Text); 7902 res.Add(part.Text);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index fc92f23..827626f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -395,10 +395,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
395 // 395 //
396 CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); 396 CheckThreatLevel(ThreatLevel.High, "osRegionRestart");
397 397
398 IRestartModule restartModule = World.RequestModuleInterface<IRestartModule>();
398 m_host.AddScriptLPS(1); 399 m_host.AddScriptLPS(1);
399 if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false)) 400 if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null))
400 { 401 {
401 World.Restart((float)seconds); 402 if (seconds < 15)
403 {
404 restartModule.AbortRestart("Restart aborted");
405 return 1;
406 }
407
408 List<int> times = new List<int>();
409 while (seconds > 0)
410 {
411 times.Add((int)seconds);
412 if (seconds > 300)
413 seconds -= 120;
414 else if (seconds > 30)
415 seconds -= 30;
416 else
417 seconds -= 15;
418 }
419
420 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
402 return 1; 421 return 1;
403 } 422 }
404 else 423 else
@@ -2315,4 +2334,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2315 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); 2334 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
2316 } 2335 }
2317 } 2336 }
2318} \ No newline at end of file 2337}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 660e9a3..8e712b6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -390,19 +390,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
390 } 390 }
391 else if (m_stateSource == StateSource.RegionStart) 391 else if (m_stateSource == StateSource.RegionStart)
392 { 392 {
393// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); 393 //m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
394 PostEvent(new EventParams("changed", 394 PostEvent(new EventParams("changed",
395 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, 395 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, new DetectParams[0]));
396 new DetectParams[0]));
397 } 396 }
398 else if (m_stateSource == StateSource.PrimCrossing) 397 else if (m_stateSource == StateSource.PrimCrossing || m_stateSource == StateSource.Teleporting)
399 { 398 {
400 // CHANGED_REGION 399 // CHANGED_REGION
401 PostEvent(new EventParams("changed", 400 PostEvent(new EventParams("changed",
402 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, 401 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, new DetectParams[0]));
403 new DetectParams[0])); 402
403 // CHANGED_TELEPORT
404 if (m_stateSource == StateSource.Teleporting)
405 PostEvent(new EventParams("changed",
406 new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0]));
404 } 407 }
405 } 408 }
406 else 409 else
407 { 410 {
408 Start(); 411 Start();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index dfc9aa3..1d55b95 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
47 { 47 {
48 48
49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; 49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
50 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
50 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
51 52
52 [SetUp] 53 [SetUp]
@@ -164,5 +165,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
164 Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail"); 165 Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail");
165 Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail"); 166 Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail");
166 } 167 }
168
169 [Test]
170 // llVecNorm test.
171 public void TestllVecNorm()
172 {
173 // Check special case for normalizing zero vector.
174 CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d));
175 // Check various vectors.
176 CheckllVecNorm(new LSL_Types.Vector3(10.0d, 25.0d, 0.0d), new LSL_Types.Vector3(0.371391d, 0.928477d, 0.0d));
177 CheckllVecNorm(new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), new LSL_Types.Vector3(1.0d, 0.0d, 0.0d));
178 CheckllVecNorm(new LSL_Types.Vector3(-90.0d, 55.0d, 2.0d), new LSL_Types.Vector3(-0.853128d, 0.521356d, 0.018958d));
179 CheckllVecNorm(new LSL_Types.Vector3(255.0d, 255.0d, 255.0d), new LSL_Types.Vector3(0.577350d, 0.577350d, 0.577350d));
180 }
181
182 public void CheckllVecNorm(LSL_Types.Vector3 vec, LSL_Types.Vector3 vecNormCheck)
183 {
184 // Call LSL function to normalize the vector.
185 LSL_Types.Vector3 vecNorm = m_lslApi.llVecNorm(vec);
186 // Check each vector component against expected result.
187 Assert.AreEqual(vecNorm.x, vecNormCheck.x, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on x component");
188 Assert.AreEqual(vecNorm.y, vecNormCheck.y, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on y component");
189 Assert.AreEqual(vecNorm.z, vecNormCheck.z, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on z component");
190 }
167 } 191 }
168} 192}
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index b6425f4..df571fa 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -53,12 +53,15 @@ namespace OpenSim.Server.Handlers.Asset
53 String.Empty); 53 String.Empty);
54 54
55 if (assetService == String.Empty) 55 if (assetService == String.Empty)
56 throw new Exception("No AssetService in config file"); 56 throw new Exception("No LocalServiceModule in config file");
57 57
58 Object[] args = new Object[] { config }; 58 Object[] args = new Object[] { config };
59 m_AssetService = 59 m_AssetService =
60 ServerUtils.LoadPlugin<IAssetService>(assetService, args); 60 ServerUtils.LoadPlugin<IAssetService>(assetService, args);
61 61
62 if (m_AssetService == null)
63 throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
64
62 bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); 65 bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false);
63 66
64 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); 67 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService));
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 22a718a..00f035c 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -153,7 +153,7 @@ namespace OpenSim.Server.Handlers.Asset
153 } 153 }
154 catch (Exception e) 154 catch (Exception e)
155 { 155 {
156 m_log.Debug("[XINVENTORY HANDLER]: Exception {0}", e); 156 m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e);
157 } 157 }
158 158
159 return FailureResult(); 159 return FailureResult();
@@ -604,6 +604,10 @@ namespace OpenSim.Server.Handlers.Asset
604 ret["CreatorId"] = item.CreatorId.ToString(); 604 ret["CreatorId"] = item.CreatorId.ToString();
605 else 605 else
606 ret["CreatorId"] = String.Empty; 606 ret["CreatorId"] = String.Empty;
607 if (item.CreatorData != null)
608 ret["CreatorData"] = item.CreatorData;
609 else
610 ret["CreatorData"] = String.Empty;
607 ret["CurrentPermissions"] = item.CurrentPermissions.ToString(); 611 ret["CurrentPermissions"] = item.CurrentPermissions.ToString();
608 ret["Description"] = item.Description.ToString(); 612 ret["Description"] = item.Description.ToString();
609 ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString(); 613 ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString();
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 470a4dd..3fd2fcf 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -43,44 +43,51 @@ namespace OpenSim.Services.AssetService
43 LogManager.GetLogger( 43 LogManager.GetLogger(
44 MethodBase.GetCurrentMethod().DeclaringType); 44 MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 protected static AssetService m_RootInstance;
47
46 public AssetService(IConfigSource config) : base(config) 48 public AssetService(IConfigSource config) : base(config)
47 { 49 {
48 MainConsole.Instance.Commands.AddCommand("kfs", false, 50 if (m_RootInstance == null)
49 "show digest",
50 "show digest <ID>",
51 "Show asset digest", HandleShowDigest);
52
53 MainConsole.Instance.Commands.AddCommand("kfs", false,
54 "delete asset",
55 "delete asset <ID>",
56 "Delete asset from database", HandleDeleteAsset);
57
58 if (m_AssetLoader != null)
59 { 51 {
60 IConfig assetConfig = config.Configs["AssetService"]; 52 m_RootInstance = this;
61 if (assetConfig == null)
62 throw new Exception("No AssetService configuration");
63 53
64 string loaderArgs = assetConfig.GetString("AssetLoaderArgs", 54 MainConsole.Instance.Commands.AddCommand("kfs", false,
65 String.Empty); 55 "show digest",
56 "show digest <ID>",
57 "Show asset digest", HandleShowDigest);
66 58
67 bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); 59 MainConsole.Instance.Commands.AddCommand("kfs", false,
60 "delete asset",
61 "delete asset <ID>",
62 "Delete asset from database", HandleDeleteAsset);
68 63
69 if (assetLoaderEnabled) 64 if (m_AssetLoader != null)
70 { 65 {
71 m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); 66 IConfig assetConfig = config.Configs["AssetService"];
72 m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, 67 if (assetConfig == null)
73 delegate(AssetBase a) 68 throw new Exception("No AssetService configuration");
74 { 69
75 Store(a); 70 string loaderArgs = assetConfig.GetString("AssetLoaderArgs",
76 }); 71 String.Empty);
72
73 bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
74
75 if (assetLoaderEnabled)
76 {
77 m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs);
78 m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs,
79 delegate(AssetBase a)
80 {
81 Store(a);
82 });
83 }
84
85 m_log.Info("[ASSET SERVICE]: Local asset service enabled");
77 } 86 }
78
79 m_log.Info("[ASSET SERVICE]: Local asset service enabled");
80 } 87 }
81 } 88 }
82 89
83 public AssetBase Get(string id) 90 public virtual AssetBase Get(string id)
84 { 91 {
85 UUID assetID; 92 UUID assetID;
86 93
@@ -93,12 +100,12 @@ namespace OpenSim.Services.AssetService
93 return m_Database.GetAsset(assetID); 100 return m_Database.GetAsset(assetID);
94 } 101 }
95 102
96 public AssetBase GetCached(string id) 103 public virtual AssetBase GetCached(string id)
97 { 104 {
98 return Get(id); 105 return Get(id);
99 } 106 }
100 107
101 public AssetMetadata GetMetadata(string id) 108 public virtual AssetMetadata GetMetadata(string id)
102 { 109 {
103 UUID assetID; 110 UUID assetID;
104 111
@@ -112,7 +119,7 @@ namespace OpenSim.Services.AssetService
112 return null; 119 return null;
113 } 120 }
114 121
115 public byte[] GetData(string id) 122 public virtual byte[] GetData(string id)
116 { 123 {
117 UUID assetID; 124 UUID assetID;
118 125
@@ -123,7 +130,7 @@ namespace OpenSim.Services.AssetService
123 return asset.Data; 130 return asset.Data;
124 } 131 }
125 132
126 public bool Get(string id, Object sender, AssetRetrieved handler) 133 public virtual bool Get(string id, Object sender, AssetRetrieved handler)
127 { 134 {
128 //m_log.DebugFormat("[AssetService]: Get asset async {0}", id); 135 //m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
129 136
@@ -141,7 +148,7 @@ namespace OpenSim.Services.AssetService
141 return true; 148 return true;
142 } 149 }
143 150
144 public string Store(AssetBase asset) 151 public virtual string Store(AssetBase asset)
145 { 152 {
146 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); 153 //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
147 m_Database.StoreAsset(asset); 154 m_Database.StoreAsset(asset);
@@ -154,7 +161,7 @@ namespace OpenSim.Services.AssetService
154 return false; 161 return false;
155 } 162 }
156 163
157 public bool Delete(string id) 164 public virtual bool Delete(string id)
158 { 165 {
159 m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id); 166 m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
160 UUID assetID; 167 UUID assetID;
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 9e96163..10e3aee 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -333,7 +333,8 @@ namespace OpenSim.Services.HypergridService
333 333
334 string addressee = parts[0]; 334 string addressee = parts[0];
335 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, m_ExternalName); 335 m_log.DebugFormat("[GATEKEEPER SERVICE]: Verifying {0} against {1}", addressee, m_ExternalName);
336 return (addressee == m_ExternalName); 336
337 return string.Equals(addressee, m_ExternalName, StringComparison.OrdinalIgnoreCase);
337 } 338 }
338 339
339 #endregion 340 #endregion
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
new file mode 100644
index 0000000..a82d0d1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31using System.Xml;
32
33using Nini.Config;
34using log4net;
35using OpenMetaverse;
36
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
41using OpenSim.Services.AssetService;
42
43namespace OpenSim.Services.HypergridService
44{
45 /// <summary>
46 /// Hypergrid asset service. It serves the IAssetService interface,
47 /// but implements it in ways that are appropriate for inter-grid
48 /// asset exchanges.
49 /// </summary>
50 public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService
51 {
52 private static readonly ILog m_log =
53 LogManager.GetLogger(
54 MethodBase.GetCurrentMethod().DeclaringType);
55
56 private string m_ProfileServiceURL;
57 private IUserAccountService m_UserAccountService;
58
59 private UserAccountCache m_Cache;
60
61 public HGAssetService(IConfigSource config) : base(config)
62 {
63 m_log.Debug("[HGAsset Service]: Starting");
64 IConfig assetConfig = config.Configs["HGAssetService"];
65 if (assetConfig == null)
66 throw new Exception("No HGAssetService configuration");
67
68 string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty);
69 if (userAccountsDll == string.Empty)
70 throw new Exception("Please specify UserAccountsService in HGAssetService configuration");
71
72 Object[] args = new Object[] { config };
73 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
74 if (m_UserAccountService == null)
75 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
76
77 m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty);
78
79 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
80 }
81
82 #region IAssetService overrides
83 public override AssetBase Get(string id)
84 {
85 AssetBase asset = base.Get(id);
86
87 if (asset == null)
88 return null;
89
90 if (asset.Metadata.Type == (sbyte)AssetType.Object)
91 asset.Data = AdjustIdentifiers(asset.Data); ;
92
93 AdjustIdentifiers(asset.Metadata);
94
95 return asset;
96 }
97
98 public override AssetMetadata GetMetadata(string id)
99 {
100 AssetMetadata meta = base.GetMetadata(id);
101
102 if (meta == null)
103 return null;
104
105 AdjustIdentifiers(meta);
106
107 return meta;
108 }
109
110 public override byte[] GetData(string id)
111 {
112 byte[] data = base.GetData(id);
113
114 if (data == null)
115 return null;
116
117 return AdjustIdentifiers(data);
118 }
119
120 //public virtual bool Get(string id, Object sender, AssetRetrieved handler)
121
122 public override bool Delete(string id)
123 {
124 // NOGO
125 return false;
126 }
127
128 #endregion
129
130 protected void AdjustIdentifiers(AssetMetadata meta)
131 {
132 UserAccount creator = m_Cache.GetUser(meta.CreatorID);
133 if (creator != null)
134 meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName;
135 }
136
137 protected byte[] AdjustIdentifiers(byte[] data)
138 {
139 string xml = Utils.BytesToString(data);
140 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero));
141 }
142
143 }
144
145}
diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs
index d62c008..9ee1ae4 100644
--- a/OpenSim/Services/InventoryService/HGInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGInventoryService.cs
@@ -33,11 +33,20 @@ using Nini.Config;
33using System.Reflection; 33using System.Reflection;
34using OpenSim.Services.Base; 34using OpenSim.Services.Base;
35using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
36using OpenSim.Services.InventoryService;
36using OpenSim.Data; 37using OpenSim.Data;
37using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Server.Base;
38 40
39namespace OpenSim.Services.InventoryService 41namespace OpenSim.Services.HypergridService
40{ 42{
43 /// <summary>
44 /// Hypergrid inventory service. It serves the IInventoryService interface,
45 /// but implements it in ways that are appropriate for inter-grid
46 /// inventory exchanges. Specifically, it does not performs deletions
47 /// and it responds to GetRootFolder requests with the ID of the
48 /// Suitcase folder, not the actual "My Inventory" folder.
49 /// </summary>
41 public class HGInventoryService : XInventoryService, IInventoryService 50 public class HGInventoryService : XInventoryService, IInventoryService
42 { 51 {
43 private static readonly ILog m_log = 52 private static readonly ILog m_log =
@@ -46,9 +55,16 @@ namespace OpenSim.Services.InventoryService
46 55
47 protected new IXInventoryData m_Database; 56 protected new IXInventoryData m_Database;
48 57
58 private string m_ProfileServiceURL;
59 private IUserAccountService m_UserAccountService;
60
61 private UserAccountCache m_Cache;
62
49 public HGInventoryService(IConfigSource config) 63 public HGInventoryService(IConfigSource config)
50 : base(config) 64 : base(config)
51 { 65 {
66 m_log.Debug("[HGInventory Service]: Starting");
67
52 string dllName = String.Empty; 68 string dllName = String.Empty;
53 string connString = String.Empty; 69 string connString = String.Empty;
54 //string realm = "Inventory"; // OSG version doesn't use this 70 //string realm = "Inventory"; // OSG version doesn't use this
@@ -68,12 +84,25 @@ namespace OpenSim.Services.InventoryService
68 // 84 //
69 // Try reading the [InventoryService] section, if it exists 85 // Try reading the [InventoryService] section, if it exists
70 // 86 //
71 IConfig authConfig = config.Configs["InventoryService"]; 87 IConfig invConfig = config.Configs["HGInventoryService"];
72 if (authConfig != null) 88 if (invConfig != null)
73 { 89 {
74 dllName = authConfig.GetString("StorageProvider", dllName); 90 dllName = invConfig.GetString("StorageProvider", dllName);
75 connString = authConfig.GetString("ConnectionString", connString); 91 connString = invConfig.GetString("ConnectionString", connString);
92
76 // realm = authConfig.GetString("Realm", realm); 93 // realm = authConfig.GetString("Realm", realm);
94 string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
95 if (userAccountsDll == string.Empty)
96 throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
97
98 Object[] args = new Object[] { config };
99 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
100 if (m_UserAccountService == null)
101 throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
102
103 m_ProfileServiceURL = invConfig.GetString("ProfileServerURI", string.Empty);
104
105 m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
77 } 106 }
78 107
79 // 108 //
@@ -282,9 +311,18 @@ namespace OpenSim.Services.InventoryService
282 //{ 311 //{
283 //} 312 //}
284 313
285 //public InventoryItemBase GetItem(InventoryItemBase item) 314 public override InventoryItemBase GetItem(InventoryItemBase item)
286 //{ 315 {
287 //} 316 InventoryItemBase it = base.GetItem(item);
317
318 UserAccount user = m_Cache.GetUser(it.CreatorId);
319
320 // Adjust the creator data
321 if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty))
322 it.CreatorData = m_ProfileServiceURL + "/" + it.CreatorId + ";" + user.FirstName + " " + user.LastName;
323
324 return it;
325 }
288 326
289 //public InventoryFolderBase GetFolder(InventoryFolderBase folder) 327 //public InventoryFolderBase GetFolder(InventoryFolderBase folder)
290 //{ 328 //{
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
new file mode 100644
index 0000000..3e9aea1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -0,0 +1,105 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using log4net;
6using OpenMetaverse;
7
8using OpenSim.Services.Interfaces;
9
10namespace OpenSim.Services.HypergridService
11{
12 public class UserAccountCache : IUserAccountService
13 {
14 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
15
16 private static readonly ILog m_log =
17 LogManager.GetLogger(
18 MethodBase.GetCurrentMethod().DeclaringType);
19 private ExpiringCache<UUID, UserAccount> m_UUIDCache;
20
21 private IUserAccountService m_UserAccountService;
22
23 private static UserAccountCache m_Singleton;
24
25 public static UserAccountCache CreateUserAccountCache(IUserAccountService u)
26 {
27 if (m_Singleton == null)
28 m_Singleton = new UserAccountCache(u);
29
30 return m_Singleton;
31 }
32
33 private UserAccountCache(IUserAccountService u)
34 {
35 m_UUIDCache = new ExpiringCache<UUID, UserAccount>();
36 m_UserAccountService = u;
37 }
38
39 public void Cache(UUID userID, UserAccount account)
40 {
41 // Cache even null accounts
42 m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
43
44 //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
45 }
46
47 public UserAccount Get(UUID userID, out bool inCache)
48 {
49 UserAccount account = null;
50 inCache = false;
51 if (m_UUIDCache.TryGetValue(userID, out account))
52 {
53 //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
54 inCache = true;
55 return account;
56 }
57
58 return null;
59 }
60
61 public UserAccount GetUser(string id)
62 {
63 UUID uuid = UUID.Zero;
64 UUID.TryParse(id, out uuid);
65 bool inCache = false;
66 UserAccount account = Get(uuid, out inCache);
67 if (!inCache)
68 {
69 account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid);
70 Cache(uuid, account);
71 }
72
73 return account;
74 }
75
76 #region IUserAccountService
77 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
78 {
79 return GetUser(userID.ToString());
80 }
81
82 public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
83 {
84 return null;
85 }
86
87 public UserAccount GetUserAccount(UUID scopeID, string Email)
88 {
89 return null;
90 }
91
92 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
93 {
94 return null;
95 }
96
97 public bool StoreUserAccount(UserAccount data)
98 {
99 return false;
100 }
101 #endregion
102
103 }
104
105}
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index e2d1f04..efc0568 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -761,6 +761,7 @@ namespace OpenSim.Services.LLLoginService
761 if (account.ServiceURLs == null) 761 if (account.ServiceURLs == null)
762 return; 762 return;
763 763
764 // Old style: get the service keys from the DB
764 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) 765 foreach (KeyValuePair<string, object> kvp in account.ServiceURLs)
765 { 766 {
766 if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty)) 767 if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty))
@@ -772,6 +773,21 @@ namespace OpenSim.Services.LLLoginService
772 aCircuit.ServiceURLs[kvp.Key] = kvp.Value; 773 aCircuit.ServiceURLs[kvp.Key] = kvp.Value;
773 } 774 }
774 } 775 }
776
777 // New style: service keys start with SRV_; override the previous
778 string[] keys = m_LoginServerConfig.GetKeys();
779
780 if (keys.Length > 0)
781 {
782 IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_"));
783 foreach (string serviceKey in serviceKeys)
784 {
785 string keyName = serviceKey.Replace("SRV_", "");
786 aCircuit.ServiceURLs[keyName] = m_LoginServerConfig.GetString(serviceKey, string.Empty);
787 m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]);
788 }
789 }
790
775 } 791 }
776 792
777 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason) 793 private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason)