diff options
author | Sean Dague | 2007-10-19 20:27:34 +0000 |
---|---|---|
committer | Sean Dague | 2007-10-19 20:27:34 +0000 |
commit | 139994757c7dab04dd03801266525e8c53395a5e (patch) | |
tree | 003ec2557de6dd80dbe1e7bc78efe8958d02d5ae /OpenSim/Region/Environment | |
parent | * Test thy commits! (oops, sorry!) (diff) | |
download | opensim-SC-139994757c7dab04dd03801266525e8c53395a5e.zip opensim-SC-139994757c7dab04dd03801266525e8c53395a5e.tar.gz opensim-SC-139994757c7dab04dd03801266525e8c53395a5e.tar.bz2 opensim-SC-139994757c7dab04dd03801266525e8c53395a5e.tar.xz |
changes to pass nini config object to the modules that get
loaded so that they may read out any bits they are interested in
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Interfaces/IRegionModule.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/ModuleLoader.cs | 407 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/AssetDownloadModule.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs | 187 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 485 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/DynamicTextureModule.cs | 381 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/FriendsModule.cs | 123 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/GroupsModule.cs | 123 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/InstantMessageModule.cs | 201 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/InventoryModule.cs | 123 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/LoadImageURLModule.cs | 247 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/TextureDownloadModule.cs | 153 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/WorldCommModule.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/XMLRPCModule.cs | 3 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/XferModule.cs | 403 |
15 files changed, 1431 insertions, 1414 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs index e60c42b..808b94a 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs | |||
@@ -27,12 +27,13 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using OpenSim.Region.Environment.Scenes; | 29 | using OpenSim.Region.Environment.Scenes; |
30 | using Nini.Config; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.Environment.Interfaces | 32 | namespace OpenSim.Region.Environment.Interfaces |
32 | { | 33 | { |
33 | public interface IRegionModule | 34 | public interface IRegionModule |
34 | { | 35 | { |
35 | void Initialise(Scene scene); | 36 | void Initialise(Scene scene, IConfigSource source); |
36 | void PostInitialise(); | 37 | void PostInitialise(); |
37 | void Close(); | 38 | void Close(); |
38 | string Name { get; } | 39 | string Name { get; } |
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 69cc379..f88f9ac 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs | |||
@@ -1,202 +1,205 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Modules; | 35 | using OpenSim.Region.Environment.Modules; |
36 | using OpenSim.Region.Environment.Scenes; | 36 | using OpenSim.Region.Environment.Scenes; |
37 | 37 | using Nini.Config; | |
38 | namespace OpenSim.Region.Environment | 38 | |
39 | { | 39 | namespace OpenSim.Region.Environment |
40 | public class ModuleLoader | 40 | { |
41 | { | 41 | public class ModuleLoader |
42 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); | 42 | { |
43 | 43 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); | |
44 | public List<IRegionModule> LoadedModules = new List<IRegionModule>(); | 44 | |
45 | public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); | 45 | public List<IRegionModule> LoadedModules = new List<IRegionModule>(); |
46 | private readonly LogBase m_log; | 46 | public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); |
47 | 47 | private readonly LogBase m_log; | |
48 | public ModuleLoader(LogBase log) | 48 | private IConfigSource m_config; |
49 | { | 49 | |
50 | m_log = log; | 50 | public ModuleLoader(LogBase log, IConfigSource config) |
51 | } | 51 | { |
52 | 52 | m_log = log; | |
53 | public void PickupModules(Scene scene, string moduleDir) | 53 | m_config = config; |
54 | { | 54 | } |
55 | DirectoryInfo dir = new DirectoryInfo(moduleDir); | 55 | |
56 | 56 | public void PickupModules(Scene scene, string moduleDir) | |
57 | foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) | 57 | { |
58 | { | 58 | DirectoryInfo dir = new DirectoryInfo(moduleDir); |
59 | LoadRegionModules(fileInfo.FullName, scene); | 59 | |
60 | } | 60 | foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) |
61 | } | 61 | { |
62 | 62 | LoadRegionModules(fileInfo.FullName, scene); | |
63 | public void LoadDefaultSharedModules() | 63 | } |
64 | { | 64 | } |
65 | DynamicTextureModule dynamicModule = new DynamicTextureModule(); | 65 | |
66 | LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); | 66 | public void LoadDefaultSharedModules() |
67 | } | 67 | { |
68 | 68 | DynamicTextureModule dynamicModule = new DynamicTextureModule(); | |
69 | public void InitialiseSharedModules(Scene scene) | 69 | LoadedSharedModules.Add(dynamicModule.Name, dynamicModule); |
70 | { | 70 | } |
71 | foreach (IRegionModule module in LoadedSharedModules.Values) | 71 | |
72 | { | 72 | public void InitialiseSharedModules(Scene scene) |
73 | module.Initialise(scene); | 73 | { |
74 | scene.AddModule(module.Name, module); //should be doing this? | 74 | foreach (IRegionModule module in LoadedSharedModules.Values) |
75 | } | 75 | { |
76 | } | 76 | module.Initialise(scene, m_config); |
77 | 77 | scene.AddModule(module.Name, module); //should be doing this? | |
78 | public void InitializeModule(IRegionModule module, Scene scene) | 78 | } |
79 | { | 79 | } |
80 | module.Initialise(scene); | 80 | |
81 | scene.AddModule(module.Name, module); | 81 | public void InitializeModule(IRegionModule module, Scene scene) |
82 | LoadedModules.Add(module); | 82 | { |
83 | } | 83 | module.Initialise(scene, m_config); |
84 | 84 | scene.AddModule(module.Name, module); | |
85 | /// <summary> | 85 | LoadedModules.Add(module); |
86 | /// Loads/initialises a Module instance that can be used by mutliple Regions | 86 | } |
87 | /// </summary> | 87 | |
88 | /// <param name="dllName"></param> | 88 | /// <summary> |
89 | /// <param name="moduleName"></param> | 89 | /// Loads/initialises a Module instance that can be used by mutliple Regions |
90 | /// <param name="scene"></param> | 90 | /// </summary> |
91 | public void LoadSharedModule(string dllName, string moduleName) | 91 | /// <param name="dllName"></param> |
92 | { | 92 | /// <param name="moduleName"></param> |
93 | IRegionModule module = LoadModule(dllName, moduleName); | 93 | /// <param name="scene"></param> |
94 | if (module != null) | 94 | public void LoadSharedModule(string dllName, string moduleName) |
95 | { | 95 | { |
96 | LoadedSharedModules.Add(module.Name, module); | 96 | IRegionModule module = LoadModule(dllName, moduleName); |
97 | } | 97 | if (module != null) |
98 | } | 98 | { |
99 | 99 | LoadedSharedModules.Add(module.Name, module); | |
100 | public void LoadRegionModules(string dllName, Scene scene) | 100 | } |
101 | { | 101 | } |
102 | IRegionModule[] modules = LoadModules(dllName); | 102 | |
103 | 103 | public void LoadRegionModules(string dllName, Scene scene) | |
104 | if (modules.Length > 0) | 104 | { |
105 | { | 105 | IRegionModule[] modules = LoadModules(dllName); |
106 | m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); | 106 | |
107 | foreach (IRegionModule module in modules) | 107 | if (modules.Length > 0) |
108 | { | 108 | { |
109 | m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); | 109 | m_log.Verbose("MODULES", "Found Module Library [{0}]", dllName ); |
110 | InitializeModule(module, scene); | 110 | foreach (IRegionModule module in modules) |
111 | } | 111 | { |
112 | } | 112 | m_log.Verbose("MODULES", " [{0}]: Initializing.", module.Name); |
113 | } | 113 | InitializeModule(module, scene); |
114 | 114 | } | |
115 | public void LoadRegionModule(string dllName, string moduleName, Scene scene) | 115 | } |
116 | { | 116 | } |
117 | IRegionModule module = LoadModule(dllName, moduleName); | 117 | |
118 | if (module != null) | 118 | public void LoadRegionModule(string dllName, string moduleName, Scene scene) |
119 | { | 119 | { |
120 | InitializeModule(module, scene); | 120 | IRegionModule module = LoadModule(dllName, moduleName); |
121 | } | 121 | if (module != null) |
122 | } | 122 | { |
123 | 123 | InitializeModule(module, scene); | |
124 | /// <summary> | 124 | } |
125 | /// Loads a external Module (if not already loaded) and creates a new instance of it. | 125 | } |
126 | /// </summary> | 126 | |
127 | /// <param name="dllName"></param> | 127 | /// <summary> |
128 | /// <param name="moduleName"></param> | 128 | /// Loads a external Module (if not already loaded) and creates a new instance of it. |
129 | /// <param name="scene"></param> | 129 | /// </summary> |
130 | public IRegionModule LoadModule(string dllName, string moduleName) | 130 | /// <param name="dllName"></param> |
131 | { | 131 | /// <param name="moduleName"></param> |
132 | IRegionModule[] modules = LoadModules(dllName); | 132 | /// <param name="scene"></param> |
133 | 133 | public IRegionModule LoadModule(string dllName, string moduleName) | |
134 | foreach (IRegionModule module in modules) | 134 | { |
135 | { | 135 | IRegionModule[] modules = LoadModules(dllName); |
136 | if ((module != null) && (module.Name == moduleName)) | 136 | |
137 | { | 137 | foreach (IRegionModule module in modules) |
138 | return module; | 138 | { |
139 | } | 139 | if ((module != null) && (module.Name == moduleName)) |
140 | } | 140 | { |
141 | 141 | return module; | |
142 | return null; | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | public IRegionModule[] LoadModules(string dllName) | 145 | return null; |
146 | { | 146 | } |
147 | List<IRegionModule> modules = new List<IRegionModule>(); | 147 | |
148 | 148 | public IRegionModule[] LoadModules(string dllName) | |
149 | Assembly pluginAssembly; | 149 | { |
150 | if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) | 150 | List<IRegionModule> modules = new List<IRegionModule>(); |
151 | { | 151 | |
152 | try | 152 | Assembly pluginAssembly; |
153 | { | 153 | if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly )) |
154 | pluginAssembly = Assembly.LoadFrom(dllName); | 154 | { |
155 | LoadedAssemblys.Add(dllName, pluginAssembly); | 155 | try |
156 | } | 156 | { |
157 | catch( BadImageFormatException e ) | 157 | pluginAssembly = Assembly.LoadFrom(dllName); |
158 | { | 158 | LoadedAssemblys.Add(dllName, pluginAssembly); |
159 | m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); | 159 | } |
160 | } | 160 | catch( BadImageFormatException e ) |
161 | } | 161 | { |
162 | 162 | m_log.Warn( "MODULES", "The file [{0}] is not a module assembly.", e.FileName ); | |
163 | 163 | } | |
164 | if (pluginAssembly != null) | 164 | } |
165 | { | 165 | |
166 | foreach (Type pluginType in pluginAssembly.GetTypes()) | 166 | |
167 | { | 167 | if (pluginAssembly != null) |
168 | if (pluginType.IsPublic) | 168 | { |
169 | { | 169 | foreach (Type pluginType in pluginAssembly.GetTypes()) |
170 | if (!pluginType.IsAbstract) | 170 | { |
171 | { | 171 | if (pluginType.IsPublic) |
172 | if( pluginType.GetInterface("IRegionModule") != null ) | 172 | { |
173 | { | 173 | if (!pluginType.IsAbstract) |
174 | modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); | 174 | { |
175 | } | 175 | if( pluginType.GetInterface("IRegionModule") != null ) |
176 | } | 176 | { |
177 | } | 177 | modules.Add((IRegionModule) Activator.CreateInstance(pluginType)); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | } | |
181 | return modules.ToArray(); | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | public void PostInitialise() | 184 | return modules.ToArray(); |
185 | { | 185 | } |
186 | foreach (IRegionModule module in LoadedSharedModules.Values) | 186 | |
187 | { | 187 | public void PostInitialise() |
188 | module.PostInitialise(); | 188 | { |
189 | } | 189 | foreach (IRegionModule module in LoadedSharedModules.Values) |
190 | 190 | { | |
191 | foreach (IRegionModule module in LoadedModules) | 191 | module.PostInitialise(); |
192 | { | 192 | } |
193 | module.PostInitialise(); | 193 | |
194 | } | 194 | foreach (IRegionModule module in LoadedModules) |
195 | } | 195 | { |
196 | 196 | module.PostInitialise(); | |
197 | public void ClearCache() | 197 | } |
198 | { | 198 | } |
199 | LoadedAssemblys.Clear(); | 199 | |
200 | } | 200 | public void ClearCache() |
201 | } | 201 | { |
202 | } | 202 | LoadedAssemblys.Clear(); |
203 | } | ||
204 | } | ||
205 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs index 417e3bc..b53c05e 100644 --- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs | |||
@@ -29,6 +29,7 @@ | |||
29 | using OpenSim.Framework.Interfaces; | 29 | using OpenSim.Framework.Interfaces; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | using OpenSim.Region.Environment.Scenes; | 31 | using OpenSim.Region.Environment.Scenes; |
32 | using Nini.Config; | ||
32 | 33 | ||
33 | namespace OpenSim.Region.Environment.Modules | 34 | namespace OpenSim.Region.Environment.Modules |
34 | { | 35 | { |
@@ -40,7 +41,7 @@ namespace OpenSim.Region.Environment.Modules | |||
40 | { | 41 | { |
41 | } | 42 | } |
42 | 43 | ||
43 | public void Initialise(Scene scene) | 44 | public void Initialise(Scene scene, IConfigSource config) |
44 | { | 45 | { |
45 | m_scene = scene; | 46 | m_scene = scene; |
46 | m_scene.EventManager.OnNewClient += NewClient; | 47 | m_scene.EventManager.OnNewClient += NewClient; |
diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs index 9c627df..4bdb61b 100644 --- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs | |||
@@ -1,93 +1,94 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | using OpenSim.Framework.Interfaces; | 30 | using OpenSim.Framework.Interfaces; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | using OpenSim.Region.Environment.Scenes; | 32 | using OpenSim.Region.Environment.Scenes; |
33 | 33 | using Nini.Config; | |
34 | namespace OpenSim.Region.Environment.Modules | 34 | |
35 | { | 35 | namespace OpenSim.Region.Environment.Modules |
36 | public class AvatarProfilesModule : IRegionModule | 36 | { |
37 | { | 37 | public class AvatarProfilesModule : IRegionModule |
38 | private Scene m_scene; | 38 | { |
39 | 39 | private Scene m_scene; | |
40 | public AvatarProfilesModule() | 40 | |
41 | { | 41 | public AvatarProfilesModule() |
42 | } | 42 | { |
43 | 43 | } | |
44 | public void Initialise(Scene scene) | 44 | |
45 | { | 45 | public void Initialise(Scene scene, IConfigSource config) |
46 | m_scene = scene; | 46 | { |
47 | m_scene.EventManager.OnNewClient += NewClient; | 47 | m_scene = scene; |
48 | } | 48 | m_scene.EventManager.OnNewClient += NewClient; |
49 | 49 | } | |
50 | public void PostInitialise() | 50 | |
51 | { | 51 | public void PostInitialise() |
52 | } | 52 | { |
53 | 53 | } | |
54 | public void Close() | 54 | |
55 | { | 55 | public void Close() |
56 | } | 56 | { |
57 | 57 | } | |
58 | public string Name | 58 | |
59 | { | 59 | public string Name |
60 | get { return "AvatarProfilesModule"; } | 60 | { |
61 | } | 61 | get { return "AvatarProfilesModule"; } |
62 | 62 | } | |
63 | public bool IsSharedModule | 63 | |
64 | { | 64 | public bool IsSharedModule |
65 | get { return false; } | 65 | { |
66 | } | 66 | get { return false; } |
67 | 67 | } | |
68 | public void NewClient(IClientAPI client) | 68 | |
69 | { | 69 | public void NewClient(IClientAPI client) |
70 | client.OnRequestAvatarProperties += RequestAvatarProperty; | 70 | { |
71 | } | 71 | client.OnRequestAvatarProperties += RequestAvatarProperty; |
72 | 72 | } | |
73 | public void RemoveClient(IClientAPI client) | 73 | |
74 | { | 74 | public void RemoveClient(IClientAPI client) |
75 | client.OnRequestAvatarProperties -= RequestAvatarProperty; | 75 | { |
76 | } | 76 | client.OnRequestAvatarProperties -= RequestAvatarProperty; |
77 | 77 | } | |
78 | /// <summary> | 78 | |
79 | /// | 79 | /// <summary> |
80 | /// </summary> | 80 | /// |
81 | /// <param name="remoteClient"></param> | 81 | /// </summary> |
82 | /// <param name="avatarID"></param> | 82 | /// <param name="remoteClient"></param> |
83 | public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) | 83 | /// <param name="avatarID"></param> |
84 | { | 84 | public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) |
85 | string about = "OpenSim crash test dummy"; | 85 | { |
86 | string bornOn = "Before now"; | 86 | string about = "OpenSim crash test dummy"; |
87 | string flAbout = "First life? What is one of those? OpenSim is my life!"; | 87 | string bornOn = "Before now"; |
88 | LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); | 88 | string flAbout = "First life? What is one of those? OpenSim is my life!"; |
89 | remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", | 89 | LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); |
90 | partner); | 90 | remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", |
91 | } | 91 | partner); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 6b8050e..a85a12c 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -1,242 +1,243 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using libsecondlife; | 33 | using libsecondlife; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Utilities; | 35 | using OpenSim.Framework.Utilities; |
36 | using OpenSim.Region.Environment.Interfaces; | 36 | using OpenSim.Region.Environment.Interfaces; |
37 | using OpenSim.Region.Environment.Scenes; | 37 | using OpenSim.Region.Environment.Scenes; |
38 | 38 | using Nini.Config; | |
39 | namespace OpenSim.Region.Environment.Modules | 39 | |
40 | { | 40 | namespace OpenSim.Region.Environment.Modules |
41 | public class ChatModule : IRegionModule, ISimChat | 41 | { |
42 | { | 42 | public class ChatModule : IRegionModule, ISimChat |
43 | private Scene m_scene; | 43 | { |
44 | 44 | private Scene m_scene; | |
45 | private string m_server = "irc2.choopa.net"; | 45 | |
46 | 46 | private string m_server = "irc2.choopa.net"; | |
47 | // private int m_port = 6668; | 47 | |
48 | //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; | 48 | // private int m_port = 6668; |
49 | private string m_nick = "OSimBot"; | 49 | //private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; |
50 | private string m_channel = "#opensim"; | 50 | private string m_nick = "OSimBot"; |
51 | 51 | private string m_channel = "#opensim"; | |
52 | // private NetworkStream m_stream; | 52 | |
53 | private TcpClient m_irc; | 53 | // private NetworkStream m_stream; |
54 | private StreamWriter m_ircWriter; | 54 | private TcpClient m_irc; |
55 | private StreamReader m_ircReader; | 55 | private StreamWriter m_ircWriter; |
56 | 56 | private StreamReader m_ircReader; | |
57 | // private Thread pingSender; | 57 | |
58 | // private Thread listener; | 58 | // private Thread pingSender; |
59 | 59 | // private Thread listener; | |
60 | private bool connected = false; | 60 | |
61 | 61 | private bool connected = false; | |
62 | public ChatModule() | 62 | |
63 | { | 63 | public ChatModule() |
64 | m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); | 64 | { |
65 | m_irc = null; | 65 | m_nick = "OSimBot" + Util.RandomClass.Next(1, 99); |
66 | m_ircWriter = null; | 66 | m_irc = null; |
67 | m_ircReader = null; | 67 | m_ircWriter = null; |
68 | } | 68 | m_ircReader = null; |
69 | 69 | } | |
70 | public void Initialise(Scene scene) | 70 | |
71 | { | 71 | public void Initialise(Scene scene, IConfigSource config) |
72 | m_scene = scene; | 72 | { |
73 | m_scene.EventManager.OnNewClient += NewClient; | 73 | m_scene = scene; |
74 | 74 | m_scene.EventManager.OnNewClient += NewClient; | |
75 | m_scene.RegisterModuleInterface<ISimChat>(this); | 75 | |
76 | } | 76 | m_scene.RegisterModuleInterface<ISimChat>(this); |
77 | 77 | } | |
78 | public void PostInitialise() | 78 | |
79 | { | 79 | public void PostInitialise() |
80 | /* | 80 | { |
81 | try | 81 | /* |
82 | { | 82 | try |
83 | m_irc = new TcpClient(m_server, m_port); | 83 | { |
84 | m_stream = m_irc.GetStream(); | 84 | m_irc = new TcpClient(m_server, m_port); |
85 | m_ircReader = new StreamReader(m_stream); | 85 | m_stream = m_irc.GetStream(); |
86 | m_ircWriter = new StreamWriter(m_stream); | 86 | m_ircReader = new StreamReader(m_stream); |
87 | 87 | m_ircWriter = new StreamWriter(m_stream); | |
88 | pingSender = new Thread(new ThreadStart(this.PingRun)); | 88 | |
89 | pingSender.Start(); | 89 | pingSender = new Thread(new ThreadStart(this.PingRun)); |
90 | 90 | pingSender.Start(); | |
91 | listener = new Thread(new ThreadStart(this.ListenerRun)); | 91 | |
92 | listener.Start(); | 92 | listener = new Thread(new ThreadStart(this.ListenerRun)); |
93 | 93 | listener.Start(); | |
94 | m_ircWriter.WriteLine(m_user); | 94 | |
95 | m_ircWriter.Flush(); | 95 | m_ircWriter.WriteLine(m_user); |
96 | m_ircWriter.WriteLine("NICK " + m_nick); | 96 | m_ircWriter.Flush(); |
97 | m_ircWriter.Flush(); | 97 | m_ircWriter.WriteLine("NICK " + m_nick); |
98 | m_ircWriter.WriteLine("JOIN " + m_channel); | 98 | m_ircWriter.Flush(); |
99 | m_ircWriter.Flush(); | 99 | m_ircWriter.WriteLine("JOIN " + m_channel); |
100 | connected = true; | 100 | m_ircWriter.Flush(); |
101 | } | 101 | connected = true; |
102 | catch (Exception e) | 102 | } |
103 | { | 103 | catch (Exception e) |
104 | Console.WriteLine(e.ToString()); | 104 | { |
105 | } | 105 | Console.WriteLine(e.ToString()); |
106 | */ | 106 | } |
107 | } | 107 | */ |
108 | 108 | } | |
109 | public void Close() | 109 | |
110 | { | 110 | public void Close() |
111 | m_ircWriter.Close(); | 111 | { |
112 | m_ircReader.Close(); | 112 | m_ircWriter.Close(); |
113 | m_irc.Close(); | 113 | m_ircReader.Close(); |
114 | } | 114 | m_irc.Close(); |
115 | 115 | } | |
116 | public string Name | 116 | |
117 | { | 117 | public string Name |
118 | get { return "ChatModule"; } | 118 | { |
119 | } | 119 | get { return "ChatModule"; } |
120 | 120 | } | |
121 | public bool IsSharedModule | 121 | |
122 | { | 122 | public bool IsSharedModule |
123 | get { return false; } | 123 | { |
124 | } | 124 | get { return false; } |
125 | 125 | } | |
126 | public void NewClient(IClientAPI client) | 126 | |
127 | { | 127 | public void NewClient(IClientAPI client) |
128 | client.OnChatFromViewer += SimChat; | 128 | { |
129 | } | 129 | client.OnChatFromViewer += SimChat; |
130 | 130 | } | |
131 | public void PingRun() | 131 | |
132 | { | 132 | public void PingRun() |
133 | while (true) | 133 | { |
134 | { | 134 | while (true) |
135 | m_ircWriter.WriteLine("PING :" + m_server); | 135 | { |
136 | m_ircWriter.Flush(); | 136 | m_ircWriter.WriteLine("PING :" + m_server); |
137 | Thread.Sleep(15000); | 137 | m_ircWriter.Flush(); |
138 | } | 138 | Thread.Sleep(15000); |
139 | } | 139 | } |
140 | 140 | } | |
141 | public void ListenerRun() | 141 | |
142 | { | 142 | public void ListenerRun() |
143 | string inputLine; | 143 | { |
144 | LLVector3 pos = new LLVector3(128, 128, 20); | 144 | string inputLine; |
145 | while (true) | 145 | LLVector3 pos = new LLVector3(128, 128, 20); |
146 | { | 146 | while (true) |
147 | while ((inputLine = m_ircReader.ReadLine()) != null) | 147 | { |
148 | { | 148 | while ((inputLine = m_ircReader.ReadLine()) != null) |
149 | Console.WriteLine(inputLine); | 149 | { |
150 | if (inputLine.Contains(m_channel)) | 150 | Console.WriteLine(inputLine); |
151 | { | 151 | if (inputLine.Contains(m_channel)) |
152 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); | 152 | { |
153 | m_scene.Broadcast(delegate(IClientAPI client) | 153 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); |
154 | { | 154 | m_scene.Broadcast(delegate(IClientAPI client) |
155 | client.SendChatMessage( | 155 | { |
156 | Helpers.StringToField(mess), 255, pos, "IRC:", | 156 | client.SendChatMessage( |
157 | LLUUID.Zero); | 157 | Helpers.StringToField(mess), 255, pos, "IRC:", |
158 | }); | 158 | LLUUID.Zero); |
159 | } | 159 | }); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | } | |
164 | public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, | 164 | |
165 | LLUUID fromAgentID) | 165 | public void SimChat(byte[] message, byte type, int channel, LLVector3 fromPos, string fromName, |
166 | { | 166 | LLUUID fromAgentID) |
167 | ScenePresence avatar = null; | 167 | { |
168 | avatar = m_scene.GetScenePresence(fromAgentID); | 168 | ScenePresence avatar = null; |
169 | if (avatar != null) | 169 | avatar = m_scene.GetScenePresence(fromAgentID); |
170 | { | 170 | if (avatar != null) |
171 | fromPos = avatar.AbsolutePosition; | 171 | { |
172 | fromName = avatar.Firstname + " " + avatar.Lastname; | 172 | fromPos = avatar.AbsolutePosition; |
173 | avatar = null; | 173 | fromName = avatar.Firstname + " " + avatar.Lastname; |
174 | } | 174 | avatar = null; |
175 | 175 | } | |
176 | if (connected) | 176 | |
177 | { | 177 | if (connected) |
178 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + | 178 | { |
179 | Util.FieldToString(message)); | 179 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + |
180 | m_ircWriter.Flush(); | 180 | Util.FieldToString(message)); |
181 | } | 181 | m_ircWriter.Flush(); |
182 | 182 | } | |
183 | if (channel == 0) | 183 | |
184 | { | 184 | if (channel == 0) |
185 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | 185 | { |
186 | { | 186 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) |
187 | int dis = -1000; | 187 | { |
188 | 188 | int dis = -1000; | |
189 | //err ??? the following code seems to be request a scenePresence when it already has a ref to it | 189 | |
190 | avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId); | 190 | //err ??? the following code seems to be request a scenePresence when it already has a ref to it |
191 | if (avatar != null) | 191 | avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId); |
192 | { | 192 | if (avatar != null) |
193 | dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); | 193 | { |
194 | } | 194 | dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); |
195 | 195 | } | |
196 | switch (type) | 196 | |
197 | { | 197 | switch (type) |
198 | case 0: // Whisper | 198 | { |
199 | if ((dis < 10) && (dis > -10)) | 199 | case 0: // Whisper |
200 | { | 200 | if ((dis < 10) && (dis > -10)) |
201 | //should change so the message is sent through the avatar rather than direct to the ClientView | 201 | { |
202 | presence.ControllingClient.SendChatMessage(message, | 202 | //should change so the message is sent through the avatar rather than direct to the ClientView |
203 | type, | 203 | presence.ControllingClient.SendChatMessage(message, |
204 | fromPos, | 204 | type, |
205 | fromName, | 205 | fromPos, |
206 | fromAgentID); | 206 | fromName, |
207 | } | 207 | fromAgentID); |
208 | break; | 208 | } |
209 | case 1: // Say | 209 | break; |
210 | if ((dis < 30) && (dis > -30)) | 210 | case 1: // Say |
211 | { | 211 | if ((dis < 30) && (dis > -30)) |
212 | //Console.WriteLine("sending chat"); | 212 | { |
213 | presence.ControllingClient.SendChatMessage(message, | 213 | //Console.WriteLine("sending chat"); |
214 | type, | 214 | presence.ControllingClient.SendChatMessage(message, |
215 | fromPos, | 215 | type, |
216 | fromName, | 216 | fromPos, |
217 | fromAgentID); | 217 | fromName, |
218 | } | 218 | fromAgentID); |
219 | break; | 219 | } |
220 | case 2: // Shout | 220 | break; |
221 | if ((dis < 100) && (dis > -100)) | 221 | case 2: // Shout |
222 | { | 222 | if ((dis < 100) && (dis > -100)) |
223 | presence.ControllingClient.SendChatMessage(message, | 223 | { |
224 | type, | 224 | presence.ControllingClient.SendChatMessage(message, |
225 | fromPos, | 225 | type, |
226 | fromName, | 226 | fromPos, |
227 | fromAgentID); | 227 | fromName, |
228 | } | 228 | fromAgentID); |
229 | break; | 229 | } |
230 | 230 | break; | |
231 | case 0xff: // Broadcast | 231 | |
232 | presence.ControllingClient.SendChatMessage(message, type, | 232 | case 0xff: // Broadcast |
233 | fromPos, | 233 | presence.ControllingClient.SendChatMessage(message, type, |
234 | fromName, | 234 | fromPos, |
235 | fromAgentID); | 235 | fromName, |
236 | break; | 236 | fromAgentID); |
237 | } | 237 | break; |
238 | }); | 238 | } |
239 | } | 239 | }); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs index e776717..4e29977 100644 --- a/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/DynamicTextureModule.cs | |||
@@ -1,190 +1,191 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using OpenSim.Framework.Types; | 32 | using OpenSim.Framework.Types; |
33 | using OpenSim.Framework.Utilities; | 33 | using OpenSim.Framework.Utilities; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | using OpenSim.Region.Environment.Scenes; | 35 | using OpenSim.Region.Environment.Scenes; |
36 | 36 | using Nini.Config; | |
37 | namespace OpenSim.Region.Environment.Modules | 37 | |
38 | { | 38 | namespace OpenSim.Region.Environment.Modules |
39 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 39 | { |
40 | { | 40 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager |
41 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); | 41 | { |
42 | 42 | private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); | |
43 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = | 43 | |
44 | new Dictionary<string, IDynamicTextureRender>(); | 44 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = |
45 | 45 | new Dictionary<string, IDynamicTextureRender>(); | |
46 | private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); | 46 | |
47 | 47 | private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); | |
48 | public void Initialise(Scene scene) | 48 | |
49 | { | 49 | public void Initialise(Scene scene, IConfigSource config) |
50 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 50 | { |
51 | { | 51 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
52 | RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); | 52 | { |
53 | scene.RegisterModuleInterface<IDynamicTextureManager>(this); | 53 | RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); |
54 | } | 54 | scene.RegisterModuleInterface<IDynamicTextureManager>(this); |
55 | } | 55 | } |
56 | 56 | } | |
57 | public void PostInitialise() | 57 | |
58 | { | 58 | public void PostInitialise() |
59 | } | 59 | { |
60 | 60 | } | |
61 | public void Close() | 61 | |
62 | { | 62 | public void Close() |
63 | } | 63 | { |
64 | 64 | } | |
65 | public string Name | 65 | |
66 | { | 66 | public string Name |
67 | get { return "DynamicTextureModule"; } | 67 | { |
68 | } | 68 | get { return "DynamicTextureModule"; } |
69 | 69 | } | |
70 | public bool IsSharedModule | 70 | |
71 | { | 71 | public bool IsSharedModule |
72 | get { return true; } | 72 | { |
73 | } | 73 | get { return true; } |
74 | 74 | } | |
75 | public void RegisterRender(string handleType, IDynamicTextureRender render) | 75 | |
76 | { | 76 | public void RegisterRender(string handleType, IDynamicTextureRender render) |
77 | if (!RenderPlugins.ContainsKey(handleType)) | 77 | { |
78 | { | 78 | if (!RenderPlugins.ContainsKey(handleType)) |
79 | RenderPlugins.Add(handleType, render); | 79 | { |
80 | } | 80 | RenderPlugins.Add(handleType, render); |
81 | } | 81 | } |
82 | 82 | } | |
83 | public void ReturnData(LLUUID id, byte[] data) | 83 | |
84 | { | 84 | public void ReturnData(LLUUID id, byte[] data) |
85 | if (Updaters.ContainsKey(id)) | 85 | { |
86 | { | 86 | if (Updaters.ContainsKey(id)) |
87 | DynamicTextureUpdater updater = Updaters[id]; | 87 | { |
88 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) | 88 | DynamicTextureUpdater updater = Updaters[id]; |
89 | { | 89 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) |
90 | Scene scene = RegisteredScenes[updater.SimUUID]; | 90 | { |
91 | updater.DataReceived(data, scene); | 91 | Scene scene = RegisteredScenes[updater.SimUUID]; |
92 | } | 92 | updater.DataReceived(data, scene); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | } | |
96 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, | 96 | |
97 | string extraParams, int updateTimer) | 97 | public LLUUID AddDynamicTextureURL(LLUUID simID, LLUUID primID, string contentType, string url, |
98 | { | 98 | string extraParams, int updateTimer) |
99 | if (RenderPlugins.ContainsKey(contentType)) | 99 | { |
100 | { | 100 | if (RenderPlugins.ContainsKey(contentType)) |
101 | //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); | 101 | { |
102 | 102 | //Console.WriteLine("dynamic texture being created: " + url + " of type " + contentType); | |
103 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | 103 | |
104 | updater.SimUUID = simID; | 104 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); |
105 | updater.PrimID = primID; | 105 | updater.SimUUID = simID; |
106 | updater.ContentType = contentType; | 106 | updater.PrimID = primID; |
107 | updater.Url = url; | 107 | updater.ContentType = contentType; |
108 | updater.UpdateTimer = updateTimer; | 108 | updater.Url = url; |
109 | updater.UpdaterID = LLUUID.Random(); | 109 | updater.UpdateTimer = updateTimer; |
110 | updater.Params = extraParams; | 110 | updater.UpdaterID = LLUUID.Random(); |
111 | 111 | updater.Params = extraParams; | |
112 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 112 | |
113 | { | 113 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
114 | Updaters.Add(updater.UpdaterID, updater); | 114 | { |
115 | } | 115 | Updaters.Add(updater.UpdaterID, updater); |
116 | 116 | } | |
117 | RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); | 117 | |
118 | return updater.UpdaterID; | 118 | RenderPlugins[contentType].AsyncConvertUrl(updater.UpdaterID, url, extraParams); |
119 | } | 119 | return updater.UpdaterID; |
120 | return LLUUID.Zero; | 120 | } |
121 | } | 121 | return LLUUID.Zero; |
122 | 122 | } | |
123 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, | 123 | |
124 | string extraParams, int updateTimer) | 124 | public LLUUID AddDynamicTextureData(LLUUID simID, LLUUID primID, string contentType, string data, |
125 | { | 125 | string extraParams, int updateTimer) |
126 | if (RenderPlugins.ContainsKey(contentType)) | 126 | { |
127 | { | 127 | if (RenderPlugins.ContainsKey(contentType)) |
128 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); | 128 | { |
129 | updater.SimUUID = simID; | 129 | DynamicTextureUpdater updater = new DynamicTextureUpdater(); |
130 | updater.PrimID = primID; | 130 | updater.SimUUID = simID; |
131 | updater.ContentType = contentType; | 131 | updater.PrimID = primID; |
132 | updater.BodyData = data; | 132 | updater.ContentType = contentType; |
133 | updater.UpdateTimer = updateTimer; | 133 | updater.BodyData = data; |
134 | updater.UpdaterID = LLUUID.Random(); | 134 | updater.UpdateTimer = updateTimer; |
135 | updater.Params = extraParams; | 135 | updater.UpdaterID = LLUUID.Random(); |
136 | 136 | updater.Params = extraParams; | |
137 | if (!Updaters.ContainsKey(updater.UpdaterID)) | 137 | |
138 | { | 138 | if (!Updaters.ContainsKey(updater.UpdaterID)) |
139 | Updaters.Add(updater.UpdaterID, updater); | 139 | { |
140 | } | 140 | Updaters.Add(updater.UpdaterID, updater); |
141 | 141 | } | |
142 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); | 142 | |
143 | return updater.UpdaterID; | 143 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); |
144 | } | 144 | return updater.UpdaterID; |
145 | return LLUUID.Zero; | 145 | } |
146 | } | 146 | return LLUUID.Zero; |
147 | 147 | } | |
148 | public class DynamicTextureUpdater | 148 | |
149 | { | 149 | public class DynamicTextureUpdater |
150 | public LLUUID SimUUID; | 150 | { |
151 | public LLUUID UpdaterID; | 151 | public LLUUID SimUUID; |
152 | public string ContentType; | 152 | public LLUUID UpdaterID; |
153 | public string Url; | 153 | public string ContentType; |
154 | public string BodyData; | 154 | public string Url; |
155 | public LLUUID PrimID; | 155 | public string BodyData; |
156 | public int UpdateTimer; | 156 | public LLUUID PrimID; |
157 | public LLUUID LastAssetID; | 157 | public int UpdateTimer; |
158 | public string Params; | 158 | public LLUUID LastAssetID; |
159 | 159 | public string Params; | |
160 | public DynamicTextureUpdater() | 160 | |
161 | { | 161 | public DynamicTextureUpdater() |
162 | LastAssetID = LLUUID.Zero; | 162 | { |
163 | UpdateTimer = 0; | 163 | LastAssetID = LLUUID.Zero; |
164 | BodyData = null; | 164 | UpdateTimer = 0; |
165 | } | 165 | BodyData = null; |
166 | 166 | } | |
167 | public void DataReceived(byte[] data, Scene scene) | 167 | |
168 | { | 168 | public void DataReceived(byte[] data, Scene scene) |
169 | //TODO delete the last asset(data), if it was a dynamic texture | 169 | { |
170 | byte[] assetData = new byte[data.Length]; | 170 | //TODO delete the last asset(data), if it was a dynamic texture |
171 | Array.Copy(data, assetData, data.Length); | 171 | byte[] assetData = new byte[data.Length]; |
172 | AssetBase asset = new AssetBase(); | 172 | Array.Copy(data, assetData, data.Length); |
173 | asset.FullID = LLUUID.Random(); | 173 | AssetBase asset = new AssetBase(); |
174 | asset.Data = assetData; | 174 | asset.FullID = LLUUID.Random(); |
175 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); | 175 | asset.Data = assetData; |
176 | asset.Type = 0; | 176 | asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000); |
177 | asset.Description = "dynamic image"; | 177 | asset.Type = 0; |
178 | asset.Local = false; | 178 | asset.Description = "dynamic image"; |
179 | asset.Temporary = false; | 179 | asset.Local = false; |
180 | scene.commsManager.AssetCache.AddAsset(asset); | 180 | asset.Temporary = false; |
181 | 181 | scene.commsManager.AssetCache.AddAsset(asset); | |
182 | LastAssetID = asset.FullID; | 182 | |
183 | 183 | LastAssetID = asset.FullID; | |
184 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); | 184 | |
185 | part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); | 185 | SceneObjectPart part = scene.GetSceneObjectPart(PrimID); |
186 | part.ScheduleFullUpdate(); | 186 | part.Shape.TextureEntry = new LLObject.TextureEntry(asset.FullID).ToBytes(); |
187 | } | 187 | part.ScheduleFullUpdate(); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs index 1b51d9e..9144bee 100644 --- a/OpenSim/Region/Environment/Modules/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs | |||
@@ -1,61 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
31 | 31 | using Nini.Config; | |
32 | namespace OpenSim.Region.Environment.Modules | 32 | |
33 | { | 33 | namespace OpenSim.Region.Environment.Modules |
34 | public class FriendsModule : IRegionModule | 34 | { |
35 | { | 35 | public class FriendsModule : IRegionModule |
36 | private Scene m_scene; | 36 | { |
37 | 37 | private Scene m_scene; | |
38 | public void Initialise(Scene scene) | 38 | |
39 | { | 39 | public void Initialise(Scene scene, IConfigSource config) |
40 | m_scene = scene; | 40 | { |
41 | } | 41 | m_scene = scene; |
42 | 42 | } | |
43 | public void PostInitialise() | 43 | |
44 | { | 44 | public void PostInitialise() |
45 | } | 45 | { |
46 | 46 | } | |
47 | public void Close() | 47 | |
48 | { | 48 | public void Close() |
49 | } | 49 | { |
50 | 50 | } | |
51 | public string Name | 51 | |
52 | { | 52 | public string Name |
53 | get { return "FriendsModule"; } | 53 | { |
54 | } | 54 | get { return "FriendsModule"; } |
55 | 55 | } | |
56 | public bool IsSharedModule | 56 | |
57 | { | 57 | public bool IsSharedModule |
58 | get { return false; } | 58 | { |
59 | } | 59 | get { return false; } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs index a024ccd..150f294 100644 --- a/OpenSim/Region/Environment/Modules/GroupsModule.cs +++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs | |||
@@ -1,61 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
31 | 31 | using Nini.Config; | |
32 | namespace OpenSim.Region.Environment.Modules | 32 | |
33 | { | 33 | namespace OpenSim.Region.Environment.Modules |
34 | public class GroupsModule : IRegionModule | 34 | { |
35 | { | 35 | public class GroupsModule : IRegionModule |
36 | private Scene m_scene; | 36 | { |
37 | 37 | private Scene m_scene; | |
38 | public void Initialise(Scene scene) | 38 | |
39 | { | 39 | public void Initialise(Scene scene, IConfigSource config) |
40 | m_scene = scene; | 40 | { |
41 | } | 41 | m_scene = scene; |
42 | 42 | } | |
43 | public void PostInitialise() | 43 | |
44 | { | 44 | public void PostInitialise() |
45 | } | 45 | { |
46 | 46 | } | |
47 | public void Close() | 47 | |
48 | { | 48 | public void Close() |
49 | } | 49 | { |
50 | 50 | } | |
51 | public string Name | 51 | |
52 | { | 52 | public string Name |
53 | get { return "GroupsModule"; } | 53 | { |
54 | } | 54 | get { return "GroupsModule"; } |
55 | 55 | } | |
56 | public bool IsSharedModule | 56 | |
57 | { | 57 | public bool IsSharedModule |
58 | get { return false; } | 58 | { |
59 | } | 59 | get { return false; } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs index dbd2434..7c4e2c8 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs | |||
@@ -1,100 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | using OpenSim.Region.Environment.Scenes; | 31 | using OpenSim.Region.Environment.Scenes; |
32 | using OpenSim.Framework.Console; | 32 | using OpenSim.Framework.Console; |
33 | 33 | using Nini.Config; | |
34 | namespace OpenSim.Region.Environment.Modules | 34 | |
35 | { | 35 | namespace OpenSim.Region.Environment.Modules |
36 | public class InstantMessageModule : IRegionModule | 36 | { |
37 | { | 37 | public class InstantMessageModule : IRegionModule |
38 | private List<Scene> m_scenes = new List<Scene>(); | 38 | { |
39 | private LogBase m_log; | 39 | private List<Scene> m_scenes = new List<Scene>(); |
40 | 40 | private LogBase m_log; | |
41 | public void Initialise(Scene scene) | 41 | |
42 | { | 42 | public void Initialise(Scene scene, IConfigSource config) |
43 | if (!m_scenes.Contains(scene)) | 43 | { |
44 | { | 44 | if (!m_scenes.Contains(scene)) |
45 | m_scenes.Add(scene); | 45 | { |
46 | 46 | m_scenes.Add(scene); | |
47 | scene.EventManager.OnNewClient += OnNewClient; | 47 | |
48 | m_log = OpenSim.Framework.Console.MainLog.Instance; | 48 | scene.EventManager.OnNewClient += OnNewClient; |
49 | } | 49 | m_log = OpenSim.Framework.Console.MainLog.Instance; |
50 | } | 50 | } |
51 | 51 | } | |
52 | void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client) | 52 | |
53 | { | 53 | void OnNewClient(OpenSim.Framework.Interfaces.IClientAPI client) |
54 | client.OnInstantMessage += OnInstantMessage; | 54 | { |
55 | } | 55 | client.OnInstantMessage += OnInstantMessage; |
56 | 56 | } | |
57 | void OnInstantMessage(libsecondlife.LLUUID fromAgentID, | 57 | |
58 | libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID, | 58 | void OnInstantMessage(libsecondlife.LLUUID fromAgentID, |
59 | libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName, | 59 | libsecondlife.LLUUID fromAgentSession, libsecondlife.LLUUID toAgentID, |
60 | string message, byte dialog) | 60 | libsecondlife.LLUUID imSessionID, uint timestamp, string fromAgentName, |
61 | { | 61 | string message, byte dialog) |
62 | // TODO: Remove after debugging. Privacy implications. | 62 | { |
63 | m_log.Verbose("IM",fromAgentName + ": " + message); | 63 | // TODO: Remove after debugging. Privacy implications. |
64 | 64 | m_log.Verbose("IM",fromAgentName + ": " + message); | |
65 | foreach (Scene m_scene in m_scenes) | 65 | |
66 | { | 66 | foreach (Scene m_scene in m_scenes) |
67 | if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) | 67 | { |
68 | { | 68 | if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) |
69 | // Local Message | 69 | { |
70 | ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; | 70 | // Local Message |
71 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | 71 | ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; |
72 | toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp); | 72 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, |
73 | 73 | toAgentID, imSessionID, user.Firstname + " " + user.Lastname, dialog, timestamp); | |
74 | // Message sent | 74 | |
75 | return; | 75 | // Message sent |
76 | } | 76 | return; |
77 | } | 77 | } |
78 | 78 | } | |
79 | // Still here, try send via Grid | 79 | |
80 | } | 80 | // Still here, try send via Grid |
81 | 81 | } | |
82 | public void PostInitialise() | 82 | |
83 | { | 83 | public void PostInitialise() |
84 | } | 84 | { |
85 | 85 | } | |
86 | public void Close() | 86 | |
87 | { | 87 | public void Close() |
88 | } | 88 | { |
89 | 89 | } | |
90 | public string Name | 90 | |
91 | { | 91 | public string Name |
92 | get { return "InstantMessageModule"; } | 92 | { |
93 | } | 93 | get { return "InstantMessageModule"; } |
94 | 94 | } | |
95 | public bool IsSharedModule | 95 | |
96 | { | 96 | public bool IsSharedModule |
97 | get { return true; } | 97 | { |
98 | } | 98 | get { return true; } |
99 | } | 99 | } |
100 | } | 100 | } |
101 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/InventoryModule.cs index d3b90c2..3f8cd6e 100644 --- a/OpenSim/Region/Environment/Modules/InventoryModule.cs +++ b/OpenSim/Region/Environment/Modules/InventoryModule.cs | |||
@@ -1,61 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | using OpenSim.Region.Environment.Scenes; | 30 | using OpenSim.Region.Environment.Scenes; |
31 | 31 | using Nini.Config; | |
32 | namespace OpenSim.Region.Environment.Modules | 32 | |
33 | { | 33 | namespace OpenSim.Region.Environment.Modules |
34 | public class InventoryModule : IRegionModule | 34 | { |
35 | { | 35 | public class InventoryModule : IRegionModule |
36 | private Scene m_scene; | 36 | { |
37 | 37 | private Scene m_scene; | |
38 | public void Initialise(Scene scene) | 38 | |
39 | { | 39 | public void Initialise(Scene scene, IConfigSource config) |
40 | m_scene = scene; | 40 | { |
41 | } | 41 | m_scene = scene; |
42 | 42 | } | |
43 | public void PostInitialise() | 43 | |
44 | { | 44 | public void PostInitialise() |
45 | } | 45 | { |
46 | 46 | } | |
47 | public void Close() | 47 | |
48 | { | 48 | public void Close() |
49 | } | 49 | { |
50 | 50 | } | |
51 | public string Name | 51 | |
52 | { | 52 | public string Name |
53 | get { return "InventoryModule"; } | 53 | { |
54 | } | 54 | get { return "InventoryModule"; } |
55 | 55 | } | |
56 | public bool IsSharedModule | 56 | |
57 | { | 57 | public bool IsSharedModule |
58 | get { return false; } | 58 | { |
59 | } | 59 | get { return false; } |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs index f1f479d..8b8b386 100644 --- a/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/LoadImageURLModule.cs | |||
@@ -1,123 +1,124 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.Net; | 4 | using System.Net; |
5 | using System.IO; | 5 | using System.IO; |
6 | using System.Drawing; | 6 | using System.Drawing; |
7 | using libsecondlife; | 7 | using libsecondlife; |
8 | using OpenJPEGNet; | 8 | using OpenJPEGNet; |
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | using OpenSim.Region.Environment.Interfaces; | 10 | using OpenSim.Region.Environment.Interfaces; |
11 | 11 | using Nini.Config; | |
12 | namespace OpenSim.Region.Environment.Modules | 12 | |
13 | { | 13 | namespace OpenSim.Region.Environment.Modules |
14 | public class LoadImageURLModule : IRegionModule , IDynamicTextureRender | 14 | { |
15 | { | 15 | public class LoadImageURLModule : IRegionModule , IDynamicTextureRender |
16 | private string m_name = "LoadImageURL"; | 16 | { |
17 | private IDynamicTextureManager m_textureManager; | 17 | private string m_name = "LoadImageURL"; |
18 | private Scene m_scene; | 18 | private IDynamicTextureManager m_textureManager; |
19 | 19 | private Scene m_scene; | |
20 | public void Initialise(Scene scene) | 20 | |
21 | { | 21 | public void Initialise(Scene scene, IConfigSource config) |
22 | if (m_scene == null) | 22 | { |
23 | { | 23 | if (m_scene == null) |
24 | m_scene = scene; | 24 | { |
25 | } | 25 | m_scene = scene; |
26 | } | 26 | } |
27 | 27 | } | |
28 | public void PostInitialise() | 28 | |
29 | { | 29 | public void PostInitialise() |
30 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | 30 | { |
31 | m_textureManager.RegisterRender(GetContentType(), this); | 31 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); |
32 | } | 32 | m_textureManager.RegisterRender(GetContentType(), this); |
33 | 33 | } | |
34 | public void Close() | 34 | |
35 | { | 35 | public void Close() |
36 | } | 36 | { |
37 | 37 | } | |
38 | public string Name | 38 | |
39 | { | 39 | public string Name |
40 | get { return m_name; } | 40 | { |
41 | } | 41 | get { return m_name; } |
42 | 42 | } | |
43 | public bool IsSharedModule | 43 | |
44 | { | 44 | public bool IsSharedModule |
45 | get { return true; } | 45 | { |
46 | } | 46 | get { return true; } |
47 | 47 | } | |
48 | public string GetName() | 48 | |
49 | { | 49 | public string GetName() |
50 | return m_name; | 50 | { |
51 | } | 51 | return m_name; |
52 | 52 | } | |
53 | public string GetContentType() | 53 | |
54 | { | 54 | public string GetContentType() |
55 | return ("image"); | 55 | { |
56 | } | 56 | return ("image"); |
57 | 57 | } | |
58 | public bool SupportsAsynchronous() | 58 | |
59 | { | 59 | public bool SupportsAsynchronous() |
60 | return true; | 60 | { |
61 | } | 61 | return true; |
62 | 62 | } | |
63 | public byte[] ConvertUrl(string url, string extraParams) | 63 | |
64 | { | 64 | public byte[] ConvertUrl(string url, string extraParams) |
65 | return null; | 65 | { |
66 | } | 66 | return null; |
67 | 67 | } | |
68 | public byte[] ConvertStream(Stream data, string extraParams) | 68 | |
69 | { | 69 | public byte[] ConvertStream(Stream data, string extraParams) |
70 | return null; | 70 | { |
71 | } | 71 | return null; |
72 | 72 | } | |
73 | public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) | 73 | |
74 | { | 74 | public bool AsyncConvertUrl(LLUUID id, string url, string extraParams) |
75 | MakeHttpRequest(url, id); | 75 | { |
76 | return true; | 76 | MakeHttpRequest(url, id); |
77 | } | 77 | return true; |
78 | 78 | } | |
79 | public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) | 79 | |
80 | { | 80 | public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams) |
81 | return false; | 81 | { |
82 | } | 82 | return false; |
83 | 83 | } | |
84 | private void MakeHttpRequest(string url, LLUUID requestID) | 84 | |
85 | { | 85 | private void MakeHttpRequest(string url, LLUUID requestID) |
86 | WebRequest request = HttpWebRequest.Create(url); | 86 | { |
87 | RequestState state = new RequestState((HttpWebRequest)request, requestID); | 87 | WebRequest request = HttpWebRequest.Create(url); |
88 | IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); | 88 | RequestState state = new RequestState((HttpWebRequest)request, requestID); |
89 | 89 | IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); | |
90 | TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); | 90 | |
91 | state.TimeOfRequest = (int)t.TotalSeconds; | 91 | TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); |
92 | } | 92 | state.TimeOfRequest = (int)t.TotalSeconds; |
93 | 93 | } | |
94 | private void HttpRequestReturn(IAsyncResult result) | 94 | |
95 | { | 95 | private void HttpRequestReturn(IAsyncResult result) |
96 | RequestState state = (RequestState)result.AsyncState; | 96 | { |
97 | WebRequest request = (WebRequest)state.Request; | 97 | RequestState state = (RequestState)result.AsyncState; |
98 | HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); | 98 | WebRequest request = (WebRequest)state.Request; |
99 | if (response.StatusCode == HttpStatusCode.OK) | 99 | HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); |
100 | { | 100 | if (response.StatusCode == HttpStatusCode.OK) |
101 | Bitmap image = new Bitmap(response.GetResponseStream()); | 101 | { |
102 | Bitmap resize = new Bitmap(image, new Size(512, 512)); | 102 | Bitmap image = new Bitmap(response.GetResponseStream()); |
103 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | 103 | Bitmap resize = new Bitmap(image, new Size(512, 512)); |
104 | 104 | byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | |
105 | m_textureManager.ReturnData(state.RequestID, imageJ2000); | 105 | |
106 | } | 106 | m_textureManager.ReturnData(state.RequestID, imageJ2000); |
107 | } | 107 | } |
108 | 108 | } | |
109 | public class RequestState | 109 | |
110 | { | 110 | public class RequestState |
111 | public HttpWebRequest Request = null; | 111 | { |
112 | public LLUUID RequestID = LLUUID.Zero; | 112 | public HttpWebRequest Request = null; |
113 | public int TimeOfRequest = 0; | 113 | public LLUUID RequestID = LLUUID.Zero; |
114 | 114 | public int TimeOfRequest = 0; | |
115 | public RequestState(HttpWebRequest request, LLUUID requestID) | 115 | |
116 | { | 116 | public RequestState(HttpWebRequest request, LLUUID requestID) |
117 | Request = request; | 117 | { |
118 | RequestID = requestID; | 118 | Request = request; |
119 | } | 119 | RequestID = requestID; |
120 | } | 120 | } |
121 | 121 | } | |
122 | } | 122 | |
123 | } | 123 | } |
124 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 2531265..d3297c8 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs | |||
@@ -1,76 +1,77 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | using OpenSim.Framework.Interfaces; | 30 | using OpenSim.Framework.Interfaces; |
31 | using OpenSim.Region.Environment.Interfaces; | 31 | using OpenSim.Region.Environment.Interfaces; |
32 | using OpenSim.Region.Environment.Scenes; | 32 | using OpenSim.Region.Environment.Scenes; |
33 | 33 | using Nini.Config; | |
34 | namespace OpenSim.Region.Environment.Modules | 34 | |
35 | { | 35 | namespace OpenSim.Region.Environment.Modules |
36 | public class TextureDownloadModule : IRegionModule | 36 | { |
37 | { | 37 | public class TextureDownloadModule : IRegionModule |
38 | private Scene m_scene; | 38 | { |
39 | 39 | private Scene m_scene; | |
40 | public TextureDownloadModule() | 40 | |
41 | { | 41 | public TextureDownloadModule() |
42 | } | 42 | { |
43 | 43 | } | |
44 | public void Initialise(Scene scene) | 44 | |
45 | { | 45 | public void Initialise(Scene scene, IConfigSource config) |
46 | m_scene = scene; | 46 | { |
47 | m_scene.EventManager.OnNewClient += NewClient; | 47 | m_scene = scene; |
48 | } | 48 | m_scene.EventManager.OnNewClient += NewClient; |
49 | 49 | } | |
50 | public void PostInitialise() | 50 | |
51 | { | 51 | public void PostInitialise() |
52 | } | 52 | { |
53 | 53 | } | |
54 | public void Close() | 54 | |
55 | { | 55 | public void Close() |
56 | } | 56 | { |
57 | 57 | } | |
58 | public string Name | 58 | |
59 | { | 59 | public string Name |
60 | get { return "TextureDownloadModule"; } | 60 | { |
61 | } | 61 | get { return "TextureDownloadModule"; } |
62 | 62 | } | |
63 | public bool IsSharedModule | 63 | |
64 | { | 64 | public bool IsSharedModule |
65 | get { return false; } | 65 | { |
66 | } | 66 | get { return false; } |
67 | 67 | } | |
68 | public void NewClient(IClientAPI client) | 68 | |
69 | { | 69 | public void NewClient(IClientAPI client) |
70 | } | 70 | { |
71 | 71 | } | |
72 | public void TextureAssetCallback(LLUUID texture, byte[] data) | 72 | |
73 | { | 73 | public void TextureAssetCallback(LLUUID texture, byte[] data) |
74 | } | 74 | { |
75 | } | 75 | } |
76 | } | 76 | } |
77 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index 994d07e..765f1b4 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Framework.Servers; | |||
40 | using Nwc.XmlRpc; | 40 | using Nwc.XmlRpc; |
41 | using System.Collections; | 41 | using System.Collections; |
42 | using System.Collections.Generic; | 42 | using System.Collections.Generic; |
43 | using Nini.Config; | ||
43 | 44 | ||
44 | /***************************************************** | 45 | /***************************************************** |
45 | * | 46 | * |
@@ -84,7 +85,7 @@ namespace OpenSim.Region.Environment.Modules | |||
84 | { | 85 | { |
85 | } | 86 | } |
86 | 87 | ||
87 | public void Initialise(Scene scene) | 88 | public void Initialise(Scene scene, IConfigSource config) |
88 | { | 89 | { |
89 | 90 | ||
90 | m_scene = scene; | 91 | m_scene = scene; |
diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs index 941d3c1..3a5b3c6 100644 --- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Framework.Servers; | |||
39 | using Nwc.XmlRpc; | 39 | using Nwc.XmlRpc; |
40 | using System.Collections; | 40 | using System.Collections; |
41 | using System.Collections.Generic; | 41 | using System.Collections.Generic; |
42 | using Nini.Config; | ||
42 | 43 | ||
43 | /***************************************************** | 44 | /***************************************************** |
44 | * | 45 | * |
@@ -93,7 +94,7 @@ namespace OpenSim.Region.Environment.Modules | |||
93 | { | 94 | { |
94 | } | 95 | } |
95 | 96 | ||
96 | public void Initialise(Scene scene) | 97 | public void Initialise(Scene scene, IConfigSource config) |
97 | { | 98 | { |
98 | m_scene = scene; | 99 | m_scene = scene; |
99 | 100 | ||
diff --git a/OpenSim/Region/Environment/Modules/XferModule.cs b/OpenSim/Region/Environment/Modules/XferModule.cs index 7bc831f..2adb1c9 100644 --- a/OpenSim/Region/Environment/Modules/XferModule.cs +++ b/OpenSim/Region/Environment/Modules/XferModule.cs | |||
@@ -1,201 +1,202 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | using OpenSim.Framework.Interfaces; | 32 | using OpenSim.Framework.Interfaces; |
33 | using OpenSim.Region.Environment.Interfaces; | 33 | using OpenSim.Region.Environment.Interfaces; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | using OpenSim.Region.Environment.Scenes; |
35 | 35 | using Nini.Config; | |
36 | namespace OpenSim.Region.Environment.Modules | 36 | |
37 | { | 37 | namespace OpenSim.Region.Environment.Modules |
38 | public class XferModule : IRegionModule, IXfer | 38 | { |
39 | { | 39 | public class XferModule : IRegionModule, IXfer |
40 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); | 40 | { |
41 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | 41 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); |
42 | 42 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | |
43 | private Scene m_scene; | 43 | |
44 | 44 | private Scene m_scene; | |
45 | public XferModule() | 45 | |
46 | { | 46 | public XferModule() |
47 | } | 47 | { |
48 | 48 | } | |
49 | public void Initialise(Scene scene) | 49 | |
50 | { | 50 | public void Initialise(Scene scene, IConfigSource config) |
51 | m_scene = scene; | 51 | { |
52 | m_scene.EventManager.OnNewClient += NewClient; | 52 | m_scene = scene; |
53 | 53 | m_scene.EventManager.OnNewClient += NewClient; | |
54 | m_scene.RegisterModuleInterface<IXfer>(this); | 54 | |
55 | } | 55 | m_scene.RegisterModuleInterface<IXfer>(this); |
56 | 56 | } | |
57 | public void PostInitialise() | 57 | |
58 | { | 58 | public void PostInitialise() |
59 | } | 59 | { |
60 | 60 | } | |
61 | public void Close() | 61 | |
62 | { | 62 | public void Close() |
63 | } | 63 | { |
64 | 64 | } | |
65 | public string Name | 65 | |
66 | { | 66 | public string Name |
67 | get { return "XferModule"; } | 67 | { |
68 | } | 68 | get { return "XferModule"; } |
69 | 69 | } | |
70 | public bool IsSharedModule | 70 | |
71 | { | 71 | public bool IsSharedModule |
72 | get { return false; } | 72 | { |
73 | } | 73 | get { return false; } |
74 | 74 | } | |
75 | public void NewClient(IClientAPI client) | 75 | |
76 | { | 76 | public void NewClient(IClientAPI client) |
77 | client.OnRequestXfer += RequestXfer; | 77 | { |
78 | client.OnConfirmXfer += AckPacket; | 78 | client.OnRequestXfer += RequestXfer; |
79 | } | 79 | client.OnConfirmXfer += AckPacket; |
80 | 80 | } | |
81 | /// <summary> | 81 | |
82 | /// | 82 | /// <summary> |
83 | /// </summary> | 83 | /// |
84 | /// <param name="remoteClient"></param> | 84 | /// </summary> |
85 | /// <param name="xferID"></param> | 85 | /// <param name="remoteClient"></param> |
86 | /// <param name="fileName"></param> | 86 | /// <param name="xferID"></param> |
87 | public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) | 87 | /// <param name="fileName"></param> |
88 | { | 88 | public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) |
89 | lock (NewFiles) | 89 | { |
90 | { | 90 | lock (NewFiles) |
91 | if (NewFiles.ContainsKey(fileName)) | 91 | { |
92 | { | 92 | if (NewFiles.ContainsKey(fileName)) |
93 | if (!Transfers.ContainsKey(xferID)) | 93 | { |
94 | { | 94 | if (!Transfers.ContainsKey(xferID)) |
95 | byte[] fileData = NewFiles[fileName]; | 95 | { |
96 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); | 96 | byte[] fileData = NewFiles[fileName]; |
97 | Transfers.Add(xferID, transaction); | 97 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); |
98 | NewFiles.Remove(fileName); | 98 | Transfers.Add(xferID, transaction); |
99 | transaction.StartSend(); | 99 | NewFiles.Remove(fileName); |
100 | } | 100 | transaction.StartSend(); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | } | |
105 | public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) | 105 | |
106 | { | 106 | public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) |
107 | if (Transfers.ContainsKey(xferID)) | 107 | { |
108 | { | 108 | if (Transfers.ContainsKey(xferID)) |
109 | Transfers[xferID].AckPacket(packet); | 109 | { |
110 | } | 110 | Transfers[xferID].AckPacket(packet); |
111 | } | 111 | } |
112 | 112 | } | |
113 | public bool AddNewFile(string fileName, byte[] data) | 113 | |
114 | { | 114 | public bool AddNewFile(string fileName, byte[] data) |
115 | lock (NewFiles) | 115 | { |
116 | { | 116 | lock (NewFiles) |
117 | if (NewFiles.ContainsKey(fileName)) | 117 | { |
118 | { | 118 | if (NewFiles.ContainsKey(fileName)) |
119 | NewFiles[fileName] = data; | 119 | { |
120 | } | 120 | NewFiles[fileName] = data; |
121 | else | 121 | } |
122 | { | 122 | else |
123 | NewFiles.Add(fileName, data); | 123 | { |
124 | } | 124 | NewFiles.Add(fileName, data); |
125 | } | 125 | } |
126 | return true; | 126 | } |
127 | } | 127 | return true; |
128 | 128 | } | |
129 | 129 | ||
130 | public class XferDownLoad | 130 | |
131 | { | 131 | public class XferDownLoad |
132 | public byte[] Data = new byte[0]; | 132 | { |
133 | public string FileName = ""; | 133 | public byte[] Data = new byte[0]; |
134 | public ulong XferID = 0; | 134 | public string FileName = ""; |
135 | public int DataPointer = 0; | 135 | public ulong XferID = 0; |
136 | public uint Packet = 0; | 136 | public int DataPointer = 0; |
137 | public IClientAPI Client; | 137 | public uint Packet = 0; |
138 | public uint Serial = 1; | 138 | public IClientAPI Client; |
139 | private bool complete = false; | 139 | public uint Serial = 1; |
140 | 140 | private bool complete = false; | |
141 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) | 141 | |
142 | { | 142 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) |
143 | FileName = fileName; | 143 | { |
144 | Data = data; | 144 | FileName = fileName; |
145 | XferID = xferID; | 145 | Data = data; |
146 | Client = client; | 146 | XferID = xferID; |
147 | } | 147 | Client = client; |
148 | 148 | } | |
149 | public XferDownLoad() | 149 | |
150 | { | 150 | public XferDownLoad() |
151 | } | 151 | { |
152 | 152 | } | |
153 | public void StartSend() | 153 | |
154 | { | 154 | public void StartSend() |
155 | if (Data.Length < 1000) | 155 | { |
156 | { | 156 | if (Data.Length < 1000) |
157 | // for now (testing ) we only support files under 1000 bytes | 157 | { |
158 | byte[] transferData = new byte[Data.Length + 4]; | 158 | // for now (testing ) we only support files under 1000 bytes |
159 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); | 159 | byte[] transferData = new byte[Data.Length + 4]; |
160 | Array.Copy(Data, 0, transferData, 4, Data.Length); | 160 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); |
161 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); | 161 | Array.Copy(Data, 0, transferData, 4, Data.Length); |
162 | complete = true; | 162 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); |
163 | } | 163 | complete = true; |
164 | else | 164 | } |
165 | { | 165 | else |
166 | byte[] transferData = new byte[1000 + 4]; | 166 | { |
167 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); | 167 | byte[] transferData = new byte[1000 + 4]; |
168 | Array.Copy(Data, 0, transferData, 4, 1000); | 168 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); |
169 | Client.SendXferPacket(XferID, 0, transferData); | 169 | Array.Copy(Data, 0, transferData, 4, 1000); |
170 | Packet++; | 170 | Client.SendXferPacket(XferID, 0, transferData); |
171 | DataPointer = 1000; | 171 | Packet++; |
172 | } | 172 | DataPointer = 1000; |
173 | } | 173 | } |
174 | 174 | } | |
175 | public void AckPacket(uint packet) | 175 | |
176 | { | 176 | public void AckPacket(uint packet) |
177 | if (!complete) | 177 | { |
178 | { | 178 | if (!complete) |
179 | if ((Data.Length - DataPointer) > 1000) | 179 | { |
180 | { | 180 | if ((Data.Length - DataPointer) > 1000) |
181 | byte[] transferData = new byte[1000]; | 181 | { |
182 | Array.Copy(Data, DataPointer, transferData, 0, 1000); | 182 | byte[] transferData = new byte[1000]; |
183 | Client.SendXferPacket(XferID, Packet, transferData); | 183 | Array.Copy(Data, DataPointer, transferData, 0, 1000); |
184 | Packet++; | 184 | Client.SendXferPacket(XferID, Packet, transferData); |
185 | DataPointer += 1000; | 185 | Packet++; |
186 | } | 186 | DataPointer += 1000; |
187 | else | 187 | } |
188 | { | 188 | else |
189 | byte[] transferData = new byte[Data.Length - DataPointer]; | 189 | { |
190 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); | 190 | byte[] transferData = new byte[Data.Length - DataPointer]; |
191 | uint endPacket = Packet |= (uint) 0x80000000; | 191 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); |
192 | Client.SendXferPacket(XferID, endPacket, transferData); | 192 | uint endPacket = Packet |= (uint) 0x80000000; |
193 | Packet++; | 193 | Client.SendXferPacket(XferID, endPacket, transferData); |
194 | DataPointer += (Data.Length - DataPointer); | 194 | Packet++; |
195 | complete = true; | 195 | DataPointer += (Data.Length - DataPointer); |
196 | } | 196 | complete = true; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | ||