diff options
author | Diva Canto | 2010-11-26 22:06:34 -0800 |
---|---|---|
committer | Diva Canto | 2010-11-26 22:06:34 -0800 |
commit | 3292a2255882018b7fed3e80f430dc26892b92ea (patch) | |
tree | 408992547f45f85c3d6275a55e8515f2d905779f /OpenSim/Region | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-3292a2255882018b7fed3e80f430dc26892b92ea.zip opensim-SC_OLD-3292a2255882018b7fed3e80f430dc26892b92ea.tar.gz opensim-SC_OLD-3292a2255882018b7fed3e80f430dc26892b92ea.tar.bz2 opensim-SC_OLD-3292a2255882018b7fed3e80f430dc26892b92ea.tar.xz |
Creator information preserved upon HG transfers.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | 83 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 12 |
2 files changed, 87 insertions, 8 deletions
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 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Xml; | ||
34 | |||
32 | using log4net; | 35 | using log4net; |
33 | using OpenMetaverse; | 36 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 37 | using 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 | ||