diff options
Diffstat (limited to 'OpenSim/Server/Base/ServerUtils.cs')
-rw-r--r-- | OpenSim/Server/Base/ServerUtils.cs | 81 |
1 files changed, 28 insertions, 53 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index a5d28a4..e7a8294 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs | |||
@@ -34,55 +34,13 @@ using System.Text; | |||
34 | using System.Collections.Generic; | 34 | using System.Collections.Generic; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenMetaverse; | ||
37 | 38 | ||
38 | namespace OpenSim.Server.Base | 39 | namespace OpenSim.Server.Base |
39 | { | 40 | { |
40 | public static class ServerUtils | 41 | public static class ServerUtils |
41 | { | 42 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | |||
44 | public static string SLAssetTypeToContentType(int assetType) | ||
45 | { | ||
46 | switch (assetType) | ||
47 | { | ||
48 | case 0: | ||
49 | return "image/jp2"; | ||
50 | case 1: | ||
51 | return "application/ogg"; | ||
52 | case 2: | ||
53 | return "application/x-metaverse-callingcard"; | ||
54 | case 3: | ||
55 | return "application/x-metaverse-landmark"; | ||
56 | case 5: | ||
57 | return "application/x-metaverse-clothing"; | ||
58 | case 6: | ||
59 | return "application/x-metaverse-primitive"; | ||
60 | case 7: | ||
61 | return "application/x-metaverse-notecard"; | ||
62 | case 8: | ||
63 | return "application/x-metaverse-folder"; | ||
64 | case 10: | ||
65 | return "application/x-metaverse-lsl"; | ||
66 | case 11: | ||
67 | return "application/x-metaverse-lso"; | ||
68 | case 12: | ||
69 | return "image/tga"; | ||
70 | case 13: | ||
71 | return "application/x-metaverse-bodypart"; | ||
72 | case 17: | ||
73 | return "audio/x-wav"; | ||
74 | case 19: | ||
75 | return "image/jpeg"; | ||
76 | case 20: | ||
77 | return "application/x-metaverse-animation"; | ||
78 | case 21: | ||
79 | return "application/x-metaverse-gesture"; | ||
80 | case 22: | ||
81 | return "application/x-metaverse-simstate"; | ||
82 | default: | ||
83 | return "application/octet-stream"; | ||
84 | } | ||
85 | } | ||
86 | 44 | ||
87 | public static byte[] SerializeResult(XmlSerializer xs, object data) | 45 | public static byte[] SerializeResult(XmlSerializer xs, object data) |
88 | { | 46 | { |
@@ -99,6 +57,12 @@ namespace OpenSim.Server.Base | |||
99 | return ret; | 57 | return ret; |
100 | } | 58 | } |
101 | 59 | ||
60 | /// <summary> | ||
61 | /// Load a plugin from a dll with the given class or interface | ||
62 | /// </summary> | ||
63 | /// <param name="dllName"></param> | ||
64 | /// <param name="args">The arguments which control which constructor is invoked on the plugin</param> | ||
65 | /// <returns></returns> | ||
102 | public static T LoadPlugin<T>(string dllName, Object[] args) where T:class | 66 | public static T LoadPlugin<T>(string dllName, Object[] args) where T:class |
103 | { | 67 | { |
104 | string[] parts = dllName.Split(new char[] {':'}); | 68 | string[] parts = dllName.Split(new char[] {':'}); |
@@ -113,6 +77,13 @@ namespace OpenSim.Server.Base | |||
113 | return LoadPlugin<T>(dllName, className, args); | 77 | return LoadPlugin<T>(dllName, className, args); |
114 | } | 78 | } |
115 | 79 | ||
80 | /// <summary> | ||
81 | /// Load a plugin from a dll with the given class or interface | ||
82 | /// </summary> | ||
83 | /// <param name="dllName"></param> | ||
84 | /// <param name="className"></param> | ||
85 | /// <param name="args">The arguments which control which constructor is invoked on the plugin</param> | ||
86 | /// <returns></returns> | ||
116 | public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class | 87 | public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class |
117 | { | 88 | { |
118 | string interfaceName = typeof(T).ToString(); | 89 | string interfaceName = typeof(T).ToString(); |
@@ -125,12 +96,12 @@ namespace OpenSim.Server.Base | |||
125 | { | 96 | { |
126 | if (pluginType.IsPublic) | 97 | if (pluginType.IsPublic) |
127 | { | 98 | { |
128 | if (className != String.Empty && | 99 | if (className != String.Empty |
129 | pluginType.ToString() != | 100 | && pluginType.ToString() != pluginType.Namespace + "." + className) |
130 | pluginType.Namespace + "." + className) | ||
131 | continue; | 101 | continue; |
132 | Type typeInterface = | 102 | |
133 | pluginType.GetInterface(interfaceName, true); | 103 | Type typeInterface = pluginType.GetInterface(interfaceName, true); |
104 | |||
134 | if (typeInterface != null) | 105 | if (typeInterface != null) |
135 | { | 106 | { |
136 | T plug = null; | 107 | T plug = null; |
@@ -155,7 +126,7 @@ namespace OpenSim.Server.Base | |||
155 | } | 126 | } |
156 | catch (Exception e) | 127 | catch (Exception e) |
157 | { | 128 | { |
158 | m_log.ErrorFormat("Error loading plugin from {0}, exception {1}", dllName, e); | 129 | m_log.Error(string.Format("Error loading plugin from {0}", dllName), e); |
159 | return null; | 130 | return null; |
160 | } | 131 | } |
161 | } | 132 | } |
@@ -182,12 +153,13 @@ namespace OpenSim.Server.Base | |||
182 | 153 | ||
183 | if (name.EndsWith("[]")) | 154 | if (name.EndsWith("[]")) |
184 | { | 155 | { |
185 | if (result.ContainsKey(name)) | 156 | string cleanName = name.Substring(0, name.Length - 2); |
157 | if (result.ContainsKey(cleanName)) | ||
186 | { | 158 | { |
187 | if (!(result[name] is List<string>)) | 159 | if (!(result[cleanName] is List<string>)) |
188 | continue; | 160 | continue; |
189 | 161 | ||
190 | List<string> l = (List<string>)result[name]; | 162 | List<string> l = (List<string>)result[cleanName]; |
191 | 163 | ||
192 | l.Add(value); | 164 | l.Add(value); |
193 | } | 165 | } |
@@ -197,7 +169,7 @@ namespace OpenSim.Server.Base | |||
197 | 169 | ||
198 | newList.Add(value); | 170 | newList.Add(value); |
199 | 171 | ||
200 | result[name] = newList; | 172 | result[cleanName] = newList; |
201 | } | 173 | } |
202 | } | 174 | } |
203 | else | 175 | else |
@@ -278,6 +250,9 @@ namespace OpenSim.Server.Base | |||
278 | { | 250 | { |
279 | foreach (KeyValuePair<string, object> kvp in data) | 251 | foreach (KeyValuePair<string, object> kvp in data) |
280 | { | 252 | { |
253 | if (kvp.Value == null) | ||
254 | continue; | ||
255 | |||
281 | XmlElement elem = parent.OwnerDocument.CreateElement("", | 256 | XmlElement elem = parent.OwnerDocument.CreateElement("", |
282 | kvp.Key, ""); | 257 | kvp.Key, ""); |
283 | 258 | ||