aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Capabilities/CapsHandlers.cs
diff options
context:
space:
mode:
authordiva2009-06-18 00:48:39 +0000
committerdiva2009-06-18 00:48:39 +0000
commit913bc3bdb380cebebd11b657966486448962ab47 (patch)
treef41837093cd692b9fe42a21c9cb1473ef81dd0f1 /OpenSim/Framework/Capabilities/CapsHandlers.cs
parentFix an uninitialized data block. Thanks, jhurliman (diff)
downloadopensim-SC-913bc3bdb380cebebd11b657966486448962ab47.zip
opensim-SC-913bc3bdb380cebebd11b657966486448962ab47.tar.gz
opensim-SC-913bc3bdb380cebebd11b657966486448962ab47.tar.bz2
opensim-SC-913bc3bdb380cebebd11b657966486448962ab47.tar.xz
Moved OpenSim/Framework/Communications/Capabilities up to OpenSim/Framework/Capabilities. Didn't change the namespace because VC# is not helping, and this would imply manually changing more than 50 files. So the namespace is still OpenSim.Framework.Communications.Capabilities, to be cleaned up later by someone with more energy.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Capabilities/CapsHandlers.cs (renamed from OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs)342
1 files changed, 171 insertions, 171 deletions
diff --git a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs b/OpenSim/Framework/Capabilities/CapsHandlers.cs
index cc44023..d977639 100644
--- a/OpenSim/Framework/Communications/Capabilities/CapsHandlers.cs
+++ b/OpenSim/Framework/Capabilities/CapsHandlers.cs
@@ -1,171 +1,171 @@
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.Collections; 28using System.Collections;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenSim.Framework.Servers; 30using OpenSim.Framework.Servers;
31using OpenSim.Framework.Servers.HttpServer; 31using OpenSim.Framework.Servers.HttpServer;
32 32
33namespace OpenSim.Framework.Communications.Capabilities 33namespace OpenSim.Framework.Communications.Capabilities
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// CapsHandlers is a cap handler container but also takes 36 /// CapsHandlers is a cap handler container but also takes
37 /// care of adding and removing cap handlers to and from the 37 /// care of adding and removing cap handlers to and from the
38 /// supplied BaseHttpServer. 38 /// supplied BaseHttpServer.
39 /// </summary> 39 /// </summary>
40 public class CapsHandlers 40 public class CapsHandlers
41 { 41 {
42 private Dictionary <string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>(); 42 private Dictionary <string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
43 private IHttpServer m_httpListener; 43 private IHttpServer m_httpListener;
44 private string m_httpListenerHostName; 44 private string m_httpListenerHostName;
45 private uint m_httpListenerPort; 45 private uint m_httpListenerPort;
46 private bool m_useSSL = false; 46 private bool m_useSSL = false;
47 47
48 /// <summary></summary> 48 /// <summary></summary>
49 /// CapsHandlers is a cap handler container but also takes 49 /// CapsHandlers is a cap handler container but also takes
50 /// care of adding and removing cap handlers to and from the 50 /// care of adding and removing cap handlers to and from the
51 /// supplied BaseHttpServer. 51 /// supplied BaseHttpServer.
52 /// </summary> 52 /// </summary>
53 /// <param name="httpListener">base HTTP server</param> 53 /// <param name="httpListener">base HTTP server</param>
54 /// <param name="httpListenerHostname">host name of the HTTP 54 /// <param name="httpListenerHostname">host name of the HTTP
55 /// server</param> 55 /// server</param>
56 /// <param name="httpListenerPort">HTTP port</param> 56 /// <param name="httpListenerPort">HTTP port</param>
57 public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort) 57 public CapsHandlers(BaseHttpServer httpListener, string httpListenerHostname, uint httpListenerPort)
58 : this (httpListener,httpListenerHostname,httpListenerPort, false) 58 : this (httpListener,httpListenerHostname,httpListenerPort, false)
59 { 59 {
60 } 60 }
61 61
62 /// <summary></summary> 62 /// <summary></summary>
63 /// CapsHandlers is a cap handler container but also takes 63 /// CapsHandlers is a cap handler container but also takes
64 /// care of adding and removing cap handlers to and from the 64 /// care of adding and removing cap handlers to and from the
65 /// supplied BaseHttpServer. 65 /// supplied BaseHttpServer.
66 /// </summary> 66 /// </summary>
67 /// <param name="httpListener">base HTTP server</param> 67 /// <param name="httpListener">base HTTP server</param>
68 /// <param name="httpListenerHostname">host name of the HTTP 68 /// <param name="httpListenerHostname">host name of the HTTP
69 /// server</param> 69 /// server</param>
70 /// <param name="httpListenerPort">HTTP port</param> 70 /// <param name="httpListenerPort">HTTP port</param>
71 public CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https) 71 public CapsHandlers(IHttpServer httpListener, string httpListenerHostname, uint httpListenerPort, bool https)
72 { 72 {
73 m_httpListener = httpListener; 73 m_httpListener = httpListener;
74 m_httpListenerHostName = httpListenerHostname; 74 m_httpListenerHostName = httpListenerHostname;
75 m_httpListenerPort = httpListenerPort; 75 m_httpListenerPort = httpListenerPort;
76 m_useSSL = https; 76 m_useSSL = https;
77 if (m_useSSL) 77 if (m_useSSL)
78 { 78 {
79 m_httpListenerHostName = httpListener.SSLCommonName; 79 m_httpListenerHostName = httpListener.SSLCommonName;
80 m_httpListenerPort = httpListener.SSLPort; 80 m_httpListenerPort = httpListener.SSLPort;
81 } 81 }
82 } 82 }
83 83
84 /// <summary> 84 /// <summary>
85 /// Remove the cap handler for a capability. 85 /// Remove the cap handler for a capability.
86 /// </summary> 86 /// </summary>
87 /// <param name="capsName">name of the capability of the cap 87 /// <param name="capsName">name of the capability of the cap
88 /// handler to be removed</param> 88 /// handler to be removed</param>
89 public void Remove(string capsName) 89 public void Remove(string capsName)
90 { 90 {
91 // This line must be here, or caps will break! 91 // This line must be here, or caps will break!
92 m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path); 92 m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[capsName].Path);
93 m_capsHandlers.Remove(capsName); 93 m_capsHandlers.Remove(capsName);
94 } 94 }
95 95
96 public bool ContainsCap(string cap) 96 public bool ContainsCap(string cap)
97 { 97 {
98 return m_capsHandlers.ContainsKey(cap); 98 return m_capsHandlers.ContainsKey(cap);
99 } 99 }
100 100
101 /// <summary> 101 /// <summary>
102 /// The indexer allows us to treat the CapsHandlers object 102 /// The indexer allows us to treat the CapsHandlers object
103 /// in an intuitive dictionary like way. 103 /// in an intuitive dictionary like way.
104 /// </summary> 104 /// </summary>
105 /// <Remarks> 105 /// <Remarks>
106 /// The indexer will throw an exception when you try to 106 /// The indexer will throw an exception when you try to
107 /// retrieve a cap handler for a cap that is not contained in 107 /// retrieve a cap handler for a cap that is not contained in
108 /// CapsHandlers. 108 /// CapsHandlers.
109 /// </Remarks> 109 /// </Remarks>
110 public IRequestHandler this[string idx] 110 public IRequestHandler this[string idx]
111 { 111 {
112 get 112 get
113 { 113 {
114 return m_capsHandlers[idx]; 114 return m_capsHandlers[idx];
115 } 115 }
116 116
117 set 117 set
118 { 118 {
119 if (m_capsHandlers.ContainsKey(idx)) 119 if (m_capsHandlers.ContainsKey(idx))
120 { 120 {
121 m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path); 121 m_httpListener.RemoveStreamHandler("POST", m_capsHandlers[idx].Path);
122 m_capsHandlers.Remove(idx); 122 m_capsHandlers.Remove(idx);
123 } 123 }
124 124
125 if (null == value) return; 125 if (null == value) return;
126 126
127 m_capsHandlers[idx] = value; 127 m_capsHandlers[idx] = value;
128 m_httpListener.AddStreamHandler(value); 128 m_httpListener.AddStreamHandler(value);
129 } 129 }
130 } 130 }
131 131
132 /// <summary> 132 /// <summary>
133 /// Return the list of cap names for which this CapsHandlers 133 /// Return the list of cap names for which this CapsHandlers
134 /// object contains cap handlers. 134 /// object contains cap handlers.
135 /// </summary> 135 /// </summary>
136 public string[] Caps 136 public string[] Caps
137 { 137 {
138 get 138 get
139 { 139 {
140 string[] __keys = new string[m_capsHandlers.Keys.Count]; 140 string[] __keys = new string[m_capsHandlers.Keys.Count];
141 m_capsHandlers.Keys.CopyTo(__keys, 0); 141 m_capsHandlers.Keys.CopyTo(__keys, 0);
142 return __keys; 142 return __keys;
143 } 143 }
144 } 144 }
145 145
146 /// <summary> 146 /// <summary>
147 /// Return an LLSD-serializable Hashtable describing the 147 /// Return an LLSD-serializable Hashtable describing the
148 /// capabilities and their handler details. 148 /// capabilities and their handler details.
149 /// </summary> 149 /// </summary>
150 public Hashtable CapsDetails 150 public Hashtable CapsDetails
151 { 151 {
152 get 152 get
153 { 153 {
154 Hashtable caps = new Hashtable(); 154 Hashtable caps = new Hashtable();
155 string protocol = "http://"; 155 string protocol = "http://";
156 156
157 if (m_useSSL) 157 if (m_useSSL)
158 protocol = "https://"; 158 protocol = "https://";
159 159
160 string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString(); 160 string baseUrl = protocol + m_httpListenerHostName + ":" + m_httpListenerPort.ToString();
161 foreach (string capsName in m_capsHandlers.Keys) 161 foreach (string capsName in m_capsHandlers.Keys)
162 { 162 {
163 // skip SEED cap 163 // skip SEED cap
164 if ("SEED" == capsName) continue; 164 if ("SEED" == capsName) continue;
165 caps[capsName] = baseUrl + m_capsHandlers[capsName].Path; 165 caps[capsName] = baseUrl + m_capsHandlers[capsName].Path;
166 } 166 }
167 return caps; 167 return caps;
168 } 168 }
169 } 169 }
170 } 170 }
171} 171}