aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMW2007-06-25 18:31:47 +0000
committerMW2007-06-25 18:31:47 +0000
commit49b99132106d0553dae6edf13c89f7b66604d133 (patch)
treeae997d4fb832bd2f15fd8920bfd3a0bd811fd39b
parentForgot these (diff)
downloadopensim-SC_OLD-49b99132106d0553dae6edf13c89f7b66604d133.zip
opensim-SC_OLD-49b99132106d0553dae6edf13c89f7b66604d133.tar.gz
opensim-SC_OLD-49b99132106d0553dae6edf13c89f7b66604d133.tar.bz2
opensim-SC_OLD-49b99132106d0553dae6edf13c89f7b66604d133.tar.xz
Some work in progress LLSD serialise / de-serialise functions.
-rw-r--r--Common/OpenSim.Framework/LLSDHelpers.cs173
-rw-r--r--Common/OpenSim.Framework/OpenSim.Framework.csproj39
-rw-r--r--Common/OpenSim.Framework/OpenSim.Framework.dll.build1
-rw-r--r--OpenSim/OpenSim.Region/Caps.cs26
4 files changed, 215 insertions, 24 deletions
diff --git a/Common/OpenSim.Framework/LLSDHelpers.cs b/Common/OpenSim.Framework/LLSDHelpers.cs
new file mode 100644
index 0000000..5b73483
--- /dev/null
+++ b/Common/OpenSim.Framework/LLSDHelpers.cs
@@ -0,0 +1,173 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using System.IO;
6using System.Xml;
7using libsecondlife;
8
9namespace OpenSim.Framework
10{
11 public class LLSDHelpers
12 {
13 public static string SerialiseLLSDReply(object obj)
14 {
15 StringWriter sw = new StringWriter();
16 XmlTextWriter writer = new XmlTextWriter(sw);
17 writer.Formatting = Formatting.None;
18 writer.WriteStartElement(String.Empty, "llsd", String.Empty);
19 LLSDHelpers.SerializeLLSDType(writer, obj);
20 writer.WriteEndElement();
21 writer.Close();
22 return sw.ToString();
23 }
24
25 public static void SerializeLLSDType(XmlTextWriter writer, object obj)
26 {
27 Type myType = obj.GetType();
28 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
29 if (llsdattributes.Length > 0)
30 {
31 switch (llsdattributes[0].ObjectType)
32 {
33 case "MAP":
34 writer.WriteStartElement(String.Empty, "map", String.Empty);
35 System.Reflection.FieldInfo[] fields = myType.GetFields();
36 for (int i = 0; i < fields.Length; i++)
37 {
38 object fieldValue = fields[i].GetValue(obj);
39 LLSDType[] fieldAttributes = (LLSDType[])fieldValue.GetType().GetCustomAttributes(typeof(LLSDType), false);
40 if (fieldAttributes.Length > 0)
41 {
42 writer.WriteStartElement(String.Empty, "key", String.Empty);
43 writer.WriteString(fields[i].Name);
44 writer.WriteEndElement();
45 SerializeLLSDType(writer, fieldValue);
46 }
47 else
48 {
49 //Console.WriteLine("LLSD field name" + fields[i].Name + " , " + fields[i].GetValue(obj).GetType());
50 writer.WriteStartElement(String.Empty, "key", String.Empty);
51 writer.WriteString(fields[i].Name);
52 writer.WriteEndElement();
53 LLSD.LLSDWriteOne(writer, fieldValue);
54 }
55 }
56 writer.WriteEndElement();
57 break;
58 case "ARRAY":
59 // LLSDArray arrayObject = obj as LLSDArray;
60 // ArrayList a = arrayObject.Array;
61 ArrayList a = (ArrayList)obj.GetType().GetField("Array").GetValue(obj);
62 writer.WriteStartElement(String.Empty, "array", String.Empty);
63 foreach (object item in a)
64 {
65 SerializeLLSDType(writer, item);
66 }
67 writer.WriteEndElement();
68 break;
69 }
70 }
71 else
72 {
73 LLSD.LLSDWriteOne(writer, obj);
74 }
75 }
76
77 public static object DeserialiseLLSDMap(Hashtable llsd, object obj)
78 {
79 Type myType = obj.GetType();
80 LLSDType[] llsdattributes = (LLSDType[])myType.GetCustomAttributes(typeof(LLSDType), false);
81 if (llsdattributes.Length > 0)
82 {
83 switch (llsdattributes[0].ObjectType)
84 {
85 case "MAP":
86 IDictionaryEnumerator enumerator = llsd.GetEnumerator();
87 while (enumerator.MoveNext())
88 {
89 System.Reflection.FieldInfo field = myType.GetField((string)enumerator.Key);
90 if (field != null)
91 {
92 field.SetValue(obj, enumerator.Value);
93 }
94 }
95 break;
96 }
97 }
98 return obj;
99 }
100 }
101
102 [LLSDType("MAP")]
103 public class LLSDMapLayer
104 {
105 public int Left = 0;
106 public int Right = 0;
107 public int Top = 0;
108 public int Bottom = 0;
109 public LLUUID ImageID = LLUUID.Zero;
110
111 public LLSDArray TestArray = new LLSDArray();
112 public LLSDMapLayer()
113 {
114
115 }
116 }
117
118 [LLSDType("ARRAY")]
119 public class LLSDArray
120 {
121 public ArrayList Array = new ArrayList();
122
123 public LLSDArray()
124 {
125
126 }
127 }
128
129 [LLSDType("MAP")]
130 public class LLSDMapRequest
131 {
132 public int Flags = 0;
133
134 public LLSDMapRequest()
135 {
136
137 }
138 }
139
140 [LLSDType("MAP")]
141 public class LLSDTest
142 {
143 public int Test1 = 20;
144 public int Test2 = 10;
145
146 public LLSDTest()
147 {
148
149 }
150 }
151
152
153 [AttributeUsage(AttributeTargets.Class)]
154 public class LLSDType : Attribute
155 {
156 private string myHandler;
157
158
159 public LLSDType(string type)
160 {
161 myHandler = type;
162
163 }
164
165 public string ObjectType
166 {
167 get
168 {
169 return myHandler;
170 }
171 }
172 }
173}
diff --git a/Common/OpenSim.Framework/OpenSim.Framework.csproj b/Common/OpenSim.Framework/OpenSim.Framework.csproj
index f9a4f2d..f12ffcb 100644
--- a/Common/OpenSim.Framework/OpenSim.Framework.csproj
+++ b/Common/OpenSim.Framework/OpenSim.Framework.csproj
@@ -1,4 +1,4 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup> 2 <PropertyGroup>
3 <ProjectType>Local</ProjectType> 3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion> 4 <ProductVersion>8.0.50727</ProductVersion>
@@ -6,7 +6,8 @@
6 <ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid> 6 <ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon> 9 <ApplicationIcon>
10 </ApplicationIcon>
10 <AssemblyKeyContainerName> 11 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName> 12 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Framework</AssemblyName> 13 <AssemblyName>OpenSim.Framework</AssemblyName>
@@ -15,9 +16,11 @@
15 <DefaultTargetSchema>IE50</DefaultTargetSchema> 16 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign> 17 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType> 18 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder> 19 <AppDesignerFolder>
20 </AppDesignerFolder>
19 <RootNamespace>OpenSim.Framework</RootNamespace> 21 <RootNamespace>OpenSim.Framework</RootNamespace>
20 <StartupObject></StartupObject> 22 <StartupObject>
23 </StartupObject>
21 <FileUpgradeFlags> 24 <FileUpgradeFlags>
22 </FileUpgradeFlags> 25 </FileUpgradeFlags>
23 </PropertyGroup> 26 </PropertyGroup>
@@ -28,7 +31,8 @@
28 <ConfigurationOverrideFile> 31 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile> 32 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants> 33 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile> 34 <DocumentationFile>
35 </DocumentationFile>
32 <DebugSymbols>True</DebugSymbols> 36 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment> 37 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize> 38 <Optimize>False</Optimize>
@@ -37,7 +41,8 @@
37 <RemoveIntegerChecks>False</RemoveIntegerChecks> 41 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors> 42 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel> 43 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn> 44 <NoWarn>
45 </NoWarn>
41 </PropertyGroup> 46 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 47 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks> 48 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
@@ -46,7 +51,8 @@
46 <ConfigurationOverrideFile> 51 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile> 52 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants> 53 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile> 54 <DocumentationFile>
55 </DocumentationFile>
50 <DebugSymbols>False</DebugSymbols> 56 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment> 57 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize> 58 <Optimize>True</Optimize>
@@ -55,22 +61,24 @@
55 <RemoveIntegerChecks>False</RemoveIntegerChecks> 61 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors> 62 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel> 63 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn> 64 <NoWarn>
65 </NoWarn>
59 </PropertyGroup> 66 </PropertyGroup>
60 <ItemGroup> 67 <ItemGroup>
61 <Reference Include="Db4objects.Db4o.dll" > 68 <Reference Include="Db4objects.Db4o.dll">
62 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath> 69 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
63 <Private>False</Private> 70 <Private>False</Private>
64 </Reference> 71 </Reference>
65 <Reference Include="libsecondlife.dll" > 72 <Reference Include="libsecondlife.dll">
66 <HintPath>..\..\bin\libsecondlife.dll</HintPath> 73 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
67 <Private>False</Private> 74 <Private>False</Private>
68 </Reference> 75 </Reference>
69 <Reference Include="System" > 76 <Reference Include="System">
70 <HintPath>System.dll</HintPath> 77 <HintPath>System.dll</HintPath>
71 <Private>False</Private> 78 <Private>False</Private>
72 </Reference> 79 </Reference>
73 <Reference Include="System.Xml" > 80 <Reference Include="System.Data" />
81 <Reference Include="System.Xml">
74 <HintPath>System.Xml.dll</HintPath> 82 <HintPath>System.Xml.dll</HintPath>
75 <Private>False</Private> 83 <Private>False</Private>
76 </Reference> 84 </Reference>
@@ -80,13 +88,13 @@
80 <Name>OpenSim.Framework.Console</Name> 88 <Name>OpenSim.Framework.Console</Name>
81 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project> 89 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private> 91 <Private>False</Private>
84 </ProjectReference> 92 </ProjectReference>
85 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj"> 93 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
86 <Name>XMLRPC</Name> 94 <Name>XMLRPC</Name>
87 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> 95 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
88 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> 96 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
89 <Private>False</Private> 97 <Private>False</Private>
90 </ProjectReference> 98 </ProjectReference>
91 </ItemGroup> 99 </ItemGroup>
92 <ItemGroup> 100 <ItemGroup>
@@ -102,6 +110,7 @@
102 <Compile Include="IRegionCommsListener.cs"> 110 <Compile Include="IRegionCommsListener.cs">
103 <SubType>Code</SubType> 111 <SubType>Code</SubType>
104 </Compile> 112 </Compile>
113 <Compile Include="LLSDHelpers.cs" />
105 <Compile Include="Logger.cs"> 114 <Compile Include="Logger.cs">
106 <SubType>Code</SubType> 115 <SubType>Code</SubType>
107 </Compile> 116 </Compile>
@@ -215,4 +224,4 @@
215 <PostBuildEvent> 224 <PostBuildEvent>
216 </PostBuildEvent> 225 </PostBuildEvent>
217 </PropertyGroup> 226 </PropertyGroup>
218</Project> 227</Project> \ No newline at end of file
diff --git a/Common/OpenSim.Framework/OpenSim.Framework.dll.build b/Common/OpenSim.Framework/OpenSim.Framework.dll.build
index ab511f2..afe1aea 100644
--- a/Common/OpenSim.Framework/OpenSim.Framework.dll.build
+++ b/Common/OpenSim.Framework/OpenSim.Framework.dll.build
@@ -15,6 +15,7 @@
15 <include name="AuthenticateSessionBase.cs" /> 15 <include name="AuthenticateSessionBase.cs" />
16 <include name="BlockingQueue.cs" /> 16 <include name="BlockingQueue.cs" />
17 <include name="IRegionCommsListener.cs" /> 17 <include name="IRegionCommsListener.cs" />
18 <include name="LLSDHelpers.cs" />
18 <include name="Logger.cs" /> 19 <include name="Logger.cs" />
19 <include name="LoginService.cs" /> 20 <include name="LoginService.cs" />
20 <include name="RegionCommsListener.cs" /> 21 <include name="RegionCommsListener.cs" />
diff --git a/OpenSim/OpenSim.Region/Caps.cs b/OpenSim/OpenSim.Region/Caps.cs
index 11b1b4d..319e027 100644
--- a/OpenSim/OpenSim.Region/Caps.cs
+++ b/OpenSim/OpenSim.Region/Caps.cs
@@ -1,8 +1,11 @@
1using System; 1using System;
2using System.Collections;
2using System.Collections.Generic; 3using System.Collections.Generic;
3using System.Text; 4using System.Text;
4using System.IO; 5using System.IO;
6using System.Xml;
5using OpenSim.Servers; 7using OpenSim.Servers;
8using OpenSim.Framework;
6using OpenSim.Framework.Utilities; 9using OpenSim.Framework.Utilities;
7using OpenSim.Framework.Types; 10using OpenSim.Framework.Types;
8using OpenSim.Caches; 11using OpenSim.Caches;
@@ -91,6 +94,11 @@ namespace OpenSim.Region
91 /// <returns></returns> 94 /// <returns></returns>
92 public string MapLayer(string request, string path, string param) 95 public string MapLayer(string request, string path, string param)
93 { 96 {
97 Encoding _enc = System.Text.Encoding.UTF8;
98 Hashtable hash =(Hashtable) LLSD.LLSDDeserialize(_enc.GetBytes(request));
99 LLSDMapRequest mapReq = new LLSDMapRequest();
100 LLSDHelpers.DeserialiseLLSDMap(hash, mapReq );
101
94 string res = "<llsd><map><key>AgentData</key><map><key>Flags</key><integer>0</integer></map><key>LayerData</key><array>"; 102 string res = "<llsd><map><key>AgentData</key><map><key>Flags</key><integer>0</integer></map><key>LayerData</key><array>";
95 res += this.BuildLLSDMapLayerResponse(); 103 res += this.BuildLLSDMapLayerResponse();
96 res += "</array></map></llsd>"; 104 res += "</array></map></llsd>";
@@ -123,14 +131,14 @@ namespace OpenSim.Region
123 131
124 public string ProcessEventQueue(string request, string path, string param) 132 public string ProcessEventQueue(string request, string path, string param)
125 { 133 {
126 // Console.WriteLine("event queue request " + request); 134 // Console.WriteLine("event queue request " + request);
127 string res = ""; 135 string res = "";
128 int timer = 0; 136 int timer = 0;
129 137
130 /*while ((timer < 200) || (this.CapsEventQueue.Count < 1)) 138 /*while ((timer < 200) || (this.CapsEventQueue.Count < 1))
131 { 139 {
132 timer++; 140 timer++;
133 }*/ 141 }*/
134 if (this.CapsEventQueue.Count > 0) 142 if (this.CapsEventQueue.Count > 0)
135 { 143 {
136 lock (this.CapsEventQueue) 144 lock (this.CapsEventQueue)
@@ -152,9 +160,9 @@ namespace OpenSim.Region
152 res += "<key>events</key><array><map>"; 160 res += "<key>events</key><array><map>";
153 res += "<key>message</key><string>EstablishAgentCommunication</string>"; 161 res += "<key>message</key><string>EstablishAgentCommunication</string>";
154 res += "<key>body</key><map>"; 162 res += "<key>body</key><map>";
155 res += "<key>sim-ip-and-port</key><string>"+ipAddressPort +"</string>"; 163 res += "<key>sim-ip-and-port</key><string>" + ipAddressPort + "</string>";
156 res += "<key>seed-capability</key><string>"+caps+"</string>"; 164 res += "<key>seed-capability</key><string>" + caps + "</string>";
157 res += "<key>agent-id</key><uuid>"+this.agentID.ToStringHyphenated()+"</uuid>"; 165 res += "<key>agent-id</key><uuid>" + this.agentID.ToStringHyphenated() + "</uuid>";
158 res += "</map>"; 166 res += "</map>";
159 res += "</map></array>"; 167 res += "</map></array>";
160 res += "</map></llsd>"; 168 res += "</map></llsd>";
@@ -195,7 +203,7 @@ namespace OpenSim.Region
195 203
196 public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data) 204 public void UploadHandler(LLUUID assetID, LLUUID inventoryItem, byte[] data)
197 { 205 {
198 // Console.WriteLine("upload handler called"); 206 // Console.WriteLine("upload handler called");
199 AssetBase asset; 207 AssetBase asset;
200 asset = new AssetBase(); 208 asset = new AssetBase();
201 asset.FullID = assetID; 209 asset.FullID = assetID;