diff options
author | Melanie | 2010-10-23 00:21:42 +0100 |
---|---|---|
committer | Melanie | 2010-10-23 00:21:42 +0100 |
commit | 7f74dc1b14d3ef31a9f20bb3a76ef8d587779f7e (patch) | |
tree | 73f156f1f7dc7d199a946d351828c7e725ebfbda /OpenSim/Region/CoreModules/Avatar | |
parent | Change some exception to use ToString(). e.Message is not sufficient to fix (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-7f74dc1b14d3ef31a9f20bb3a76ef8d587779f7e.zip opensim-SC-7f74dc1b14d3ef31a9f20bb3a76ef8d587779f7e.tar.gz opensim-SC-7f74dc1b14d3ef31a9f20bb3a76ef8d587779f7e.tar.bz2 opensim-SC-7f74dc1b14d3ef31a9f20bb3a76ef8d587779f7e.tar.xz |
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
4 files changed, 86 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 2a590f1..8ab4391 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
169 | // sanity check: | 169 | // sanity check: |
170 | if (c.Sender == null) | 170 | if (c.Sender == null) |
171 | { | 171 | { |
172 | m_log.ErrorFormat("[CHAT] OnChatFromClient from {0} has empty Sender field!", sender); | 172 | m_log.ErrorFormat("[CHAT]: OnChatFromClient from {0} has empty Sender field!", sender); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | 175 | ||
@@ -234,8 +234,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
234 | if (message.Length >= 1000) // libomv limit | 234 | if (message.Length >= 1000) // libomv limit |
235 | message = message.Substring(0, 1000); | 235 | message = message.Substring(0, 1000); |
236 | 236 | ||
237 | // m_log.DebugFormat("[CHAT]: DCTA: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, c.Type, sourceType); | 237 | // m_log.DebugFormat( |
238 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", | ||
239 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); | ||
238 | 240 | ||
241 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | ||
242 | |||
239 | foreach (Scene s in m_scenes) | 243 | foreach (Scene s in m_scenes) |
240 | { | 244 | { |
241 | s.ForEachScenePresence( | 245 | s.ForEachScenePresence( |
@@ -250,13 +254,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
250 | // objects on a parcel with access restrictions | 254 | // objects on a parcel with access restrictions |
251 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | 255 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) |
252 | { | 256 | { |
253 | TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType); | 257 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) |
258 | receiverIDs.Add(presence.UUID); | ||
254 | } | 259 | } |
255 | } | 260 | } |
256 | 261 | ||
257 | } | 262 | } |
258 | ); | 263 | ); |
259 | } | 264 | } |
265 | |||
266 | (scene as Scene).EventManager.TriggerOnChatToClients( | ||
267 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | ||
260 | } | 268 | } |
261 | 269 | ||
262 | static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); | 270 | static private Vector3 CenterOfRegion = new Vector3(128, 128, 30); |
@@ -294,6 +302,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
294 | } | 302 | } |
295 | 303 | ||
296 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 304 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
305 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | ||
306 | |||
297 | if (c.Scene != null) | 307 | if (c.Scene != null) |
298 | { | 308 | { |
299 | ((Scene)c.Scene).ForEachScenePresence | 309 | ((Scene)c.Scene).ForEachScenePresence |
@@ -314,18 +324,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
314 | 324 | ||
315 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 325 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
316 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 326 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
327 | receiverIDs.Add(presence.UUID); | ||
317 | } | 328 | } |
318 | ); | 329 | ); |
330 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | ||
331 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
319 | } | 332 | } |
320 | } | 333 | } |
321 | 334 | ||
322 | 335 | /// <summary> | |
323 | protected virtual void TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 336 | /// Try to send a message to the given presence |
337 | /// </summary> | ||
338 | /// <param name="presence">The receiver</param> | ||
339 | /// <param name="fromPos"></param> | ||
340 | /// <param name="regionPos">/param> | ||
341 | /// <param name="fromAgentID"></param> | ||
342 | /// <param name="fromName"></param> | ||
343 | /// <param name="type"></param> | ||
344 | /// <param name="message"></param> | ||
345 | /// <param name="src"></param> | ||
346 | /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a | ||
347 | /// precondition</returns> | ||
348 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | ||
324 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 349 | UUID fromAgentID, string fromName, ChatTypeEnum type, |
325 | string message, ChatSourceType src) | 350 | string message, ChatSourceType src) |
326 | { | 351 | { |
327 | // don't send stuff to child agents | 352 | // don't send stuff to child agents |
328 | if (presence.IsChildAgent) return; | 353 | if (presence.IsChildAgent) return false; |
329 | 354 | ||
330 | Vector3 fromRegionPos = fromPos + regionPos; | 355 | Vector3 fromRegionPos = fromPos + regionPos; |
331 | Vector3 toRegionPos = presence.AbsolutePosition + | 356 | Vector3 toRegionPos = presence.AbsolutePosition + |
@@ -338,12 +363,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
338 | type == ChatTypeEnum.Say && dis > m_saydistance || | 363 | type == ChatTypeEnum.Say && dis > m_saydistance || |
339 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | 364 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) |
340 | { | 365 | { |
341 | return; | 366 | return false; |
342 | } | 367 | } |
343 | 368 | ||
344 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 369 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
345 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, | 370 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, |
346 | fromAgentID,(byte)src,(byte)ChatAudibleLevel.Fully); | 371 | fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully); |
372 | |||
373 | return true; | ||
347 | } | 374 | } |
348 | 375 | ||
349 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | 376 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 80adc46..d8e0f96 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -598,7 +598,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
598 | try | 598 | try |
599 | { | 599 | { |
600 | 600 | ||
601 | XmlRpcResponse GridResp = GridReq.Send(reginfo.ServerURI, 3000); | 601 | XmlRpcResponse GridResp = GridReq.Send("http://" + reginfo.ExternalHostName + ":" + reginfo.HttpPort, 3000); |
602 | 602 | ||
603 | Hashtable responseData = (Hashtable)GridResp.Value; | 603 | Hashtable responseData = (Hashtable)GridResp.Value; |
604 | 604 | ||
@@ -620,8 +620,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
620 | } | 620 | } |
621 | catch (WebException e) | 621 | catch (WebException e) |
622 | { | 622 | { |
623 | m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to {0}} the host didn't respond ({2})", | 623 | m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Error sending message to http://{0}:{1} the host didn't respond ({2})", |
624 | reginfo.ServerURI, e.Message); | 624 | reginfo.ExternalHostName, reginfo.HttpPort, e.Message); |
625 | } | 625 | } |
626 | 626 | ||
627 | return false; | 627 | return false; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index c1df827..5500557 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -33,6 +33,7 @@ using System.Reflection; | |||
33 | using System.Threading; | 33 | using System.Threading; |
34 | using System.Text; | 34 | using System.Text; |
35 | using System.Xml; | 35 | using System.Xml; |
36 | using System.Xml.Linq; | ||
36 | using log4net; | 37 | using log4net; |
37 | using OpenMetaverse; | 38 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
@@ -50,6 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
50 | { | 51 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | 53 | ||
54 | /// <summary> | ||
55 | /// The maximum major version of archive that we can read. Minor versions shouldn't need a max number since version | ||
56 | /// bumps here should be compatible. | ||
57 | /// </summary> | ||
58 | public static int MAX_MAJOR_VERSION = 0; | ||
59 | |||
53 | protected TarArchiveReader archive; | 60 | protected TarArchiveReader archive; |
54 | 61 | ||
55 | private UserAccount m_userInfo; | 62 | private UserAccount m_userInfo; |
@@ -133,7 +140,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
133 | 140 | ||
134 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | 141 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) |
135 | { | 142 | { |
136 | if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | 143 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) |
144 | { | ||
145 | LoadControlFile(filePath, data); | ||
146 | } | ||
147 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | ||
137 | { | 148 | { |
138 | if (LoadAsset(filePath, data)) | 149 | if (LoadAsset(filePath, data)) |
139 | successfulAssetRestores++; | 150 | successfulAssetRestores++; |
@@ -461,5 +472,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
461 | return false; | 472 | return false; |
462 | } | 473 | } |
463 | } | 474 | } |
475 | |||
476 | /// <summary> | ||
477 | /// Load control file | ||
478 | /// </summary> | ||
479 | /// <param name="path"></param> | ||
480 | /// <param name="data"></param> | ||
481 | protected void LoadControlFile(string path, byte[] data) | ||
482 | { | ||
483 | XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data)); | ||
484 | XElement archiveElement = doc.Element("archive"); | ||
485 | int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value); | ||
486 | int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value); | ||
487 | string version = string.Format("{0}.{1}", majorVersion, minorVersion); | ||
488 | |||
489 | if (majorVersion > MAX_MAJOR_VERSION) | ||
490 | { | ||
491 | throw new Exception( | ||
492 | string.Format( | ||
493 | "The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below", | ||
494 | majorVersion, MAX_MAJOR_VERSION)); | ||
495 | } | ||
496 | |||
497 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version); | ||
498 | } | ||
464 | } | 499 | } |
465 | } \ No newline at end of file | 500 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index bae5a7a..249a8b4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -123,9 +123,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
123 | 123 | ||
124 | try | 124 | try |
125 | { | 125 | { |
126 | // We're almost done. Just need to write out the control file now | ||
127 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); | ||
128 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
129 | m_archiveWriter.Close(); | 126 | m_archiveWriter.Close(); |
130 | } | 127 | } |
131 | catch (Exception e) | 128 | catch (Exception e) |
@@ -216,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
216 | public void Execute() | 213 | public void Execute() |
217 | { | 214 | { |
218 | try | 215 | try |
219 | { | 216 | { |
220 | InventoryFolderBase inventoryFolder = null; | 217 | InventoryFolderBase inventoryFolder = null; |
221 | InventoryItemBase inventoryItem = null; | 218 | InventoryItemBase inventoryItem = null; |
222 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); | 219 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID); |
@@ -277,6 +274,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
277 | 274 | ||
278 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 275 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
279 | 276 | ||
277 | // Write out control file. This has to be done first so that subsequent loaders will see this file first | ||
278 | // XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this | ||
279 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); | ||
280 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive."); | ||
281 | |||
280 | if (inventoryFolder != null) | 282 | if (inventoryFolder != null) |
281 | { | 283 | { |
282 | m_log.DebugFormat( | 284 | m_log.DebugFormat( |
@@ -399,13 +401,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
399 | /// <returns></returns> | 401 | /// <returns></returns> |
400 | public static string Create0p1ControlFile() | 402 | public static string Create0p1ControlFile() |
401 | { | 403 | { |
404 | int majorVersion = 0, minorVersion = 1; | ||
405 | |||
406 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Creating version {0}.{1} IAR", majorVersion, minorVersion); | ||
407 | |||
402 | StringWriter sw = new StringWriter(); | 408 | StringWriter sw = new StringWriter(); |
403 | XmlTextWriter xtw = new XmlTextWriter(sw); | 409 | XmlTextWriter xtw = new XmlTextWriter(sw); |
404 | xtw.Formatting = Formatting.Indented; | 410 | xtw.Formatting = Formatting.Indented; |
405 | xtw.WriteStartDocument(); | 411 | xtw.WriteStartDocument(); |
406 | xtw.WriteStartElement("archive"); | 412 | xtw.WriteStartElement("archive"); |
407 | xtw.WriteAttributeString("major_version", "0"); | 413 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); |
408 | xtw.WriteAttributeString("minor_version", "1"); | 414 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); |
409 | xtw.WriteEndElement(); | 415 | xtw.WriteEndElement(); |
410 | 416 | ||
411 | xtw.Flush(); | 417 | xtw.Flush(); |