diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Interfaces/IRegionModule.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/Environment/ModuleLoader.cs | 93 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs | 61 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 165 | ||||
-rw-r--r-- | OpenSim/Region/Environment/RegionManager.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 92 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 62 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneEvents.cs | 9 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Environment/StorageManager.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/XferModule.cs (renamed from OpenSim/Region/Environment/XferManager.cs) | 41 |
14 files changed, 450 insertions, 108 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 9b97fc6..24da06c 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs | |||
@@ -36,7 +36,7 @@ using OpenSim.Region.Environment.LandManagement; | |||
36 | 36 | ||
37 | using System.Collections.Generic; | 37 | using System.Collections.Generic; |
38 | 38 | ||
39 | namespace OpenSim.Region.Interfaces | 39 | namespace OpenSim.Region.Environment.Interfaces |
40 | { | 40 | { |
41 | public interface IRegionDataStore | 41 | public interface IRegionDataStore |
42 | { | 42 | { |
diff --git a/OpenSim/Region/Environment/Interfaces/IRegionModule.cs b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs new file mode 100644 index 0000000..84e156f --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/IRegionModule.cs | |||
@@ -0,0 +1,14 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Region.Environment.Interfaces | ||
6 | { | ||
7 | public interface IRegionModule | ||
8 | { | ||
9 | void Initialise(Scenes.Scene scene); | ||
10 | void PostInitialise(); | ||
11 | void CloseDown(); | ||
12 | string GetName(); | ||
13 | } | ||
14 | } | ||
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs new file mode 100644 index 0000000..8e42d90 --- /dev/null +++ b/OpenSim/Region/Environment/ModuleLoader.cs | |||
@@ -0,0 +1,93 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | using System.Text; | ||
5 | using OpenSim.Region.Environment.Scenes; | ||
6 | using OpenSim.Region.Environment.Interfaces; | ||
7 | using OpenSim.Region.Environment.Modules; | ||
8 | |||
9 | namespace OpenSim.Region.Environment | ||
10 | { | ||
11 | public class ModuleLoader | ||
12 | { | ||
13 | |||
14 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); | ||
15 | |||
16 | public ModuleLoader() | ||
17 | { | ||
18 | |||
19 | } | ||
20 | |||
21 | /// <summary> | ||
22 | /// Really just a test method for loading a set of currently internal modules | ||
23 | /// </summary> | ||
24 | /// <param name="scene"></param> | ||
25 | public void LoadInternalModules(Scene scene) | ||
26 | { | ||
27 | //Testing IRegionModule ideas | ||
28 | XferModule xferManager = new XferModule(); | ||
29 | xferManager.Initialise(scene); | ||
30 | scene.AddModule(xferManager.GetName(), xferManager); | ||
31 | |||
32 | ChatModule chatModule = new ChatModule(); | ||
33 | chatModule.Initialise(scene); | ||
34 | scene.AddModule(chatModule.GetName(), chatModule); | ||
35 | |||
36 | AvatarProfilesModule avatarProfiles = new AvatarProfilesModule(); | ||
37 | avatarProfiles.Initialise(scene); | ||
38 | scene.AddModule(avatarProfiles.GetName(), avatarProfiles); | ||
39 | |||
40 | // Post Initialise Modules | ||
41 | xferManager.PostInitialise(); | ||
42 | // chatModule.PostInitialise(); //for now leave this disabled as it would start up a partially working irc bot | ||
43 | avatarProfiles.PostInitialise(); | ||
44 | } | ||
45 | |||
46 | public void LoadModule(string dllName, string moduleName, Scene scene) | ||
47 | { | ||
48 | Assembly pluginAssembly = null; | ||
49 | if (LoadedAssemblys.ContainsKey(dllName)) | ||
50 | { | ||
51 | pluginAssembly = LoadedAssemblys[dllName]; | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | pluginAssembly = Assembly.LoadFrom(dllName); | ||
56 | this.LoadedAssemblys.Add(dllName, pluginAssembly); | ||
57 | } | ||
58 | |||
59 | IRegionModule module = null; | ||
60 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
61 | { | ||
62 | if (pluginType.IsPublic) | ||
63 | { | ||
64 | if (!pluginType.IsAbstract) | ||
65 | { | ||
66 | Type typeInterface = pluginType.GetInterface("IRegionModule", true); | ||
67 | |||
68 | if (typeInterface != null) | ||
69 | { | ||
70 | module = (IRegionModule)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
71 | break; | ||
72 | } | ||
73 | typeInterface = null; | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | pluginAssembly = null; | ||
78 | |||
79 | if (module.GetName() == moduleName) | ||
80 | { | ||
81 | module.Initialise(scene); | ||
82 | scene.AddModule(moduleName, module); | ||
83 | module.PostInitialise(); //shouldn't be done here | ||
84 | } | ||
85 | |||
86 | } | ||
87 | |||
88 | public void ClearCache() | ||
89 | { | ||
90 | this.LoadedAssemblys.Clear(); | ||
91 | } | ||
92 | } | ||
93 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs new file mode 100644 index 0000000..1427c58 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using OpenSim.Framework.Interfaces; | ||
6 | using OpenSim.Region.Environment.Scenes; | ||
7 | using OpenSim.Region.Environment.Interfaces; | ||
8 | |||
9 | namespace OpenSim.Region.Environment.Modules | ||
10 | { | ||
11 | public class AvatarProfilesModule :IRegionModule | ||
12 | { | ||
13 | |||
14 | private Scene m_scene; | ||
15 | |||
16 | public AvatarProfilesModule() | ||
17 | { | ||
18 | |||
19 | } | ||
20 | |||
21 | public void Initialise(Scene scene) | ||
22 | { | ||
23 | m_scene = scene; | ||
24 | m_scene.EventManager.OnNewClient += NewClient; | ||
25 | } | ||
26 | |||
27 | public void PostInitialise() | ||
28 | { | ||
29 | |||
30 | } | ||
31 | |||
32 | public void CloseDown() | ||
33 | { | ||
34 | |||
35 | } | ||
36 | |||
37 | public string GetName() | ||
38 | { | ||
39 | return "AvatarProfilesModule"; | ||
40 | } | ||
41 | |||
42 | public void NewClient(IClientAPI client) | ||
43 | { | ||
44 | client.OnRequestAvatarProperties += RequestAvatarProperty; | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// | ||
49 | /// </summary> | ||
50 | /// <param name="remoteClient"></param> | ||
51 | /// <param name="avatarID"></param> | ||
52 | public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) | ||
53 | { | ||
54 | string about = "OpenSim crash test dummy"; | ||
55 | string bornOn = "Before now"; | ||
56 | string flAbout = "First life? What is one of those? OpenSim is my life!"; | ||
57 | LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); | ||
58 | remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); | ||
59 | } | ||
60 | } | ||
61 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs new file mode 100644 index 0000000..703fe65 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -0,0 +1,165 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Net; | ||
5 | using System.Net.Sockets; | ||
6 | using System.Threading; | ||
7 | using System.IO; | ||
8 | using libsecondlife; | ||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | using OpenSim.Region.Environment.Interfaces; | ||
11 | using OpenSim.Framework.Interfaces; | ||
12 | using OpenSim.Framework.Utilities; | ||
13 | |||
14 | namespace OpenSim.Region.Environment.Modules | ||
15 | { | ||
16 | public class ChatModule :IRegionModule | ||
17 | { | ||
18 | private Scene m_scene; | ||
19 | |||
20 | private string m_server = "irc2.choopa.net"; | ||
21 | |||
22 | private int m_port = 6668; | ||
23 | private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; | ||
24 | private string m_nick = "OpenSimBoT"; | ||
25 | private string m_channel = "#opensim"; | ||
26 | |||
27 | private NetworkStream m_stream; | ||
28 | private TcpClient m_irc; | ||
29 | private StreamWriter m_ircWriter; | ||
30 | private StreamReader m_ircReader; | ||
31 | |||
32 | private Thread pingSender; | ||
33 | |||
34 | private bool connected = false; | ||
35 | |||
36 | public ChatModule() | ||
37 | { | ||
38 | |||
39 | } | ||
40 | |||
41 | public void Initialise(Scene scene) | ||
42 | { | ||
43 | m_scene = scene; | ||
44 | m_scene.EventManager.OnNewClient += NewClient; | ||
45 | |||
46 | //should register a optional API Method, so other modules can send chat messages using this module | ||
47 | } | ||
48 | |||
49 | public void PostInitialise() | ||
50 | { | ||
51 | try | ||
52 | { | ||
53 | m_irc = new TcpClient(m_server, m_port); | ||
54 | m_stream = m_irc.GetStream(); | ||
55 | m_ircReader = new StreamReader(m_stream); | ||
56 | m_ircWriter = new StreamWriter(m_stream); | ||
57 | |||
58 | pingSender = new Thread(new ThreadStart(this.PingRun)); | ||
59 | pingSender.Start(); | ||
60 | |||
61 | m_ircWriter.WriteLine(m_user); | ||
62 | m_ircWriter.Flush(); | ||
63 | m_ircWriter.WriteLine("NICK " + m_nick); | ||
64 | m_ircWriter.Flush(); | ||
65 | m_ircWriter.WriteLine("JOIN " + m_channel); | ||
66 | m_ircWriter.Flush(); | ||
67 | connected = true; | ||
68 | } | ||
69 | catch (Exception e) | ||
70 | { | ||
71 | Console.WriteLine(e.ToString()); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void CloseDown() | ||
76 | { | ||
77 | m_ircWriter.Close(); | ||
78 | m_ircReader.Close(); | ||
79 | m_irc.Close(); | ||
80 | } | ||
81 | |||
82 | public string GetName() | ||
83 | { | ||
84 | return "ChatModule"; | ||
85 | } | ||
86 | |||
87 | public void NewClient(IClientAPI client) | ||
88 | { | ||
89 | client.OnChatFromViewer += SimChat; | ||
90 | } | ||
91 | |||
92 | public void PingRun() | ||
93 | { | ||
94 | while (true) | ||
95 | { | ||
96 | m_ircWriter.WriteLine("PING :" + m_server); | ||
97 | m_ircWriter.Flush(); | ||
98 | Thread.Sleep(15000); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
103 | { | ||
104 | ScenePresence avatar = null; | ||
105 | avatar = m_scene.RequestAvatar(fromAgentID); | ||
106 | if (avatar != null) | ||
107 | { | ||
108 | fromPos = avatar.AbsolutePosition; | ||
109 | fromName = avatar.Firstname + " " + avatar.Lastname; | ||
110 | avatar = null; | ||
111 | } | ||
112 | |||
113 | if (connected) | ||
114 | { | ||
115 | m_ircWriter.WriteLine("MSG " + m_channel +" :" + fromName + ", " + Util.FieldToString(message)); | ||
116 | m_ircWriter.Flush(); | ||
117 | } | ||
118 | |||
119 | m_scene.ForEachScenePresence(delegate(ScenePresence presence) | ||
120 | { | ||
121 | int dis = -1000; | ||
122 | |||
123 | //err ??? the following code seems to be request a scenePresence when it already has a ref to it | ||
124 | avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); | ||
125 | if (avatar != null) | ||
126 | { | ||
127 | dis = (int)avatar.AbsolutePosition.GetDistanceTo(fromPos); | ||
128 | } | ||
129 | |||
130 | switch (type) | ||
131 | { | ||
132 | case 0: // Whisper | ||
133 | if ((dis < 10) && (dis > -10)) | ||
134 | { | ||
135 | //should change so the message is sent through the avatar rather than direct to the ClientView | ||
136 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | ||
137 | fromAgentID); | ||
138 | } | ||
139 | break; | ||
140 | case 1: // Say | ||
141 | if ((dis < 30) && (dis > -30)) | ||
142 | { | ||
143 | //Console.WriteLine("sending chat"); | ||
144 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | ||
145 | fromAgentID); | ||
146 | } | ||
147 | break; | ||
148 | case 2: // Shout | ||
149 | if ((dis < 100) && (dis > -100)) | ||
150 | { | ||
151 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | ||
152 | fromAgentID); | ||
153 | } | ||
154 | break; | ||
155 | |||
156 | case 0xff: // Broadcast | ||
157 | presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName, | ||
158 | fromAgentID); | ||
159 | break; | ||
160 | } | ||
161 | }); | ||
162 | } | ||
163 | |||
164 | } | ||
165 | } | ||
diff --git a/OpenSim/Region/Environment/RegionManager.cs b/OpenSim/Region/Environment/RegionManager.cs index 255aa45..0146b52 100644 --- a/OpenSim/Region/Environment/RegionManager.cs +++ b/OpenSim/Region/Environment/RegionManager.cs | |||
@@ -9,6 +9,8 @@ using OpenSim.Region.Environment.LandManagement; | |||
9 | 9 | ||
10 | namespace OpenSim.Region.Environment | 10 | namespace OpenSim.Region.Environment |
11 | { | 11 | { |
12 | public delegate TResult ModuleAPIMethod<TResult, TParam0, TParam1>(TParam0 param0, TParam1 param1); | ||
13 | |||
12 | public class RegionManager | 14 | public class RegionManager |
13 | { | 15 | { |
14 | protected AgentCircuitManager authenticateHandler; | 16 | protected AgentCircuitManager authenticateHandler; |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 16cd484..d31b5b0 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -201,7 +201,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
201 | bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); | 201 | bool fileChange = ((SceneObjectGroup)ent).GetPartInventoryFileName(remoteClient, primLocalID); |
202 | if (fileChange) | 202 | if (fileChange) |
203 | { | 203 | { |
204 | ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, xferManager); | 204 | if (this.AddXferFile != null) |
205 | { | ||
206 | ((SceneObjectGroup)ent).RequestInventoryFile(primLocalID, AddXferFile); | ||
207 | } | ||
205 | } | 208 | } |
206 | break; | 209 | break; |
207 | } | 210 | } |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index d94a748..dcec289 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -57,60 +57,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
57 | if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0))) | 57 | if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0))) |
58 | return; | 58 | return; |
59 | 59 | ||
60 | // Shiny. | 60 | //if it wasn't for the permission checking we could have the terrain module directly subscribe to the OnModifyTerrain event |
61 | double size = (double)(1 << brushsize); | 61 | Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, remoteUser); |
62 | |||
63 | switch (action) | ||
64 | { | ||
65 | case 0: | ||
66 | // flatten terrain | ||
67 | Terrain.FlattenTerrain(west, north, size, (double)seconds / 5.0); | ||
68 | break; | ||
69 | case 1: | ||
70 | // raise terrain | ||
71 | Terrain.RaiseTerrain(west, north, size, (double)seconds / 5.0); | ||
72 | break; | ||
73 | case 2: | ||
74 | //lower terrain | ||
75 | Terrain.LowerTerrain(west, north, size, (double)seconds / 5.0); | ||
76 | break; | ||
77 | case 3: | ||
78 | // smooth terrain | ||
79 | Terrain.SmoothTerrain(west, north, size, (double)seconds / 5.0); | ||
80 | break; | ||
81 | case 4: | ||
82 | // noise | ||
83 | Terrain.NoiseTerrain(west, north, size, (double)seconds / 5.0); | ||
84 | break; | ||
85 | case 5: | ||
86 | // revert | ||
87 | Terrain.RevertTerrain(west, north, size, (double)seconds / 5.0); | ||
88 | break; | ||
89 | |||
90 | // CLIENT EXTENSIONS GO HERE | ||
91 | case 128: | ||
92 | // erode-thermal | ||
93 | break; | ||
94 | case 129: | ||
95 | // erode-aerobic | ||
96 | break; | ||
97 | case 130: | ||
98 | // erode-hydraulic | ||
99 | break; | ||
100 | } | ||
101 | |||
102 | for (int x = 0; x < 16; x++) | ||
103 | { | ||
104 | for (int y = 0; y < 16; y++) | ||
105 | { | ||
106 | if (Terrain.Tainted(x * 16, y * 16)) | ||
107 | { | ||
108 | remoteUser.SendLayerData(x, y, Terrain.GetHeights1D()); | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | |||
113 | return; | ||
114 | } | 62 | } |
115 | 63 | ||
116 | /// <summary> | 64 | /// <summary> |
@@ -146,7 +94,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
146 | } | 94 | } |
147 | 95 | ||
148 | /// <summary> | 96 | /// <summary> |
149 | /// | 97 | /// Should be removed soon as the Chat modules should take over this function |
150 | /// </summary> | 98 | /// </summary> |
151 | /// <param name="message"></param> | 99 | /// <param name="message"></param> |
152 | /// <param name="type"></param> | 100 | /// <param name="type"></param> |
@@ -616,40 +564,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
616 | } | 564 | } |
617 | } | 565 | } |
618 | 566 | ||
619 | /// <summary> | ||
620 | /// | ||
621 | /// </summary> | ||
622 | /// <param name="remoteClient"></param> | ||
623 | /// <param name="avatarID"></param> | ||
624 | public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) | ||
625 | { | ||
626 | string about = "OpenSim crash test dummy"; | ||
627 | string bornOn = "Before now"; | ||
628 | string flAbout = "First life? What is one of those? OpenSim is my life!"; | ||
629 | LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); | ||
630 | remoteClient.SendAvatarProperties(avatarID, about, bornOn, "", flAbout, 0, LLUUID.Zero, LLUUID.Zero, "", partner); | ||
631 | } | ||
632 | |||
633 | /// <summary> | ||
634 | /// | ||
635 | /// </summary> | ||
636 | /// <param name="remoteClient"></param> | ||
637 | /// <param name="xferID"></param> | ||
638 | /// <param name="fileName"></param> | ||
639 | public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) | ||
640 | { | ||
641 | /* | ||
642 | foreach (EntityBase ent in Entities.Values) | ||
643 | { | ||
644 | if (ent is SceneObjectGroup) | ||
645 | { | ||
646 | ((SceneObjectGroup)ent).RequestInventoryFile(remoteClient, ((SceneObjectGroup)ent).LocalId, xferID); | ||
647 | break; | ||
648 | } | ||
649 | }*/ | ||
650 | } | ||
651 | |||
652 | |||
653 | public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) | 567 | public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) |
654 | { | 568 | { |
655 | this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); | 569 | this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient); |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 2259a3e..b2ddb7d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -42,6 +42,8 @@ using OpenSim.Framework.Utilities; | |||
42 | using OpenSim.Physics.Manager; | 42 | using OpenSim.Physics.Manager; |
43 | using OpenSim.Framework.Communications.Caches; | 43 | using OpenSim.Framework.Communications.Caches; |
44 | using OpenSim.Region.Environment.LandManagement; | 44 | using OpenSim.Region.Environment.LandManagement; |
45 | using OpenSim.Region.Environment; | ||
46 | using OpenSim.Region.Environment.Interfaces; | ||
45 | using OpenSim.Region.Scripting; | 47 | using OpenSim.Region.Scripting; |
46 | using OpenSim.Region.Terrain; | 48 | using OpenSim.Region.Terrain; |
47 | using OpenSim.Framework.Data; | 49 | using OpenSim.Framework.Data; |
@@ -73,15 +75,24 @@ namespace OpenSim.Region.Environment.Scenes | |||
73 | 75 | ||
74 | private Mutex updateLock; | 76 | private Mutex updateLock; |
75 | 77 | ||
78 | protected ModuleLoader m_moduleLoader; | ||
76 | protected StorageManager storageManager; | 79 | protected StorageManager storageManager; |
77 | protected AgentCircuitManager authenticateHandler; | 80 | protected AgentCircuitManager authenticateHandler; |
78 | protected RegionCommsListener regionCommsHost; | 81 | protected RegionCommsListener regionCommsHost; |
79 | protected CommunicationsManager commsManager; | 82 | protected CommunicationsManager commsManager; |
80 | protected XferManager xferManager; | 83 | // protected XferManager xferManager; |
81 | 84 | ||
82 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); | 85 | protected Dictionary<LLUUID, Caps> capsHandlers = new Dictionary<LLUUID, Caps>(); |
83 | protected BaseHttpServer httpListener; | 86 | protected BaseHttpServer httpListener; |
84 | 87 | ||
88 | protected Dictionary<string, IRegionModule> Modules = new Dictionary<string, IRegionModule>(); | ||
89 | protected Dictionary<string, object> APIMethods = new Dictionary<string, object>(); | ||
90 | |||
91 | //API method Delegates | ||
92 | |||
93 | // this most likely shouldn't be handled as a API method like this, but doing it for testing purposes | ||
94 | public ModuleAPIMethod<bool, string, byte[]>AddXferFile = null; | ||
95 | |||
85 | #region Properties | 96 | #region Properties |
86 | 97 | ||
87 | public AgentCircuitManager AuthenticateHandler | 98 | public AgentCircuitManager AuthenticateHandler |
@@ -146,9 +157,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
146 | /// <param name="regionHandle">Region Handle for this region</param> | 157 | /// <param name="regionHandle">Region Handle for this region</param> |
147 | /// <param name="regionName">Region Name for this region</param> | 158 | /// <param name="regionName">Region Name for this region</param> |
148 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, | 159 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, |
149 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer) | 160 | AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer, ModuleLoader moduleLoader) |
150 | { | 161 | { |
151 | updateLock = new Mutex(false); | 162 | updateLock = new Mutex(false); |
163 | |||
164 | m_moduleLoader = moduleLoader; | ||
152 | authenticateHandler = authen; | 165 | authenticateHandler = authen; |
153 | commsManager = commsMan; | 166 | commsManager = commsMan; |
154 | storageManager = storeManager; | 167 | storageManager = storeManager; |
@@ -164,8 +177,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
164 | m_scriptManager = new ScriptManager(this); | 177 | m_scriptManager = new ScriptManager(this); |
165 | m_eventManager = new EventManager(); | 178 | m_eventManager = new EventManager(); |
166 | m_permissionManager = new PermissionManager(this); | 179 | m_permissionManager = new PermissionManager(this); |
167 | xferManager = new XferManager(); | ||
168 | 180 | ||
181 | MainLog.Instance.Verbose("Loading Region Modules"); | ||
182 | m_moduleLoader.LoadInternalModules(this); | ||
183 | |||
169 | m_eventManager.OnParcelPrimCountAdd += | 184 | m_eventManager.OnParcelPrimCountAdd += |
170 | m_LandManager.addPrimToLandPrimCounts; | 185 | m_LandManager.addPrimToLandPrimCounts; |
171 | 186 | ||
@@ -182,10 +197,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
182 | ScenePresence.LoadAnims(); | 197 | ScenePresence.LoadAnims(); |
183 | 198 | ||
184 | httpListener = httpServer; | 199 | httpListener = httpServer; |
200 | |||
201 | SetMethodDelegates(); | ||
185 | } | 202 | } |
186 | 203 | ||
187 | #endregion | 204 | #endregion |
188 | 205 | ||
206 | private void SetMethodDelegates() | ||
207 | { | ||
208 | AddXferFile = (ModuleAPIMethod<bool, string, byte[]>)this.RequestAPIMethod("API_AddXferFile"); | ||
209 | } | ||
210 | |||
189 | #region Script Handling Methods | 211 | #region Script Handling Methods |
190 | 212 | ||
191 | public void SendCommandToScripts(string[] args) | 213 | public void SendCommandToScripts(string[] args) |
@@ -682,7 +704,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
682 | client.OnRegionHandShakeReply += SendLayerData; | 704 | client.OnRegionHandShakeReply += SendLayerData; |
683 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); | 705 | //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); |
684 | client.OnModifyTerrain += ModifyTerrain; | 706 | client.OnModifyTerrain += ModifyTerrain; |
685 | client.OnChatFromViewer += SimChat; | 707 | //client.OnChatFromViewer += SimChat; |
686 | client.OnInstantMessage += InstantMessage; | 708 | client.OnInstantMessage += InstantMessage; |
687 | client.OnRequestWearables += InformClientOfNeighbours; | 709 | client.OnRequestWearables += InformClientOfNeighbours; |
688 | client.OnAddPrim += AddNewPrim; | 710 | client.OnAddPrim += AddNewPrim; |
@@ -725,15 +747,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
725 | client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; | 747 | client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset; |
726 | client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest; | 748 | client.OnAssetUploadRequest += commsManager.TransactionsManager.HandleUDPUploadRequest; |
727 | client.OnXferReceive += commsManager.TransactionsManager.HandleXfer; | 749 | client.OnXferReceive += commsManager.TransactionsManager.HandleXfer; |
728 | // client.OnRequestXfer += RequestXfer; | ||
729 | client.OnRequestXfer += xferManager.RequestXfer; | ||
730 | client.OnConfirmXfer += xferManager.AckPacket; | ||
731 | client.OnRezScript += RezScript; | 750 | client.OnRezScript += RezScript; |
732 | client.OnRemoveTaskItem += RemoveTaskInventory; | 751 | client.OnRemoveTaskItem += RemoveTaskInventory; |
733 | 752 | ||
734 | client.OnRequestAvatarProperties += RequestAvatarProperty; | 753 | // client.OnRequestAvatarProperties += RequestAvatarProperty; |
735 | 754 | ||
736 | client.OnGrabObject += ProcessObjectGrab; | 755 | client.OnGrabObject += ProcessObjectGrab; |
756 | |||
757 | EventManager.TriggerOnNewClient(client); | ||
737 | } | 758 | } |
738 | 759 | ||
739 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) | 760 | protected ScenePresence CreateAndAddScenePresence(IClientAPI client) |
@@ -1093,6 +1114,31 @@ namespace OpenSim.Region.Environment.Scenes | |||
1093 | 1114 | ||
1094 | #endregion | 1115 | #endregion |
1095 | 1116 | ||
1117 | public void AddModule(string name, IRegionModule module) | ||
1118 | { | ||
1119 | if (!this.Modules.ContainsKey(name)) | ||
1120 | { | ||
1121 | Modules.Add(name, module); | ||
1122 | } | ||
1123 | } | ||
1124 | |||
1125 | public void RegisterAPIMethod(string name, object method) | ||
1126 | { | ||
1127 | if (!this.APIMethods.ContainsKey(name)) | ||
1128 | { | ||
1129 | this.APIMethods.Add(name, method); | ||
1130 | } | ||
1131 | } | ||
1132 | |||
1133 | public object RequestAPIMethod(string name) | ||
1134 | { | ||
1135 | if (this.APIMethods.ContainsKey(name)) | ||
1136 | { | ||
1137 | return APIMethods[name]; | ||
1138 | } | ||
1139 | return false; | ||
1140 | } | ||
1141 | |||
1096 | public void SetTimePhase(int phase) | 1142 | public void SetTimePhase(int phase) |
1097 | { | 1143 | { |
1098 | m_timePhase = phase; | 1144 | m_timePhase = phase; |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 3c6b277..a86a1bc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -14,6 +14,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
14 | public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); | 14 | public delegate void OnBackupDelegate(Interfaces.IRegionDataStore datastore); |
15 | public event OnBackupDelegate OnBackup; | 15 | public event OnBackupDelegate OnBackup; |
16 | 16 | ||
17 | public delegate void OnNewClientDelegate(IClientAPI client); | ||
18 | public event OnNewClientDelegate OnNewClient; | ||
19 | |||
17 | public delegate void OnNewPresenceDelegate(ScenePresence presence); | 20 | public delegate void OnNewPresenceDelegate(ScenePresence presence); |
18 | public event OnNewPresenceDelegate OnNewPresence; | 21 | public event OnNewPresenceDelegate OnNewPresence; |
19 | 22 | ||
@@ -63,6 +66,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
63 | } | 66 | } |
64 | } | 67 | } |
65 | 68 | ||
69 | public void TriggerOnNewClient(IClientAPI client) | ||
70 | { | ||
71 | if (OnNewClient != null) | ||
72 | OnNewClient(client); | ||
73 | } | ||
74 | |||
66 | public void TriggerOnNewPresence(ScenePresence presence) | 75 | public void TriggerOnNewPresence(ScenePresence presence) |
67 | { | 76 | { |
68 | if (OnNewPresence != null) | 77 | if (OnNewPresence != null) |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 2fd7b57..0fc1656 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -642,12 +642,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
642 | return false; | 642 | return false; |
643 | } | 643 | } |
644 | 644 | ||
645 | public string RequestInventoryFile(uint localID, XferManager xferManager) | 645 | public string RequestInventoryFile(uint localID, ModuleAPIMethod<bool, string, byte[]> addXferFile) |
646 | { | 646 | { |
647 | SceneObjectPart part = this.GetChildPart(localID); | 647 | SceneObjectPart part = this.GetChildPart(localID); |
648 | if (part != null) | 648 | if (part != null) |
649 | { | 649 | { |
650 | return part.RequestInventoryFile(xferManager); | 650 | part.RequestInventoryFile(addXferFile); |
651 | } | 651 | } |
652 | return ""; | 652 | return ""; |
653 | } | 653 | } |
@@ -967,7 +967,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
967 | /// Processes backup | 967 | /// Processes backup |
968 | /// </summary> | 968 | /// </summary> |
969 | /// <param name="datastore"></param> | 969 | /// <param name="datastore"></param> |
970 | public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) | 970 | public void ProcessBackup(OpenSim.Region.Environment.Interfaces.IRegionDataStore datastore) |
971 | { | 971 | { |
972 | datastore.StoreObject(this, m_scene.RegionInfo.SimUUID); | 972 | datastore.StoreObject(this, m_scene.RegionInfo.SimUUID); |
973 | } | 973 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index a621632..cc8e717 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -482,7 +482,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
482 | return false; | 482 | return false; |
483 | } | 483 | } |
484 | 484 | ||
485 | public string RequestInventoryFile(XferManager xferManager) | 485 | public string RequestInventoryFile(ModuleAPIMethod<bool, string, byte[]> addXferFile) |
486 | { | 486 | { |
487 | byte[] fileData = new byte[0]; | 487 | byte[] fileData = new byte[0]; |
488 | InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID); | 488 | InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, this.UUID); |
@@ -516,7 +516,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
516 | fileData = Helpers.StringToField(invString.BuildString); | 516 | fileData = Helpers.StringToField(invString.BuildString); |
517 | if (fileData.Length > 2) | 517 | if (fileData.Length > 2) |
518 | { | 518 | { |
519 | xferManager.AddNewFile(m_inventoryFileName, fileData); | 519 | addXferFile(m_inventoryFileName, fileData); |
520 | } | 520 | } |
521 | return ""; | 521 | return ""; |
522 | } | 522 | } |
diff --git a/OpenSim/Region/Environment/StorageManager.cs b/OpenSim/Region/Environment/StorageManager.cs index a7d67d3..a478827 100644 --- a/OpenSim/Region/Environment/StorageManager.cs +++ b/OpenSim/Region/Environment/StorageManager.cs | |||
@@ -7,7 +7,7 @@ using OpenSim.Framework.Communications; | |||
7 | using OpenSim.Framework.Servers; | 7 | using OpenSim.Framework.Servers; |
8 | using OpenSim.Region.Capabilities; | 8 | using OpenSim.Region.Capabilities; |
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | using OpenSim.Region.Interfaces; | 10 | using OpenSim.Region.Environment.Interfaces; |
11 | 11 | ||
12 | using System.Reflection; | 12 | using System.Reflection; |
13 | 13 | ||
diff --git a/OpenSim/Region/Environment/XferManager.cs b/OpenSim/Region/Environment/XferModule.cs index c49601c..beb72120 100644 --- a/OpenSim/Region/Environment/XferManager.cs +++ b/OpenSim/Region/Environment/XferModule.cs | |||
@@ -5,17 +5,50 @@ using System.Text; | |||
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using OpenSim.Framework.Interfaces; | 6 | using OpenSim.Framework.Interfaces; |
7 | using OpenSim.Framework.Utilities; | 7 | using OpenSim.Framework.Utilities; |
8 | using OpenSim.Region.Environment.Scenes; | ||
9 | using OpenSim.Region.Environment.Interfaces; | ||
8 | 10 | ||
9 | namespace OpenSim.Region.Environment | 11 | namespace OpenSim.Region.Environment |
10 | { | 12 | { |
11 | public class XferManager | 13 | public class XferModule : IRegionModule |
12 | { | 14 | { |
13 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); | 15 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); |
14 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | 16 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); |
15 | 17 | ||
16 | public XferManager() | 18 | private Scene m_scene; |
19 | |||
20 | public XferModule() | ||
21 | { | ||
22 | |||
23 | } | ||
24 | |||
25 | public void Initialise(Scene scene) | ||
26 | { | ||
27 | m_scene = scene; | ||
28 | m_scene.EventManager.OnNewClient += NewClient; | ||
29 | |||
30 | m_scene.RegisterAPIMethod("API_AddXferFile", new ModuleAPIMethod<bool, string, byte[]>(this.AddNewFile)); | ||
31 | } | ||
32 | |||
33 | public void PostInitialise() | ||
34 | { | ||
35 | |||
36 | } | ||
37 | |||
38 | public void CloseDown() | ||
39 | { | ||
40 | |||
41 | } | ||
42 | |||
43 | public string GetName() | ||
17 | { | 44 | { |
45 | return "XferModule"; | ||
46 | } | ||
18 | 47 | ||
48 | public void NewClient(IClientAPI client) | ||
49 | { | ||
50 | client.OnRequestXfer += RequestXfer; | ||
51 | client.OnConfirmXfer += AckPacket; | ||
19 | } | 52 | } |
20 | 53 | ||
21 | /// <summary> | 54 | /// <summary> |
@@ -50,7 +83,7 @@ namespace OpenSim.Region.Environment | |||
50 | } | 83 | } |
51 | } | 84 | } |
52 | 85 | ||
53 | public void AddNewFile(string fileName, byte[] data) | 86 | public bool AddNewFile(string fileName, byte[] data) |
54 | { | 87 | { |
55 | lock (NewFiles) | 88 | lock (NewFiles) |
56 | { | 89 | { |
@@ -63,8 +96,10 @@ namespace OpenSim.Region.Environment | |||
63 | NewFiles.Add(fileName, data); | 96 | NewFiles.Add(fileName, data); |
64 | } | 97 | } |
65 | } | 98 | } |
99 | return true; | ||
66 | } | 100 | } |
67 | 101 | ||
102 | |||
68 | public class XferDownLoad | 103 | public class XferDownLoad |
69 | { | 104 | { |
70 | public byte[] Data = new byte[0]; | 105 | public byte[] Data = new byte[0]; |