diff options
author | Justin Clark-Casey (justincc) | 2012-01-05 20:51:49 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-01-05 20:51:49 +0000 |
commit | 7319ba62dd1791a3dade5b5453e369d955de48a2 (patch) | |
tree | 5acaf68647385bc8d3b8318b3a5bfb51ea657d7a | |
parent | Move asset commands from AssetService to AssetServerConnector so that we can ... (diff) | |
download | opensim-SC_OLD-7319ba62dd1791a3dade5b5453e369d955de48a2.zip opensim-SC_OLD-7319ba62dd1791a3dade5b5453e369d955de48a2.tar.gz opensim-SC_OLD-7319ba62dd1791a3dade5b5453e369d955de48a2.tar.bz2 opensim-SC_OLD-7319ba62dd1791a3dade5b5453e369d955de48a2.tar.xz |
Move simulator asset info commands to an optional module from the connector. Make them conform with service side commands.
This stops them appearing twice when Hypergrid is enabled.
3 files changed, 138 insertions, 46 deletions
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs new file mode 100644 index 0000000..9ea6343 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs | |||
@@ -0,0 +1,134 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Console; | ||
39 | using OpenSim.Region.Framework.Interfaces; | ||
40 | using OpenSim.Region.Framework.Scenes; | ||
41 | |||
42 | namespace 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", false, "dump asset", | ||
92 | "dump asset <id>", | ||
93 | "Dump an asset", | ||
94 | HandleDumpAsset); | ||
95 | } | ||
96 | |||
97 | void HandleDumpAsset(string module, string[] args) | ||
98 | { | ||
99 | if (args.Length < 3) | ||
100 | { | ||
101 | MainConsole.Instance.Output("Usage is dump asset <ID>"); | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | UUID assetId; | ||
106 | string rawAssetId = args[2]; | ||
107 | |||
108 | if (!UUID.TryParse(rawAssetId, out assetId)) | ||
109 | { | ||
110 | MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | AssetBase asset = m_scene.AssetService.Get(assetId.ToString()); | ||
115 | if (asset == null) | ||
116 | { | ||
117 | MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); | ||
118 | return; | ||
119 | } | ||
120 | |||
121 | string fileName = rawAssetId; | ||
122 | |||
123 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | ||
124 | { | ||
125 | using (BinaryWriter bw = new BinaryWriter(fs)) | ||
126 | { | ||
127 | bw.Write(asset.Data); | ||
128 | } | ||
129 | } | ||
130 | |||
131 | MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); | ||
132 | } | ||
133 | } | ||
134 | } \ No newline at end of file | ||
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; | |||
30 | using OpenMetaverse.Assets; | 30 | using OpenMetaverse.Assets; |
31 | 31 | ||
32 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 32 | namespace 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/Services/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs index d7b2ff8..e4c3eaf 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -86,11 +86,8 @@ namespace OpenSim.Services.Connectors | |||
86 | m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); | 86 | m_log.Error("[ASSET CONNECTOR]: No Server URI named in section AssetService"); |
87 | throw new Exception("Asset connector init error"); | 87 | throw new Exception("Asset connector init error"); |
88 | } | 88 | } |
89 | m_ServerURI = serviceURI; | ||
90 | 89 | ||
91 | MainConsole.Instance.Commands.AddCommand("asset", false, "dump asset", | 90 | m_ServerURI = serviceURI; |
92 | "dump asset <id> <file>", | ||
93 | "dump one cached asset", HandleDumpAsset); | ||
94 | } | 91 | } |
95 | 92 | ||
96 | protected void SetCache(IImprovedAssetCache cache) | 93 | protected void SetCache(IImprovedAssetCache cache) |
@@ -328,43 +325,5 @@ namespace OpenSim.Services.Connectors | |||
328 | } | 325 | } |
329 | return false; | 326 | return false; |
330 | } | 327 | } |
331 | |||
332 | private void HandleDumpAsset(string module, string[] args) | ||
333 | { | ||
334 | if (args.Length != 4) | ||
335 | { | ||
336 | MainConsole.Instance.Output("Syntax: dump asset <id> <file>"); | ||
337 | return; | ||
338 | } | ||
339 | |||
340 | UUID assetID; | ||
341 | |||
342 | if (!UUID.TryParse(args[2], out assetID)) | ||
343 | { | ||
344 | MainConsole.Instance.Output("Invalid asset ID"); | ||
345 | return; | ||
346 | } | ||
347 | |||
348 | if (m_Cache == null) | ||
349 | { | ||
350 | MainConsole.Instance.Output("Instance uses no cache"); | ||
351 | return; | ||
352 | } | ||
353 | |||
354 | AssetBase asset = m_Cache.Get(assetID.ToString()); | ||
355 | |||
356 | if (asset == null) | ||
357 | { | ||
358 | MainConsole.Instance.Output("Asset not found in cache"); | ||
359 | return; | ||
360 | } | ||
361 | |||
362 | string fileName = args[3]; | ||
363 | |||
364 | FileStream fs = File.Create(fileName); | ||
365 | fs.Write(asset.Data, 0, asset.Data.Length); | ||
366 | |||
367 | fs.Close(); | ||
368 | } | ||
369 | } | 328 | } |
370 | } | 329 | } \ No newline at end of file |