aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base/ServerUtils.cs
diff options
context:
space:
mode:
authorMelanie2009-10-02 08:23:38 +0100
committerMelanie2009-10-02 08:23:38 +0100
commit31d8cec0f8cd47ff445edc7771e5e73825a57927 (patch)
treea2d60604317739fa530502c40ffc71bab2a5c494 /OpenSim/Server/Base/ServerUtils.cs
parentRestore the missing image handling to the image manager. The missing (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.zip
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.gz
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.bz2
opensim-SC_OLD-31d8cec0f8cd47ff445edc7771e5e73825a57927.tar.xz
Merge branch 'master' into diva-textures
Diffstat (limited to 'OpenSim/Server/Base/ServerUtils.cs')
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs120
1 files changed, 119 insertions, 1 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 0a36bbe..9beadd8 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -141,7 +141,9 @@ namespace OpenSim.Server.Base
141 } 141 }
142 catch (Exception e) 142 catch (Exception e)
143 { 143 {
144 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException); 144 if (!(e is System.MissingMethodException))
145 m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e.InnerException);
146 return null;
145 } 147 }
146 148
147 return plug; 149 return plug;
@@ -183,5 +185,121 @@ namespace OpenSim.Server.Base
183 185
184 return result; 186 return result;
185 } 187 }
188
189 public static string BuildQueryString(Dictionary<string, string> data)
190 {
191 string qstring = String.Empty;
192
193 foreach (KeyValuePair<string, string> kvp in data)
194 {
195 string part;
196 if (kvp.Value != String.Empty)
197 {
198 part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
199 "=" + System.Web.HttpUtility.UrlEncode(kvp.Value);
200 }
201 else
202 {
203 part = System.Web.HttpUtility.UrlEncode(kvp.Key);
204 }
205
206 if (qstring != String.Empty)
207 qstring += "&";
208
209 qstring += part;
210 }
211
212 return qstring;
213 }
214
215 public static string BuildXmlResponse(Dictionary<string, object> data)
216 {
217 XmlDocument doc = new XmlDocument();
218
219 XmlNode xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration,
220 "", "");
221
222 doc.AppendChild(xmlnode);
223
224 XmlElement rootElement = doc.CreateElement("", "ServerResponse",
225 "");
226
227 doc.AppendChild(rootElement);
228
229 BuildXmlData(rootElement, data);
230
231 return doc.InnerXml;
232 }
233
234 private static void BuildXmlData(XmlElement parent, Dictionary<string, object> data)
235 {
236 foreach (KeyValuePair<string, object> kvp in data)
237 {
238 XmlElement elem = parent.OwnerDocument.CreateElement("",
239 kvp.Key, "");
240
241 if (kvp.Value is Dictionary<string, object>)
242 {
243 XmlAttribute type = parent.OwnerDocument.CreateAttribute("",
244 "type", "");
245 type.Value = "List";
246
247 elem.Attributes.Append(type);
248
249 BuildXmlData(elem, (Dictionary<string, object>)kvp.Value);
250 }
251 else
252 {
253 elem.AppendChild(parent.OwnerDocument.CreateTextNode(
254 kvp.Value.ToString()));
255 }
256
257 parent.AppendChild(elem);
258 }
259 }
260
261 public static Dictionary<string, object> ParseXmlResponse(string data)
262 {
263 //m_log.DebugFormat("[XXX]: received xml string: {0}", data);
264
265 Dictionary<string, object> ret = new Dictionary<string, object>();
266
267 XmlDocument doc = new XmlDocument();
268
269 doc.LoadXml(data);
270
271 XmlNodeList rootL = doc.GetElementsByTagName("ServerResponse");
272
273 if (rootL.Count != 1)
274 return ret;
275
276 XmlNode rootNode = rootL[0];
277
278 ret = ParseElement(rootNode);
279
280 return ret;
281 }
282
283 private static Dictionary<string, object> ParseElement(XmlNode element)
284 {
285 Dictionary<string, object> ret = new Dictionary<string, object>();
286
287 XmlNodeList partL = element.ChildNodes;
288
289 foreach (XmlNode part in partL)
290 {
291 XmlNode type = part.Attributes.GetNamedItem("type");
292 if (type == null || type.Value != "List")
293 {
294 ret[part.Name] = part.InnerText;
295 }
296 else
297 {
298 ret[part.Name] = ParseElement(part);
299 }
300 }
301
302 return ret;
303 }
186 } 304 }
187} 305}