diff options
author | Melanie Thielker | 2009-05-10 22:55:44 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-10 22:55:44 +0000 |
commit | 225252f48ee0e58d8bd9955ceae6c4c31e4d1a3d (patch) | |
tree | 90f7c9c58d49aa3b751b5f4b120e718a83ebe1ad /OpenSim | |
parent | Enhance the submodule loader and port the enhancements to the services base (diff) | |
download | opensim-SC-225252f48ee0e58d8bd9955ceae6c4c31e4d1a3d.zip opensim-SC-225252f48ee0e58d8bd9955ceae6c4c31e4d1a3d.tar.gz opensim-SC-225252f48ee0e58d8bd9955ceae6c4c31e4d1a3d.tar.bz2 opensim-SC-225252f48ee0e58d8bd9955ceae6c4c31e4d1a3d.tar.xz |
Add the HG asset module skeleton
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetServiceConnector.cs | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetServiceConnector.cs new file mode 100644 index 0000000..58cc134 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/HGAssetServiceConnector.cs | |||
@@ -0,0 +1,165 @@ | |||
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 OpenSim 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 log4net; | ||
29 | using Nini.Config; | ||
30 | using System; | ||
31 | using System.Collections.Generic; | ||
32 | using System.Reflection; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Servers.Base; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | |||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset | ||
40 | { | ||
41 | public class HGAssetServicesConnector : | ||
42 | ISharedRegionModule, IAssetService | ||
43 | { | ||
44 | private static readonly ILog m_log = | ||
45 | LogManager.GetLogger( | ||
46 | MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private IImprovedAssetCache m_Cache = null; | ||
49 | |||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | public string Name | ||
53 | { | ||
54 | get { return "HGAssetServicesConnector"; } | ||
55 | } | ||
56 | |||
57 | public void Initialise(IConfigSource source) | ||
58 | { | ||
59 | IConfig moduleConfig = source.Configs["Modules"]; | ||
60 | if (moduleConfig != null) | ||
61 | { | ||
62 | string name = moduleConfig.GetString("AssetServices", ""); | ||
63 | if (name == Name) | ||
64 | { | ||
65 | IConfig assetConfig = source.Configs["AssetService"]; | ||
66 | if (assetConfig == null) | ||
67 | { | ||
68 | m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpanSim.ini"); | ||
69 | return; | ||
70 | } | ||
71 | |||
72 | m_Enabled = true; | ||
73 | m_log.Info("[ASSET CONNECTOR]: HG asset connector enabled"); | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public void PostInitialise() | ||
79 | { | ||
80 | } | ||
81 | |||
82 | public void Close() | ||
83 | { | ||
84 | } | ||
85 | |||
86 | public void AddRegion(Scene scene) | ||
87 | { | ||
88 | if (!m_Enabled) | ||
89 | return; | ||
90 | |||
91 | scene.RegisterModuleInterface<IAssetService>(this); | ||
92 | } | ||
93 | |||
94 | public void RemoveRegion(Scene scene) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | public void RegionLoaded(Scene scene) | ||
99 | { | ||
100 | if (!m_Enabled) | ||
101 | return; | ||
102 | |||
103 | if (m_Cache == null) | ||
104 | { | ||
105 | m_Cache = scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
106 | |||
107 | if (!(m_Cache is ISharedRegionModule)) | ||
108 | m_Cache = null; | ||
109 | } | ||
110 | |||
111 | m_log.InfoFormat("[ASSET CONNECTOR]: Enabled local assets for region {0}", scene.RegionInfo.RegionName); | ||
112 | |||
113 | if (m_Cache != null) | ||
114 | { | ||
115 | m_log.InfoFormat("[ASSET CONNECTOR]: Enabled asset caching for region {0}", scene.RegionInfo.RegionName); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | // | ||
120 | // Note to Diva: | ||
121 | // | ||
122 | // This is not the broker! | ||
123 | // This module is not supposed to route anything anywhere. This is where | ||
124 | // the code to access remote assets (by URL) goes. It can be assumed | ||
125 | // that the ID is a URL. The broker makes sure of that. | ||
126 | // | ||
127 | // This is a disposable comment :) Feel free to remove it | ||
128 | // | ||
129 | |||
130 | public AssetBase Get(string id) | ||
131 | { | ||
132 | return null; | ||
133 | } | ||
134 | |||
135 | public AssetMetadata GetMetadata(string id) | ||
136 | { | ||
137 | return null; | ||
138 | } | ||
139 | |||
140 | public byte[] GetData(string id) | ||
141 | { | ||
142 | return null; | ||
143 | } | ||
144 | |||
145 | public bool Get(string id, Object sender, AssetRetrieved handler) | ||
146 | { | ||
147 | return false; | ||
148 | } | ||
149 | |||
150 | public string Store(AssetBase asset) | ||
151 | { | ||
152 | return String.Empty; | ||
153 | } | ||
154 | |||
155 | public bool UpdateContent(string id, byte[] data) | ||
156 | { | ||
157 | return false; | ||
158 | } | ||
159 | |||
160 | public bool Delete(string id) | ||
161 | { | ||
162 | return false; | ||
163 | } | ||
164 | } | ||
165 | } | ||