aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs172
1 files changed, 169 insertions, 3 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
index 26586a5..d9d2875 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -24,10 +24,12 @@
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 27using System;
28using System.Collections;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using libsecondlife; 30using libsecondlife;
30using Nini.Config; 31using Nini.Config;
32using Nwc.XmlRpc;
31using OpenSim.Framework; 33using OpenSim.Framework;
32using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
33using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
@@ -40,6 +42,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
40 42
41 #region IRegionModule Members 43 #region IRegionModule Members
42 44
45 private bool gridmode = false;
46
43 public void Initialise(Scene scene, IConfigSource config) 47 public void Initialise(Scene scene, IConfigSource config)
44 { 48 {
45 lock (m_scenes) 49 lock (m_scenes)
@@ -47,6 +51,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
47 if (m_scenes.Count == 0) 51 if (m_scenes.Count == 0)
48 { 52 {
49 //scene.AddXmlRPCHandler("avatar_location_update", processPresenceUpdate); 53 //scene.AddXmlRPCHandler("avatar_location_update", processPresenceUpdate);
54 scene.AddXmlRPCHandler("grid_instant_message", processXMLRPCGridInstantMessage);
55 ReadConfig(config);
50 } 56 }
51 57
52 if (!m_scenes.Contains(scene)) 58 if (!m_scenes.Contains(scene))
@@ -58,6 +64,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
58 } 64 }
59 } 65 }
60 66
67 private void ReadConfig(IConfigSource config)
68 {
69 IConfig cnf = config.Configs["Startup"];
70 if (cnf != null)
71 {
72 gridmode = cnf.GetBoolean("gridmode", false);
73 }
74 }
75
61 public void PostInitialise() 76 public void PostInitialise()
62 { 77 {
63 } 78 }
@@ -137,9 +152,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
137 } 152 }
138 } 153 }
139 154
155 if (gridmode)
156 {
157 // Still here, try send via Grid
158 // TODO
140 159
141 // Still here, try send via Grid 160 }
142 // TODO
143 } 161 }
144 162
145 // Trusty OSG1 called method. This method also gets called from the FriendsModule 163 // Trusty OSG1 called method. This method also gets called from the FriendsModule
@@ -154,5 +172,153 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
154 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID), 172 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
155 msg.binaryBucket); 173 msg.binaryBucket);
156 } 174 }
175 protected virtual XmlRpcResponse processXMLRPCGridInstantMessage(XmlRpcRequest request)
176 {
177 // various rational defaults
178 LLUUID fromAgentID = LLUUID.Zero;
179 LLUUID fromAgentSession = LLUUID.Zero;
180 LLUUID toAgentID = LLUUID.Zero;
181 LLUUID imSessionID = LLUUID.Zero;
182 uint timestamp = 0;
183 string fromAgentName = "";
184 string message = "";
185 byte dialog = (byte)0;
186 bool fromGroup = false;
187 byte offline = (byte)0;
188 uint ParentEstateID;
189 LLVector3 Position = LLVector3.Zero;
190 LLUUID RegionID = LLUUID.Zero ;
191 byte[] binaryBucket = new byte[0];
192
193 float pos_x = 0;
194 float pos_y = 0;
195 float pos_z = 0;
196
197
198
199 Hashtable requestData = (Hashtable)request.Params[0];
200
201 if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("from_agent_session")
202 && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id")
203 && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name")
204 && requestData.ContainsKey("message") && requestData.ContainsKey("dialog")
205 && requestData.ContainsKey("from_group")
206 && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id")
207 && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y")
208 && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id")
209 && requestData.ContainsKey("binary_bucket") && requestData.ContainsKey("region_handle"))
210 {
211 Helpers.TryParse((string)requestData["from_agent_id"], out fromAgentID);
212 Helpers.TryParse((string)requestData["from_agent_session"], out fromAgentSession);
213 Helpers.TryParse((string)requestData["to_agent_id"], out toAgentID);
214 Helpers.TryParse((string)requestData["im_session_id"], out imSessionID);
215 Helpers.TryParse((string)requestData["region_id"], out RegionID);
216
217 # region timestamp
218 try
219 {
220 timestamp = (uint)Convert.ToInt32((string)requestData["timestamp"]);
221 }
222 catch (ArgumentException)
223 {
224 }
225 catch (FormatException)
226 {
227 }
228 catch (OverflowException)
229 {
230 }
231 # endregion
232
233 fromAgentName = (string)requestData["from_agent_name"];
234 message = (string)requestData["message"];
235 dialog = (byte)requestData["dialog"];
236
237 if ((string)requestData["from_group"] == "TRUE")
238 fromGroup = true;
239
240 offline = (byte)requestData["offline"];
241
242 # region ParentEstateID
243 try
244 {
245 ParentEstateID = (uint)Convert.ToInt32((string)requestData["parent_estate_id"]);
246 }
247 catch (ArgumentException)
248 {
249 }
250 catch (FormatException)
251 {
252 }
253 catch (OverflowException)
254 {
255 }
256 # endregion
257
258 # region pos_x
259 try
260 {
261 pos_x = (uint)Convert.ToInt32((string)requestData["position_x"]);
262 }
263 catch (ArgumentException)
264 {
265 }
266 catch (FormatException)
267 {
268 }
269 catch (OverflowException)
270 {
271 }
272 # endregion
273 # region pos_y
274 try
275 {
276 pos_y = (uint)Convert.ToInt32((string)requestData["position_y"]);
277 }
278 catch (ArgumentException)
279 {
280 }
281 catch (FormatException)
282 {
283 }
284 catch (OverflowException)
285 {
286 }
287 # endregion
288 # region pos_z
289 try
290 {
291 pos_z = (uint)Convert.ToInt32((string)requestData["position_z"]);
292 }
293 catch (ArgumentException)
294 {
295 }
296 catch (FormatException)
297 {
298 }
299 catch (OverflowException)
300 {
301 }
302 # endregion
303
304 Position = new LLVector3(pos_x, pos_y, pos_z);
305 binaryBucket = (byte[])requestData["binary_bucket"];
306 }
307
308 return new XmlRpcResponse();
309 //(string)
310 //(string)requestData["message"];
311
312 }
313
314 protected virtual void SendGridInstantMessageViaXMLRPC(IClientAPI client, LLUUID fromAgentID,
315 LLUUID fromAgentSession, LLUUID toAgentID,
316 LLUUID imSessionID, uint timestamp, string fromAgentName,
317 string message, byte dialog, bool fromGroup, byte offline,
318 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
319 byte[] binaryBucket)
320 {
321
322 }
157 } 323 }
158} \ No newline at end of file 324} \ No newline at end of file