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_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.zip opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.gz opensim-SC_OLD-f5c312bc3c2567449c7268a54a08a54119f58d53.tar.bz2 opensim-SC_OLD-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 'OpenSim/Region/Environment/Modules/InstantMessageModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/InstantMessageModule.cs | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs deleted file mode 100644 index 6e13b73..0000000 --- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs +++ /dev/null | |||
@@ -1,159 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections; | ||
29 | using System.Collections.Generic; | ||
30 | using libsecondlife; | ||
31 | using Nini.Config; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Region.Environment.Interfaces; | ||
34 | using OpenSim.Region.Environment.Scenes; | ||
35 | |||
36 | namespace OpenSim.Region.Environment.Modules | ||
37 | { | ||
38 | public class InstantMessageModule : IRegionModule | ||
39 | { | ||
40 | private List<Scene> m_scenes = new List<Scene>(); | ||
41 | private Hashtable m_RegionInfoCache = new Hashtable(); | ||
42 | |||
43 | public void Initialise(Scene scene, IConfigSource config) | ||
44 | { | ||
45 | lock (m_scenes) | ||
46 | { | ||
47 | if (m_scenes.Count == 0) | ||
48 | { | ||
49 | //scene.AddXmlRPCHandler("avatar_location_update", processPresenceUpdate); | ||
50 | } | ||
51 | |||
52 | if (!m_scenes.Contains(scene)) | ||
53 | { | ||
54 | m_scenes.Add(scene); | ||
55 | scene.EventManager.OnNewClient += OnNewClient; | ||
56 | scene.EventManager.OnGridInstantMessageToIMModule += OnGridInstantMessage; | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | private void OnNewClient(IClientAPI client) | ||
62 | { | ||
63 | client.OnInstantMessage += OnInstantMessage; | ||
64 | } | ||
65 | |||
66 | private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID, | ||
67 | LLUUID fromAgentSession, LLUUID toAgentID, | ||
68 | LLUUID imSessionID, uint timestamp, string fromAgentName, | ||
69 | string message, byte dialog, bool fromGroup, byte offline, | ||
70 | uint ParentEstateID, LLVector3 Position, LLUUID RegionID, | ||
71 | byte[] binaryBucket) | ||
72 | { | ||
73 | bool dialogHandledElsewhere | ||
74 | = ((dialog == (byte)38) || (dialog == (byte)39) || (dialog == (byte)40) | ||
75 | || dialog == (byte)InstantMessageDialog.InventoryOffered | ||
76 | || dialog == (byte)InstantMessageDialog.InventoryAccepted | ||
77 | || dialog == (byte)InstantMessageDialog.InventoryDeclined); | ||
78 | |||
79 | // IM dialogs need to be pre-processed and have their sessionID filled by the server | ||
80 | // so the sim can match the transaction on the return packet. | ||
81 | |||
82 | // Don't send a Friend Dialog IM with a LLUUID.Zero session. | ||
83 | if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero)) | ||
84 | { | ||
85 | // Try root avatar only first | ||
86 | foreach (Scene scene in m_scenes) | ||
87 | { | ||
88 | if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) | ||
89 | { | ||
90 | // Local message | ||
91 | ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; | ||
92 | if (!user.IsChildAgent) | ||
93 | { | ||
94 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | ||
95 | toAgentID, imSessionID, fromAgentName, dialog, | ||
96 | timestamp); | ||
97 | // Message sent | ||
98 | return; | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | |||
103 | // try child avatar second | ||
104 | foreach (Scene scene in m_scenes) | ||
105 | { | ||
106 | if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) | ||
107 | { | ||
108 | // Local message | ||
109 | ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; | ||
110 | |||
111 | user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, | ||
112 | toAgentID, imSessionID, fromAgentName, dialog, | ||
113 | timestamp); | ||
114 | // Message sent | ||
115 | return; | ||
116 | |||
117 | } | ||
118 | } | ||
119 | |||
120 | } | ||
121 | |||
122 | |||
123 | // Still here, try send via Grid | ||
124 | // TODO | ||
125 | } | ||
126 | |||
127 | // Trusty OSG1 called method. This method also gets called from the FriendsModule | ||
128 | // Turns out the sim has to send an instant message to the user to get it to show an accepted friend. | ||
129 | |||
130 | private void OnGridInstantMessage(GridInstantMessage msg) | ||
131 | { | ||
132 | // Trigger the above event handler | ||
133 | OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), | ||
134 | new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, | ||
135 | msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, | ||
136 | new LLVector3(msg.Position.x,msg.Position.y,msg.Position.z), new LLUUID(msg.RegionID), | ||
137 | msg.binaryBucket); | ||
138 | |||
139 | } | ||
140 | |||
141 | public void PostInitialise() | ||
142 | { | ||
143 | } | ||
144 | |||
145 | public void Close() | ||
146 | { | ||
147 | } | ||
148 | |||
149 | public string Name | ||
150 | { | ||
151 | get { return "InstantMessageModule"; } | ||
152 | } | ||
153 | |||
154 | public bool IsSharedModule | ||
155 | { | ||
156 | get { return true; } | ||
157 | } | ||
158 | } | ||
159 | } | ||