aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/XMPP
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/XMPP/XmppSerializer.cs79
-rw-r--r--OpenSim/Framework/DOMap.cs (renamed from OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs)95
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs (renamed from OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs)47
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs (renamed from OpenSim/Framework/Communications/XMPP/XmppStanza.cs)54
-rw-r--r--OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs (renamed from OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs)40
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs (renamed from OpenSim/Framework/Communications/XMPP/XmppWriter.cs)113
-rw-r--r--OpenSim/Services/Interfaces/IBakedTextureService.cs (renamed from OpenSim/Framework/Communications/XMPP/XmppError.cs)13
7 files changed, 167 insertions, 274 deletions
diff --git a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs b/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs
deleted file mode 100644
index e37ef28..0000000
--- a/OpenSim/Framework/Communications/XMPP/XmppSerializer.cs
+++ /dev/null
@@ -1,79 +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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Xml;
31using System.Xml.Serialization;
32
33namespace OpenSim.Framework.Communications.XMPP
34{
35 public class XmppSerializer
36 {
37 // private static readonly ILog _log =
38 // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39
40 // need to do it this way, as XmlSerializer(type, extratypes)
41 // does not work on mono (at least).
42 private Dictionary<Type, XmlSerializer> _serializerForType = new Dictionary<Type, XmlSerializer>();
43 private Dictionary<string, XmlSerializer> _serializerForName = new Dictionary<string, XmlSerializer>();
44 private XmlSerializerNamespaces _xmlNs;
45 private string _defaultNS;
46
47 public XmppSerializer(bool server)
48 {
49 _xmlNs = new XmlSerializerNamespaces();
50 _xmlNs.Add(String.Empty, String.Empty);
51 if (server)
52 _defaultNS = "jabber:server";
53 else
54 _defaultNS = "jabber:client";
55
56 // TODO: do this via reflection
57 _serializerForType[typeof(XmppMessageStanza)] = _serializerForName["message"] =
58 new XmlSerializer(typeof(XmppMessageStanza), _defaultNS);
59 }
60
61 public void Serialize(XmlWriter xw, object o)
62 {
63 if (!_serializerForType.ContainsKey(o.GetType()))
64 throw new ArgumentException(String.Format("no serializer available for type {0}", o.GetType()));
65
66 _serializerForType[o.GetType()].Serialize(xw, o, _xmlNs);
67 }
68
69 public object Deserialize(XmlReader xr)
70 {
71 // position on next element
72 xr.Read();
73 if (!_serializerForName.ContainsKey(xr.LocalName))
74 throw new ArgumentException(String.Format("no serializer available for name {0}", xr.LocalName));
75
76 return _serializerForName[xr.LocalName].Deserialize(xr);
77 }
78 }
79}
diff --git a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs b/OpenSim/Framework/DOMap.cs
index 1e8c33e..f5b650b 100644
--- a/OpenSim/Framework/Communications/XMPP/XmppMessageStanza.cs
+++ b/OpenSim/Framework/DOMap.cs
@@ -25,69 +25,74 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.IO;
32using System.Text;
33using System.Xml;
34using System.Xml.Schema;
28using System.Xml.Serialization; 35using System.Xml.Serialization;
36using OpenMetaverse;
37using OpenMetaverse.StructuredData;
29 38
30namespace OpenSim.Framework.Communications.XMPP 39namespace OpenSim.Framework
31{ 40{
32 /// <summary> 41 /// <summary>
33 /// Message types. 42 /// This class stores and retrieves dynamic objects.
34 /// </summary> 43 /// </summary>
35 public enum XmppMessageType 44 /// <remarks>
45 /// Experimental - DO NOT USE. Does not yet have namespace support.
46 /// </remarks>
47 public class DOMap
36 { 48 {
37 [XmlEnum("chat")] chat, 49 private IDictionary<string, object> m_map;
38 [XmlEnum("error")] error, 50
39 [XmlEnum("groupchat")] groupchat, 51 public void Add(string ns, string objName, object dynObj)
40 [XmlEnum("headline")] headline,
41 [XmlEnum("normal")] normal,
42 }
43
44 /// <summary>
45 /// Message body.
46 /// </summary>
47 public class XmppMessageBody
48 {
49 [XmlText]
50 public string Text;
51
52 public XmppMessageBody()
53 { 52 {
54 } 53 DAMap.ValidateNamespace(ns);
55 54
56 public XmppMessageBody(string message) 55 lock (this)
57 { 56 {
58 Text = message; 57 if (m_map == null)
58 m_map = new Dictionary<string, object>();
59
60 m_map.Add(objName, dynObj);
61 }
59 } 62 }
60 63
61 new public string ToString() 64 public bool ContainsKey(string key)
62 { 65 {
63 return Text; 66 return Get(key) != null;
64 } 67 }
65 }
66 68
67 [XmlRoot("message")]
68 public class XmppMessageStanza: XmppStanza
69 {
70 /// <summary> 69 /// <summary>
71 /// IQ type: one of set, get, result, error 70 /// Get a dynamic object
72 /// </summary> 71 /// </summary>
73 [XmlAttribute("type")] 72 /// <remarks>
74 public XmppMessageType MessageType; 73 /// Not providing an index method so that users can't casually overwrite each other's objects.
75 74 /// </remarks>
76 // [XmlAttribute("error")] 75 /// <param name='key'></param>
77 // public XmppError Error; 76 public object Get(string key)
78
79 [XmlElement("body")]
80 public XmppMessageBody Body;
81
82 public XmppMessageStanza() : base()
83 { 77 {
78 lock (this)
79 {
80 if (m_map == null)
81 return null;
82 else
83 return m_map[key];
84 }
84 } 85 }
85 86
86 public XmppMessageStanza(string fromJid, string toJid, XmppMessageType mType, string message) : 87 public bool Remove(string key)
87 base(fromJid, toJid)
88 { 88 {
89 MessageType = mType; 89 lock (this)
90 Body = new XmppMessageBody(message); 90 {
91 if (m_map == null)
92 return false;
93 else
94 return m_map.Remove(key);
95 }
91 } 96 }
92 } 97 }
93} 98} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs
index 4d45ac0..72b3065 100644
--- a/OpenSim/Framework/Communications/XMPP/XmppPresenceStanza.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs
@@ -25,45 +25,36 @@
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
28using System.Xml.Serialization; 28using System.IO;
29 29
30namespace OpenSim.Framework.Communications.XMPP 30namespace OpenSim.Framework.Servers.HttpServer
31{ 31{
32 /// <summary> 32 /// <summary>
33 /// Message types. 33 /// Base handler for writing to an output stream
34 /// </summary> 34 /// </summary>
35 public enum XmppPresenceType 35 /// <remarks>
36 /// Inheriting classes should override ProcessRequest() rather than Handle()
37 /// </remarks>
38 public abstract class BaseOutputStreamHandler : BaseRequestHandler, IRequestHandler
36 { 39 {
37 [XmlEnum("unavailable")] unavailable, 40 protected BaseOutputStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
38 [XmlEnum("subscribe")] subscribe,
39 [XmlEnum("subscribed")] subscribed,
40 [XmlEnum("unsubscribe")] unsubscribe,
41 [XmlEnum("unsubscribed")] unsubscribed,
42 [XmlEnum("probe")] probe,
43 [XmlEnum("error")] error,
44 }
45 41
42 protected BaseOutputStreamHandler(string httpMethod, string path, string name, string description)
43 : base(httpMethod, path, name, description) {}
46 44
47 [XmlRoot("message")] 45 public virtual void Handle(
48 public class XmppPresenceStanza: XmppStanza 46 string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
49 { 47 {
50 /// <summary> 48 RequestsReceived++;
51 /// IQ type: one of set, get, result, error
52 /// </summary>
53 [XmlAttribute("type")]
54 public XmppPresenceType PresenceType;
55 49
56 // [XmlAttribute("error")] 50 ProcessRequest(path, request, response, httpRequest, httpResponse);
57 // public XmppError Error;
58 51
59 public XmppPresenceStanza() : base() 52 RequestsHandled++;
60 {
61 } 53 }
62 54
63 public XmppPresenceStanza(string fromJid, string toJid, XmppPresenceType pType) : 55 protected virtual void ProcessRequest(
64 base(fromJid, toJid) 56 string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
65 { 57 {
66 PresenceType = pType;
67 } 58 }
68 } 59 }
69} 60} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs
index 5312a31..78a43db 100644
--- a/OpenSim/Framework/Communications/XMPP/XmppStanza.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFeature.cs
@@ -26,45 +26,35 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Xml.Serialization; 29using OpenSim.Region.Framework.Interfaces;
30 30
31namespace OpenSim.Framework.Communications.XMPP 31namespace OpenSim.Region.CoreModules.World.Terrain
32{ 32{
33 public abstract class XmppStanza 33 public interface ITerrainFeature
34 { 34 {
35 /// <summary> 35 /// <summary>
36 /// counter used for generating ID 36 /// Creates the feature.
37 /// </summary> 37 /// </summary>
38 [XmlIgnore] 38 /// <returns>
39 private static ulong _ctr = 0; 39 /// Empty string if successful, otherwise error message.
40 /// </returns>
41 /// <param name='map'>
42 /// ITerrainChannel holding terrain data.
43 /// </param>
44 /// <param name='args'>
45 /// command-line arguments from console.
46 /// </param>
47 string CreateFeature(ITerrainChannel map, string[] args);
40 48
41 /// <summary> 49 /// <summary>
42 /// recipient JID 50 /// Gets a string describing the usage.
43 /// </summary> 51 /// </summary>
44 [XmlAttribute("to")] 52 /// <returns>
45 public string ToJid; 53 /// A string describing parameters for creating the feature.
46 54 /// Format is "feature-name <arg1> <arg2> ..."
47 /// <summary> 55 /// </returns>
48 /// sender JID 56 string GetUsage();
49 /// </summary>
50 [XmlAttribute("from")]
51 public string FromJid;
52
53 /// <summary>
54 /// unique ID.
55 /// </summary>
56 [XmlAttribute("id")]
57 public string MessageId;
58
59 public XmppStanza()
60 {
61 }
62
63 public XmppStanza(string fromJid, string toJid)
64 {
65 ToJid = toJid;
66 FromJid = fromJid;
67 MessageId = String.Format("OpenSim_{0}{1}", DateTime.UtcNow.Ticks, _ctr++);
68 }
69 } 57 }
58
70} 59}
60
diff --git a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs b/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs
index 12263f4..a730cfd 100644
--- a/OpenSim/Framework/Communications/XMPP/XmppIqStanza.cs
+++ b/OpenSim/Region/Framework/Interfaces/IExternalCapsModule.cs
@@ -25,36 +25,24 @@
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
28using System.Xml.Serialization; 28using System;
29using OpenMetaverse;
30using OpenSim.Framework;
31using Caps=OpenSim.Framework.Capabilities.Caps;
29 32
30namespace OpenSim.Framework.Communications.XMPP 33namespace OpenSim.Region.Framework.Interfaces
31{ 34{
32 /// <summary> 35 public interface IExternalCapsModule
33 /// An IQ needs to have one of the follow types set.
34 /// </summary>
35 public enum XmppIqType
36 {
37 [XmlEnum("set")] set,
38 [XmlEnum("get")] get,
39 [XmlEnum("result")] result,
40 [XmlEnum("error")] error,
41 }
42
43 /// <summary>
44 /// XmppIqStanza needs to be subclassed as the query content is
45 /// specific to the query type.
46 /// </summary>
47 [XmlRoot("iq")]
48 public abstract class XmppIqStanza: XmppStanza
49 { 36 {
50 /// <summary> 37 /// <summary>
51 /// IQ type: one of set, get, result, error 38 /// This function extends the simple URL configuration in the caps handlers
39 /// to facilitate more interesting computation when an external handler is
40 /// sent to the viewer.
52 /// </summary> 41 /// </summary>
53 [XmlAttribute("type")] 42 /// <param name="agentID">New user UUID</param>
54 public XmppIqType Type; 43 /// <param name="caps">Internal caps registry, where the external handler will be registered</param>
55 44 /// <param name="capName">Name of the specific cap we are registering</param>
56 public XmppIqStanza(): base() 45 /// <param name="urlSkel">The skeleton URL provided in the caps configuration</param>
57 { 46 bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel);
58 }
59 } 47 }
60} 48}
diff --git a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs
index 415d808..0be1f4c 100644..100755
--- a/OpenSim/Framework/Communications/XMPP/XmppWriter.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTests.cs
@@ -1,57 +1,56 @@
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 OpenSimulator Project nor the 12 * * Neither the name of the OpenSimulator 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
28using System.IO; 28using System;
29using System.Text; 29using System.Collections.Generic;
30using System.Xml; 30using System.Linq;
31using IOStream = System.IO.Stream; 31using System.Text;
32 32
33namespace OpenSim.Framework.Communications.XMPP 33using NUnit.Framework;
34{ 34using log4net;
35 public class XMPPWriter: XmlTextWriter 35
36 { 36using OpenSim.Tests.Common;
37 public XMPPWriter(TextWriter textWriter) : base(textWriter) 37
38 { 38namespace OpenSim.Region.PhysicsModule.BulletS.Tests
39 } 39{
40 40[TestFixture]
41 public XMPPWriter(IOStream stream) : this(stream, Util.UTF8) 41public class BulletSimTests : OpenSimTestCase
42 { 42{
43 } 43 // Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
44 44 // Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
45 public XMPPWriter(IOStream stream, Encoding enc) : base(stream, enc) 45
46 { 46 [TestFixtureSetUp]
47 } 47 public void Init()
48 48 {
49 public override void WriteStartDocument() 49 }
50 { 50
51 } 51 [TestFixtureTearDown]
52 52 public void TearDown()
53 public override void WriteStartDocument(bool standalone) 53 {
54 { 54 }
55 } 55}
56 } 56}
57}
diff --git a/OpenSim/Framework/Communications/XMPP/XmppError.cs b/OpenSim/Services/Interfaces/IBakedTextureService.cs
index 3d36e9c..69df4a0 100644
--- a/OpenSim/Framework/Communications/XMPP/XmppError.cs
+++ b/OpenSim/Services/Interfaces/IBakedTextureService.cs
@@ -25,15 +25,14 @@
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
28using System.Xml.Serialization; 28using System;
29using Nini.Config;
29 30
30namespace OpenSim.Framework.Communications.XMPP 31namespace OpenSim.Services.Interfaces
31{ 32{
32 [XmlRoot("error")] 33 public interface IBakedTextureService
33 public class XmppErrorStanza
34 { 34 {
35 public XmppErrorStanza() 35 string Get(string id);
36 { 36 void Store(string id, string data);
37 }
38 } 37 }
39} 38}