diff options
author | Adam Frisby | 2008-04-30 21:16:36 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-30 21:16:36 +0000 |
commit | f5c312bc3c2567449c7268a54a08a54119f58d53 (patch) | |
tree | 424668a4bbec6873ebc5b8256f3671db102f5e9c /OpenSim/Region/Environment/Modules/InstantMessageModule.cs | |
parent | * Adds the AuthbuyerID field to sqlite and makes use of it. (diff) | |
download | opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.zip opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2 opensim-SC-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.xz |
* Refactored Environment/Modules directory - modules now reside in their own directory with any associated module-specific classes.
* Each module directory is currently inside one of the following category folders: Agent (Anything relating to do with Client<->Server communications.), Avatar (Anything to do with the avatar or presence inworld), Framework (Classes modules can use), Grid (Grid traffic, new OGS2 grid comms), Scripting (Scripting functions, etc), World (The enrivonment/scene, IE Sun/Tree modules.)
* This should be moved into a seperate project file.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs (renamed from OpenSim/Region/Environment/Modules/InstantMessageModule.cs) | 316 |
1 files changed, 157 insertions, 159 deletions
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs index 6e13b73..1b82837 100644 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -1,159 +1,157 @@ | |||
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 | using System.Collections; | 28 | using System.Collections.Generic; |
29 | using System.Collections.Generic; | 29 | using libsecondlife; |
30 | using libsecondlife; | 30 | using Nini.Config; |
31 | using Nini.Config; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Region.Environment.Interfaces; |
33 | using OpenSim.Region.Environment.Interfaces; | 33 | using OpenSim.Region.Environment.Scenes; |
34 | using OpenSim.Region.Environment.Scenes; | 34 | |
35 | 35 | namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage | |
36 | namespace OpenSim.Region.Environment.Modules | 36 | { |
37 | { | 37 | public class InstantMessageModule : IRegionModule |
38 | public class InstantMessageModule : IRegionModule | 38 | { |
39 | { | 39 | private readonly List<Scene> m_scenes = new List<Scene>(); |
40 | private List<Scene> m_scenes = new List<Scene>(); | 40 | |
41 | private Hashtable m_RegionInfoCache = new Hashtable(); | 41 | public void Initialise(Scene scene, IConfigSource config) |
42 | 42 | { | |
43 | public void Initialise(Scene scene, IConfigSource config) | 43 | lock (m_scenes) |
44 | { | 44 | { |
45 | lock (m_scenes) | 45 | if (m_scenes.Count == 0) |
46 | { | 46 | { |
47 | if (m_scenes.Count == 0) | 47 | //scene.AddXmlRPCHandler("avatar_location_update", processPresenceUpdate); |
48 | { | 48 | } |
49 | //scene.AddXmlRPCHandler("avatar_location_update", processPresenceUpdate); | 49 | |
50 | } | 50 | if (!m_scenes.Contains(scene)) |
51 | 51 | { | |
52 | if (!m_scenes.Contains(scene)) | 52 | m_scenes.Add(scene); |
53 | { | 53 | scene.EventManager.OnNewClient += OnNewClient; |
54 | m_scenes.Add(scene); | 54 | scene.EventManager.OnGridInstantMessageToIMModule += OnGridInstantMessage; |
55 | scene.EventManager.OnNewClient += OnNewClient; | 55 | } |
56 | scene.EventManager.OnGridInstantMessageToIMModule += OnGridInstantMessage; | 56 | } |
57 | } | 57 | } |
58 | } | 58 | |
59 | } | 59 | private void OnNewClient(IClientAPI client) |
60 | 60 | { | |
61 | private void OnNewClient(IClientAPI client) | 61 | client.OnInstantMessage += OnInstantMessage; |
62 | { | 62 | } |
63 | client.OnInstantMessage += OnInstantMessage; | 63 | |
64 | } | 64 | private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID, |
65 | 65 | LLUUID fromAgentSession, LLUUID toAgentID, | |
66 | private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID, | 66 | LLUUID imSessionID, uint timestamp, string fromAgentName, |
67 | LLUUID fromAgentSession, LLUUID toAgentID, | 67 | string message, byte dialog, bool fromGroup, byte offline, |
68 | LLUUID imSessionID, uint timestamp, string fromAgentName, | 68 | uint ParentEstateID, LLVector3 Position, LLUUID RegionID, |
69 | string message, byte dialog, bool fromGroup, byte offline, | 69 | byte[] binaryBucket) |
70 | uint ParentEstateID, LLVector3 Position, LLUUID RegionID, | 70 | { |
71 | byte[] binaryBucket) | 71 | bool dialogHandledElsewhere |
72 | { | 72 | = ((dialog == 38) || (dialog == 39) || (dialog == 40) |
73 | bool dialogHandledElsewhere | 73 | || dialog == (byte)InstantMessageDialog.InventoryOffered |
74 | = ((dialog == (byte)38) || (dialog == (byte)39) || (dialog == (byte)40) | 74 | || dialog == (byte)InstantMessageDialog.InventoryAccepted |
75 | || dialog == (byte)InstantMessageDialog.InventoryOffered | 75 | || dialog == (byte)InstantMessageDialog.InventoryDeclined); |
76 | || dialog == (byte)InstantMessageDialog.InventoryAccepted | 76 | |
77 | || dialog == (byte)InstantMessageDialog.InventoryDeclined); | 77 | // IM dialogs need to be pre-processed and have their sessionID filled by the server |
78 | 78 | // so the sim can match the transaction on the return packet. | |
79 | // IM dialogs need to be pre-processed and have their sessionID filled by the server | 79 | |
80 | // so the sim can match the transaction on the return packet. | 80 | // Don't send a Friend Dialog IM with a LLUUID.Zero session. |
81 | 81 | if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero)) | |
82 | // Don't send a Friend Dialog IM with a LLUUID.Zero session. | 82 | { |
83 | if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero)) | 83 | // Try root avatar only first |
84 | { | 84 | foreach (Scene scene in m_scenes) |
85 | // Try root avatar only first | 85 | { |
86 | foreach (Scene scene in m_scenes) | 86 | if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) |
87 | { | 87 | { |
88 | if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) | 88 | // Local message |
89 | { | 89 | ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; |
90 | // Local message | 90 | if (!user.IsChildAgent) |
91 | ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; | 91 | { |
92 | if (!user.IsChildAgent) | 92 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, |
93 | { | 93 | toAgentID, imSessionID, fromAgentName, dialog, |
94 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | 94 | timestamp); |
95 | toAgentID, imSessionID, fromAgentName, dialog, | 95 | // Message sent |
96 | timestamp); | 96 | return; |
97 | // Message sent | 97 | } |
98 | return; | 98 | } |
99 | } | 99 | } |
100 | } | 100 | |
101 | } | 101 | // try child avatar second |
102 | 102 | foreach (Scene scene in m_scenes) | |
103 | // try child avatar second | 103 | { |
104 | foreach (Scene scene in m_scenes) | 104 | if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) |
105 | { | 105 | { |
106 | if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) | 106 | // Local message |
107 | { | 107 | ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; |
108 | // Local message | 108 | |
109 | ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; | 109 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, |
110 | 110 | toAgentID, imSessionID, fromAgentName, dialog, | |
111 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | 111 | timestamp); |
112 | toAgentID, imSessionID, fromAgentName, dialog, | 112 | // Message sent |
113 | timestamp); | 113 | return; |
114 | // Message sent | 114 | |
115 | return; | 115 | } |
116 | 116 | } | |
117 | } | 117 | |
118 | } | 118 | } |
119 | 119 | ||
120 | } | 120 | |
121 | 121 | // Still here, try send via Grid | |
122 | 122 | // TODO | |
123 | // Still here, try send via Grid | 123 | } |
124 | // TODO | 124 | |
125 | } | 125 | // Trusty OSG1 called method. This method also gets called from the FriendsModule |
126 | 126 | // Turns out the sim has to send an instant message to the user to get it to show an accepted friend. | |
127 | // Trusty OSG1 called method. This method also gets called from the FriendsModule | 127 | |
128 | // Turns out the sim has to send an instant message to the user to get it to show an accepted friend. | 128 | private void OnGridInstantMessage(GridInstantMessage msg) |
129 | 129 | { | |
130 | private void OnGridInstantMessage(GridInstantMessage msg) | 130 | // Trigger the above event handler |
131 | { | 131 | OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), |
132 | // Trigger the above event handler | 132 | new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, |
133 | OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), | 133 | msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, |
134 | new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, | 134 | new LLVector3(msg.Position.x,msg.Position.y,msg.Position.z), new LLUUID(msg.RegionID), |
135 | msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, | 135 | msg.binaryBucket); |
136 | new LLVector3(msg.Position.x,msg.Position.y,msg.Position.z), new LLUUID(msg.RegionID), | 136 | |
137 | msg.binaryBucket); | 137 | } |
138 | 138 | ||
139 | } | 139 | public void PostInitialise() |
140 | 140 | { | |
141 | public void PostInitialise() | 141 | } |
142 | { | 142 | |
143 | } | 143 | public void Close() |
144 | 144 | { | |
145 | public void Close() | 145 | } |
146 | { | 146 | |
147 | } | 147 | public string Name |
148 | 148 | { | |
149 | public string Name | 149 | get { return "InstantMessageModule"; } |
150 | { | 150 | } |
151 | get { return "InstantMessageModule"; } | 151 | |
152 | } | 152 | public bool IsSharedModule |
153 | 153 | { | |
154 | public bool IsSharedModule | 154 | get { return true; } |
155 | { | 155 | } |
156 | get { return true; } | 156 | } |
157 | } | 157 | } \ No newline at end of file |
158 | } | ||
159 | } | ||