aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2012-01-06 00:08:18 +0000
committerMelanie2012-01-06 00:08:18 +0000
commitfdfc4ab2a8e171139caf9751a23eb75afe881c2b (patch)
treebc0d8d3066ecf5fe87e0778e23190d14a58d3bc1
parentThat needs to be callable from elsewhere! (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.zip
opensim-SC-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.gz
opensim-SC-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.bz2
opensim-SC-fdfc4ab2a8e171139caf9751a23eb75afe881c2b.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
-rw-r--r--OpenSim/Framework/ISearchModule.cs36
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs35
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs7
-rw-r--r--OpenSim/Region/DataSnapshot/DataRequestHandler.cs2
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs5
-rw-r--r--OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs19
-rw-r--r--OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs155
-rw-r--r--OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs185
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs13
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs5
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs129
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs124
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs39
13 files changed, 571 insertions, 183 deletions
diff --git a/OpenSim/Framework/ISearchModule.cs b/OpenSim/Framework/ISearchModule.cs
new file mode 100644
index 0000000..64bf72c
--- /dev/null
+++ b/OpenSim/Framework/ISearchModule.cs
@@ -0,0 +1,36 @@
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 OpenMetaverse;
29
30namespace OpenSim.Framework
31{
32 public interface ISearchModule
33 {
34
35 }
36}
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
index 14dee84..a1a2501 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs
@@ -133,18 +133,20 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
133 133
134 // Do Decode! 134 // Do Decode!
135 if (decode) 135 if (decode)
136 DoJ2KDecode(assetID, j2kData); 136 Decode(assetID, j2kData);
137 } 137 }
138 } 138 }
139 139
140 /// <summary> 140 public bool Decode(UUID assetID, byte[] j2kData)
141 /// Provides a synchronous decode so that caller can be assured that this executes before the next line 141 {
142 /// </summary> 142 OpenJPEG.J2KLayerInfo[] layers;
143 /// <param name="assetID"></param> 143 int components;
144 /// <param name="j2kData"></param> 144 return Decode(assetID, j2kData, out layers, out components);
145 public void Decode(UUID assetID, byte[] j2kData) 145 }
146
147 public bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components)
146 { 148 {
147 DoJ2KDecode(assetID, j2kData); 149 return DoJ2KDecode(assetID, j2kData, out layers, out components);
148 } 150 }
149 151
150 #endregion IJ2KDecoder 152 #endregion IJ2KDecoder
@@ -154,14 +156,21 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
154 /// </summary> 156 /// </summary>
155 /// <param name="assetID">UUID of Asset</param> 157 /// <param name="assetID">UUID of Asset</param>
156 /// <param name="j2kData">JPEG2000 data</param> 158 /// <param name="j2kData">JPEG2000 data</param>
157 private void DoJ2KDecode(UUID assetID, byte[] j2kData) 159 /// <param name="layers">layer data</param>
160 /// <param name="components">number of components</param>
161 /// <returns>true if decode was successful. false otherwise.</returns>
162 private bool DoJ2KDecode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components)
158 { 163 {
159// m_log.DebugFormat( 164// m_log.DebugFormat(
160// "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID); 165// "[J2KDecoderModule]: Doing J2K decoding of {0} bytes for asset {1}", j2kData.Length, assetID);
161 166
167 bool decodedSuccessfully = true;
168
162 //int DecodeTime = 0; 169 //int DecodeTime = 0;
163 //DecodeTime = Environment.TickCount; 170 //DecodeTime = Environment.TickCount;
164 OpenJPEG.J2KLayerInfo[] layers; 171
172 // We don't get this from CSJ2K. Is it relevant?
173 components = 0;
165 174
166 if (!TryLoadCacheForAsset(assetID, out layers)) 175 if (!TryLoadCacheForAsset(assetID, out layers))
167 { 176 {
@@ -196,14 +205,15 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
196 catch (Exception ex) 205 catch (Exception ex)
197 { 206 {
198 m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message); 207 m_log.Warn("[J2KDecoderModule]: CSJ2K threw an exception decoding texture " + assetID + ": " + ex.Message);
208 decodedSuccessfully = false;
199 } 209 }
200 } 210 }
201 else 211 else
202 { 212 {
203 int components;
204 if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components)) 213 if (!OpenJPEG.DecodeLayerBoundaries(j2kData, out layers, out components))
205 { 214 {
206 m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID); 215 m_log.Warn("[J2KDecoderModule]: OpenJPEG failed to decode texture " + assetID);
216 decodedSuccessfully = false;
207 } 217 }
208 } 218 }
209 219
@@ -212,6 +222,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
212 m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults"); 222 m_log.Warn("[J2KDecoderModule]: Failed to decode layer data for texture " + assetID + ", guessing sane defaults");
213 // Layer decoding completely failed. Guess at sane defaults for the layer boundaries 223 // Layer decoding completely failed. Guess at sane defaults for the layer boundaries
214 layers = CreateDefaultLayers(j2kData.Length); 224 layers = CreateDefaultLayers(j2kData.Length);
225 decodedSuccessfully = false;
215 } 226 }
216 227
217 // Cache Decoded layers 228 // Cache Decoded layers
@@ -231,6 +242,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
231 m_notifyList.Remove(assetID); 242 m_notifyList.Remove(assetID);
232 } 243 }
233 } 244 }
245
246 return decodedSuccessfully;
234 } 247 }
235 248
236 private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength) 249 private OpenJPEG.J2KLayerInfo[] CreateDefaultLayers(int j2kLength)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 9df0592..d68d28c 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -321,8 +321,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
321 return (defonly ? false : true); 321 return (defonly ? false : true);
322 } 322 }
323 323
324 public void RequestRebake(IScenePresence sp, bool missingTexturesOnly) 324 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
325 { 325 {
326 int texturesRebaked = 0;
327
326 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 328 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
327 { 329 {
328 int idx = AvatarAppearance.BAKE_INDICES[i]; 330 int idx = AvatarAppearance.BAKE_INDICES[i];
@@ -359,8 +361,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
359 face.TextureID, idx, sp.Name); 361 face.TextureID, idx, sp.Name);
360 } 362 }
361 363
364 texturesRebaked++;
362 sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID); 365 sp.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
363 } 366 }
367
368 return texturesRebaked;
364 } 369 }
365 370
366 #endregion 371 #endregion
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
index b760454..93648d6 100644
--- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
+++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Region.DataSnapshot
67 67
68 public void OnRegisterCaps(UUID agentID, Caps caps) 68 public void OnRegisterCaps(UUID agentID, Caps caps)
69 { 69 {
70 m_log.Info("[DATASNAPSHOT]: Registering service discovery capability for " + agentID); 70// m_log.InfoFormat("[DATASNAPSHOT]: Registering service discovery capability for {0}", agentID);
71 string capsBase = "/CAPS/" + caps.CapsObjectPath; 71 string capsBase = "/CAPS/" + caps.CapsObjectPath;
72 caps.RegisterHandler("PublicSnapshotDataInfo", 72 caps.RegisterHandler("PublicSnapshotDataInfo",
73 new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt)); 73 new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt));
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
index 04df9c3..39a760c 100644
--- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs
@@ -82,7 +82,10 @@ namespace OpenSim.Region.Framework.Interfaces
82 /// If true, only request a rebake for the textures that are missing. 82 /// If true, only request a rebake for the textures that are missing.
83 /// If false then we request a rebake of all textures for which we already have references. 83 /// If false then we request a rebake of all textures for which we already have references.
84 /// </param> 84 /// </param>
85 void RequestRebake(IScenePresence sp, bool missingTexturesOnly); 85 /// <returns>
86 /// Number of rebake requests made. This will depend upon whether we've previously received texture IDs.
87 /// </returns>
88 int RequestRebake(IScenePresence sp, bool missingTexturesOnly);
86 89
87 void QueueAppearanceSend(UUID agentid); 90 void QueueAppearanceSend(UUID agentid);
88 void QueueAppearanceSave(UUID agentid); 91 void QueueAppearanceSave(UUID agentid);
diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs
index 856eb11..46d03b3 100644
--- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs
+++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs
@@ -35,6 +35,23 @@ namespace OpenSim.Region.Framework.Interfaces
35 public interface IJ2KDecoder 35 public interface IJ2KDecoder
36 { 36 {
37 void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback); 37 void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback);
38 void Decode(UUID assetID, byte[] j2kData); 38
39 /// <summary>
40 /// Provides a synchronous decode so that caller can be assured that this executes before the next line
41 /// </summary>
42 /// <param name="assetID"></param>
43 /// <param name="j2kData"></param>
44 /// <returns>true if decode was successful. false otherwise.</returns>
45 bool Decode(UUID assetID, byte[] j2kData);
46
47 /// <summary>
48 /// Provides a synchronous decode so that caller can be assured that this executes before the next line
49 /// </summary>
50 /// <param name="assetID"></param>
51 /// <param name="j2kData"></param>
52 /// <param name="layers">layer data</param>
53 /// <param name="components">number of components</param>
54 /// <returns>true if decode was successful. false otherwise.</returns>
55 bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components);
39 } 56 }
40} 57}
diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
new file mode 100644
index 0000000..439096a
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
@@ -0,0 +1,155 @@
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.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenMetaverse.Imaging;
38using OpenSim.Framework;
39using OpenSim.Framework.Console;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes;
42
43namespace OpenSim.Region.OptionalModules.Agent.TextureSender
44{
45 /// <summary>
46 /// Commands for the J2KDecoder module. For debugging purposes.
47 /// </summary>
48 /// <remarks>
49 /// Placed here so that they can be removed if not required and to keep the J2KDecoder module itself simple.
50 /// </remarks>
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "J2KDecoderCommandModule")]
52 public class J2KDecoderCommandModule : ISharedRegionModule
53 {
54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 private Scene m_scene;
57
58 public string Name { get { return "Asset Information Module"; } }
59
60 public Type ReplaceableInterface { get { return null; } }
61
62 public void Initialise(IConfigSource source)
63 {
64// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: INITIALIZED MODULE");
65 }
66
67 public void PostInitialise()
68 {
69// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: POST INITIALIZED MODULE");
70 }
71
72 public void Close()
73 {
74// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: CLOSED MODULE");
75 }
76
77 public void AddRegion(Scene scene)
78 {
79// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 }
81
82 public void RemoveRegion(Scene scene)
83 {
84// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85 }
86
87 public void RegionLoaded(Scene scene)
88 {
89// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
90
91 if (m_scene == null)
92 m_scene = scene;
93
94 MainConsole.Instance.Commands.AddCommand(
95 "j2k",
96 false,
97 "j2k decode",
98 "j2k decode <ID>",
99 "Do JPEG2000 decoding of an asset.",
100 "This is for debugging purposes. The asset id given must contain JPEG2000 data.",
101 HandleDecode);
102 }
103
104 void HandleDecode(string module, string[] args)
105 {
106 if (args.Length < 3)
107 {
108 MainConsole.Instance.Output("Usage is j2k decode <ID>");
109 return;
110 }
111
112 UUID assetId;
113 string rawAssetId = args[2];
114
115 if (!UUID.TryParse(rawAssetId, out assetId))
116 {
117 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
118 return;
119 }
120
121 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
122 if (asset == null)
123 {
124 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
125 return;
126 }
127
128 if (asset.Type != (sbyte)AssetType.Texture)
129 {
130 MainConsole.Instance.OutputFormat("ERROR: Asset {0} is not a texture type", assetId);
131 return;
132 }
133
134 IJ2KDecoder decoder = m_scene.RequestModuleInterface<IJ2KDecoder>();
135 if (decoder == null)
136 {
137 MainConsole.Instance.OutputFormat("ERROR: No IJ2KDecoder module available");
138 return;
139 }
140
141 OpenJPEG.J2KLayerInfo[] layers;
142 int components;
143 if (decoder.Decode(assetId, asset.Data, out layers, out components))
144 {
145 MainConsole.Instance.OutputFormat(
146 "Successfully decoded asset {0} with {1} layers and {2} components",
147 assetId, layers.Length, components);
148 }
149 else
150 {
151 MainConsole.Instance.OutputFormat("Decode of asset {0} failed", assetId);
152 }
153 }
154 }
155} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
new file mode 100644
index 0000000..a5207eb
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -0,0 +1,185 @@
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.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Text;
33using log4net;
34using Mono.Addins;
35using Nini.Config;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Region.Framework.Interfaces;
40using OpenSim.Region.Framework.Scenes;
41
42namespace OpenSim.Region.OptionalModules.Asset
43{
44 /// <summary>
45 /// A module that just holds commands for inspecting assets.
46 /// </summary>
47 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetInfoModule")]
48 public class AssetInfoModule : ISharedRegionModule
49 {
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 private Scene m_scene;
53
54 public string Name { get { return "Asset Information Module"; } }
55
56 public Type ReplaceableInterface { get { return null; } }
57
58 public void Initialise(IConfigSource source)
59 {
60// m_log.DebugFormat("[ASSET INFO MODULE]: INITIALIZED MODULE");
61 }
62
63 public void PostInitialise()
64 {
65// m_log.DebugFormat("[ASSET INFO MODULE]: POST INITIALIZED MODULE");
66 }
67
68 public void Close()
69 {
70// m_log.DebugFormat("[ASSET INFO MODULE]: CLOSED MODULE");
71 }
72
73 public void AddRegion(Scene scene)
74 {
75// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
76 }
77
78 public void RemoveRegion(Scene scene)
79 {
80// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
81 }
82
83 public void RegionLoaded(Scene scene)
84 {
85// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
86
87 if (m_scene == null)
88 m_scene = scene;
89
90 MainConsole.Instance.Commands.AddCommand(
91 "asset",
92 false,
93 "show asset",
94 "show asset <ID>",
95 "Show asset information",
96 HandleShowAsset);
97
98 MainConsole.Instance.Commands.AddCommand(
99 "asset", false, "dump asset",
100 "dump asset <id>",
101 "Dump an asset",
102 HandleDumpAsset);
103 }
104
105 void HandleDumpAsset(string module, string[] args)
106 {
107 if (args.Length < 3)
108 {
109 MainConsole.Instance.Output("Usage is dump asset <ID>");
110 return;
111 }
112
113 UUID assetId;
114 string rawAssetId = args[2];
115
116 if (!UUID.TryParse(rawAssetId, out assetId))
117 {
118 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
119 return;
120 }
121
122 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
123 if (asset == null)
124 {
125 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
126 return;
127 }
128
129 string fileName = rawAssetId;
130
131 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
132 {
133 using (BinaryWriter bw = new BinaryWriter(fs))
134 {
135 bw.Write(asset.Data);
136 }
137 }
138
139 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
140 }
141
142 void HandleShowAsset(string module, string[] args)
143 {
144 if (args.Length < 3)
145 {
146 MainConsole.Instance.Output("Syntax: show asset <ID>");
147 return;
148 }
149
150 AssetBase asset = m_scene.AssetService.Get(args[2]);
151
152 if (asset == null || asset.Data.Length == 0)
153 {
154 MainConsole.Instance.Output("Asset not found");
155 return;
156 }
157
158 int i;
159
160 MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
161 MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
162 MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
163 MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
164 MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length);
165 MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no");
166 MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
167
168 for (i = 0 ; i < 5 ; i++)
169 {
170 int off = i * 16;
171 if (asset.Data.Length <= off)
172 break;
173 int len = 16;
174 if (asset.Data.Length < off + len)
175 len = asset.Data.Length - off;
176
177 byte[] line = new byte[len];
178 Array.Copy(asset.Data, off, line, 0, len);
179
180 string text = BitConverter.ToString(line);
181 MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
182 }
183 }
184 }
185} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
index 7e15718..39cd4c9 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
@@ -240,11 +240,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
240 ScenePresence sp = scene.GetScenePresence(firstname, lastname); 240 ScenePresence sp = scene.GetScenePresence(firstname, lastname);
241 if (sp != null && !sp.IsChildAgent) 241 if (sp != null && !sp.IsChildAgent)
242 { 242 {
243 MainConsole.Instance.OutputFormat( 243 int rebakesRequested = scene.AvatarFactory.RequestRebake(sp, false);
244 "Requesting rebake of uploaded textures for {0}",
245 sp.Name, scene.RegionInfo.RegionName);
246 244
247 scene.AvatarFactory.RequestRebake(sp, false); 245 if (rebakesRequested > 0)
246 MainConsole.Instance.OutputFormat(
247 "Requesting rebake of {0} uploaded textures for {1} in {2}",
248 rebakesRequested, sp.Name, scene.RegionInfo.RegionName);
249 else
250 MainConsole.Instance.OutputFormat(
251 "No texture IDs available for rebake request for {0} in {1}",
252 sp.Name, scene.RegionInfo.RegionName);
248 } 253 }
249 } 254 }
250 } 255 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
index 16cd7e4..a8e545c 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
@@ -30,8 +30,7 @@ using OpenMetaverse;
30using OpenMetaverse.Assets; 30using OpenMetaverse.Assets;
31 31
32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
33{ 33{
34
35 /// <summary> 34 /// <summary>
36 /// This implements the methods needed to operate on individual inventory items. 35 /// This implements the methods needed to operate on individual inventory items.
37 /// </summary> 36 /// </summary>
@@ -39,6 +38,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
39 { 38 {
40 int Type { get; } 39 int Type { get; }
41 UUID AssetID { get; } 40 UUID AssetID { get; }
42 T RetrieveAsset<T>() where T : Asset, new(); 41 T RetrieveAsset<T>() where T : OpenMetaverse.Assets.Asset, new();
43 } 42 }
44} 43}
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index df571fa..9b80245 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -26,7 +26,11 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using Nini.Config; 30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Console;
30using OpenSim.Server.Base; 34using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer; 36using OpenSim.Framework.Servers.HttpServer;
@@ -67,6 +71,129 @@ namespace OpenSim.Server.Handlers.Asset
67 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); 71 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService));
68 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); 72 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService));
69 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); 73 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete));
74
75 MainConsole.Instance.Commands.AddCommand("kfs", false,
76 "show asset",
77 "show asset <ID>",
78 "Show asset information",
79 HandleShowAsset);
80
81 MainConsole.Instance.Commands.AddCommand("kfs", false,
82 "delete asset",
83 "delete asset <ID>",
84 "Delete asset from database",
85 HandleDeleteAsset);
86
87 MainConsole.Instance.Commands.AddCommand("kfs", false,
88 "dump asset",
89 "dump asset <ID>",
90 "Dump asset to a file",
91 "The filename is the same as the ID given.",
92 HandleDumpAsset);
93 }
94
95 void HandleDeleteAsset(string module, string[] args)
96 {
97 if (args.Length < 3)
98 {
99 MainConsole.Instance.Output("Syntax: delete asset <ID>");
100 return;
101 }
102
103 AssetBase asset = m_AssetService.Get(args[2]);
104
105 if (asset == null || asset.Data.Length == 0)
106 {
107 MainConsole.Instance.Output("Asset not found");
108 return;
109 }
110
111 m_AssetService.Delete(args[2]);
112
113 //MainConsole.Instance.Output("Asset deleted");
114 // TODO: Implement this
115
116 MainConsole.Instance.Output("Asset deletion not supported by database");
117 }
118
119 void HandleDumpAsset(string module, string[] args)
120 {
121 if (args.Length < 3)
122 {
123 MainConsole.Instance.Output("Usage is dump asset <ID>");
124 return;
125 }
126
127 UUID assetId;
128 string rawAssetId = args[2];
129
130 if (!UUID.TryParse(rawAssetId, out assetId))
131 {
132 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
133 return;
134 }
135
136 AssetBase asset = m_AssetService.Get(assetId.ToString());
137 if (asset == null)
138 {
139 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
140 return;
141 }
142
143 string fileName = rawAssetId;
144
145 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
146 {
147 using (BinaryWriter bw = new BinaryWriter(fs))
148 {
149 bw.Write(asset.Data);
150 }
151 }
152
153 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
154 }
155
156 void HandleShowAsset(string module, string[] args)
157 {
158 if (args.Length < 3)
159 {
160 MainConsole.Instance.Output("Syntax: show asset <ID>");
161 return;
162 }
163
164 AssetBase asset = m_AssetService.Get(args[2]);
165
166 if (asset == null || asset.Data.Length == 0)
167 {
168 MainConsole.Instance.Output("Asset not found");
169 return;
170 }
171
172 int i;
173
174 MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
175 MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
176 MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
177 MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
178 MainConsole.Instance.OutputFormat("Size: {0} bytes", asset.Data.Length);
179 MainConsole.Instance.OutputFormat("Temporary: {0}", asset.Temporary ? "yes" : "no");
180 MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
181
182 for (i = 0 ; i < 5 ; i++)
183 {
184 int off = i * 16;
185 if (asset.Data.Length <= off)
186 break;
187 int len = 16;
188 if (asset.Data.Length < off + len)
189 len = asset.Data.Length - off;
190
191 byte[] line = new byte[len];
192 Array.Copy(asset.Data, off, line, 0, len);
193
194 string text = BitConverter.ToString(line);
195 MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
196 }
70 } 197 }
71 } 198 }
72} 199} \ No newline at end of file
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index ec424c0..d4bfe8f 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -32,7 +32,6 @@ using System.Reflection;
32using Nini.Config; 32using Nini.Config;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Data; 35using OpenSim.Data;
37using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
38using OpenMetaverse; 37using OpenMetaverse;
@@ -53,23 +52,6 @@ namespace OpenSim.Services.AssetService
53 { 52 {
54 m_RootInstance = this; 53 m_RootInstance = this;
55 54
56 MainConsole.Instance.Commands.AddCommand("kfs", false,
57 "show digest",
58 "show digest <ID>",
59 "Show asset digest", HandleShowDigest);
60
61 MainConsole.Instance.Commands.AddCommand("kfs", false,
62 "delete asset",
63 "delete asset <ID>",
64 "Delete asset from database", HandleDeleteAsset);
65
66 MainConsole.Instance.Commands.AddCommand("kfs", false,
67 "dump asset",
68 "dump asset <ID>",
69 "Dump asset to a file",
70 "The filename is the same as the ID given.",
71 HandleDumpAsset);
72
73 if (m_AssetLoader != null) 55 if (m_AssetLoader != null)
74 { 56 {
75 IConfig assetConfig = config.Configs["AssetService"]; 57 IConfig assetConfig = config.Configs["AssetService"];
@@ -221,111 +203,11 @@ namespace OpenSim.Services.AssetService
221 return m_Database.Delete(id); 203 return m_Database.Delete(id);
222 } 204 }
223 else 205 else
224 m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id);
225
226 return false;
227 }
228
229 void HandleDumpAsset(string module, string[] args)
230 {
231 if (args.Length < 3)
232 {
233 MainConsole.Instance.Output("Usage is dump asset <ID>");
234 return;
235 }
236
237 string rawAssetId = args[2];
238 UUID assetId;
239
240 if (!UUID.TryParse(rawAssetId, out assetId))
241 {
242 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
243 return;
244 }
245
246 AssetBase asset = m_Database.GetAsset(assetId);
247 if (asset == null)
248 {
249 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
250 return;
251 }
252
253 string fileName = rawAssetId;
254
255 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
256 {
257 using (BinaryWriter bw = new BinaryWriter(fs))
258 {
259 bw.Write(asset.Data);
260 }
261 }
262
263 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
264 }
265
266 void HandleShowDigest(string module, string[] args)
267 {
268 if (args.Length < 3)
269 {
270 MainConsole.Instance.Output("Syntax: show digest <ID>");
271 return;
272 }
273
274 AssetBase asset = Get(args[2]);
275
276 if (asset == null || asset.Data.Length == 0)
277 {
278 MainConsole.Instance.Output("Asset not found");
279 return;
280 }
281
282 int i;
283
284 MainConsole.Instance.OutputFormat("Name: {0}", asset.Name);
285 MainConsole.Instance.OutputFormat("Description: {0}", asset.Description);
286 MainConsole.Instance.OutputFormat("Type: {0} (type number = {1})", (AssetType)asset.Type, asset.Type);
287 MainConsole.Instance.OutputFormat("Content-type: {0}", asset.Metadata.ContentType);
288 MainConsole.Instance.OutputFormat("Flags: {0}", asset.Metadata.Flags);
289
290 for (i = 0 ; i < 5 ; i++)
291 { 206 {
292 int off = i * 16; 207 m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id);
293 if (asset.Data.Length <= off)
294 break;
295 int len = 16;
296 if (asset.Data.Length < off + len)
297 len = asset.Data.Length - off;
298
299 byte[] line = new byte[len];
300 Array.Copy(asset.Data, off, line, 0, len);
301
302 string text = BitConverter.ToString(line);
303 MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
304 }
305 }
306
307 void HandleDeleteAsset(string module, string[] args)
308 {
309 if (args.Length < 3)
310 {
311 MainConsole.Instance.Output("Syntax: delete asset <ID>");
312 return;
313 }
314
315 AssetBase asset = Get(args[2]);
316
317 if (asset == null || asset.Data.Length == 0)
318 {
319 MainConsole.Instance.Output("Asset not found");
320 return;
321 } 208 }
322 209
323 Delete(args[2]); 210 return false;
324
325 //MainConsole.Instance.Output("Asset deleted");
326 // TODO: Implement this
327
328 MainConsole.Instance.Output("Asset deletion not supported by database");
329 } 211 }
330 } 212 }
331} 213} \ No newline at end of file
diff --git a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
index c3268d1..9bd04ed 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs
@@ -89,7 +89,6 @@ namespace OpenSim.Services.Connectors
89 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); 89 m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService");
90 throw new Exception("Asset connector init error"); 90 throw new Exception("Asset connector init error");
91 } 91 }
92 m_ServerURI = serviceURI;
93 92
94 MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", 93 MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset",
95 "dump asset <id> <file>", 94 "dump asset <id> <file>",
@@ -461,43 +460,5 @@ namespace OpenSim.Services.Connectors
461 } 460 }
462 return false; 461 return false;
463 } 462 }
464
465 private void HandleDumpAsset(string module, string[] args)
466 {
467 if (args.Length != 4)
468 {
469 MainConsole.Instance.Output("Syntax: dump asset <id> <file>");
470 return;
471 }
472
473 UUID assetID;
474
475 if (!UUID.TryParse(args[2], out assetID))
476 {
477 MainConsole.Instance.Output("Invalid asset ID");
478 return;
479 }
480
481 if (m_Cache == null)
482 {
483 MainConsole.Instance.Output("Instance uses no cache");
484 return;
485 }
486
487 AssetBase asset = m_Cache.Get(assetID.ToString());
488
489 if (asset == null)
490 {
491 MainConsole.Instance.Output("Asset not found in cache");
492 return;
493 }
494
495 string fileName = args[3];
496
497 FileStream fs = File.Create(fileName);
498 fs.Write(asset.Data, 0, asset.Data.Length);
499
500 fs.Close();
501 }
502 } 463 }
503} 464}