yeack, better not break other notecards HG; improve TestNotecardAsset()
parent
c245ce3c25
commit
43fea6530f
|
@ -29,7 +29,6 @@ using OpenMetaverse;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
|
@ -874,7 +873,15 @@ namespace OpenSim.Framework
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ids.Count == 0)
|
indx = note.IndexOf("Text length",indx);
|
||||||
|
if(indx > 0)
|
||||||
|
{
|
||||||
|
indx += 14;
|
||||||
|
List<UUID> textIDs = Util.GetUUIDsOnString(ref note, indx);
|
||||||
|
if(textIDs.Count > 0)
|
||||||
|
ids.AddRange(textIDs);
|
||||||
|
}
|
||||||
|
if (ids.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
|
@ -719,6 +719,124 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||||
|
static bool IsHexa(char c)
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
return true;
|
||||||
|
if (c >= 'a' && c <= 'f')
|
||||||
|
return true;
|
||||||
|
if (c >= 'A' && c <= 'F')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<UUID> GetUUIDsOnString(ref string s, int indx)
|
||||||
|
{
|
||||||
|
var ids = new List<UUID>();
|
||||||
|
if (s.Length < 36)
|
||||||
|
return ids;
|
||||||
|
|
||||||
|
int end = s.Length - 35;
|
||||||
|
int idbase;
|
||||||
|
int next;
|
||||||
|
int retry;
|
||||||
|
|
||||||
|
while (indx < end)
|
||||||
|
{
|
||||||
|
for (; indx < end; ++indx)
|
||||||
|
{
|
||||||
|
if (IsHexa(s[indx]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (indx == end)
|
||||||
|
break;
|
||||||
|
|
||||||
|
idbase = indx;
|
||||||
|
for (; indx < s.Length - 26; ++indx)
|
||||||
|
{
|
||||||
|
if (!IsHexa(s[indx]))
|
||||||
|
break;
|
||||||
|
if (indx - idbase >= 8)
|
||||||
|
++idbase;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s[indx] != '-')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
++indx;
|
||||||
|
retry = indx;
|
||||||
|
next = indx + 4;
|
||||||
|
for (; indx < next; ++indx)
|
||||||
|
{
|
||||||
|
if (!IsHexa(s[indx]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (indx != next)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (s[indx] != '-')
|
||||||
|
{
|
||||||
|
indx = retry;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
++indx;
|
||||||
|
retry = indx;
|
||||||
|
next = indx + 4;
|
||||||
|
for (; indx < next; ++indx)
|
||||||
|
{
|
||||||
|
if (!IsHexa(s[indx]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (indx != next)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (s[indx] != '-')
|
||||||
|
{
|
||||||
|
indx = retry;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
++indx;
|
||||||
|
retry = indx;
|
||||||
|
next = indx + 4;
|
||||||
|
for (; indx < next; ++indx)
|
||||||
|
{
|
||||||
|
if (!IsHexa(s[indx]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (indx != next)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (s[indx] != '-')
|
||||||
|
{
|
||||||
|
indx = retry;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
++indx;
|
||||||
|
retry = indx;
|
||||||
|
|
||||||
|
next = indx + 12;
|
||||||
|
for (; indx < next; ++indx)
|
||||||
|
{
|
||||||
|
if (!IsHexa(s[indx]))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (indx != next)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (UUID.TryParse(s.Substring(idbase, 36), out UUID u))
|
||||||
|
{
|
||||||
|
ids.Add(u);
|
||||||
|
}
|
||||||
|
++indx;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is the platform Windows?
|
/// Is the platform Windows?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -42,6 +42,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
protected IAssetService m_assetService;
|
protected IAssetService m_assetService;
|
||||||
protected UuidGatherer m_uuidGatherer;
|
protected UuidGatherer m_uuidGatherer;
|
||||||
|
|
||||||
|
protected static string noteBase = @"Linden text version 2\n{\nLLEmbeddedItems version 1\n
|
||||||
|
{\ncount 0\n}\nText length xxx\n"; // len does not matter on this test
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
|
@ -58,7 +60,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
|
|
||||||
UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
|
UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
|
||||||
AssetBase corruptAsset
|
AssetBase corruptAsset
|
||||||
= AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, "CORRUPT ASSET", UUID.Zero);
|
= AssetHelpers.CreateAsset(corruptAssetUuid, AssetType.Notecard, noteBase + "CORRUPT ASSET", UUID.Zero);
|
||||||
m_assetService.Store(corruptAsset);
|
m_assetService.Store(corruptAsset);
|
||||||
|
|
||||||
m_uuidGatherer.AddForInspection(corruptAssetUuid);
|
m_uuidGatherer.AddForInspection(corruptAssetUuid);
|
||||||
|
@ -87,9 +89,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNotecardAsset()
|
public void TestNotecardAsset()
|
||||||
{
|
{
|
||||||
/* TODO fix this actually creating a valid notecard
|
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// TestHelpers.EnableLogging();
|
// TestHelpers.EnableLogging();
|
||||||
|
|
||||||
UUID ownerId = TestHelpers.ParseTail(0x10);
|
UUID ownerId = TestHelpers.ParseTail(0x10);
|
||||||
UUID embeddedId = TestHelpers.ParseTail(0x20);
|
UUID embeddedId = TestHelpers.ParseTail(0x20);
|
||||||
|
@ -99,35 +100,34 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||||
|
|
||||||
AssetBase ncAsset
|
AssetBase ncAsset
|
||||||
= AssetHelpers.CreateNotecardAsset(
|
= AssetHelpers.CreateNotecardAsset(
|
||||||
ncAssetId, string.Format("Hello{0}World{1}", embeddedId, missingEmbeddedId));
|
ncAssetId, string.Format("{0}Hello{1}World{2}", noteBase, embeddedId, missingEmbeddedId));
|
||||||
m_assetService.Store(ncAsset);
|
m_assetService.Store(ncAsset);
|
||||||
|
|
||||||
AssetBase embeddedAsset
|
AssetBase embeddedAsset
|
||||||
= AssetHelpers.CreateNotecardAsset(embeddedId, string.Format("{0} We'll meet again.", secondLevelEmbeddedId));
|
= AssetHelpers.CreateNotecardAsset(embeddedId, string.Format("{0}{1} We'll meet again.", noteBase, secondLevelEmbeddedId));
|
||||||
m_assetService.Store(embeddedAsset);
|
m_assetService.Store(embeddedAsset);
|
||||||
|
|
||||||
AssetBase secondLevelEmbeddedAsset
|
AssetBase secondLevelEmbeddedAsset
|
||||||
= AssetHelpers.CreateNotecardAsset(secondLevelEmbeddedId, "Don't know where, don't know when.");
|
= AssetHelpers.CreateNotecardAsset(secondLevelEmbeddedId, noteBase + "Don't know where, don't know when.");
|
||||||
m_assetService.Store(secondLevelEmbeddedAsset);
|
m_assetService.Store(secondLevelEmbeddedAsset);
|
||||||
|
|
||||||
m_uuidGatherer.AddForInspection(ncAssetId);
|
m_uuidGatherer.AddForInspection(ncAssetId);
|
||||||
m_uuidGatherer.GatherAll();
|
m_uuidGatherer.GatherAll();
|
||||||
|
|
||||||
// foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys)
|
// foreach (UUID key in m_uuidGatherer.GatheredUuids.Keys)
|
||||||
// System.Console.WriteLine("key : {0}", key);
|
// System.Console.WriteLine("key : {0}", key);
|
||||||
|
|
||||||
Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(3));
|
Assert.That(m_uuidGatherer.GatheredUuids.Count, Is.EqualTo(3));
|
||||||
Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(ncAssetId));
|
Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(ncAssetId));
|
||||||
Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId));
|
Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(embeddedId));
|
||||||
Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(secondLevelEmbeddedId));
|
Assert.That(m_uuidGatherer.GatheredUuids.ContainsKey(secondLevelEmbeddedId));
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestTaskItems()
|
public void TestTaskItems()
|
||||||
{
|
{
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// TestHelpers.EnableLogging();
|
// TestHelpers.EnableLogging();
|
||||||
|
|
||||||
UUID ownerId = TestHelpers.ParseTail(0x10);
|
UUID ownerId = TestHelpers.ParseTail(0x10);
|
||||||
|
|
||||||
|
|
|
@ -527,29 +527,30 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="textAsset"></param>
|
/// <param name="textAsset"></param>
|
||||||
private void RecordTextEmbeddedAssetUuids(AssetBase textAsset)
|
private void RecordTextEmbeddedAssetUuids(AssetBase textAsset)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);
|
// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);
|
||||||
|
|
||||||
string text = Utils.BytesToString(textAsset.Data);
|
string text = Utils.BytesToString(textAsset.Data);
|
||||||
// m_log.DebugFormat("[UUID GATHERER]: Text {0}", text);
|
if(text.Length < 36)
|
||||||
MatchCollection uuidMatches = Util.PermissiveUUIDPattern.Matches(text);
|
return;
|
||||||
// m_log.DebugFormat("[UUID GATHERER]: Found {0} matches in text", uuidMatches.Count);
|
|
||||||
|
|
||||||
foreach (Match uuidMatch in uuidMatches)
|
List<UUID> ids = Util.GetUUIDsOnString(ref text, 0);
|
||||||
|
if (ids == null || ids.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < ids.Count; ++i)
|
||||||
{
|
{
|
||||||
UUID uuid = new UUID(uuidMatch.Value);
|
if (ids[i] == UUID.Zero)
|
||||||
if(uuid == UUID.Zero)
|
|
||||||
continue;
|
continue;
|
||||||
// m_log.DebugFormat("[UUID GATHERER]: Recording {0} in text", uuid);
|
if (!UncertainAssetsUUIDs.Contains(ids[i]))
|
||||||
if(!UncertainAssetsUUIDs.Contains(uuid))
|
UncertainAssetsUUIDs.Add(ids[i]);
|
||||||
UncertainAssetsUUIDs.Add(uuid);
|
AddForInspection(ids[i]);
|
||||||
AddForInspection(uuid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecordNoteCardEmbeddedAssetUuids(AssetBase textAsset)
|
private void RecordNoteCardEmbeddedAssetUuids(AssetBase textAsset)
|
||||||
{
|
{
|
||||||
List<UUID> ids = SLUtil.GetEmbeddedAssetIDs(textAsset.Data);
|
List<UUID> ids = SLUtil.GetEmbeddedAssetIDs(textAsset.Data);
|
||||||
if(ids == null)
|
if(ids == null || ids.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(int i = 0; i < ids.Count; ++i)
|
for(int i = 0; i < ids.Count; ++i)
|
||||||
|
|
Loading…
Reference in New Issue