aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common
diff options
context:
space:
mode:
authorMW2007-05-26 13:40:19 +0000
committerMW2007-05-26 13:40:19 +0000
commit3436961bb5c01d659d09be134368f4f69460cef9 (patch)
tree3753ba4d7818df2a6bce0bbe863ff033cdfd568a /Common
downloadopensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.zip
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz
Start of rewrite 5279!
Diffstat (limited to 'Common')
-rw-r--r--Common/OpenSim.Framework.Console/AssemblyInfo.cs31
-rw-r--r--Common/OpenSim.Framework.Console/ConsoleBase.cs166
-rw-r--r--Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs12
-rw-r--r--Common/OpenSim.Framework.Console/MainConsole.cs48
-rw-r--r--Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj89
-rw-r--r--Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user12
-rw-r--r--Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build42
-rw-r--r--Common/OpenSim.Framework/AgentInventory.cs251
-rw-r--r--Common/OpenSim.Framework/BlockingQueue.cs33
-rw-r--r--Common/OpenSim.Framework/HeightMapGenHills.cs149
-rw-r--r--Common/OpenSim.Framework/Interfaces/IAssetServer.cs68
-rw-r--r--Common/OpenSim.Framework/Interfaces/IClientAPI.cs35
-rw-r--r--Common/OpenSim.Framework/Interfaces/IConfig.cs76
-rw-r--r--Common/OpenSim.Framework/Interfaces/IGenericConfig.cs15
-rw-r--r--Common/OpenSim.Framework/Interfaces/IGridConfig.cs64
-rw-r--r--Common/OpenSim.Framework/Interfaces/IGridServer.cs81
-rw-r--r--Common/OpenSim.Framework/Interfaces/ILocalStorage.cs54
-rw-r--r--Common/OpenSim.Framework/Interfaces/IScriptAPI.cs14
-rw-r--r--Common/OpenSim.Framework/Interfaces/IScriptEngine.cs14
-rw-r--r--Common/OpenSim.Framework/Interfaces/IUserConfig.cs58
-rw-r--r--Common/OpenSim.Framework/Interfaces/IUserServer.cs15
-rw-r--r--Common/OpenSim.Framework/Interfaces/LocalGridBase.cs24
-rw-r--r--Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs37
-rw-r--r--Common/OpenSim.Framework/LoginService.cs14
-rw-r--r--Common/OpenSim.Framework/OpenSim.Framework.csproj194
-rw-r--r--Common/OpenSim.Framework/OpenSim.Framework.csproj.user12
-rw-r--r--Common/OpenSim.Framework/OpenSim.Framework.dll.build75
-rw-r--r--Common/OpenSim.Framework/Properties/AssemblyInfo.cs33
-rw-r--r--Common/OpenSim.Framework/Remoting.cs109
-rw-r--r--Common/OpenSim.Framework/SimProfile.cs83
-rw-r--r--Common/OpenSim.Framework/SimProfileBase.cs27
-rw-r--r--Common/OpenSim.Framework/Types/AgentCiruitData.cs22
-rw-r--r--Common/OpenSim.Framework/Types/AssetBase.cs22
-rw-r--r--Common/OpenSim.Framework/Types/AssetLandmark.cs34
-rw-r--r--Common/OpenSim.Framework/Types/AssetStorage.cs23
-rw-r--r--Common/OpenSim.Framework/Types/Login.cs24
-rw-r--r--Common/OpenSim.Framework/Types/NeighbourInfo.cs19
-rw-r--r--Common/OpenSim.Framework/Types/OSVector3.cs18
-rw-r--r--Common/OpenSim.Framework/Types/PrimData.cs173
-rw-r--r--Common/OpenSim.Framework/UserProfile.cs62
-rw-r--r--Common/OpenSim.Framework/UserProfileManager.cs272
-rw-r--r--Common/OpenSim.Framework/UserProfileManagerBase.cs124
-rw-r--r--Common/OpenSim.Framework/Util.cs151
-rw-r--r--Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj93
-rw-r--r--Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user12
-rw-r--r--Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build42
-rw-r--r--Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs35
-rw-r--r--Common/OpenSim.GenericConfig/Xml/XmlConfig.cs109
-rw-r--r--Common/OpenSim.Servers/BaseHttpServer.cs256
-rw-r--r--Common/OpenSim.Servers/BaseServer.cs10
-rw-r--r--Common/OpenSim.Servers/CheckSumServer.cs113
-rw-r--r--Common/OpenSim.Servers/IRestHandler.cs8
-rw-r--r--Common/OpenSim.Servers/LocalUserProfileManager.cs123
-rw-r--r--Common/OpenSim.Servers/LoginResponse.cs670
-rw-r--r--Common/OpenSim.Servers/LoginServer.cs284
-rw-r--r--Common/OpenSim.Servers/OpenSim.Servers.csproj130
-rw-r--r--Common/OpenSim.Servers/OpenSim.Servers.csproj.user12
-rw-r--r--Common/OpenSim.Servers/OpenSim.Servers.dll.build52
-rw-r--r--Common/OpenSim.Servers/UDPServerBase.cs68
-rw-r--r--Common/OpenSim.Servers/XmlRpcMethod.cs7
-rw-r--r--Common/XmlRpcCS/Logger.cs46
-rw-r--r--Common/XmlRpcCS/SimpleHttpRequest.cs204
-rw-r--r--Common/XmlRpcCS/XMLRPC.csproj138
-rw-r--r--Common/XmlRpcCS/XMLRPC.csproj.user12
-rw-r--r--Common/XmlRpcCS/XMLRPC.dll.build58
-rw-r--r--Common/XmlRpcCS/XmlRpcBoxcarRequest.cs51
-rw-r--r--Common/XmlRpcCS/XmlRpcClientProxy.cs61
-rw-r--r--Common/XmlRpcCS/XmlRpcDeserializer.cs195
-rw-r--r--Common/XmlRpcCS/XmlRpcErrorCodes.cs51
-rw-r--r--Common/XmlRpcCS/XmlRpcException.cs39
-rw-r--r--Common/XmlRpcCS/XmlRpcExposedAttribute.cs60
-rw-r--r--Common/XmlRpcCS/XmlRpcRequest.cs150
-rw-r--r--Common/XmlRpcCS/XmlRpcRequestDeserializer.cs64
-rw-r--r--Common/XmlRpcCS/XmlRpcRequestSerializer.cs51
-rw-r--r--Common/XmlRpcCS/XmlRpcResponder.cs98
-rw-r--r--Common/XmlRpcCS/XmlRpcResponse.cs85
-rw-r--r--Common/XmlRpcCS/XmlRpcResponseDeserializer.cs65
-rw-r--r--Common/XmlRpcCS/XmlRpcResponseSerializer.cs57
-rw-r--r--Common/XmlRpcCS/XmlRpcSerializer.cs109
-rw-r--r--Common/XmlRpcCS/XmlRpcServer.cs239
-rw-r--r--Common/XmlRpcCS/XmlRpcSystemObject.cs252
-rw-r--r--Common/XmlRpcCS/XmlRpcXmlTokens.cs76
82 files changed, 7064 insertions, 0 deletions
diff --git a/Common/OpenSim.Framework.Console/AssemblyInfo.cs b/Common/OpenSim.Framework.Console/AssemblyInfo.cs
new file mode 100644
index 0000000..00a9b7d
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/AssemblyInfo.cs
@@ -0,0 +1,31 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// Information about this assembly is defined by the following
6// attributes.
7//
8// change them to the information which is associated with the assembly
9// you compile.
10
11[assembly: AssemblyTitle("ServerConsole")]
12[assembly: AssemblyDescription("")]
13[assembly: AssemblyConfiguration("")]
14[assembly: AssemblyCompany("")]
15[assembly: AssemblyProduct("ServerConsole")]
16[assembly: AssemblyCopyright("")]
17[assembly: AssemblyTrademark("")]
18[assembly: AssemblyCulture("")]
19
20// This sets the default COM visibility of types in the assembly to invisible.
21// If you need to expose a type to COM, use [ComVisible(true)] on that type.
22[assembly: ComVisible(false)]
23
24// The assembly version has following format :
25//
26// Major.Minor.Build.Revision
27//
28// You can specify all values by your own or you can build default build and revision
29// numbers with the '*' character (the default):
30
31[assembly: AssemblyVersion("1.0.*")]
diff --git a/Common/OpenSim.Framework.Console/ConsoleBase.cs b/Common/OpenSim.Framework.Console/ConsoleBase.cs
new file mode 100644
index 0000000..6a1c53c
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/ConsoleBase.cs
@@ -0,0 +1,166 @@
1using System;
2using System.IO;
3
4namespace OpenSim.Framework.Console
5{
6 public enum LogPriority : int
7 {
8 CRITICAL,
9 HIGH,
10 MEDIUM,
11 NORMAL,
12 LOW,
13 VERBOSE,
14 EXTRAVERBOSE
15 }
16
17 public class ConsoleBase
18 {
19 StreamWriter Log;
20 public conscmd_callback cmdparser;
21 public string componentname;
22 private bool m_silent;
23
24 public ConsoleBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent )
25 {
26 this.componentname = componentname;
27 this.cmdparser = cmdparser;
28 this.m_silent = silent;
29 System.Console.WriteLine("ServerConsole.cs - creating new local console");
30 System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
31 Log = File.AppendText(LogFile);
32 Log.WriteLine("========================================================================");
33 Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
34 }
35
36 public void Close()
37 {
38 Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
39 Log.Close();
40 }
41
42 public void Write(string format, params object[] args)
43 {
44 WriteLine(LogPriority.NORMAL,format,args);
45 return;
46 }
47
48 [Obsolete("WriteLine(msg,args) has been depreciated, use WriteLine(priority,msg,args) instead.")]
49 public void WriteLine(string format, params object[] args)
50 {
51 Log.WriteLine(format, args);
52 Log.Flush();
53 if(!m_silent)
54 {
55 System.Console.WriteLine(format, args);
56 }
57 return;
58 }
59
60 public void WriteLine(LogPriority importance, string format, params object[] args)
61 {
62 Log.WriteLine(format, args);
63 Log.Flush();
64 if (!m_silent)
65 {
66 System.Console.WriteLine(format, args);
67 }
68 return;
69 }
70
71 public string ReadLine()
72 {
73 string TempStr = System.Console.ReadLine();
74 Log.WriteLine(TempStr);
75 return TempStr;
76 }
77
78 public int Read()
79 {
80 int TempInt = System.Console.Read();
81 Log.Write((char)TempInt);
82 return TempInt;
83 }
84
85 // Displays a prompt and waits for the user to enter a string, then returns that string
86 // Done with no echo and suitable for passwords
87 public string PasswdPrompt(string prompt)
88 {
89 // FIXME: Needs to be better abstracted
90 Log.WriteLine(prompt);
91 this.Write(prompt);
92 ConsoleColor oldfg = System.Console.ForegroundColor;
93 System.Console.ForegroundColor = System.Console.BackgroundColor;
94 string temp = System.Console.ReadLine();
95 System.Console.ForegroundColor = oldfg;
96 return temp;
97 }
98
99 // Displays a command prompt and waits for the user to enter a string, then returns that string
100 public string CmdPrompt(string prompt)
101 {
102 this.Write(String.Format("{0}: ", prompt));
103 return this.ReadLine();
104 }
105
106 // Displays a command prompt and returns a default value if the user simply presses enter
107 public string CmdPrompt(string prompt, string defaultresponse)
108 {
109 string temp = CmdPrompt(String.Format( "{0} [{1}]", prompt, defaultresponse ));
110 if (temp == "")
111 {
112 return defaultresponse;
113 }
114 else
115 {
116 return temp;
117 }
118 }
119
120 // Displays a command prompt and returns a default value, user may only enter 1 of 2 options
121 public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
122 {
123 bool itisdone = false;
124 string temp = CmdPrompt(prompt, defaultresponse);
125 while (itisdone == false)
126 {
127 if ((temp == OptionA) || (temp == OptionB))
128 {
129 itisdone = true;
130 }
131 else
132 {
133 this.WriteLine(LogPriority.MEDIUM,"Valid options are " + OptionA + " or " + OptionB);
134 temp = CmdPrompt(prompt, defaultresponse);
135 }
136 }
137 return temp;
138 }
139
140 // Runs a command with a number of parameters
141 public Object RunCmd(string Cmd, string[] cmdparams)
142 {
143 cmdparser.RunCmd(Cmd, cmdparams);
144 return null;
145 }
146
147 // Shows data about something
148 public void ShowCommands(string ShowWhat)
149 {
150 cmdparser.Show(ShowWhat);
151 }
152
153 public void MainConsolePrompt()
154 {
155 string[] tempstrarray;
156 string tempstr = this.CmdPrompt(this.componentname + "# ");
157 tempstrarray = tempstr.Split(' ');
158 string cmd = tempstrarray[0];
159 Array.Reverse(tempstrarray);
160 Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
161 Array.Reverse(tempstrarray);
162 string[] cmdparams = (string[])tempstrarray;
163 RunCmd(cmd, cmdparams);
164 }
165 }
166}
diff --git a/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs b/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs
new file mode 100644
index 0000000..bb589d2
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs
@@ -0,0 +1,12 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Console
6{
7 public interface conscmd_callback
8 {
9 void RunCmd(string cmd, string[] cmdparams);
10 void Show(string ShowWhat);
11 }
12}
diff --git a/Common/OpenSim.Framework.Console/MainConsole.cs b/Common/OpenSim.Framework.Console/MainConsole.cs
new file mode 100644
index 0000000..02c4ae8
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/MainConsole.cs
@@ -0,0 +1,48 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28
29namespace OpenSim.Framework.Console
30{
31 public class MainConsole {
32
33 private static ConsoleBase instance;
34
35 public static ConsoleBase Instance
36 {
37 get
38 {
39 return instance;
40 }
41 set
42 {
43 instance = value;
44 }
45 }
46 }
47
48}
diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj
new file mode 100644
index 0000000..7af0eca
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj
@@ -0,0 +1,89 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{A7CD0630-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Framework.Console</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Framework.Console</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 </ItemGroup>
66 <ItemGroup>
67 </ItemGroup>
68 <ItemGroup>
69 <Compile Include="AssemblyInfo.cs">
70 <SubType>Code</SubType>
71 </Compile>
72 <Compile Include="ConsoleBase.cs">
73 <SubType>Code</SubType>
74 </Compile>
75 <Compile Include="ConsoleCallbacksBase.cs">
76 <SubType>Code</SubType>
77 </Compile>
78 <Compile Include="MainConsole.cs">
79 <SubType>Code</SubType>
80 </Compile>
81 </ItemGroup>
82 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
83 <PropertyGroup>
84 <PreBuildEvent>
85 </PreBuildEvent>
86 <PostBuildEvent>
87 </PostBuildEvent>
88 </PropertyGroup>
89</Project>
diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build
new file mode 100644
index 0000000..9a03b54
--- /dev/null
+++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build
@@ -0,0 +1,42 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Framework.Console" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Framework.Console" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AssemblyInfo.cs" />
15 <include name="ConsoleBase.cs" />
16 <include name="ConsoleCallbacksBase.cs" />
17 <include name="MainConsole.cs" />
18 </sources>
19 <references basedir="${project::get-base-directory()}">
20 <lib>
21 <include name="${project::get-base-directory()}" />
22 <include name="${project::get-base-directory()}/${build.dir}" />
23 </lib>
24 <include name="System.dll" />
25 </references>
26 </csc>
27 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
28 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
29 <copy todir="${project::get-base-directory()}/../../bin/">
30 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
31 <include name="*.dll"/>
32 <include name="*.exe"/>
33 </fileset>
34 </copy>
35 </target>
36 <target name="clean">
37 <delete dir="${bin.dir}" failonerror="false" />
38 <delete dir="${obj.dir}" failonerror="false" />
39 </target>
40 <target name="doc" description="Creates documentation.">
41 </target>
42</project>
diff --git a/Common/OpenSim.Framework/AgentInventory.cs b/Common/OpenSim.Framework/AgentInventory.cs
new file mode 100644
index 0000000..b28645e
--- /dev/null
+++ b/Common/OpenSim.Framework/AgentInventory.cs
@@ -0,0 +1,251 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Framework.Types;
7using OpenSim.Framework.Utilities;
8
9namespace OpenSim.Framework.Inventory
10{
11 public class AgentInventory
12 {
13 //Holds the local copy of Inventory info for a agent
14 public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
15 public Dictionary<LLUUID, InventoryItem> InventoryItems;
16 public InventoryFolder InventoryRoot;
17 public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
18 public LLUUID AgentID;
19 public AvatarWearable[] Wearables;
20
21 public AgentInventory()
22 {
23 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
24 InventoryItems = new Dictionary<LLUUID, InventoryItem>();
25 this.Initialise();
26 }
27
28 public virtual void Initialise()
29 {
30 Wearables = new AvatarWearable[13]; //should be 12 of these
31 for (int i = 0; i < 13; i++)
32 {
33 Wearables[i] = new AvatarWearable();
34 }
35
36 }
37
38 public bool CreateNewFolder(LLUUID folderID, ushort type)
39 {
40 InventoryFolder Folder = new InventoryFolder();
41 Folder.FolderID = folderID;
42 Folder.OwnerID = this.AgentID;
43 Folder.DefaultType = type;
44 this.InventoryFolders.Add(Folder.FolderID, Folder);
45 return (true);
46 }
47
48 public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
49 {
50 this.AgentID = newAgentID;
51 InventoryRoot = new InventoryFolder();
52 InventoryRoot.FolderID = LLUUID.Random();
53 InventoryRoot.ParentID = new LLUUID();
54 InventoryRoot.Version = 1;
55 InventoryRoot.DefaultType = 8;
56 InventoryRoot.OwnerID = this.AgentID;
57 InventoryRoot.FolderName = "My Inventory";
58 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
59 InventoryRoot.OwnerID = this.AgentID;
60 if (createTextures)
61 {
62 this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
63 }
64 }
65
66 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
67 {
68 InventoryFolder Folder = new InventoryFolder();
69 Folder.FolderID = folderID;
70 Folder.OwnerID = this.AgentID;
71 Folder.DefaultType = type;
72 Folder.FolderName = folderName;
73 this.InventoryFolders.Add(Folder.FolderID, Folder);
74
75 return (true);
76 }
77
78 public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
79 {
80 if (!this.InventoryFolders.ContainsKey(folderID))
81 {
82 Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
83 InventoryFolder Folder = new InventoryFolder();
84 Folder.FolderID = folderID;
85 Folder.OwnerID = this.AgentID;
86 Folder.DefaultType = type;
87 Folder.FolderName = folderName;
88 Folder.ParentID = parent;
89 this.InventoryFolders.Add(Folder.FolderID, Folder);
90 }
91
92 return (true);
93 }
94
95 public bool HasFolder(LLUUID folderID)
96 {
97 if (this.InventoryFolders.ContainsKey(folderID))
98 {
99 return true;
100 }
101 return false;
102 }
103
104 public LLUUID GetFolderID(string folderName)
105 {
106 foreach (InventoryFolder inv in this.InventoryFolders.Values)
107 {
108 if (inv.FolderName == folderName)
109 {
110 return inv.FolderID;
111 }
112 }
113
114 return LLUUID.Zero;
115 }
116
117 public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
118 {
119 if(this.InventoryItems.ContainsKey(itemID))
120 {
121 InventoryItem Item = this.InventoryItems[itemID];
122 Item.AssetID = asset.FullID;
123 Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
124 //TODO need to update the rest of the info
125 }
126 return true;
127 }
128
129 public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
130 {
131 Console.WriteLine("updating inventory item details");
132 if (this.InventoryItems.ContainsKey(itemID))
133 {
134 Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
135 InventoryItem Item = this.InventoryItems[itemID];
136 Item.Name = Util.FieldToString(packet.Name);
137 Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
138 //TODO need to update the rest of the info
139 }
140 return true;
141 }
142
143 public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
144 {
145 if (this.InventoryFolders.ContainsKey(folderID))
146 {
147 LLUUID NewItemID = LLUUID.Random();
148
149 InventoryItem Item = new InventoryItem();
150 Item.FolderID = folderID;
151 Item.OwnerID = AgentID;
152 Item.AssetID = asset.FullID;
153 Item.ItemID = NewItemID;
154 Item.Type = asset.Type;
155 Item.Name = asset.Name;
156 Item.Description = asset.Description;
157 Item.InvType = asset.InvType;
158 this.InventoryItems.Add(Item.ItemID, Item);
159 InventoryFolder Folder = InventoryFolders[Item.FolderID];
160 Folder.Items.Add(Item);
161 return (Item.ItemID);
162 }
163 else
164 {
165 return (null);
166 }
167 }
168
169 public bool DeleteFromInventory(LLUUID itemID)
170 {
171 bool res = false;
172 if (this.InventoryItems.ContainsKey(itemID))
173 {
174 InventoryItem item = this.InventoryItems[itemID];
175 this.InventoryItems.Remove(itemID);
176 foreach (InventoryFolder fold in InventoryFolders.Values)
177 {
178 if (fold.Items.Contains(item))
179 {
180 fold.Items.Remove(item);
181 break;
182 }
183 }
184 res = true;
185
186 }
187 return res;
188 }
189 }
190
191 public class InventoryFolder
192 {
193 public List<InventoryItem> Items;
194 //public List<InventoryFolder> Subfolders;
195 public LLUUID FolderID;
196 public LLUUID OwnerID;
197 public LLUUID ParentID = LLUUID.Zero;
198 public string FolderName;
199 public ushort DefaultType;
200 public ushort Version;
201
202 public InventoryFolder()
203 {
204 Items = new List<InventoryItem>();
205 //Subfolders = new List<InventoryFolder>();
206 }
207
208 }
209
210 public class InventoryItem
211 {
212 public LLUUID FolderID;
213 public LLUUID OwnerID;
214 public LLUUID ItemID;
215 public LLUUID AssetID;
216 public LLUUID CreatorID;
217 public sbyte InvType;
218 public sbyte Type;
219 public string Name ="";
220 public string Description;
221
222 public InventoryItem()
223 {
224 this.CreatorID = LLUUID.Zero;
225 }
226
227 public string ExportString()
228 {
229 string typ = "notecard";
230 string result = "";
231 result += "\tinv_object\t0\n\t{\n";
232 result += "\t\tobj_id\t%s\n";
233 result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
234 result += "\t\ttype\t"+ typ +"\n";
235 result += "\t\tname\t" + Name+"|\n";
236 result += "\t}\n";
237 return result;
238 }
239 }
240
241 public class AvatarWearable
242 {
243 public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
244 public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
245
246 public AvatarWearable()
247 {
248
249 }
250 }
251}
diff --git a/Common/OpenSim.Framework/BlockingQueue.cs b/Common/OpenSim.Framework/BlockingQueue.cs
new file mode 100644
index 0000000..f840354
--- /dev/null
+++ b/Common/OpenSim.Framework/BlockingQueue.cs
@@ -0,0 +1,33 @@
1using System;
2using System.Threading;
3using System.Collections.Generic;
4using System.Text;
5
6namespace OpenSim.Framework.Utilities
7{
8 public class BlockingQueue<T>
9 {
10 private Queue<T> _queue = new Queue<T>();
11 private object _queueSync = new object();
12
13 public void Enqueue(T value)
14 {
15 lock (_queueSync)
16 {
17 _queue.Enqueue(value);
18 Monitor.Pulse(_queueSync);
19 }
20 }
21
22 public T Dequeue()
23 {
24 lock (_queueSync)
25 {
26 if (_queue.Count < 1)
27 Monitor.Wait(_queueSync);
28
29 return _queue.Dequeue();
30 }
31 }
32 }
33}
diff --git a/Common/OpenSim.Framework/HeightMapGenHills.cs b/Common/OpenSim.Framework/HeightMapGenHills.cs
new file mode 100644
index 0000000..6a729da
--- /dev/null
+++ b/Common/OpenSim.Framework/HeightMapGenHills.cs
@@ -0,0 +1,149 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29
30namespace OpenSim.Framework.Terrain
31{
32 public class HeightmapGenHills
33 {
34 private Random Rand = new Random();
35 private int NumHills;
36 private float HillMin;
37 private float HillMax;
38 private bool Island;
39 private float[] heightmap;
40
41 public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island)
42 {
43 NumHills = numHills;
44 HillMin = hillMin;
45 HillMax = hillMax;
46 Island = island;
47
48 heightmap = new float[256 * 256];
49
50 for (int i = 0; i < numHills; i++)
51 {
52 AddHill();
53 }
54
55 Normalize();
56
57 return heightmap;
58 }
59
60 private void AddHill()
61 {
62 float x, y;
63 float radius = RandomRange(HillMin, HillMax);
64
65 if (Island)
66 {
67 // Which direction from the center of the map the hill is placed
68 float theta = RandomRange(0, 6.28f);
69
70 // How far from the center of the map to place the hill. The radius
71 // is subtracted from the range to prevent any part of the hill from
72 // reaching the edge of the map
73 float distance = RandomRange(radius / 2.0f, 128.0f - radius);
74
75 x = 128.0f + (float)Math.Cos(theta) * distance;
76 y = 128.0f + (float)Math.Sin(theta) * distance;
77 }
78 else
79 {
80 x = RandomRange(-radius, 256.0f + radius);
81 y = RandomRange(-radius, 256.0f + radius);
82 }
83
84 float radiusSq = radius * radius;
85 float distSq;
86 float height;
87
88 int xMin = (int)(x - radius) - 1;
89 int xMax = (int)(x + radius) + 1;
90 if (xMin < 0) xMin = 0;
91 if (xMax > 255) xMax = 255;
92
93 int yMin = (int)(y - radius) - 1;
94 int yMax = (int)(y + radius) + 1;
95 if (yMin < 0) yMin = 0;
96 if (yMax > 255) yMax = 255;
97
98 // Loop through each affected cell and determine the height at that point
99 for (int v = yMin; v <= yMax; ++v)
100 {
101 float fv = (float)v;
102
103 for (int h = xMin; h <= xMax; ++h)
104 {
105 float fh = (float)h;
106
107 // Determine how far from the center of this hill this point is
108 distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv);
109 height = radiusSq - distSq;
110
111 // Don't add negative hill values
112 if (height > 0.0f) heightmap[h + v * 256] += height;
113 }
114 }
115 }
116
117 private void Normalize()
118 {
119 float min = heightmap[0];
120 float max = heightmap[0];
121
122 for (int x = 0; x < 256; x++)
123 {
124 for (int y = 0; y < 256; y++)
125 {
126 if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256];
127 if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256];
128 }
129 }
130
131 // Avoid a rare divide by zero
132 if (min != max)
133 {
134 for (int x = 0; x < 256; x++)
135 {
136 for (int y = 0; y < 256; y++)
137 {
138 heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin);
139 }
140 }
141 }
142 }
143
144 private float RandomRange(float min, float max)
145 {
146 return (float)Rand.NextDouble() * (max - min) + min;
147 }
148 }
149}
diff --git a/Common/OpenSim.Framework/Interfaces/IAssetServer.cs b/Common/OpenSim.Framework/Interfaces/IAssetServer.cs
new file mode 100644
index 0000000..3f86acc
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IAssetServer.cs
@@ -0,0 +1,68 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Net;
29using System.Net.Sockets;
30using System.IO;
31using System.Threading;
32using libsecondlife;
33using OpenSim.Framework.Types;
34
35namespace OpenSim.Framework.Interfaces
36{
37 /// <summary>
38 /// Description of IAssetServer.
39 /// </summary>
40
41 public interface IAssetServer
42 {
43 void SetReceiver(IAssetReceiver receiver);
44 void RequestAsset(LLUUID assetID, bool isTexture);
45 void UpdateAsset(AssetBase asset);
46 void UploadNewAsset(AssetBase asset);
47 void SetServerInfo(string ServerUrl, string ServerKey);
48 void Close();
49 }
50
51 // could change to delegate?
52 public interface IAssetReceiver
53 {
54 void AssetReceived(AssetBase asset, bool IsTexture);
55 void AssetNotFound(AssetBase asset);
56 }
57
58 public interface IAssetPlugin
59 {
60 IAssetServer GetAssetServer();
61 }
62
63 public struct ARequest
64 {
65 public LLUUID AssetID;
66 public bool IsTexture;
67 }
68}
diff --git a/Common/OpenSim.Framework/Interfaces/IClientAPI.cs b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs
new file mode 100644
index 0000000..9f7b619
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs
@@ -0,0 +1,35 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Inventory;
5using libsecondlife;
6using libsecondlife.Packets;
7using OpenSim.Framework.Types;
8
9namespace OpenSim.Framework.Interfaces
10{
11 public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
12 public delegate void RezObject(AssetBase primAsset, LLVector3 pos);
13 public delegate void ModifyTerrain(byte action, float north, float west);
14 public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
15 public delegate void StartAnim(LLUUID animID, int seq);
16 public delegate void LinkObjects(uint parent, List<uint> children);
17
18 public interface IClientAPI
19 {
20 event ChatFromViewer OnChatFromViewer;
21 event RezObject OnRezObject;
22 event ModifyTerrain OnModifyTerrain;
23 event SetAppearance OnSetAppearance;
24 event StartAnim OnStartAnim;
25 event LinkObjects OnLinkObjects;
26
27 LLVector3 StartPos
28 {
29 get;
30 set;
31 }
32 void SendAppearance(AvatarWearable[] wearables);
33 void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
34 }
35}
diff --git a/Common/OpenSim.Framework/Interfaces/IConfig.cs b/Common/OpenSim.Framework/Interfaces/IConfig.cs
new file mode 100644
index 0000000..7b4c040
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IConfig.cs
@@ -0,0 +1,76 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* Copyright (c) <year>, <copyright holder>
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections.Generic;
32using System.IO;
33using libsecondlife;
34//using OpenSim.world;
35
36namespace OpenSim.Framework.Interfaces
37{
38 /// <summary>
39 /// This class handles connection to the underlying database used for configuration of the region.
40 /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate
41 /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from
42 /// what is hardcoded here and then saved into opensim.yap for future startups.
43 /// </summary>
44
45
46 public abstract class SimConfig
47 {
48 public string RegionName;
49
50 public uint RegionLocX;
51 public uint RegionLocY;
52 public ulong RegionHandle;
53
54 public int IPListenPort;
55 public string IPListenAddr;
56
57 public string AssetURL;
58 public string AssetSendKey;
59
60 public string GridURL;
61 public string GridSendKey;
62 public string GridRecvKey;
63 public string UserURL;
64 public string UserSendKey;
65 public string UserRecvKey;
66
67 public abstract void InitConfig(bool sandboxMode);
68 public abstract void LoadFromGrid();
69
70 }
71
72 public interface ISimConfig
73 {
74 SimConfig GetConfigObject();
75 }
76}
diff --git a/Common/OpenSim.Framework/Interfaces/IGenericConfig.cs b/Common/OpenSim.Framework/Interfaces/IGenericConfig.cs
new file mode 100644
index 0000000..a853fe4
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IGenericConfig.cs
@@ -0,0 +1,15 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Interfaces
6{
7 public interface IGenericConfig
8 {
9 void LoadData();
10 string GetAttribute(string attributeName);
11 bool SetAttribute(string attributeName, string attributeValue);
12 void Commit();
13 void Close();
14 }
15}
diff --git a/Common/OpenSim.Framework/Interfaces/IGridConfig.cs b/Common/OpenSim.Framework/Interfaces/IGridConfig.cs
new file mode 100644
index 0000000..b2f26da
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IGridConfig.cs
@@ -0,0 +1,64 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* Copyright (c) <year>, <copyright holder>
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections.Generic;
32using System.IO;
33using libsecondlife;
34//using OpenSim.world;
35
36namespace OpenSim.Framework.Interfaces
37{
38 /// <summary>
39 /// </summary>
40
41
42 public abstract class GridConfig
43 {
44 public string GridOwner;
45 public string DefaultStartupMsg;
46 public string DefaultAssetServer;
47 public string AssetSendKey;
48 public string AssetRecvKey;
49 public string DefaultUserServer;
50 public string UserSendKey;
51 public string UserRecvKey;
52 public string SimSendKey;
53 public string SimRecvKey;
54
55
56 public abstract void InitConfig();
57
58 }
59
60 public interface IGridConfig
61 {
62 GridConfig GetConfigObject();
63 }
64}
diff --git a/Common/OpenSim.Framework/Interfaces/IGridServer.cs b/Common/OpenSim.Framework/Interfaces/IGridServer.cs
new file mode 100644
index 0000000..e67ea98
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IGridServer.cs
@@ -0,0 +1,81 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.Net;
33using System.Net.Sockets;
34using System.IO;
35using libsecondlife;
36using OpenSim;
37using OpenSim.Framework.Types;
38
39namespace OpenSim.Framework.Interfaces
40{
41 /// <summary>
42 /// Handles connection to Grid Servers.
43 /// also Sim to Sim connections?
44 /// </summary>
45
46 public interface IGridServer
47 {
48 UUIDBlock RequestUUIDBlock();
49 NeighbourInfo[] RequestNeighbours(); //should return a array of neighbouring regions
50 AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
51 bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
52 string GetName();
53 bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
54 void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
55 IList RequestMapBlocks(int minX, int minY, int maxX, int maxY);
56 void Close();
57 }
58
59 public struct UUIDBlock
60 {
61 public LLUUID BlockStart;
62 public LLUUID BlockEnd;
63 }
64
65 public class AuthenticateResponse
66 {
67 public bool Authorised;
68 public Login LoginInfo;
69
70 public AuthenticateResponse()
71 {
72
73 }
74
75 }
76
77 public interface IGridPlugin
78 {
79 IGridServer GetGridServer();
80 }
81}
diff --git a/Common/OpenSim.Framework/Interfaces/ILocalStorage.cs b/Common/OpenSim.Framework/Interfaces/ILocalStorage.cs
new file mode 100644
index 0000000..4dd8868
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/ILocalStorage.cs
@@ -0,0 +1,54 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using libsecondlife;
30using OpenSim.Framework.Types;
31
32namespace OpenSim.Framework.Interfaces
33{
34 /// <summary>
35 /// ILocalStorage. Really hacked together right now needs cleaning up
36 /// </summary>
37 public interface ILocalStorage
38 {
39 void Initialise(string datastore);
40 void StorePrim(PrimData prim);
41 void RemovePrim(LLUUID primID);
42 void LoadPrimitives(ILocalStorageReceiver receiver);
43 float[] LoadWorld();
44 void SaveMap(float[] heightmap);
45 void ShutDown();
46 }
47
48 public interface ILocalStorageReceiver
49 {
50 void PrimFromStorage(PrimData prim);
51 }
52
53}
54
diff --git a/Common/OpenSim.Framework/Interfaces/IScriptAPI.cs b/Common/OpenSim.Framework/Interfaces/IScriptAPI.cs
new file mode 100644
index 0000000..3ad0f06
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IScriptAPI.cs
@@ -0,0 +1,14 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Types;
5
6namespace OpenSim.Framework.Interfaces
7{
8 public interface IScriptAPI
9 {
10 OSVector3 GetEntityPosition(uint localID);
11 void SetEntityPosition(uint localID, float x, float y, float z);
12 uint GetRandomAvatarID();
13 }
14}
diff --git a/Common/OpenSim.Framework/Interfaces/IScriptEngine.cs b/Common/OpenSim.Framework/Interfaces/IScriptEngine.cs
new file mode 100644
index 0000000..ed8974c
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IScriptEngine.cs
@@ -0,0 +1,14 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Interfaces
6{
7 public interface IScriptEngine
8 {
9 bool Init(IScriptAPI api);
10 string GetName();
11 void LoadScript(string script, string scriptName, uint entityID);
12 void OnFrame();
13 }
14}
diff --git a/Common/OpenSim.Framework/Interfaces/IUserConfig.cs b/Common/OpenSim.Framework/Interfaces/IUserConfig.cs
new file mode 100644
index 0000000..e15867d
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IUserConfig.cs
@@ -0,0 +1,58 @@
1/*
2Copyright (c) OpenSim project, http://osgrid.org/
3
4* Copyright (c) <year>, <copyright holder>
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Collections.Generic;
32using System.IO;
33using libsecondlife;
34//using OpenSim.world;
35
36namespace OpenSim.Framework.Interfaces
37{
38 /// <summary>
39 /// </summary>
40
41
42 public abstract class UserConfig
43 {
44 public string DefaultStartupMsg;
45 public string GridServerURL;
46 public string GridSendKey;
47 public string GridRecvKey;
48
49
50 public abstract void InitConfig();
51
52 }
53
54 public interface IUserConfig
55 {
56 UserConfig GetConfigObject();
57 }
58}
diff --git a/Common/OpenSim.Framework/Interfaces/IUserServer.cs b/Common/OpenSim.Framework/Interfaces/IUserServer.cs
new file mode 100644
index 0000000..21f2721
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/IUserServer.cs
@@ -0,0 +1,15 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.Framework.Inventory;
5using libsecondlife;
6
7namespace OpenSim.Framework.Interfaces
8{
9 public interface IUserServer
10 {
11 AgentInventory RequestAgentsInventory(LLUUID agentID);
12 void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
13 bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory);
14 }
15}
diff --git a/Common/OpenSim.Framework/Interfaces/LocalGridBase.cs b/Common/OpenSim.Framework/Interfaces/LocalGridBase.cs
new file mode 100644
index 0000000..ff46502
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/LocalGridBase.cs
@@ -0,0 +1,24 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Types;
6using System.Collections;
7
8namespace OpenSim.Framework.Interfaces
9{
10 public abstract class LocalGridBase : IGridServer
11 {
12 public abstract UUIDBlock RequestUUIDBlock();
13 public abstract NeighbourInfo[] RequestNeighbours();
14 public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
15 public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
16 public abstract string GetName();
17 public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
18 public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
19 public abstract void AddNewSession(Login session);
20 public abstract IList RequestMapBlocks(int minX, int minY, int maxX, int maxY);
21 public abstract void Close();
22 }
23
24}
diff --git a/Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs b/Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs
new file mode 100644
index 0000000..ed13ed5
--- /dev/null
+++ b/Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs
@@ -0,0 +1,37 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using libsecondlife;
6using OpenSim.Framework.Types;
7
8namespace OpenSim.Framework.Interfaces
9{
10 public abstract class RemoteGridBase : IGridServer
11 {
12 public abstract Dictionary<uint, AgentCircuitData> agentcircuits
13 {
14 get;
15 set;
16 }
17
18 public abstract UUIDBlock RequestUUIDBlock();
19 public abstract NeighbourInfo[] RequestNeighbours();
20 public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
21 public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
22 public abstract string GetName();
23 public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
24 public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
25 public abstract IList RequestMapBlocks(int minX, int minY, int maxX, int maxY);
26 public abstract void Close();
27 public abstract Hashtable GridData {
28 get;
29 set;
30 }
31
32 public abstract ArrayList neighbours {
33 get;
34 set;
35 }
36 }
37}
diff --git a/Common/OpenSim.Framework/LoginService.cs b/Common/OpenSim.Framework/LoginService.cs
new file mode 100644
index 0000000..eba0281
--- /dev/null
+++ b/Common/OpenSim.Framework/LoginService.cs
@@ -0,0 +1,14 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using Nwc.XmlRpc;
6using libsecondlife;
7
8namespace OpenSim.Framework.Grid
9{
10 public abstract class LoginService
11 {
12
13 }
14} \ No newline at end of file
diff --git a/Common/OpenSim.Framework/OpenSim.Framework.csproj b/Common/OpenSim.Framework/OpenSim.Framework.csproj
new file mode 100644
index 0000000..f58a2d7
--- /dev/null
+++ b/Common/OpenSim.Framework/OpenSim.Framework.csproj
@@ -0,0 +1,194 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Framework</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Framework</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 <Reference Include="Db4objects.Db4o.dll" >
74 <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
75 <Private>False</Private>
76 </Reference>
77 </ItemGroup>
78 <ItemGroup>
79 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
80 <Name>XMLRPC</Name>
81 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
82 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
83 <Private>False</Private>
84 </ProjectReference>
85 </ItemGroup>
86 <ItemGroup>
87 <Compile Include="AgentInventory.cs">
88 <SubType>Code</SubType>
89 </Compile>
90 <Compile Include="BlockingQueue.cs">
91 <SubType>Code</SubType>
92 </Compile>
93 <Compile Include="HeightMapGenHills.cs">
94 <SubType>Code</SubType>
95 </Compile>
96 <Compile Include="LoginService.cs">
97 <SubType>Code</SubType>
98 </Compile>
99 <Compile Include="Remoting.cs">
100 <SubType>Code</SubType>
101 </Compile>
102 <Compile Include="SimProfile.cs">
103 <SubType>Code</SubType>
104 </Compile>
105 <Compile Include="SimProfileBase.cs">
106 <SubType>Code</SubType>
107 </Compile>
108 <Compile Include="UserProfile.cs">
109 <SubType>Code</SubType>
110 </Compile>
111 <Compile Include="UserProfileManager.cs">
112 <SubType>Code</SubType>
113 </Compile>
114 <Compile Include="UserProfileManagerBase.cs">
115 <SubType>Code</SubType>
116 </Compile>
117 <Compile Include="Util.cs">
118 <SubType>Code</SubType>
119 </Compile>
120 <Compile Include="Interfaces\IAssetServer.cs">
121 <SubType>Code</SubType>
122 </Compile>
123 <Compile Include="Interfaces\IClientAPI.cs">
124 <SubType>Code</SubType>
125 </Compile>
126 <Compile Include="Interfaces\IConfig.cs">
127 <SubType>Code</SubType>
128 </Compile>
129 <Compile Include="Interfaces\IGenericConfig.cs">
130 <SubType>Code</SubType>
131 </Compile>
132 <Compile Include="Interfaces\IGridConfig.cs">
133 <SubType>Code</SubType>
134 </Compile>
135 <Compile Include="Interfaces\IGridServer.cs">
136 <SubType>Code</SubType>
137 </Compile>
138 <Compile Include="Interfaces\ILocalStorage.cs">
139 <SubType>Code</SubType>
140 </Compile>
141 <Compile Include="Interfaces\IScriptAPI.cs">
142 <SubType>Code</SubType>
143 </Compile>
144 <Compile Include="Interfaces\IScriptEngine.cs">
145 <SubType>Code</SubType>
146 </Compile>
147 <Compile Include="Interfaces\IUserConfig.cs">
148 <SubType>Code</SubType>
149 </Compile>
150 <Compile Include="Interfaces\IUserServer.cs">
151 <SubType>Code</SubType>
152 </Compile>
153 <Compile Include="Interfaces\LocalGridBase.cs">
154 <SubType>Code</SubType>
155 </Compile>
156 <Compile Include="Interfaces\RemoteGridBase.cs">
157 <SubType>Code</SubType>
158 </Compile>
159 <Compile Include="Properties\AssemblyInfo.cs">
160 <SubType>Code</SubType>
161 </Compile>
162 <Compile Include="Types\AgentCiruitData.cs">
163 <SubType>Code</SubType>
164 </Compile>
165 <Compile Include="Types\AssetBase.cs">
166 <SubType>Code</SubType>
167 </Compile>
168 <Compile Include="Types\AssetLandmark.cs">
169 <SubType>Code</SubType>
170 </Compile>
171 <Compile Include="Types\AssetStorage.cs">
172 <SubType>Code</SubType>
173 </Compile>
174 <Compile Include="Types\Login.cs">
175 <SubType>Code</SubType>
176 </Compile>
177 <Compile Include="Types\NeighbourInfo.cs">
178 <SubType>Code</SubType>
179 </Compile>
180 <Compile Include="Types\OSVector3.cs">
181 <SubType>Code</SubType>
182 </Compile>
183 <Compile Include="Types\PrimData.cs">
184 <SubType>Code</SubType>
185 </Compile>
186 </ItemGroup>
187 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
188 <PropertyGroup>
189 <PreBuildEvent>
190 </PreBuildEvent>
191 <PostBuildEvent>
192 </PostBuildEvent>
193 </PropertyGroup>
194</Project>
diff --git a/Common/OpenSim.Framework/OpenSim.Framework.csproj.user b/Common/OpenSim.Framework/OpenSim.Framework.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/Common/OpenSim.Framework/OpenSim.Framework.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/Common/OpenSim.Framework/OpenSim.Framework.dll.build b/Common/OpenSim.Framework/OpenSim.Framework.dll.build
new file mode 100644
index 0000000..34be1c8
--- /dev/null
+++ b/Common/OpenSim.Framework/OpenSim.Framework.dll.build
@@ -0,0 +1,75 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Framework" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Framework" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="AgentInventory.cs" />
15 <include name="BlockingQueue.cs" />
16 <include name="HeightMapGenHills.cs" />
17 <include name="LoginService.cs" />
18 <include name="Remoting.cs" />
19 <include name="SimProfile.cs" />
20 <include name="SimProfileBase.cs" />
21 <include name="UserProfile.cs" />
22 <include name="UserProfileManager.cs" />
23 <include name="UserProfileManagerBase.cs" />
24 <include name="Util.cs" />
25 <include name="Interfaces/IAssetServer.cs" />
26 <include name="Interfaces/IClientAPI.cs" />
27 <include name="Interfaces/IConfig.cs" />
28 <include name="Interfaces/IGenericConfig.cs" />
29 <include name="Interfaces/IGridConfig.cs" />
30 <include name="Interfaces/IGridServer.cs" />
31 <include name="Interfaces/ILocalStorage.cs" />
32 <include name="Interfaces/IScriptAPI.cs" />
33 <include name="Interfaces/IScriptEngine.cs" />
34 <include name="Interfaces/IUserConfig.cs" />
35 <include name="Interfaces/IUserServer.cs" />
36 <include name="Interfaces/LocalGridBase.cs" />
37 <include name="Interfaces/RemoteGridBase.cs" />
38 <include name="Properties/AssemblyInfo.cs" />
39 <include name="Types/AgentCiruitData.cs" />
40 <include name="Types/AssetBase.cs" />
41 <include name="Types/AssetLandmark.cs" />
42 <include name="Types/AssetStorage.cs" />
43 <include name="Types/Login.cs" />
44 <include name="Types/NeighbourInfo.cs" />
45 <include name="Types/OSVector3.cs" />
46 <include name="Types/PrimData.cs" />
47 </sources>
48 <references basedir="${project::get-base-directory()}">
49 <lib>
50 <include name="${project::get-base-directory()}" />
51 <include name="${project::get-base-directory()}/${build.dir}" />
52 </lib>
53 <include name="System.dll" />
54 <include name="System.Xml.dll" />
55 <include name="../../bin/libsecondlife.dll" />
56 <include name="../../bin/Db4objects.Db4o.dll" />
57 <include name="../../bin/XMLRPC.dll" />
58 </references>
59 </csc>
60 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
61 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
62 <copy todir="${project::get-base-directory()}/../../bin/">
63 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
64 <include name="*.dll"/>
65 <include name="*.exe"/>
66 </fileset>
67 </copy>
68 </target>
69 <target name="clean">
70 <delete dir="${bin.dir}" failonerror="false" />
71 <delete dir="${obj.dir}" failonerror="false" />
72 </target>
73 <target name="doc" description="Creates documentation.">
74 </target>
75</project>
diff --git a/Common/OpenSim.Framework/Properties/AssemblyInfo.cs b/Common/OpenSim.Framework/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..86f5cdb
--- /dev/null
+++ b/Common/OpenSim.Framework/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.FrameWork")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.FrameWork")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("a08e20c7-f191-4137-b1f0-9291408fa521")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Common/OpenSim.Framework/Remoting.cs b/Common/OpenSim.Framework/Remoting.cs
new file mode 100644
index 0000000..1212ee5
--- /dev/null
+++ b/Common/OpenSim.Framework/Remoting.cs
@@ -0,0 +1,109 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Security.Cryptography;
5
6namespace OpenSim.Framework
7{
8 /// <summary>
9 /// NEEDS AUDIT.
10 /// </summary>
11 /// <remarks>
12 /// Suggested implementation
13 /// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para>
14 /// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
15 /// <para>When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
16 /// <para>Both hosts should be performing these operations for this to be effective.</para>
17 /// </remarks>
18 class RemoteDigest
19 {
20 private byte[] currentHash;
21 private byte[] secret;
22
23 private SHA512Managed SHA512;
24
25 /// <summary>
26 /// Initialises a new RemoteDigest authentication mechanism
27 /// </summary>
28 /// <remarks>Needs an audit by a cryptographic professional - was not "roll your own"'d by choice but rather a serious lack of decent authentication mechanisms in .NET remoting</remarks>
29 /// <param name="sharedSecret">The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup)</param>
30 /// <param name="salt">Binary salt - some common value - to be decided what</param>
31 /// <param name="challenge">The challenge key provided by the third party</param>
32 public RemoteDigest(string sharedSecret, byte[] salt, string challenge)
33 {
34 SHA512 = new SHA512Managed();
35 Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret,salt);
36 secret = RFC2898.GetBytes(512);
37 ASCIIEncoding ASCII = new ASCIIEncoding();
38
39 currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge)));
40 }
41
42 /// <summary>
43 /// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented.
44 /// </summary>
45 /// <param name="data">The incoming data</param>
46 /// <param name="digest">The remote digest</param>
47 /// <returns></returns>
48 public bool Authenticate(byte[] data, byte[] digest)
49 {
50 byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
51 if (digest == newHash)
52 {
53 currentHash = newHash;
54 return true;
55 }
56 else
57 {
58 throw new Exception("Hash comparison failed. Key resync required.");
59 }
60 }
61
62 /// <summary>
63 /// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message.
64 /// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the
65 /// hashes will get out of sync and throw an exception when validation is attempted.
66 /// </summary>
67 /// <param name="data">The outgoing data</param>
68 /// <returns>The local digest</returns>
69 public byte[] Sign(byte[] data)
70 {
71 currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
72 return currentHash;
73 }
74
75 /// <summary>
76 /// Generates a new challenge string to be issued to a foreign host. Challenges are 1024-bit (effective strength of less than 512-bits) messages generated using the Crytographic Random Number Generator.
77 /// </summary>
78 /// <returns>A 128-character hexadecimal string containing the challenge.</returns>
79 public static string GenerateChallenge()
80 {
81 RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
82 byte[] bytes = new byte[64];
83 RNG.GetBytes(bytes);
84
85 StringBuilder sb = new StringBuilder(bytes.Length * 2);
86 foreach (byte b in bytes)
87 {
88 sb.AppendFormat("{0:x2}", b);
89 }
90 return sb.ToString();
91 }
92
93 /// <summary>
94 /// Helper function, merges two byte arrays
95 /// </summary>
96 /// <remarks>Sourced from MSDN Forum</remarks>
97 /// <param name="a">A</param>
98 /// <param name="b">B</param>
99 /// <returns>C</returns>
100 private byte[] AppendArrays(byte[] a, byte[] b)
101 {
102 byte[] c = new byte[a.Length + b.Length];
103 Buffer.BlockCopy(a, 0, c, 0, a.Length);
104 Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
105 return c;
106 }
107
108 }
109}
diff --git a/Common/OpenSim.Framework/SimProfile.cs b/Common/OpenSim.Framework/SimProfile.cs
new file mode 100644
index 0000000..8acb20b
--- /dev/null
+++ b/Common/OpenSim.Framework/SimProfile.cs
@@ -0,0 +1,83 @@
1using System;
2using System.Collections.Generic;
3using System.Collections;
4using System.Xml;
5using System.Text;
6using libsecondlife;
7using Nwc.XmlRpc;
8
9namespace OpenSim.Framework.Sims
10{
11 public class SimProfile : SimProfileBase
12 {
13 public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey)
14 {
15 try
16 {
17 Hashtable GridReqParams = new Hashtable();
18 GridReqParams["region_handle"] = region_handle.ToString();
19 GridReqParams["authkey"] = SendKey;
20 ArrayList SendParams = new ArrayList();
21 SendParams.Add(GridReqParams);
22 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
23
24 XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
25
26 Hashtable RespData = (Hashtable)GridResp.Value;
27 this.UUID = new LLUUID((string)RespData["UUID"]);
28 this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
29 this.regionname = (string)RespData["regionname"];
30 this.sim_ip = (string)RespData["sim_ip"];
31 this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
32 this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
33 this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
34 this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
35 this.sendkey = SendKey;
36 this.recvkey = RecvKey;
37 }
38 catch (Exception e)
39 {
40 Console.WriteLine(e.ToString());
41 }
42 return this;
43 }
44
45 public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey)
46 {
47 try
48 {
49 Hashtable GridReqParams = new Hashtable();
50 GridReqParams["UUID"] = UUID.ToString();
51 GridReqParams["authkey"] = SendKey;
52 ArrayList SendParams = new ArrayList();
53 SendParams.Add(GridReqParams);
54 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
55
56 XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
57
58 Hashtable RespData = (Hashtable)GridResp.Value;
59 this.UUID = new LLUUID((string)RespData["UUID"]);
60 this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
61 this.regionname = (string)RespData["regionname"];
62 this.sim_ip = (string)RespData["sim_ip"];
63 this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
64 this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
65 this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
66 this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
67 this.sendkey = SendKey;
68 this.recvkey = RecvKey;
69 }
70 catch (Exception e)
71 {
72 Console.WriteLine(e.ToString());
73 }
74 return this;
75 }
76
77
78 public SimProfile()
79 {
80 }
81 }
82
83}
diff --git a/Common/OpenSim.Framework/SimProfileBase.cs b/Common/OpenSim.Framework/SimProfileBase.cs
new file mode 100644
index 0000000..30e2e0f
--- /dev/null
+++ b/Common/OpenSim.Framework/SimProfileBase.cs
@@ -0,0 +1,27 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Sims
7{
8 [System.Obsolete("Depreciated, use SimProfileData instead")]
9 public class SimProfileBase
10 {
11 public LLUUID UUID;
12 public ulong regionhandle;
13 public string regionname;
14 public string sim_ip;
15 public uint sim_port;
16 public string caps_url;
17 public uint RegionLocX;
18 public uint RegionLocY;
19 public string sendkey;
20 public string recvkey;
21 public bool online;
22
23 public SimProfileBase()
24 {
25 }
26 }
27}
diff --git a/Common/OpenSim.Framework/Types/AgentCiruitData.cs b/Common/OpenSim.Framework/Types/AgentCiruitData.cs
new file mode 100644
index 0000000..7314586
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/AgentCiruitData.cs
@@ -0,0 +1,22 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class AgentCircuitData
9 {
10 public AgentCircuitData() { }
11 public LLUUID AgentID;
12 public LLUUID SessionID;
13 public LLUUID SecureSessionID;
14 public LLVector3 startpos;
15 public string firstname;
16 public string lastname;
17 public uint circuitcode;
18 public bool child;
19 public LLUUID InventoryFolder;
20 public LLUUID BaseFolder;
21 }
22}
diff --git a/Common/OpenSim.Framework/Types/AssetBase.cs b/Common/OpenSim.Framework/Types/AssetBase.cs
new file mode 100644
index 0000000..f6104f8
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/AssetBase.cs
@@ -0,0 +1,22 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class AssetBase
9 {
10 public byte[] Data;
11 public LLUUID FullID;
12 public sbyte Type;
13 public sbyte InvType;
14 public string Name;
15 public string Description;
16
17 public AssetBase()
18 {
19
20 }
21 }
22}
diff --git a/Common/OpenSim.Framework/Types/AssetLandmark.cs b/Common/OpenSim.Framework/Types/AssetLandmark.cs
new file mode 100644
index 0000000..9d1a326
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/AssetLandmark.cs
@@ -0,0 +1,34 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class AssetLandmark : AssetBase
9 {
10 public int Version;
11 public LLVector3 Position;
12 public LLUUID RegionID;
13
14 public AssetLandmark(AssetBase a)
15 {
16 this.Data = a.Data;
17 this.FullID = a.FullID;
18 this.Type = a.Type;
19 this.InvType = a.InvType;
20 this.Name = a.Name;
21 this.Description = a.Description;
22 InternData();
23 }
24
25 private void InternData()
26 {
27 string temp = System.Text.Encoding.UTF8.GetString(Data).Trim();
28 string[] parts = temp.Split('\n');
29 int.TryParse(parts[0].Substring(17, 1), out Version);
30 LLUUID.TryParse(parts[1].Substring(10, 36), out RegionID);
31 LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position);
32 }
33 }
34}
diff --git a/Common/OpenSim.Framework/Types/AssetStorage.cs b/Common/OpenSim.Framework/Types/AssetStorage.cs
new file mode 100644
index 0000000..5b5b3b2
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/AssetStorage.cs
@@ -0,0 +1,23 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class AssetStorage
9 {
10
11 public AssetStorage() {
12 }
13
14 public AssetStorage(LLUUID assetUUID) {
15 UUID=assetUUID;
16 }
17
18 public byte[] Data;
19 public sbyte Type;
20 public string Name;
21 public LLUUID UUID;
22 }
23}
diff --git a/Common/OpenSim.Framework/Types/Login.cs b/Common/OpenSim.Framework/Types/Login.cs
new file mode 100644
index 0000000..71f9de3
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/Login.cs
@@ -0,0 +1,24 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class Login
9 {
10 public string First = "Test";
11 public string Last = "User";
12 public LLUUID Agent;
13 public LLUUID Session;
14 public LLUUID SecureSession = LLUUID.Zero;
15 public LLUUID InventoryFolder;
16 public LLUUID BaseFolder;
17 public uint CircuitCode;
18
19 public Login()
20 {
21
22 }
23 }
24}
diff --git a/Common/OpenSim.Framework/Types/NeighbourInfo.cs b/Common/OpenSim.Framework/Types/NeighbourInfo.cs
new file mode 100644
index 0000000..58b6cb1
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/NeighbourInfo.cs
@@ -0,0 +1,19 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Types
6{
7 public class NeighbourInfo
8 {
9 public NeighbourInfo()
10 {
11 }
12
13 public ulong regionhandle;
14 public uint RegionLocX;
15 public uint RegionLocY;
16 public string sim_ip;
17 public uint sim_port;
18 }
19}
diff --git a/Common/OpenSim.Framework/Types/OSVector3.cs b/Common/OpenSim.Framework/Types/OSVector3.cs
new file mode 100644
index 0000000..8fb840b
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/OSVector3.cs
@@ -0,0 +1,18 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Framework.Types
6{
7 public class OSVector3
8 {
9 public float X;
10 public float Y;
11 public float Z;
12
13 public OSVector3()
14 {
15
16 }
17 }
18}
diff --git a/Common/OpenSim.Framework/Types/PrimData.cs b/Common/OpenSim.Framework/Types/PrimData.cs
new file mode 100644
index 0000000..68e2a22
--- /dev/null
+++ b/Common/OpenSim.Framework/Types/PrimData.cs
@@ -0,0 +1,173 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.Framework.Types
7{
8 public class PrimData
9 {
10 private const uint FULL_MASK_PERMISSIONS = 2147483647;
11
12 public LLUUID OwnerID;
13 public byte PCode;
14 public ushort PathBegin;
15 public ushort PathEnd;
16 public byte PathScaleX;
17 public byte PathScaleY;
18 public byte PathShearX;
19 public byte PathShearY;
20 public sbyte PathSkew;
21 public ushort ProfileBegin;
22 public ushort ProfileEnd;
23 public LLVector3 Scale;
24 public byte PathCurve;
25 public byte ProfileCurve;
26 public uint ParentID = 0;
27 public ushort ProfileHollow;
28 public sbyte PathRadiusOffset;
29 public byte PathRevolutions;
30 public sbyte PathTaperX;
31 public sbyte PathTaperY;
32 public sbyte PathTwist;
33 public sbyte PathTwistBegin;
34 public byte[] Texture;
35
36
37 public Int32 CreationDate;
38 public uint OwnerMask = FULL_MASK_PERMISSIONS;
39 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
40 public uint GroupMask = FULL_MASK_PERMISSIONS;
41 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
42 public uint BaseMask = FULL_MASK_PERMISSIONS;
43
44 //following only used during prim storage
45 public LLVector3 Position;
46 public LLQuaternion Rotation = new LLQuaternion(0,1,0,0);
47 public uint LocalID;
48 public LLUUID FullID;
49
50 public PrimData()
51 {
52
53 }
54
55 public PrimData(byte[] data)
56 {
57 int i =0;
58
59 this.OwnerID = new LLUUID(data, i); i += 16;
60 this.PCode = data[i++];
61 this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
62 this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
63 this.PathScaleX = data[i++];
64 this.PathScaleY = data[i++];
65 this.PathShearX = data[i++];
66 this.PathShearY = data[i++];
67 this.PathSkew = (sbyte)data[i++];
68 this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
69 this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
70 this.Scale = new LLVector3(data, i); i += 12;
71 this.PathCurve = data[i++];
72 this.ProfileCurve = data[i++];
73 this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
74 this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
75 this.PathRadiusOffset = (sbyte)data[i++];
76 this.PathRevolutions = data[i++];
77 this.PathTaperX = (sbyte)data[i++];
78 this.PathTaperY =(sbyte) data[i++];
79 this.PathTwist = (sbyte) data[i++];
80 this.PathTwistBegin = (sbyte) data[i++];
81 ushort length = (ushort)(data[i++] + (data[i++] << 8));
82 this.Texture = new byte[length];
83 Array.Copy(data, i, Texture, 0, length); i += length;
84 this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
85 this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
86 this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
87 this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
88 this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
89 this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
90 this.Position = new LLVector3(data, i); i += 12;
91 this.Rotation = new LLQuaternion(data,i, true); i += 12;
92 this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
93 this.FullID = new LLUUID(data, i); i += 16;
94
95 }
96
97 public byte[] ToBytes()
98 {
99 int i = 0;
100 byte[] bytes = new byte[126 + Texture.Length];
101 Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
102 bytes[i++] = this.PCode;
103 bytes[i++] = (byte)(this.PathBegin % 256);
104 bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
105 bytes[i++] = (byte)(this.PathEnd % 256);
106 bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
107 bytes[i++] = this.PathScaleX;
108 bytes[i++] = this.PathScaleY;
109 bytes[i++] = this.PathShearX;
110 bytes[i++] = this.PathShearY;
111 bytes[i++] = (byte)this.PathSkew;
112 bytes[i++] = (byte)(this.ProfileBegin % 256);
113 bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
114 bytes[i++] = (byte)(this.ProfileEnd % 256);
115 bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
116 Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
117 bytes[i++] = this.PathCurve;
118 bytes[i++] = this.ProfileCurve;
119 bytes[i++] = (byte)(ParentID % 256);
120 bytes[i++] = (byte)((ParentID >> 8) % 256);
121 bytes[i++] = (byte)((ParentID >> 16) % 256);
122 bytes[i++] = (byte)((ParentID >> 24) % 256);
123 bytes[i++] = (byte)(this.ProfileHollow %256);
124 bytes[i++] = (byte)((this.ProfileHollow >> 8)% 256);
125 bytes[i++] = ((byte)this.PathRadiusOffset);
126 bytes[i++] = this.PathRevolutions;
127 bytes[i++] = ((byte) this.PathTaperX);
128 bytes[i++] = ((byte) this.PathTaperY);
129 bytes[i++] = ((byte) this.PathTwist);
130 bytes[i++] = ((byte) this.PathTwistBegin);
131 bytes[i++] = (byte)(Texture.Length % 256);
132 bytes[i++] = (byte)((Texture.Length >> 8) % 256);
133 Array.Copy(Texture, 0, bytes, i, Texture.Length); i += Texture.Length;
134 bytes[i++] = (byte)(this.CreationDate % 256);
135 bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
136 bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
137 bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
138 bytes[i++] = (byte)(this.OwnerMask % 256);
139 bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
140 bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
141 bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
142 bytes[i++] = (byte)(this.NextOwnerMask % 256);
143 bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
144 bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
145 bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
146 bytes[i++] = (byte)(this.GroupMask % 256);
147 bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
148 bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
149 bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
150 bytes[i++] = (byte)(this.EveryoneMask % 256);
151 bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
152 bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
153 bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
154 bytes[i++] = (byte)(this.BaseMask % 256);
155 bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
156 bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
157 bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
158 Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
159 if (this.Rotation == new LLQuaternion(0,0,0,0))
160 {
161 this.Rotation = new LLQuaternion(0, 1, 0, 0);
162 }
163 Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
164 bytes[i++] = (byte)(this.LocalID % 256);
165 bytes[i++] = (byte)((this.LocalID >> 8) % 256);
166 bytes[i++] = (byte)((this.LocalID >> 16) % 256);
167 bytes[i++] = (byte)((this.LocalID >> 24) % 256);
168 Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
169
170 return bytes;
171 }
172 }
173}
diff --git a/Common/OpenSim.Framework/UserProfile.cs b/Common/OpenSim.Framework/UserProfile.cs
new file mode 100644
index 0000000..f95a8fa
--- /dev/null
+++ b/Common/OpenSim.Framework/UserProfile.cs
@@ -0,0 +1,62 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Inventory;
6using System.Security.Cryptography;
7
8namespace OpenSim.Framework.User
9{
10 public class UserProfile
11 {
12
13 public string firstname;
14 public string lastname;
15 public ulong homeregionhandle;
16 public LLVector3 homepos;
17 public LLVector3 homelookat;
18
19 public bool IsGridGod = false;
20 public bool IsLocal = true; // will be used in future for visitors from foreign grids
21 public string AssetURL;
22 public string MD5passwd;
23
24 public LLUUID CurrentSessionID;
25 public LLUUID CurrentSecureSessionID;
26 public LLUUID UUID;
27 public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
28
29 public AgentInventory Inventory;
30
31 public UserProfile()
32 {
33 Circuits = new Dictionary<LLUUID, uint>();
34 Inventory = new AgentInventory();
35 homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
36 homepos = new LLVector3();
37 homelookat = new LLVector3();
38 }
39
40 public void InitSessionData()
41 {
42 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
43
44 byte[] randDataS = new byte[16];
45 byte[] randDataSS = new byte[16];
46
47 rand.GetBytes(randDataS);
48 rand.GetBytes(randDataSS);
49
50 CurrentSecureSessionID = new LLUUID(randDataSS,0);
51 CurrentSessionID = new LLUUID(randDataS,0);
52
53 }
54
55 public void AddSimCircuit(uint circuitCode, LLUUID regionUUID)
56 {
57 if (this.Circuits.ContainsKey(regionUUID) == false)
58 this.Circuits.Add(regionUUID, circuitCode);
59 }
60
61 }
62}
diff --git a/Common/OpenSim.Framework/UserProfileManager.cs b/Common/OpenSim.Framework/UserProfileManager.cs
new file mode 100644
index 0000000..18b3513
--- /dev/null
+++ b/Common/OpenSim.Framework/UserProfileManager.cs
@@ -0,0 +1,272 @@
1using System;
2using System.Collections.Generic;
3using System.Collections;
4using System.Text;
5using System.Text.RegularExpressions;
6using System.Xml;
7using libsecondlife;
8using Nwc.XmlRpc;
9using OpenSim.Framework.Sims;
10using OpenSim.Framework.Inventory;
11using OpenSim.Framework.Utilities;
12
13namespace OpenSim.Framework.User
14{
15 public class UserProfileManager : UserProfileManagerBase
16 {
17 public string GridURL;
18 public string GridSendKey;
19 public string GridRecvKey;
20 public string DefaultStartupMsg;
21
22 public UserProfileManager()
23 {
24
25 }
26
27 public void SetKeys(string sendKey, string recvKey, string url, string message)
28 {
29 GridRecvKey = recvKey;
30 GridSendKey = sendKey;
31 GridURL = url;
32 DefaultStartupMsg = message;
33 }
34
35 public virtual string ParseXMLRPC(string requestBody)
36 {
37
38 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
39
40 switch (request.MethodName)
41 {
42 case "login_to_simulator":
43 XmlRpcResponse response = XmlRpcLoginMethod(request);
44
45 return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(response), "utf-16", "utf-8"));
46 }
47
48 return "";
49 }
50
51 public string RestDeleteUserSessionMethod( string request, string path, string param )
52 {
53 LLUUID sessionid = new LLUUID(param); // get usersessions/sessionid
54 foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
55 {
56 if ( UserProfiles[UUID].CurrentSessionID == sessionid)
57 {
58 UserProfiles[UUID].CurrentSessionID = null;
59 UserProfiles[UUID].CurrentSecureSessionID = null;
60 UserProfiles[UUID].Circuits.Clear();
61 }
62 }
63
64 return "OK";
65 }
66
67 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
68 {
69 XmlRpcResponse response = new XmlRpcResponse();
70 Hashtable requestData = (Hashtable)request.Params[0];
71
72 bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
73 bool GoodLogin = false;
74 string firstname = "";
75 string lastname = "";
76 string passwd = "";
77
78 if (GoodXML)
79 {
80 firstname = (string)requestData["first"];
81 lastname = (string)requestData["last"];
82 passwd = (string)requestData["passwd"];
83 GoodLogin = AuthenticateUser(firstname, lastname, passwd);
84 }
85
86
87 if (!(GoodXML && GoodLogin))
88 {
89 response = CreateErrorConnectingToGridResponse();
90 }
91 else
92 {
93 UserProfile TheUser = GetProfileByName(firstname, lastname);
94 //we need to sort out how sessions are logged out , currently the sim tells the gridserver
95 //but if as this suggests the userserver handles it then please have the sim telling the userserver instead
96 //as it really makes things messy for sandbox mode
97 //if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null)))
98 // {
99 // response = CreateAlreadyLoggedInResponse();
100 // }
101 //else
102 //{
103 try
104 {
105 Hashtable responseData = new Hashtable();
106
107 LLUUID AgentID = TheUser.UUID;
108 TheUser.InitSessionData();
109
110 //for loading data from a grid server, make any changes in CustomiseResponse() (or create a sub class of this and override that method)
111 //SimProfile SimInfo = new SimProfile();
112 //SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
113
114
115 Hashtable GlobalT = new Hashtable();
116 GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
117 GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
118 GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
119 ArrayList GlobalTextures = new ArrayList();
120 GlobalTextures.Add(GlobalT);
121
122 Hashtable LoginFlagsHash = new Hashtable();
123 LoginFlagsHash["daylight_savings"] = "N";
124 LoginFlagsHash["stipend_since_login"] = "N";
125 LoginFlagsHash["gendered"] = "Y";
126 LoginFlagsHash["ever_logged_in"] = "Y";
127 ArrayList LoginFlags = new ArrayList();
128 LoginFlags.Add(LoginFlagsHash);
129
130 Hashtable uiconfig = new Hashtable();
131 uiconfig["allow_first_life"] = "Y";
132 ArrayList ui_config = new ArrayList();
133 ui_config.Add(uiconfig);
134
135 Hashtable ClassifiedCategoriesHash = new Hashtable();
136 ClassifiedCategoriesHash["category_name"] = "bla bla";
137 ClassifiedCategoriesHash["category_id"] = (Int32)1;
138 ArrayList ClassifiedCategories = new ArrayList();
139 ClassifiedCategories.Add(ClassifiedCategoriesHash);
140
141 ArrayList AgentInventory = new ArrayList();
142 Console.WriteLine("adding inventory to response");
143 Hashtable TempHash;
144 foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values)
145 {
146 TempHash = new Hashtable();
147 Console.WriteLine("adding folder " + InvFolder.FolderName + ", ID: " + InvFolder.FolderID.ToStringHyphenated() + " with parent: " + InvFolder.ParentID.ToStringHyphenated());
148 TempHash["name"] = InvFolder.FolderName;
149 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
150 TempHash["version"] = (Int32)InvFolder.Version;
151 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
152 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
153 AgentInventory.Add(TempHash);
154 }
155
156 Hashtable InventoryRootHash = new Hashtable();
157 InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
158 ArrayList InventoryRoot = new ArrayList();
159 InventoryRoot.Add(InventoryRootHash);
160
161 Hashtable InitialOutfitHash = new Hashtable();
162 InitialOutfitHash["folder_name"] = "Nightclub Female";
163 InitialOutfitHash["gender"] = "female";
164 ArrayList InitialOutfit = new ArrayList();
165 InitialOutfit.Add(InitialOutfitHash);
166
167 uint circode = (uint)(Util.RandomClass.Next());
168 //TheUser.AddSimCircuit(circode, SimInfo.UUID);
169
170 responseData["last_name"] = TheUser.lastname;
171 responseData["ui-config"] = ui_config;
172 responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
173 responseData["login-flags"] = LoginFlags;
174 responseData["global-textures"] = GlobalTextures;
175 responseData["classified_categories"] = ClassifiedCategories;
176 responseData["event_categories"] = new ArrayList();
177 responseData["inventory-skeleton"] = AgentInventory;
178 responseData["inventory-skel-lib"] = new ArrayList();
179 responseData["inventory-root"] = InventoryRoot;
180 responseData["event_notifications"] = new ArrayList();
181 responseData["gestures"] = new ArrayList();
182 responseData["inventory-lib-owner"] = new ArrayList();
183 responseData["initial-outfit"] = InitialOutfit;
184 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
185 responseData["start_location"] = "last";
186 responseData["home"] = "{'region_handle':[r" + (0 * 256).ToString() + ",r" + (0 * 256).ToString() + "], 'position':[r" + TheUser.homepos.X.ToString() + ",r" + TheUser.homepos.Y.ToString() + ",r" + TheUser.homepos.Z.ToString() + "], 'look_at':[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]}";
187 responseData["message"] = DefaultStartupMsg;
188 responseData["first_name"] = TheUser.firstname;
189 responseData["circuit_code"] = (Int32)circode;
190 responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port;
191 responseData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated();
192 responseData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n";
193 responseData["agent_id"] = AgentID.ToStringHyphenated();
194 responseData["region_y"] = (Int32)0 * 256; // (Int32)SimInfo.RegionLocY * 256;
195 responseData["region_x"] = (Int32)0 * 256; //SimInfo.RegionLocX * 256;
196 responseData["seed_capability"] = "";
197 responseData["agent_access"] = "M";
198 responseData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated();
199 responseData["login"] = "true";
200
201 this.CustomiseResponse(ref responseData, TheUser);
202 response.Value = responseData;
203 // TheUser.SendDataToSim(SimInfo);
204 return response;
205
206 }
207 catch (Exception E)
208 {
209 Console.WriteLine(E.ToString());
210 }
211 //}
212 }
213 return response;
214
215 }
216
217 private static XmlRpcResponse CreateErrorConnectingToGridResponse()
218 {
219 XmlRpcResponse response = new XmlRpcResponse();
220 Hashtable ErrorRespData = new Hashtable();
221 ErrorRespData["reason"] = "key";
222 ErrorRespData["message"] = "Error connecting to grid. Please double check your login details and check with the grid owner if you are sure these are correct";
223 ErrorRespData["login"] = "false";
224 response.Value = ErrorRespData;
225 return response;
226 }
227
228 private static XmlRpcResponse CreateAlreadyLoggedInResponse()
229 {
230 XmlRpcResponse response = new XmlRpcResponse();
231 Hashtable PresenceErrorRespData = new Hashtable();
232 PresenceErrorRespData["reason"] = "presence";
233 PresenceErrorRespData["message"] = "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner";
234 PresenceErrorRespData["login"] = "false";
235 response.Value = PresenceErrorRespData;
236 return response;
237 }
238
239 public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser)
240 {
241 //default method set up to act as ogs user server
242 SimProfile SimInfo= new SimProfile();
243 //get siminfo from grid server
244 SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
245 Int32 circode = (Int32)Convert.ToUInt32(response["circuit_code"]);
246 theUser.AddSimCircuit((uint)circode, SimInfo.UUID);
247 response["home"] = "{'region_handle':[r" + (SimInfo.RegionLocX * 256).ToString() + ",r" + (SimInfo.RegionLocY * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
248 response["sim_ip"] = SimInfo.sim_ip;
249 response["sim_port"] = (Int32)SimInfo.sim_port;
250 response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
251 response["region_x"] = (Int32)SimInfo.RegionLocX * 256;
252
253 //default is ogs user server, so let the sim know about the user via a XmlRpcRequest
254 Console.WriteLine(SimInfo.caps_url);
255 Hashtable SimParams = new Hashtable();
256 SimParams["session_id"] = theUser.CurrentSessionID.ToString();
257 SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString();
258 SimParams["firstname"] = theUser.firstname;
259 SimParams["lastname"] = theUser.lastname;
260 SimParams["agent_id"] = theUser.UUID.ToString();
261 SimParams["circuit_code"] = (Int32)circode;
262 SimParams["startpos_x"] = theUser.homepos.X.ToString();
263 SimParams["startpos_y"] = theUser.homepos.Y.ToString();
264 SimParams["startpos_z"] = theUser.homepos.Z.ToString();
265 ArrayList SendParams = new ArrayList();
266 SendParams.Add(SimParams);
267
268 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
269 XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
270 }
271 }
272}
diff --git a/Common/OpenSim.Framework/UserProfileManagerBase.cs b/Common/OpenSim.Framework/UserProfileManagerBase.cs
new file mode 100644
index 0000000..d1307a5
--- /dev/null
+++ b/Common/OpenSim.Framework/UserProfileManagerBase.cs
@@ -0,0 +1,124 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Framework.Utilities;
6using OpenSim.Framework.Inventory;
7using Db4objects.Db4o;
8
9namespace OpenSim.Framework.User
10{
11 public class UserProfileManagerBase
12 {
13
14 public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
15
16 public UserProfileManagerBase()
17 {
18 }
19
20 public virtual void InitUserProfiles()
21 {
22 IObjectContainer db;
23 db = Db4oFactory.OpenFile("userprofiles.yap");
24 IObjectSet result = db.Get(typeof(UserProfile));
25 foreach (UserProfile userprof in result)
26 {
27 UserProfiles.Add(userprof.UUID, userprof);
28 }
29 Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database");
30 db.Close();
31 }
32
33 public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT!
34 {
35 IObjectContainer db;
36 db = Db4oFactory.OpenFile("userprofiles.yap");
37 IObjectSet result = db.Get(typeof(UserProfile));
38 foreach (UserProfile userprof in result)
39 {
40 db.Delete(userprof);
41 db.Commit();
42 }
43 foreach (UserProfile userprof in UserProfiles.Values)
44 {
45 db.Set(userprof);
46 db.Commit();
47 }
48 db.Close();
49 }
50
51 public UserProfile GetProfileByName(string firstname, string lastname)
52 {
53 foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
54 {
55 if (UserProfiles[UUID].firstname.Equals(firstname)) if (UserProfiles[UUID].lastname.Equals(lastname))
56 {
57 return UserProfiles[UUID];
58 }
59 }
60 return null;
61 }
62
63 public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID)
64 {
65 return UserProfiles[ProfileLLUUID];
66 }
67
68 public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
69 {
70 UserProfile TheUser = GetProfileByName(firstname, lastname);
71 passwd = passwd.Remove(0, 3); //remove $1$
72 if (TheUser != null)
73 {
74 if (TheUser.MD5passwd == passwd)
75 {
76 Console.WriteLine("UserProfile - authorised " + firstname + " " + lastname);
77 return true;
78 }
79 else
80 {
81 Console.WriteLine("UserProfile - not authorised, password not match " + TheUser.MD5passwd + " and " + passwd);
82 return false;
83 }
84 }
85 else
86 {
87 Console.WriteLine("UserProfile - not authorised , unkown: " + firstname + " , " + lastname);
88 return false;
89 }
90
91 }
92
93 public void SetGod(LLUUID GodID)
94 {
95 this.UserProfiles[GodID].IsGridGod = true;
96 }
97
98 public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
99 {
100 Console.WriteLine("creating new profile for : " + firstname + " , " + lastname);
101 UserProfile newprofile = new UserProfile();
102 newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
103 newprofile.firstname = firstname;
104 newprofile.lastname = lastname;
105 newprofile.MD5passwd = MD5passwd;
106 newprofile.UUID = LLUUID.Random();
107 newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
108 this.UserProfiles.Add(newprofile.UUID, newprofile);
109 return newprofile;
110 }
111
112 public virtual AgentInventory GetUsersInventory(LLUUID agentID)
113 {
114 UserProfile user = this.GetProfileByLLUUID(agentID);
115 if (user != null)
116 {
117 return user.Inventory;
118 }
119
120 return null;
121 }
122
123 }
124}
diff --git a/Common/OpenSim.Framework/Util.cs b/Common/OpenSim.Framework/Util.cs
new file mode 100644
index 0000000..400f415
--- /dev/null
+++ b/Common/OpenSim.Framework/Util.cs
@@ -0,0 +1,151 @@
1using System;
2using System.Security.Cryptography;
3using System.Collections.Generic;
4using System.Text;
5using libsecondlife;
6using libsecondlife.Packets;
7
8namespace OpenSim.Framework.Utilities
9{
10 public class Util
11 {
12 private static Random randomClass = new Random();
13 private static uint nextXferID = 5000;
14 private static object XferLock = new object();
15
16 public static ulong UIntsToLong(uint X, uint Y)
17 {
18 return Helpers.UIntsToLong(X, Y);
19 }
20
21 public static Random RandomClass
22 {
23 get
24 {
25 return randomClass;
26 }
27 }
28
29 public static uint GetNextXferID()
30 {
31 uint id = 0;
32 lock(XferLock)
33 {
34 id = nextXferID;
35 nextXferID++;
36 }
37 return id;
38 }
39
40 public static int UnixTimeSinceEpoch()
41 {
42 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
43 int timestamp = (int)t.TotalSeconds;
44 return timestamp;
45 }
46
47 public static string Md5Hash(string pass)
48 {
49 MD5 md5 = MD5CryptoServiceProvider.Create();
50 byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass));
51 StringBuilder sb = new StringBuilder();
52 for (int i = 0; i < dataMd5.Length; i++)
53 sb.AppendFormat("{0:x2}", dataMd5[i]);
54 return sb.ToString();
55 }
56
57 //public static int fast_distance2d(int x, int y)
58 //{
59 // x = System.Math.Abs(x);
60 // y = System.Math.Abs(y);
61
62 // int min = System.Math.Min(x, y);
63
64 // return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
65 //}
66
67 public static string FieldToString(byte[] bytes)
68 {
69 return FieldToString(bytes, String.Empty);
70 }
71
72 /// <summary>
73 /// Convert a variable length field (byte array) to a string, with a
74 /// field name prepended to each line of the output
75 /// </summary>
76 /// <remarks>If the byte array has unprintable characters in it, a
77 /// hex dump will be put in the string instead</remarks>
78 /// <param name="bytes">The byte array to convert to a string</param>
79 /// <param name="fieldName">A field name to prepend to each line of output</param>
80 /// <returns>An ASCII string or a string containing a hex dump, minus
81 /// the null terminator</returns>
82 public static string FieldToString(byte[] bytes, string fieldName)
83 {
84 // Check for a common case
85 if (bytes.Length == 0) return String.Empty;
86
87 StringBuilder output = new StringBuilder();
88 bool printable = true;
89
90 for (int i = 0; i < bytes.Length; ++i)
91 {
92 // Check if there are any unprintable characters in the array
93 if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
94 && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
95 {
96 printable = false;
97 break;
98 }
99 }
100
101 if (printable)
102 {
103 if (fieldName.Length > 0)
104 {
105 output.Append(fieldName);
106 output.Append(": ");
107 }
108
109 if (bytes[bytes.Length - 1] == 0x00)
110 output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
111 else
112 output.Append(UTF8Encoding.UTF8.GetString(bytes));
113 }
114 else
115 {
116 for (int i = 0; i < bytes.Length; i += 16)
117 {
118 if (i != 0)
119 output.Append(Environment.NewLine);
120 if (fieldName.Length > 0)
121 {
122 output.Append(fieldName);
123 output.Append(": ");
124 }
125
126 for (int j = 0; j < 16; j++)
127 {
128 if ((i + j) < bytes.Length)
129 output.Append(String.Format("{0:X2} ", bytes[i + j]));
130 else
131 output.Append(" ");
132 }
133
134 for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
135 {
136 if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
137 output.Append((char)bytes[i + j]);
138 else
139 output.Append(".");
140 }
141 }
142 }
143
144 return output.ToString();
145 }
146 public Util()
147 {
148
149 }
150 }
151}
diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj
new file mode 100644
index 0000000..df68722
--- /dev/null
+++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj
@@ -0,0 +1,93 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{E88EF749-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.GenericConfig.Xml</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.GenericConfig.Xml</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 </ItemGroup>
70 <ItemGroup>
71 <ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
72 <Name>OpenSim.Framework</Name>
73 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
74 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
75 <Private>False</Private>
76 </ProjectReference>
77 </ItemGroup>
78 <ItemGroup>
79 <Compile Include="XmlConfig.cs">
80 <SubType>Code</SubType>
81 </Compile>
82 <Compile Include="Properties\AssemblyInfo.cs">
83 <SubType>Code</SubType>
84 </Compile>
85 </ItemGroup>
86 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
87 <PropertyGroup>
88 <PreBuildEvent>
89 </PreBuildEvent>
90 <PostBuildEvent>
91 </PostBuildEvent>
92 </PropertyGroup>
93</Project>
diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build
new file mode 100644
index 0000000..926e72c
--- /dev/null
+++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build
@@ -0,0 +1,42 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.GenericConfig.Xml" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.GenericConfig.Xml" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="XmlConfig.cs" />
15 <include name="Properties/AssemblyInfo.cs" />
16 </sources>
17 <references basedir="${project::get-base-directory()}">
18 <lib>
19 <include name="${project::get-base-directory()}" />
20 <include name="${project::get-base-directory()}/${build.dir}" />
21 </lib>
22 <include name="System.dll" />
23 <include name="System.Xml.dll" />
24 <include name="../../../bin/OpenSim.Framework.dll" />
25 </references>
26 </csc>
27 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
28 <mkdir dir="${project::get-base-directory()}/../../../bin/"/>
29 <copy todir="${project::get-base-directory()}/../../../bin/">
30 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
31 <include name="*.dll"/>
32 <include name="*.exe"/>
33 </fileset>
34 </copy>
35 </target>
36 <target name="clean">
37 <delete dir="${bin.dir}" failonerror="false" />
38 <delete dir="${obj.dir}" failonerror="false" />
39 </target>
40 <target name="doc" description="Creates documentation.">
41 </target>
42</project>
diff --git a/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs b/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..de5f48d
--- /dev/null
+++ b/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("OpenSim.GenericConfig")]
9[assembly: AssemblyDescription("")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("OpenSim.GenericConfig")]
13[assembly: AssemblyCopyright("Copyright © 2007")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Setting ComVisible to false makes the types in this assembly not visible
18// to COM components. If you need to access a type in this assembly from
19// COM, set the ComVisible attribute to true on that type.
20[assembly: ComVisible(false)]
21
22// The following GUID is for the ID of the typelib if this project is exposed to COM
23[assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")]
24
25// Version information for an assembly consists of the following four values:
26//
27// Major Version
28// Minor Version
29// Build Number
30// Revision
31//
32// You can specify all the values or you can default the Revision and Build Numbers
33// by using the '*' as shown below:
34[assembly: AssemblyVersion("1.0.0.0")]
35[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs
new file mode 100644
index 0000000..62e3cbf
--- /dev/null
+++ b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs
@@ -0,0 +1,109 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Xml;
5using OpenSim.Framework.Interfaces;
6
7namespace OpenSim.GenericConfig
8{
9 public class XmlConfig : IGenericConfig
10 {
11 private XmlDocument doc;
12 private XmlNode rootNode;
13 private XmlNode configNode;
14 private string fileName;
15 private bool createdFile = false;
16
17 public XmlConfig(string filename)
18 {
19 fileName = filename;
20 }
21
22 public void LoadData()
23 {
24 doc = new XmlDocument();
25 try
26 {
27 if (System.IO.File.Exists(fileName))
28 {
29 XmlTextReader reader = new XmlTextReader(fileName);
30 reader.WhitespaceHandling = WhitespaceHandling.None;
31 doc.Load(reader);
32 reader.Close();
33 }
34 else
35 {
36 createdFile = true;
37 rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
38 doc.AppendChild(rootNode);
39 configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
40 rootNode.AppendChild(configNode);
41 }
42
43 }
44 catch (Exception e)
45 {
46 Console.WriteLine(e.Message);
47 return;
48 }
49 try
50 {
51 rootNode = doc.FirstChild;
52 if (rootNode.Name != "Root")
53 throw new Exception("Error: Invalid .xml File. Missing <Root>");
54
55 configNode = rootNode.FirstChild;
56 if (configNode.Name != "Config")
57 throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
58
59 }
60 catch (Exception e)
61 {
62 Console.WriteLine(e.Message);
63 }
64 if (createdFile)
65 {
66 this.Commit();
67 }
68 }
69
70 public string GetAttribute(string attributeName)
71 {
72 string result = "";
73 if (configNode.Attributes[attributeName] != null)
74 {
75 result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
76 }
77 return result;
78 }
79
80 public bool SetAttribute(string attributeName, string attributeValue)
81 {
82 if (configNode.Attributes[attributeName] != null)
83 {
84 ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
85 }
86 else
87 {
88 XmlAttribute attri;
89 attri = doc.CreateAttribute(attributeName);
90 attri.Value = attributeValue;
91 configNode.Attributes.Append(attri);
92 }
93 return true;
94 }
95
96 public void Commit()
97 {
98 doc.Save(fileName);
99 }
100
101 public void Close()
102 {
103 configNode = null;
104 rootNode = null;
105 doc = null;
106 }
107
108 }
109}
diff --git a/Common/OpenSim.Servers/BaseHttpServer.cs b/Common/OpenSim.Servers/BaseHttpServer.cs
new file mode 100644
index 0000000..38f4370
--- /dev/null
+++ b/Common/OpenSim.Servers/BaseHttpServer.cs
@@ -0,0 +1,256 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Text;
5using System.Text.RegularExpressions;
6using System.Threading;
7//using OpenSim.CAPS;
8using Nwc.XmlRpc;
9using System.Collections;
10using OpenSim.Framework.Console;
11
12namespace OpenSim.Servers
13{
14 public class BaseHttpServer
15 {
16 protected class RestMethodEntry
17 {
18 private string m_path;
19 public string Path
20 {
21 get { return m_path; }
22 }
23
24 private RestMethod m_restMethod;
25 public RestMethod RestMethod
26 {
27 get { return m_restMethod; }
28 }
29
30 public RestMethodEntry(string path, RestMethod restMethod)
31 {
32 m_path = path;
33 m_restMethod = restMethod;
34 }
35 }
36
37 protected Thread m_workerThread;
38 protected HttpListener m_httpListener;
39 protected Dictionary<string, RestMethodEntry> m_restHandlers = new Dictionary<string, RestMethodEntry>();
40 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
41 protected int m_port;
42
43 public BaseHttpServer(int port)
44 {
45 m_port = port;
46 }
47
48 public bool AddRestHandler(string method, string path, RestMethod handler)
49 {
50 string methodKey = String.Format("{0}: {1}", method, path);
51
52 if (!this.m_restHandlers.ContainsKey(methodKey))
53 {
54 this.m_restHandlers.Add(methodKey, new RestMethodEntry(path, handler));
55 return true;
56 }
57
58 //must already have a handler for that path so return false
59 return false;
60 }
61
62 public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
63 {
64 if (!this.m_rpcHandlers.ContainsKey(method))
65 {
66 this.m_rpcHandlers.Add(method, handler);
67 return true;
68 }
69
70 //must already have a handler for that path so return false
71 return false;
72 }
73
74 protected virtual string ProcessXMLRPCMethod(string methodName, XmlRpcRequest request)
75 {
76 XmlRpcResponse response;
77
78 XmlRpcMethod method;
79 if (this.m_rpcHandlers.TryGetValue(methodName, out method))
80 {
81 response = method(request);
82 }
83 else
84 {
85 response = new XmlRpcResponse();
86 Hashtable unknownMethodError = new Hashtable();
87 unknownMethodError["reason"] = "XmlRequest"; ;
88 unknownMethodError["message"] = "Unknown Rpc request";
89 unknownMethodError["login"] = "false";
90 response.Value = unknownMethodError;
91 }
92
93 return XmlRpcResponseSerializer.Singleton.Serialize(response);
94 }
95
96 protected virtual string ParseREST(string request, string path, string method)
97 {
98 string response;
99
100 string requestKey = String.Format("{0}: {1}", method, path);
101
102 string bestMatch = String.Empty;
103 foreach (string currentKey in m_restHandlers.Keys)
104 {
105 if (requestKey.StartsWith(currentKey))
106 {
107 if (currentKey.Length > bestMatch.Length)
108 {
109 bestMatch = currentKey;
110 }
111 }
112 }
113
114 RestMethodEntry restMethodEntry;
115 if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry))
116 {
117 RestMethod restMethod = restMethodEntry.RestMethod;
118
119 string param = path.Substring(restMethodEntry.Path.Length);
120 response = restMethod(request, path, param);
121
122 }
123 else
124 {
125 response = String.Empty;
126 }
127
128 return response;
129 }
130
131 protected virtual string ParseLLSDXML(string requestBody)
132 {
133 // dummy function for now - IMPLEMENT ME!
134 return "";
135 }
136
137 protected virtual string ParseXMLRPC(string requestBody)
138 {
139 string responseString = String.Empty;
140
141 try
142 {
143 XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
144
145 string methodName = request.MethodName;
146
147 responseString = ProcessXMLRPCMethod(methodName, request);
148 }
149 catch (Exception e)
150 {
151 Console.WriteLine(e.ToString());
152 }
153 return responseString;
154 }
155
156 public virtual void HandleRequest(Object stateinfo)
157 {
158 try
159 {
160 HttpListenerContext context = (HttpListenerContext)stateinfo;
161
162 HttpListenerRequest request = context.Request;
163 HttpListenerResponse response = context.Response;
164
165 response.KeepAlive = false;
166 response.SendChunked = false;
167
168 System.IO.Stream body = request.InputStream;
169 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
170 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
171
172 string requestBody = reader.ReadToEnd();
173 body.Close();
174 reader.Close();
175
176 //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType);
177 //Console.WriteLine(requestBody);
178
179 string responseString = "";
180 switch (request.ContentType)
181 {
182 case "text/xml":
183 // must be XML-RPC, so pass to the XML-RPC parser
184
185 responseString = ParseXMLRPC(requestBody);
186 responseString = Regex.Replace(responseString, "utf-16", "utf-8");
187
188 response.AddHeader("Content-type", "text/xml");
189 break;
190
191 case "application/xml":
192 // probably LLSD we hope, otherwise it should be ignored by the parser
193 responseString = ParseLLSDXML(requestBody);
194 response.AddHeader("Content-type", "application/xml");
195 break;
196
197 case "application/x-www-form-urlencoded":
198 // a form data POST so send to the REST parser
199 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
200 response.AddHeader("Content-type", "text/html");
201 break;
202
203 case null:
204 // must be REST or invalid crap, so pass to the REST parser
205 responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
206 response.AddHeader("Content-type", "text/html");
207 break;
208
209 }
210
211 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
212 System.IO.Stream output = response.OutputStream;
213 response.SendChunked = false;
214 response.ContentLength64 = buffer.Length;
215 output.Write(buffer, 0, buffer.Length);
216 output.Close();
217 }
218 catch (Exception e)
219 {
220 Console.WriteLine(e.ToString());
221 }
222 }
223
224 public void Start()
225 {
226 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server");
227
228 m_workerThread = new Thread(new ThreadStart(StartHTTP));
229 m_workerThread.IsBackground = true;
230 m_workerThread.Start();
231 }
232
233 private void StartHTTP()
234 {
235 try
236 {
237 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: StartHTTP() - Spawned main thread OK");
238 m_httpListener = new HttpListener();
239
240 m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
241 m_httpListener.Start();
242
243 HttpListenerContext context;
244 while (true)
245 {
246 context = m_httpListener.GetContext();
247 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
248 }
249 }
250 catch (Exception e)
251 {
252 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.MEDIUM, e.Message);
253 }
254 }
255 }
256}
diff --git a/Common/OpenSim.Servers/BaseServer.cs b/Common/OpenSim.Servers/BaseServer.cs
new file mode 100644
index 0000000..0a4c498
--- /dev/null
+++ b/Common/OpenSim.Servers/BaseServer.cs
@@ -0,0 +1,10 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Servers
6{
7 public class BaseServer
8 {
9 }
10}
diff --git a/Common/OpenSim.Servers/CheckSumServer.cs b/Common/OpenSim.Servers/CheckSumServer.cs
new file mode 100644
index 0000000..1125baf
--- /dev/null
+++ b/Common/OpenSim.Servers/CheckSumServer.cs
@@ -0,0 +1,113 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13using OpenSim.Framework.Console;
14
15
16namespace OpenSim.Servers
17{
18 public class CheckSumServer : UDPServerBase
19 {
20 //protected ConsoleBase m_console;
21
22 public CheckSumServer(int port)
23 : base(port)
24 {
25 }
26
27 protected override void OnReceivedData(IAsyncResult result)
28 {
29 ipeSender = new IPEndPoint(IPAddress.Any, 0);
30 epSender = (EndPoint)ipeSender;
31 Packet packet = null;
32 int numBytes = Server.EndReceiveFrom(result, ref epSender);
33 int packetEnd = numBytes - 1;
34
35 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
36
37 if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
38 {
39 SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
40 TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
41 checkreply.DataBlock.Checksum = 3220703154;//180572585;
42 checkreply.DataBlock.Flags = 0;
43 checkreply.DataBlock.MajorVersion = 1;
44 checkreply.DataBlock.MinorVersion = 15;
45 checkreply.DataBlock.PatchVersion = 0;
46 checkreply.DataBlock.ServerVersion = 0;
47 checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
48 this.SendPacket(checkreply, epSender);
49
50 /*
51 //if we wanted to echo the the checksum/ version from the client (so that any client worked)
52 SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
53 checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
54 this.SendPacket(checkrequest, epSender);
55 */
56 }
57 else if (packet.Type == PacketType.TemplateChecksumReply)
58 {
59 //echo back the client checksum reply (Hegemon's method)
60 TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
61 TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
62 checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
63 checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
64 checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
65 checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
66 checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
67 checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
68 checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
69 this.SendPacket(checkreply2, epSender);
70 }
71 else
72 {
73 }
74
75 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
76 }
77
78 private void SendPacket(Packet Pack, EndPoint endp)
79 {
80 if (!Pack.Header.Resent)
81 {
82 Pack.Header.Sequence = 1;
83 }
84
85 byte[] ZeroOutBuffer = new byte[4096];
86 byte[] sendbuffer;
87 sendbuffer = Pack.ToBytes();
88
89 try
90 {
91 if (Pack.Header.Zerocoded)
92 {
93 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
94 this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
95 }
96 else
97 {
98 this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
99 }
100 }
101 catch (Exception)
102 {
103 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
104
105 }
106 }
107
108 private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
109 {
110 this.Server.SendTo(buffer, size, flags, endp);
111 }
112 }
113} \ No newline at end of file
diff --git a/Common/OpenSim.Servers/IRestHandler.cs b/Common/OpenSim.Servers/IRestHandler.cs
new file mode 100644
index 0000000..c322505
--- /dev/null
+++ b/Common/OpenSim.Servers/IRestHandler.cs
@@ -0,0 +1,8 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Servers
6{
7 public delegate string RestMethod( string request, string path, string param );
8}
diff --git a/Common/OpenSim.Servers/LocalUserProfileManager.cs b/Common/OpenSim.Servers/LocalUserProfileManager.cs
new file mode 100644
index 0000000..a8b5f1f
--- /dev/null
+++ b/Common/OpenSim.Servers/LocalUserProfileManager.cs
@@ -0,0 +1,123 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using System.Collections;
31using System.Text;
32using OpenSim.Framework.User;
33using OpenSim.Framework.Grid;
34using OpenSim.Framework.Inventory;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37using libsecondlife;
38
39namespace OpenSim.UserServer
40{
41 public class LocalUserProfileManager : UserProfileManager
42 {
43 private IGridServer m_gridServer;
44 private int m_port;
45 private string m_ipAddr;
46 private uint regionX;
47 private uint regionY;
48 private AddNewSessionHandler AddSession;
49
50 public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr , uint regX, uint regY)
51 {
52 m_gridServer = gridServer;
53 m_port = simPort;
54 m_ipAddr = ipAddr;
55 regionX = regX;
56 regionY = regY;
57 }
58
59 public void SetSessionHandler(AddNewSessionHandler sessionHandler)
60 {
61 this.AddSession = sessionHandler;
62 }
63
64 public override void InitUserProfiles()
65 {
66 // TODO: need to load from database
67 }
68
69 public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
70 {
71 Int32 circode = (Int32)response["circuit_code"];
72 theUser.AddSimCircuit((uint)circode, LLUUID.Random());
73 response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
74 response["sim_port"] = m_port;
75 response["sim_ip"] = m_ipAddr;
76 response["region_y"] = (Int32)regionY* 256;
77 response["region_x"] = (Int32)regionX* 256;
78
79 string first;
80 string last;
81 if (response.Contains("first_name"))
82 {
83 first = (string)response["first_name"];
84 }
85 else
86 {
87 first = "test";
88 }
89
90 if (response.Contains("last_name"))
91 {
92 last = (string)response["last_name"];
93 }
94 else
95 {
96 last = "User";
97 }
98
99 ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
100 Hashtable Inventory1 = (Hashtable)InventoryList[0];
101
102 Login _login = new Login();
103 //copy data to login object
104 _login.First = first;
105 _login.Last = last;
106 _login.Agent = new LLUUID((string)response["agent_id"]) ;
107 _login.Session = new LLUUID((string)response["session_id"]);
108 _login.SecureSession = new LLUUID((string)response["secure_session_id"]);
109 _login.CircuitCode =(uint) circode;
110 _login.BaseFolder = null;
111 _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
112
113 //working on local computer if so lets add to the gridserver's list of sessions?
114 /*if (m_gridServer.GetName() == "Local")
115 {
116 Console.WriteLine("adding login data to gridserver");
117 ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
118 }*/
119
120 this.AddSession(_login);
121 }
122 }
123}
diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs
new file mode 100644
index 0000000..7333d1f
--- /dev/null
+++ b/Common/OpenSim.Servers/LoginResponse.cs
@@ -0,0 +1,670 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using Nwc.XmlRpc;
29using System;
30using System.IO;
31using System.Net;
32using System.Net.Sockets;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Collections;
37using System.Security.Cryptography;
38using System.Xml;
39using libsecondlife;
40using OpenSim;
41using OpenSim.Framework.User;
42using OpenSim.Framework.Inventory;
43using OpenSim.Framework.Utilities;
44using OpenSim.Framework.Interfaces;
45
46// ?
47using OpenSim.Framework.Grid;
48
49namespace OpenSim.UserServer
50{
51 /// <summary>
52 /// A temp class to handle login response.
53 /// Should make use of UserProfileManager where possible.
54 /// </summary>
55
56 public class LoginResponse
57 {
58 private Hashtable loginFlagsHash;
59 private Hashtable globalTexturesHash;
60 private Hashtable loginError;
61 private Hashtable eventCategoriesHash;
62 private Hashtable uiConfigHash;
63 private Hashtable classifiedCategoriesHash;
64
65 private ArrayList loginFlags;
66 private ArrayList globalTextures;
67 private ArrayList eventCategories;
68 private ArrayList uiConfig;
69 private ArrayList classifiedCategories;
70 private ArrayList inventoryRoot;
71 private ArrayList initialOutfit;
72 private ArrayList agentInventory;
73
74 private UserProfile userProfile;
75
76 private LLUUID agentID;
77 private LLUUID sessionID;
78 private LLUUID secureSessionID;
79 private LLUUID baseFolderID;
80 private LLUUID inventoryFolderID;
81
82 // Login Flags
83 private string dst;
84 private string stipendSinceLogin;
85 private string gendered;
86 private string everLoggedIn;
87 private string login;
88 private string simPort;
89 private string simAddress;
90 private string agentAccess;
91 private Int32 circuitCode;
92 private uint regionX;
93 private uint regionY;
94
95 // Login
96 private string firstname;
97 private string lastname;
98
99 // Global Textures
100 private string sunTexture;
101 private string cloudTexture;
102 private string moonTexture;
103
104 // Error Flags
105 private string errorReason;
106 private string errorMessage;
107
108 // Response
109 private XmlRpcResponse xmlRpcResponse;
110 private XmlRpcResponse defaultXmlRpcResponse;
111
112 private string welcomeMessage;
113 private string startLocation;
114 private string allowFirstLife;
115 private string home;
116 private string seedCapability;
117 private string lookAt;
118
119 public LoginResponse()
120 {
121 this.loginFlags = new ArrayList();
122 this.globalTextures = new ArrayList();
123 this.eventCategories = new ArrayList();
124 this.uiConfig = new ArrayList();
125 this.classifiedCategories = new ArrayList();
126
127 this.loginError = new Hashtable();
128 this.eventCategoriesHash = new Hashtable();
129 this.classifiedCategoriesHash = new Hashtable();
130 this.uiConfigHash = new Hashtable();
131
132 this.defaultXmlRpcResponse = new XmlRpcResponse();
133 this.userProfile = new UserProfile();
134 this.inventoryRoot = new ArrayList();
135 this.initialOutfit = new ArrayList();
136 this.agentInventory = new ArrayList();
137
138 this.xmlRpcResponse = new XmlRpcResponse();
139 this.defaultXmlRpcResponse = new XmlRpcResponse();
140
141 this.SetDefaultValues();
142 } // LoginServer
143
144 public void SetDefaultValues()
145 {
146 try
147 {
148 this.DST = "N";
149 this.StipendSinceLogin = "N";
150 this.Gendered = "Y";
151 this.EverLoggedIn = "Y";
152 this.login = "false";
153 this.firstname = "Test";
154 this.lastname = "User";
155 this.agentAccess = "M";
156 this.startLocation = "last";
157 this.allowFirstLife = "Y";
158
159 this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
160 this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
161 this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
162
163 this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
164 this.ErrorReason = "key";
165 this.welcomeMessage = "Welcome to OpenSim!";
166 this.seedCapability = "";
167 this.home = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + this.userProfile.homepos.X.ToString() + ",r" + this.userProfile.homepos.Y.ToString() + ",r" + this.userProfile.homepos.Z.ToString() + "], 'look_at':[r" + this.userProfile.homelookat.X.ToString() + ",r" + this.userProfile.homelookat.Y.ToString() + ",r" + this.userProfile.homelookat.Z.ToString() + "]}";
168 this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
169 this.RegionX = (uint)255232;
170 this.RegionY = (uint)254976;
171
172 // Classifieds;
173 this.AddClassifiedCategory((Int32)1, "Shopping");
174 this.AddClassifiedCategory((Int32)2, "Land Rental");
175 this.AddClassifiedCategory((Int32)3, "Property Rental");
176 this.AddClassifiedCategory((Int32)4, "Special Attraction");
177 this.AddClassifiedCategory((Int32)5, "New Products");
178 this.AddClassifiedCategory((Int32)6, "Employment");
179 this.AddClassifiedCategory((Int32)7, "Wanted");
180 this.AddClassifiedCategory((Int32)8, "Service");
181 this.AddClassifiedCategory((Int32)9, "Personal");
182
183 int SessionRand = Util.RandomClass.Next(1, 999);
184 this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
185 this.SecureSessionID = LLUUID.Random();
186
187 this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true);
188 this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures");
189 this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-");
190 Hashtable InventoryRootHash = new Hashtable();
191 InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
192 this.inventoryRoot.Add(InventoryRootHash);
193
194 Hashtable TempHash;
195 foreach (InventoryFolder InvFolder in this.userProfile.Inventory.InventoryFolders.Values)
196 {
197 TempHash = new Hashtable();
198 TempHash["name"] = InvFolder.FolderName;
199 TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
200 TempHash["version"] = (Int32)InvFolder.Version;
201 TempHash["type_default"] = (Int32)InvFolder.DefaultType;
202 TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
203 this.agentInventory.Add(TempHash);
204 }
205
206 Hashtable InitialOutfitHash = new Hashtable();
207 InitialOutfitHash["folder_name"] = "Nightclub Female";
208 InitialOutfitHash["gender"] = "female";
209 this.initialOutfit.Add(InitialOutfitHash);
210 }
211 catch (Exception e)
212 {
213 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
214 OpenSim.Framework.Console.LogPriority.LOW,
215 "LoginResponse: Unable to set default values: " + e.Message
216 );
217 }
218
219 } // SetDefaultValues
220
221 protected virtual LLUUID GetAgentId()
222 {
223 // todo
224 LLUUID Agent;
225 int AgentRand = Util.RandomClass.Next(1, 9999);
226 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
227 return Agent;
228 } // GetAgentId
229
230 private XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
231 {
232 // Overwrite any default values;
233 this.xmlRpcResponse = new XmlRpcResponse();
234
235 // Ensure Login Failed message/reason;
236 this.ErrorMessage = message;
237 this.ErrorReason = reason;
238
239 this.loginError["reason"] = this.ErrorReason;
240 this.loginError["message"] = this.ErrorMessage;
241 this.loginError["login"] = login;
242 this.xmlRpcResponse.Value = this.loginError;
243 return (this.xmlRpcResponse);
244 } // GenerateResponse
245
246 public XmlRpcResponse LoginFailedResponse()
247 {
248 return (this.GenerateFailureResponse("key", "You have entered an invalid name/password combination. Check Caps/lock.", "false"));
249 } // LoginFailedResponse
250
251 public XmlRpcResponse ConnectionFailedResponse()
252 {
253 return (this.LoginFailedResponse());
254 } // CreateErrorConnectingToGridResponse()
255
256 public XmlRpcResponse CreateAlreadyLoggedInResponse()
257 {
258 return (this.GenerateFailureResponse("presence", "You appear to be already logged in, if this is not the case please wait for your session to timeout, if this takes longer than a few minutes please contact the grid owner", "false"));
259 } // CreateAlreadyLoggedInResponse()
260
261 public XmlRpcResponse ToXmlRpcResponse()
262 {
263 try
264 {
265
266 Hashtable responseData = new Hashtable();
267
268 this.loginFlagsHash = new Hashtable();
269 this.loginFlagsHash["daylight_savings"] = this.DST;
270 this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
271 this.loginFlagsHash["gendered"] = this.Gendered;
272 this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
273 this.loginFlags.Add(this.loginFlagsHash);
274
275 responseData["first_name"] = this.Firstname;
276 responseData["last_name"] = this.Lastname;
277 responseData["agent_access"] = this.agentAccess;
278
279 this.globalTexturesHash = new Hashtable();
280 this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
281 this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
282 this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
283 this.globalTextures.Add(this.globalTexturesHash);
284 this.eventCategories.Add(this.eventCategoriesHash);
285
286 this.AddToUIConfig("allow_first_life", this.allowFirstLife);
287 this.uiConfig.Add(this.uiConfigHash);
288
289 // Create a agent and session LLUUID
290 this.agentID = this.GetAgentId();
291
292 responseData["sim_port"] = this.SimPort;
293 responseData["sim_ip"] = this.SimAddress;
294 responseData["agent_id"] = this.AgentID.ToStringHyphenated();
295 responseData["session_id"] = this.SessionID.ToStringHyphenated();
296 responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
297 responseData["circuit_code"] = this.CircuitCode;
298 responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
299 responseData["login-flags"] = this.loginFlags;
300 responseData["global-textures"] = this.globalTextures;
301 responseData["seed_capability"] = this.seedCapability;
302
303 responseData["event_categories"] = this.eventCategories;
304 responseData["event_notifications"] = new ArrayList(); // todo
305 responseData["classified_categories"] = this.classifiedCategories;
306 responseData["ui-config"] = this.uiConfig;
307
308 responseData["inventory-skeleton"] = this.agentInventory;
309 responseData["inventory-skel-lib"] = new ArrayList(); // todo
310 responseData["inventory-root"] = this.inventoryRoot;
311 responseData["gestures"] = new ArrayList(); // todo
312 responseData["inventory-lib-owner"] = new ArrayList(); // todo
313 responseData["initial-outfit"] = this.initialOutfit;
314 responseData["start_location"] = this.startLocation;
315 responseData["seed_capability"] = this.seedCapability;
316 responseData["home"] = this.home;
317 responseData["look_at"] = this.lookAt;
318 responseData["message"] = this.welcomeMessage;
319 responseData["region_x"] = (Int32)this.RegionX * 256;
320 responseData["region_y"] = (Int32)this.RegionY * 256;
321
322 responseData["login"] = "true";
323 this.xmlRpcResponse.Value = responseData;
324
325 return (this.xmlRpcResponse);
326 }
327 catch (Exception e)
328 {
329 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(
330 OpenSim.Framework.Console.LogPriority.LOW,
331 "LoginResponse: Error creating XML-RPC Response: " + e.Message
332 );
333 return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
334
335 }
336
337 } // ToXmlRpcResponse
338
339 public void SetEventCategories(string category, string value)
340 {
341 this.eventCategoriesHash[category] = value;
342 } // SetEventCategories
343
344 public void AddToUIConfig(string itemName, string item)
345 {
346 this.uiConfigHash[itemName] = item;
347 } // SetUIConfig
348
349 public void AddClassifiedCategory(Int32 ID, string categoryName)
350 {
351 this.classifiedCategoriesHash["category_name"] = categoryName;
352 this.classifiedCategoriesHash["category_id"] = ID;
353 this.classifiedCategories.Add(this.classifiedCategoriesHash);
354 // this.classifiedCategoriesHash.Clear();
355 } // SetClassifiedCategory
356
357 public string Login
358 {
359 get
360 {
361 return this.login;
362 }
363 set
364 {
365 this.login = value;
366 }
367 } // Login
368
369 public string DST
370 {
371 get
372 {
373 return this.dst;
374 }
375 set
376 {
377 this.dst = value;
378 }
379 } // DST
380
381 public string StipendSinceLogin
382 {
383 get
384 {
385 return this.stipendSinceLogin;
386 }
387 set
388 {
389 this.stipendSinceLogin = value;
390 }
391 } // StipendSinceLogin
392
393 public string Gendered
394 {
395 get
396 {
397 return this.gendered;
398 }
399 set
400 {
401 this.gendered = value;
402 }
403 } // Gendered
404
405 public string EverLoggedIn
406 {
407 get
408 {
409 return this.everLoggedIn;
410 }
411 set
412 {
413 this.everLoggedIn = value;
414 }
415 } // EverLoggedIn
416
417 public string SimPort
418 {
419 get
420 {
421 return this.simPort;
422 }
423 set
424 {
425 this.simPort = value;
426 }
427 } // SimPort
428
429 public string SimAddress
430 {
431 get
432 {
433 return this.simAddress;
434 }
435 set
436 {
437 this.simAddress = value;
438 }
439 } // SimAddress
440
441 public LLUUID AgentID
442 {
443 get
444 {
445 return this.agentID;
446 }
447 set
448 {
449 this.agentID = value;
450 }
451 } // AgentID
452
453 public LLUUID SessionID
454 {
455 get
456 {
457 return this.sessionID;
458 }
459 set
460 {
461 this.sessionID = value;
462 }
463 } // SessionID
464
465 public LLUUID SecureSessionID
466 {
467 get
468 {
469 return this.secureSessionID;
470 }
471 set
472 {
473 this.secureSessionID = value;
474 }
475 } // SecureSessionID
476
477 public LLUUID BaseFolderID
478 {
479 get
480 {
481 return this.baseFolderID;
482 }
483 set
484 {
485 this.baseFolderID = value;
486 }
487 } // BaseFolderID
488
489 public LLUUID InventoryFolderID
490 {
491 get
492 {
493 return this.inventoryFolderID;
494 }
495 set
496 {
497 this.inventoryFolderID = value;
498 }
499 } // InventoryFolderID
500
501 public Int32 CircuitCode
502 {
503 get
504 {
505 return this.circuitCode;
506 }
507 set
508 {
509 this.circuitCode = value;
510 }
511 } // CircuitCode
512
513 public uint RegionX
514 {
515 get
516 {
517 return this.regionX;
518 }
519 set
520 {
521 this.regionX = value;
522 }
523 } // RegionX
524
525 public uint RegionY
526 {
527 get
528 {
529 return this.regionY;
530 }
531 set
532 {
533 this.regionY = value;
534 }
535 } // RegionY
536
537 public string SunTexture
538 {
539 get
540 {
541 return this.sunTexture;
542 }
543 set
544 {
545 this.sunTexture = value;
546 }
547 } // SunTexture
548
549 public string CloudTexture
550 {
551 get
552 {
553 return this.cloudTexture;
554 }
555 set
556 {
557 this.cloudTexture = value;
558 }
559 } // CloudTexture
560
561 public string MoonTexture
562 {
563 get
564 {
565 return this.moonTexture;
566 }
567 set
568 {
569 this.moonTexture = value;
570 }
571 } // MoonTexture
572
573 public string Firstname
574 {
575 get
576 {
577 return this.firstname;
578 }
579 set
580 {
581 this.firstname = value;
582 }
583 } // Firstname
584
585 public string Lastname
586 {
587 get
588 {
589 return this.lastname;
590 }
591 set
592 {
593 this.lastname = value;
594 }
595 } // Lastname
596
597 public string AgentAccess
598 {
599 get
600 {
601 return this.agentAccess;
602 }
603 set
604 {
605 this.agentAccess = value;
606 }
607 }
608
609 public string StartLocation
610 {
611 get
612 {
613 return this.startLocation;
614 }
615 set
616 {
617 this.startLocation = value;
618 }
619 } // StartLocation
620
621 public string LookAt
622 {
623 get
624 {
625 return this.lookAt;
626 }
627 set
628 {
629 this.lookAt = value;
630 }
631 }
632
633 public string SeedCapability
634 {
635 get
636 {
637 return this.seedCapability;
638 }
639 set
640 {
641 this.seedCapability = value;
642 }
643 } // SeedCapability
644
645 public string ErrorReason
646 {
647 get
648 {
649 return this.errorReason;
650 }
651 set
652 {
653 this.errorReason = value;
654 }
655 } // ErrorReason
656
657 public string ErrorMessage
658 {
659 get
660 {
661 return this.errorMessage;
662 }
663 set
664 {
665 this.errorMessage = value;
666 }
667 } // ErrorMessage
668
669 } // LoginResponse
670} // namespace OpenSim.UserServer \ No newline at end of file
diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs
new file mode 100644
index 0000000..6fd174b
--- /dev/null
+++ b/Common/OpenSim.Servers/LoginServer.cs
@@ -0,0 +1,284 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using Nwc.XmlRpc;
29using System;
30using System.IO;
31using System.Net;
32using System.Net.Sockets;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Threading;
36using System.Collections;
37using System.Security.Cryptography;
38using System.Xml;
39using libsecondlife;
40using OpenSim;
41using OpenSim.Framework.Interfaces;
42using OpenSim.Framework.Grid;
43using OpenSim.Framework.Inventory;
44using OpenSim.Framework.User;
45using OpenSim.Framework.Utilities;
46using OpenSim.Framework.Types;
47
48namespace OpenSim.UserServer
49{
50 public delegate void AddNewSessionHandler(Login loginData);
51 /// <summary>
52 /// When running in local (default) mode , handles client logins.
53 /// </summary>
54 public class LoginServer : LoginService, IUserServer
55 {
56 private IGridServer m_gridServer;
57 public IPAddress clientAddress = IPAddress.Loopback;
58 public IPAddress remoteAddress = IPAddress.Any;
59 private int NumClients;
60 private bool userAccounts = false;
61 private string _mpasswd;
62 private bool _needPasswd = false;
63 private LocalUserProfileManager userManager;
64 private int m_simPort;
65 private string m_simAddr;
66 private uint regionX;
67 private uint regionY;
68 private AddNewSessionHandler AddSession;
69
70 public LocalUserProfileManager LocalUserManager
71 {
72 get
73 {
74 return userManager;
75 }
76 }
77
78 public LoginServer( string simAddr, int simPort, uint regX, uint regY, bool useAccounts)
79 {
80 m_simPort = simPort;
81 m_simAddr = simAddr;
82 regionX = regX;
83 regionY = regY;
84 this.userAccounts = useAccounts;
85 }
86
87 public void SetSessionHandler(AddNewSessionHandler sessionHandler)
88 {
89 this.AddSession = sessionHandler;
90 this.userManager.SetSessionHandler(sessionHandler);
91 }
92
93 public void Startup()
94 {
95 this._needPasswd = false;
96
97 this._mpasswd = EncodePassword("testpass");
98
99 userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr, regionX, regionY);
100 //userManager.InitUserProfiles();
101 userManager.SetKeys("", "", "", "Welcome to OpenSim");
102 }
103
104 public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
105 {
106 Console.WriteLine("login attempt");
107 Hashtable requestData = (Hashtable)request.Params[0];
108 string first;
109 string last;
110 string passwd;
111
112 LoginResponse loginResponse = new LoginResponse();
113 loginResponse.RegionX = regionX;
114 loginResponse.RegionY = regionY;
115
116 //get login name
117 if (requestData.Contains("first"))
118 {
119 first = (string)requestData["first"];
120 }
121 else
122 {
123 first = "test";
124 }
125
126 if (requestData.Contains("last"))
127 {
128 last = (string)requestData["last"];
129 }
130 else
131 {
132 last = "User" + NumClients.ToString();
133 }
134
135 if (requestData.Contains("passwd"))
136 {
137 passwd = (string)requestData["passwd"];
138 }
139 else
140 {
141 passwd = "notfound";
142 }
143
144 if (!Authenticate(first, last, passwd))
145 {
146 return loginResponse.LoginFailedResponse();
147 }
148
149 NumClients++;
150
151 // Create a agent and session LLUUID
152 // Agent = GetAgentId(first, last);
153 // int SessionRand = Util.RandomClass.Next(1, 999);
154 // Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
155 // LLUUID secureSess = LLUUID.Random();
156
157 loginResponse.SimPort = m_simPort.ToString();
158 loginResponse.SimAddress = m_simAddr.ToString();
159 // loginResponse.AgentID = Agent.ToStringHyphenated();
160 // loginResponse.SessionID = Session.ToStringHyphenated();
161 // loginResponse.SecureSessionID = secureSess.ToStringHyphenated();
162 loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next());
163 XmlRpcResponse response = loginResponse.ToXmlRpcResponse();
164 Hashtable responseData = (Hashtable)response.Value;
165
166 //inventory
167 /* ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"];
168 Hashtable Inventory1 = (Hashtable)InventoryList[0];
169 Hashtable Inventory2 = (Hashtable)InventoryList[1];
170 LLUUID BaseFolderID = LLUUID.Random();
171 LLUUID InventoryFolderID = LLUUID.Random();
172 Inventory2["name"] = "Textures";
173 Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
174 Inventory2["type_default"] = 0;
175 Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
176
177 ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"];
178 Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
179 Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
180 */
181 CustomiseLoginResponse(responseData, first, last);
182
183 Login _login = new Login();
184 //copy data to login object
185 _login.First = first;
186 _login.Last = last;
187 _login.Agent = loginResponse.AgentID;
188 _login.Session = loginResponse.SessionID;
189 _login.SecureSession = loginResponse.SecureSessionID;
190 _login.CircuitCode = (uint) loginResponse.CircuitCode;
191 _login.BaseFolder = loginResponse.BaseFolderID;
192 _login.InventoryFolder = loginResponse.InventoryFolderID;
193
194 //working on local computer if so lets add to the gridserver's list of sessions?
195 /* if (m_gridServer.GetName() == "Local")
196 {
197 ((LocalGridBase)m_gridServer).AddNewSession(_login);
198 }*/
199 AddSession(_login);
200
201 return response;
202 }
203
204 protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last)
205 {
206 }
207
208 protected virtual LLUUID GetAgentId(string firstName, string lastName)
209 {
210 LLUUID Agent;
211 int AgentRand = Util.RandomClass.Next(1, 9999);
212 Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
213 return Agent;
214 }
215
216 protected virtual bool Authenticate(string first, string last, string passwd)
217 {
218 if (this._needPasswd)
219 {
220 //every user needs the password to login
221 string encodedPass = passwd.Remove(0, 3); //remove $1$
222 if (encodedPass == this._mpasswd)
223 {
224 return true;
225 }
226 else
227 {
228 return false;
229 }
230 }
231 else
232 {
233 //do not need password to login
234 return true;
235 }
236 }
237
238 private static string EncodePassword(string passwd)
239 {
240 Byte[] originalBytes;
241 Byte[] encodedBytes;
242 MD5 md5;
243
244 md5 = new MD5CryptoServiceProvider();
245 originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
246 encodedBytes = md5.ComputeHash(originalBytes);
247
248 return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
249 }
250
251 public bool CreateUserAccount(string firstName, string lastName, string password)
252 {
253 Console.WriteLine("creating new user account");
254 string mdPassword = EncodePassword(password);
255 Console.WriteLine("with password: " + mdPassword);
256 this.userManager.CreateNewProfile(firstName, lastName, mdPassword);
257 return true;
258 }
259
260 //IUserServer implementation
261 public AgentInventory RequestAgentsInventory(LLUUID agentID)
262 {
263 AgentInventory aInventory = null;
264 if (this.userAccounts)
265 {
266 aInventory = this.userManager.GetUsersInventory(agentID);
267 }
268
269 return aInventory;
270 }
271
272 public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory)
273 {
274 return true;
275 }
276
277 public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
278 {
279
280 }
281 }
282
283
284}
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj b/Common/OpenSim.Servers/OpenSim.Servers.csproj
new file mode 100644
index 0000000..e89a62c
--- /dev/null
+++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj
@@ -0,0 +1,130 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{8BB20F0A-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>OpenSim.Servers</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>OpenSim.Servers</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 <Reference Include="libsecondlife.dll" >
70 <HintPath>..\..\bin\libsecondlife.dll</HintPath>
71 <Private>False</Private>
72 </Reference>
73 </ItemGroup>
74 <ItemGroup>
75 <ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
76 <Name>OpenSim.Framework</Name>
77 <Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
78 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
79 <Private>False</Private>
80 </ProjectReference>
81 <ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
82 <Name>OpenSim.Framework.Console</Name>
83 <Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
84 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
85 <Private>False</Private>
86 </ProjectReference>
87 <ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
88 <Name>XMLRPC</Name>
89 <Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
90 <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
91 <Private>False</Private>
92 </ProjectReference>
93 </ItemGroup>
94 <ItemGroup>
95 <Compile Include="BaseHttpServer.cs">
96 <SubType>Code</SubType>
97 </Compile>
98 <Compile Include="BaseServer.cs">
99 <SubType>Code</SubType>
100 </Compile>
101 <Compile Include="CheckSumServer.cs">
102 <SubType>Code</SubType>
103 </Compile>
104 <Compile Include="IRestHandler.cs">
105 <SubType>Code</SubType>
106 </Compile>
107 <Compile Include="LocalUserProfileManager.cs">
108 <SubType>Code</SubType>
109 </Compile>
110 <Compile Include="LoginResponse.cs">
111 <SubType>Code</SubType>
112 </Compile>
113 <Compile Include="LoginServer.cs">
114 <SubType>Code</SubType>
115 </Compile>
116 <Compile Include="UDPServerBase.cs">
117 <SubType>Code</SubType>
118 </Compile>
119 <Compile Include="XmlRpcMethod.cs">
120 <SubType>Code</SubType>
121 </Compile>
122 </ItemGroup>
123 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
124 <PropertyGroup>
125 <PreBuildEvent>
126 </PreBuildEvent>
127 <PostBuildEvent>
128 </PostBuildEvent>
129 </PropertyGroup>
130</Project>
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj.user b/Common/OpenSim.Servers/OpenSim.Servers.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/Common/OpenSim.Servers/OpenSim.Servers.dll.build b/Common/OpenSim.Servers/OpenSim.Servers.dll.build
new file mode 100644
index 0000000..41c1350
--- /dev/null
+++ b/Common/OpenSim.Servers/OpenSim.Servers.dll.build
@@ -0,0 +1,52 @@
1<?xml version="1.0" ?>
2<project name="OpenSim.Servers" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="OpenSim.Servers" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="BaseHttpServer.cs" />
15 <include name="BaseServer.cs" />
16 <include name="CheckSumServer.cs" />
17 <include name="IRestHandler.cs" />
18 <include name="LocalUserProfileManager.cs" />
19 <include name="LoginResponse.cs" />
20 <include name="LoginServer.cs" />
21 <include name="UDPServerBase.cs" />
22 <include name="XmlRpcMethod.cs" />
23 </sources>
24 <references basedir="${project::get-base-directory()}">
25 <lib>
26 <include name="${project::get-base-directory()}" />
27 <include name="${project::get-base-directory()}/${build.dir}" />
28 </lib>
29 <include name="System.dll" />
30 <include name="System.Xml.dll" />
31 <include name="../../bin/OpenSim.Framework.dll" />
32 <include name="../../bin/OpenSim.Framework.Console.dll" />
33 <include name="../../bin/libsecondlife.dll" />
34 <include name="../../bin/XMLRPC.dll" />
35 </references>
36 </csc>
37 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
38 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
39 <copy todir="${project::get-base-directory()}/../../bin/">
40 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
41 <include name="*.dll"/>
42 <include name="*.exe"/>
43 </fileset>
44 </copy>
45 </target>
46 <target name="clean">
47 <delete dir="${bin.dir}" failonerror="false" />
48 <delete dir="${obj.dir}" failonerror="false" />
49 </target>
50 <target name="doc" description="Creates documentation.">
51 </target>
52</project>
diff --git a/Common/OpenSim.Servers/UDPServerBase.cs b/Common/OpenSim.Servers/UDPServerBase.cs
new file mode 100644
index 0000000..a308052
--- /dev/null
+++ b/Common/OpenSim.Servers/UDPServerBase.cs
@@ -0,0 +1,68 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13
14namespace OpenSim.Servers
15{
16 public class UDPServerBase
17 {
18 public Socket Server;
19 protected IPEndPoint ServerIncoming;
20 protected byte[] RecvBuffer = new byte[4096];
21 protected byte[] ZeroBuffer = new byte[8192];
22 protected IPEndPoint ipeSender;
23 protected EndPoint epSender;
24 protected AsyncCallback ReceivedData;
25 protected int listenPort;
26
27 public UDPServerBase(int port)
28 {
29 listenPort = port;
30 }
31
32 protected virtual void OnReceivedData(IAsyncResult result)
33 {
34 ipeSender = new IPEndPoint(IPAddress.Any, 0);
35 epSender = (EndPoint)ipeSender;
36 Packet packet = null;
37 int numBytes = Server.EndReceiveFrom(result, ref epSender);
38 int packetEnd = numBytes - 1;
39
40 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
41
42 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
43 }
44
45 protected virtual void AddNewClient(Packet packet)
46 {
47 }
48
49 public virtual void ServerListener()
50 {
51
52 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
53 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
54 Server.Bind(ServerIncoming);
55
56 ipeSender = new IPEndPoint(IPAddress.Any, 0);
57 epSender = (EndPoint)ipeSender;
58 ReceivedData = new AsyncCallback(this.OnReceivedData);
59 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
60 }
61
62 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
63 {
64
65 }
66 }
67}
68
diff --git a/Common/OpenSim.Servers/XmlRpcMethod.cs b/Common/OpenSim.Servers/XmlRpcMethod.cs
new file mode 100644
index 0000000..2295405
--- /dev/null
+++ b/Common/OpenSim.Servers/XmlRpcMethod.cs
@@ -0,0 +1,7 @@
1using System;
2using Nwc.XmlRpc;
3
4namespace OpenSim.Servers
5{
6 public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
7}
diff --git a/Common/XmlRpcCS/Logger.cs b/Common/XmlRpcCS/Logger.cs
new file mode 100644
index 0000000..ebf804b
--- /dev/null
+++ b/Common/XmlRpcCS/Logger.cs
@@ -0,0 +1,46 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4
5 /// <summary>Define levels of logging.</summary><remarks> This duplicates
6 /// similar enumerations in System.Diagnostics.EventLogEntryType. The
7 /// duplication was merited because .NET Compact Framework lacked the EventLogEntryType enum.</remarks>
8 public enum LogLevel
9 {
10 /// <summary>Information level, log entry for informational reasons only.</summary>
11 Information,
12 /// <summary>Warning level, indicates a possible problem.</summary>
13 Warning,
14 /// <summary>Error level, implies a significant problem.</summary>
15 Error
16 }
17
18 ///<summary>
19 ///Logging singleton with swappable output delegate.
20 ///</summary>
21 ///<remarks>
22 ///This singleton provides a centralized log. The actual WriteEntry calls are passed
23 ///off to a delegate however. Having a delegate do the actual logginh allows you to
24 ///implement different logging mechanism and have them take effect throughout the system.
25 ///</remarks>
26 public class Logger
27 {
28 ///<summary>Delegate definition for logging.</summary>
29 ///<param name="message">The message <c>String</c> to log.</param>
30 ///<param name="level">The <c>LogLevel</c> of your message.</param>
31 public delegate void LoggerDelegate(String message, LogLevel level);
32 ///<summary>The LoggerDelegate that will recieve WriteEntry requests.</summary>
33 static public LoggerDelegate Delegate = null;
34
35 ///<summary>
36 ///Method logging events are sent to.
37 ///</summary>
38 ///<param name="message">The message <c>String</c> to log.</param>
39 ///<param name="level">The <c>LogLevel</c> of your message.</param>
40 static public void WriteEntry(String message, LogLevel level)
41 {
42 if (Delegate != null)
43 Delegate(message, level);
44 }
45 }
46}
diff --git a/Common/XmlRpcCS/SimpleHttpRequest.cs b/Common/XmlRpcCS/SimpleHttpRequest.cs
new file mode 100644
index 0000000..e5326c3
--- /dev/null
+++ b/Common/XmlRpcCS/SimpleHttpRequest.cs
@@ -0,0 +1,204 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.IO;
5 using System.Net.Sockets;
6 using System.Collections;
7
8 ///<summary>Very basic HTTP request handler.</summary>
9 ///<remarks>This class is designed to accept a TcpClient and treat it as an HTTP request.
10 /// It will do some basic header parsing and manage the input and output streams associated
11 /// with the request.</remarks>
12 public class SimpleHttpRequest
13 {
14 private String _httpMethod = null;
15 private String _protocol;
16 private String _filePathFile = null;
17 private String _filePathDir = null;
18 private String __filePath;
19 private TcpClient _client;
20 private StreamReader _input;
21 private StreamWriter _output;
22 private Hashtable _headers;
23
24 /// <summary>A constructor which accepts the TcpClient.</summary>
25 /// <remarks>It creates the associated input and output streams, determines the request type,
26 /// and parses the remaining HTTP header.</remarks>
27 /// <param name="client">The <c>TcpClient</c> associated with the HTTP connection.</param>
28 public SimpleHttpRequest(TcpClient client)
29 {
30 _client = client;
31 _output = new StreamWriter(client.GetStream());
32 _input = new StreamReader(client.GetStream());
33 GetRequestMethod();
34 GetRequestHeaders();
35 }
36
37 /// <summary>The output <c>StreamWriter</c> associated with the request.</summary>
38 public StreamWriter Output
39 {
40 get { return _output; }
41 }
42
43 /// <summary>The input <c>StreamReader</c> associated with the request.</summary>
44 public StreamReader Input
45 {
46 get { return _input; }
47 }
48
49 /// <summary>The <c>TcpClient</c> with the request.</summary>
50 public TcpClient Client
51 {
52 get { return _client; }
53 }
54
55 private String _filePath
56 {
57 get { return __filePath; }
58 set
59 {
60 __filePath = value;
61 _filePathDir = null;
62 _filePathFile = null;
63 }
64 }
65
66 /// <summary>The type of HTTP request (i.e. PUT, GET, etc.).</summary>
67 public String HttpMethod
68 {
69 get { return _httpMethod; }
70 }
71
72 /// <summary>The level of the HTTP protocol.</summary>
73 public String Protocol
74 {
75 get { return _protocol; }
76 }
77
78 /// <summary>The "path" which is part of any HTTP request.</summary>
79 public String FilePath
80 {
81 get { return _filePath; }
82 }
83
84 /// <summary>The file portion of the "path" which is part of any HTTP request.</summary>
85 public String FilePathFile
86 {
87 get
88 {
89 if (_filePathFile != null)
90 return _filePathFile;
91
92 int i = FilePath.LastIndexOf("/");
93
94 if (i == -1)
95 return "";
96
97 i++;
98 _filePathFile = FilePath.Substring(i, FilePath.Length - i);
99 return _filePathFile;
100 }
101 }
102
103 /// <summary>The directory portion of the "path" which is part of any HTTP request.</summary>
104 public String FilePathDir
105 {
106 get
107 {
108 if (_filePathDir != null)
109 return _filePathDir;
110
111 int i = FilePath.LastIndexOf("/");
112
113 if (i == -1)
114 return "";
115
116 i++;
117 _filePathDir = FilePath.Substring(0, i);
118 return _filePathDir;
119 }
120 }
121
122 private void GetRequestMethod()
123 {
124 string req = _input.ReadLine();
125 if (req == null)
126 throw new ApplicationException("Void request.");
127
128 if (0 == String.Compare("GET ", req.Substring(0, 4), true))
129 _httpMethod = "GET";
130 else if (0 == String.Compare("POST ", req.Substring(0, 5), true))
131 _httpMethod = "POST";
132 else
133 throw new InvalidOperationException("Unrecognized method in query: " + req);
134
135 req = req.TrimEnd();
136 int idx = req.IndexOf(' ') + 1;
137 if (idx >= req.Length)
138 throw new ApplicationException("What do you want?");
139
140 string page_protocol = req.Substring(idx);
141 int idx2 = page_protocol.IndexOf(' ');
142 if (idx2 == -1)
143 idx2 = page_protocol.Length;
144
145 _filePath = page_protocol.Substring(0, idx2).Trim();
146 _protocol = page_protocol.Substring(idx2).Trim();
147 }
148
149 private void GetRequestHeaders()
150 {
151 String line;
152 int idx;
153
154 _headers = new Hashtable();
155
156 while ((line = _input.ReadLine()) != "")
157 {
158 if (line == null)
159 {
160 break;
161 }
162
163 idx = line.IndexOf(':');
164 if (idx == -1 || idx == line.Length - 1)
165 {
166 Logger.WriteEntry("Malformed header line: " + line, LogLevel.Information);
167 continue;
168 }
169
170 String key = line.Substring(0, idx);
171 String value = line.Substring(idx + 1);
172
173 try
174 {
175 _headers.Add(key, value);
176 }
177 catch (Exception)
178 {
179 Logger.WriteEntry("Duplicate header key in line: " + line, LogLevel.Information);
180 }
181 }
182 }
183
184 /// <summary>
185 /// Format the object contents into a useful string representation.
186 /// </summary>
187 ///<returns><c>String</c> representation of the <c>SimpleHttpRequest</c> as the <i>HttpMethod FilePath Protocol</i>.</returns>
188 override public String ToString()
189 {
190 return HttpMethod + " " + FilePath + " " + Protocol;
191 }
192
193 /// <summary>
194 /// Close the <c>SimpleHttpRequest</c>. This flushes and closes all associated io streams.
195 /// </summary>
196 public void Close()
197 {
198 _output.Flush();
199 _output.Close();
200 _input.Close();
201 _client.Close();
202 }
203 }
204}
diff --git a/Common/XmlRpcCS/XMLRPC.csproj b/Common/XmlRpcCS/XMLRPC.csproj
new file mode 100644
index 0000000..61f8be0
--- /dev/null
+++ b/Common/XmlRpcCS/XMLRPC.csproj
@@ -0,0 +1,138 @@
1<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <ProjectType>Local</ProjectType>
4 <ProductVersion>8.0.50727</ProductVersion>
5 <SchemaVersion>2.0</SchemaVersion>
6 <ProjectGuid>{8E81D43C-0000-0000-0000-000000000000}</ProjectGuid>
7 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
8 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
9 <ApplicationIcon></ApplicationIcon>
10 <AssemblyKeyContainerName>
11 </AssemblyKeyContainerName>
12 <AssemblyName>XMLRPC</AssemblyName>
13 <DefaultClientScript>JScript</DefaultClientScript>
14 <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
15 <DefaultTargetSchema>IE50</DefaultTargetSchema>
16 <DelaySign>false</DelaySign>
17 <OutputType>Library</OutputType>
18 <AppDesignerFolder></AppDesignerFolder>
19 <RootNamespace>XMLRPC</RootNamespace>
20 <StartupObject></StartupObject>
21 <FileUpgradeFlags>
22 </FileUpgradeFlags>
23 </PropertyGroup>
24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
25 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
26 <BaseAddress>285212672</BaseAddress>
27 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
28 <ConfigurationOverrideFile>
29 </ConfigurationOverrideFile>
30 <DefineConstants>TRACE;DEBUG</DefineConstants>
31 <DocumentationFile></DocumentationFile>
32 <DebugSymbols>True</DebugSymbols>
33 <FileAlignment>4096</FileAlignment>
34 <Optimize>False</Optimize>
35 <OutputPath>..\..\bin\</OutputPath>
36 <RegisterForComInterop>False</RegisterForComInterop>
37 <RemoveIntegerChecks>False</RemoveIntegerChecks>
38 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
39 <WarningLevel>4</WarningLevel>
40 <NoWarn></NoWarn>
41 </PropertyGroup>
42 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
43 <AllowUnsafeBlocks>False</AllowUnsafeBlocks>
44 <BaseAddress>285212672</BaseAddress>
45 <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
46 <ConfigurationOverrideFile>
47 </ConfigurationOverrideFile>
48 <DefineConstants>TRACE</DefineConstants>
49 <DocumentationFile></DocumentationFile>
50 <DebugSymbols>False</DebugSymbols>
51 <FileAlignment>4096</FileAlignment>
52 <Optimize>True</Optimize>
53 <OutputPath>..\..\bin\</OutputPath>
54 <RegisterForComInterop>False</RegisterForComInterop>
55 <RemoveIntegerChecks>False</RemoveIntegerChecks>
56 <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
57 <WarningLevel>4</WarningLevel>
58 <NoWarn></NoWarn>
59 </PropertyGroup>
60 <ItemGroup>
61 <Reference Include="System" >
62 <HintPath>System.dll</HintPath>
63 <Private>False</Private>
64 </Reference>
65 <Reference Include="System.Xml" >
66 <HintPath>System.Xml.dll</HintPath>
67 <Private>False</Private>
68 </Reference>
69 </ItemGroup>
70 <ItemGroup>
71 </ItemGroup>
72 <ItemGroup>
73 <Compile Include="Logger.cs">
74 <SubType>Code</SubType>
75 </Compile>
76 <Compile Include="SimpleHttpRequest.cs">
77 <SubType>Code</SubType>
78 </Compile>
79 <Compile Include="XmlRpcBoxcarRequest.cs">
80 <SubType>Code</SubType>
81 </Compile>
82 <Compile Include="XmlRpcClientProxy.cs">
83 <SubType>Code</SubType>
84 </Compile>
85 <Compile Include="XmlRpcDeserializer.cs">
86 <SubType>Code</SubType>
87 </Compile>
88 <Compile Include="XmlRpcErrorCodes.cs">
89 <SubType>Code</SubType>
90 </Compile>
91 <Compile Include="XmlRpcException.cs">
92 <SubType>Code</SubType>
93 </Compile>
94 <Compile Include="XmlRpcExposedAttribute.cs">
95 <SubType>Code</SubType>
96 </Compile>
97 <Compile Include="XmlRpcRequest.cs">
98 <SubType>Code</SubType>
99 </Compile>
100 <Compile Include="XmlRpcRequestDeserializer.cs">
101 <SubType>Code</SubType>
102 </Compile>
103 <Compile Include="XmlRpcRequestSerializer.cs">
104 <SubType>Code</SubType>
105 </Compile>
106 <Compile Include="XmlRpcResponder.cs">
107 <SubType>Code</SubType>
108 </Compile>
109 <Compile Include="XmlRpcResponse.cs">
110 <SubType>Code</SubType>
111 </Compile>
112 <Compile Include="XmlRpcResponseDeserializer.cs">
113 <SubType>Code</SubType>
114 </Compile>
115 <Compile Include="XmlRpcResponseSerializer.cs">
116 <SubType>Code</SubType>
117 </Compile>
118 <Compile Include="XmlRpcSerializer.cs">
119 <SubType>Code</SubType>
120 </Compile>
121 <Compile Include="XmlRpcServer.cs">
122 <SubType>Code</SubType>
123 </Compile>
124 <Compile Include="XmlRpcSystemObject.cs">
125 <SubType>Code</SubType>
126 </Compile>
127 <Compile Include="XmlRpcXmlTokens.cs">
128 <SubType>Code</SubType>
129 </Compile>
130 </ItemGroup>
131 <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
132 <PropertyGroup>
133 <PreBuildEvent>
134 </PreBuildEvent>
135 <PostBuildEvent>
136 </PostBuildEvent>
137 </PropertyGroup>
138</Project>
diff --git a/Common/XmlRpcCS/XMLRPC.csproj.user b/Common/XmlRpcCS/XMLRPC.csproj.user
new file mode 100644
index 0000000..d47d65d
--- /dev/null
+++ b/Common/XmlRpcCS/XMLRPC.csproj.user
@@ -0,0 +1,12 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup>
3 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
5 <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath>
6 <LastOpenVersion>8.0.50727</LastOpenVersion>
7 <ProjectView>ProjectFiles</ProjectView>
8 <ProjectTrust>0</ProjectTrust>
9 </PropertyGroup>
10 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
11 <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
12</Project>
diff --git a/Common/XmlRpcCS/XMLRPC.dll.build b/Common/XmlRpcCS/XMLRPC.dll.build
new file mode 100644
index 0000000..2eabfcd
--- /dev/null
+++ b/Common/XmlRpcCS/XMLRPC.dll.build
@@ -0,0 +1,58 @@
1<?xml version="1.0" ?>
2<project name="XMLRPC" default="build">
3 <target name="build">
4 <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
5 <mkdir dir="${project::get-base-directory()}/${build.dir}" />
6 <copy todir="${project::get-base-directory()}/${build.dir}">
7 <fileset basedir="${project::get-base-directory()}">
8 </fileset>
9 </copy>
10 <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
11 <resources prefix="XMLRPC" dynamicprefix="true" >
12 </resources>
13 <sources failonempty="true">
14 <include name="Logger.cs" />
15 <include name="SimpleHttpRequest.cs" />
16 <include name="XmlRpcBoxcarRequest.cs" />
17 <include name="XmlRpcClientProxy.cs" />
18 <include name="XmlRpcDeserializer.cs" />
19 <include name="XmlRpcErrorCodes.cs" />
20 <include name="XmlRpcException.cs" />
21 <include name="XmlRpcExposedAttribute.cs" />
22 <include name="XmlRpcRequest.cs" />
23 <include name="XmlRpcRequestDeserializer.cs" />
24 <include name="XmlRpcRequestSerializer.cs" />
25 <include name="XmlRpcResponder.cs" />
26 <include name="XmlRpcResponse.cs" />
27 <include name="XmlRpcResponseDeserializer.cs" />
28 <include name="XmlRpcResponseSerializer.cs" />
29 <include name="XmlRpcSerializer.cs" />
30 <include name="XmlRpcServer.cs" />
31 <include name="XmlRpcSystemObject.cs" />
32 <include name="XmlRpcXmlTokens.cs" />
33 </sources>
34 <references basedir="${project::get-base-directory()}">
35 <lib>
36 <include name="${project::get-base-directory()}" />
37 <include name="${project::get-base-directory()}/${build.dir}" />
38 </lib>
39 <include name="System.dll" />
40 <include name="System.Xml.dll" />
41 </references>
42 </csc>
43 <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
44 <mkdir dir="${project::get-base-directory()}/../../bin/"/>
45 <copy todir="${project::get-base-directory()}/../../bin/">
46 <fileset basedir="${project::get-base-directory()}/${build.dir}/" >
47 <include name="*.dll"/>
48 <include name="*.exe"/>
49 </fileset>
50 </copy>
51 </target>
52 <target name="clean">
53 <delete dir="${bin.dir}" failonerror="false" />
54 <delete dir="${obj.dir}" failonerror="false" />
55 </target>
56 <target name="doc" description="Creates documentation.">
57 </target>
58</project>
diff --git a/Common/XmlRpcCS/XmlRpcBoxcarRequest.cs b/Common/XmlRpcCS/XmlRpcBoxcarRequest.cs
new file mode 100644
index 0000000..f87f7a5
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcBoxcarRequest.cs
@@ -0,0 +1,51 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Xml;
7 using System.Net;
8 using System.Text;
9 using System.Reflection;
10
11 /// <summary>Class that collects individual <c>XmlRpcRequest</c> objects and submits them as a <i>boxcarred</i> request.</summary>
12 /// <remarks>A boxcared request is when a number of request are collected before being sent via XML-RPC, and then are sent via
13 /// a single HTTP connection. This results in a speed up from reduced connection time. The results are then retuned collectively
14 /// as well.
15 ///</remarks>
16 /// <seealso cref="XmlRpcRequest"/>
17 public class XmlRpcBoxcarRequest : XmlRpcRequest
18 {
19 /// <summary>ArrayList to collect the requests to boxcar.</summary>
20 public IList Requests = new ArrayList();
21
22 /// <summary>Basic constructor.</summary>
23 public XmlRpcBoxcarRequest()
24 {
25 }
26
27 /// <summary>Returns the <c>String</c> "system.multiCall" which is the server method that handles boxcars.</summary>
28 public override String MethodName
29 {
30 get { return "system.multiCall"; }
31 }
32
33 /// <summary>The <c>ArrayList</c> of boxcarred <paramref>Requests</paramref> as properly formed parameters.</summary>
34 public override IList Params
35 {
36 get {
37 _params.Clear();
38 ArrayList reqArray = new ArrayList();
39 foreach (XmlRpcRequest request in Requests)
40 {
41 Hashtable requestEntry = new Hashtable();
42 requestEntry.Add(XmlRpcXmlTokens.METHOD_NAME, request.MethodName);
43 requestEntry.Add(XmlRpcXmlTokens.PARAMS, request.Params);
44 reqArray.Add(requestEntry);
45 }
46 _params.Add(reqArray);
47 return _params;
48 }
49 }
50 }
51}
diff --git a/Common/XmlRpcCS/XmlRpcClientProxy.cs b/Common/XmlRpcCS/XmlRpcClientProxy.cs
new file mode 100644
index 0000000..f52273a
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcClientProxy.cs
@@ -0,0 +1,61 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Runtime.Remoting.Proxies;
5 using System.Runtime.Remoting.Messaging;
6
7 /// <summary>This class provides support for creating local proxies of XML-RPC remote objects</summary>
8 /// <remarks>
9 /// To create a local proxy you need to create a local C# interface and then, via <i>createProxy</i>
10 /// associate that interface with a remote object at a given URL.
11 /// </remarks>
12public class XmlRpcClientProxy : RealProxy
13{
14 private String _remoteObjectName;
15 private String _url;
16 private XmlRpcRequest _client = new XmlRpcRequest();
17
18 /// <summary>Factory method to create proxies.</summary>
19 /// <remarks>
20 /// To create a local proxy you need to create a local C# interface with methods that mirror those of the server object.
21 /// Next, pass that interface into <c>createProxy</c> along with the object name and URL of the remote object and
22 /// cast the resulting object to the specifice interface.
23 /// </remarks>
24 /// <param name="remoteObjectName"><c>String</c> The name of the remote object.</param>
25 /// <param name="url"><c>String</c> The URL of the remote object.</param>
26 /// <param name="anInterface"><c>Type</c> The typeof() of a C# interface.</param>
27 /// <returns><c>Object</c> A proxy for your specified interface. Cast to appropriate type.</returns>
28 public static Object createProxy(String remoteObjectName, String url, Type anInterface)
29 {
30 return new XmlRpcClientProxy(remoteObjectName, url, anInterface).GetTransparentProxy();
31 }
32
33 private XmlRpcClientProxy(String remoteObjectName, String url, Type t) : base(t)
34 {
35 _remoteObjectName = remoteObjectName;
36 _url = url;
37 }
38
39 /// <summary>The local method dispatcher - do not invoke.</summary>
40 override public IMessage Invoke(IMessage msg)
41 {
42 IMethodCallMessage methodMessage = (IMethodCallMessage)msg;
43
44 _client.MethodName = _remoteObjectName + "." + methodMessage.MethodName;
45 _client.Params.Clear();
46 foreach (Object o in methodMessage.Args)
47 _client.Params.Add(o);
48
49 try
50 {
51 Object ret = _client.Invoke(_url);
52 return new ReturnMessage(ret,null,0,
53 methodMessage.LogicalCallContext, methodMessage);
54 }
55 catch (Exception e)
56 {
57 return new ReturnMessage(e, methodMessage);
58 }
59 }
60}
61}
diff --git a/Common/XmlRpcCS/XmlRpcDeserializer.cs b/Common/XmlRpcCS/XmlRpcDeserializer.cs
new file mode 100644
index 0000000..bd736c0
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcDeserializer.cs
@@ -0,0 +1,195 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Xml;
7 using System.Globalization;
8
9 /// <summary>Parser context, we maintain contexts in a stack to avoiding recursion. </summary>
10 struct Context
11 {
12 public String Name;
13 public Object Container;
14 }
15
16 /// <summary>Basic XML-RPC data deserializer.</summary>
17 /// <remarks>Uses <c>XmlTextReader</c> to parse the XML data. This level of the class
18 /// only handles the tokens common to both Requests and Responses. This class is not useful in and of itself
19 /// but is designed to be subclassed.</remarks>
20 public class XmlRpcDeserializer : XmlRpcXmlTokens
21 {
22 private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo();
23
24 private Object _container;
25 private Stack _containerStack;
26
27 /// <summary>Protected reference to last text.</summary>
28 protected String _text;
29 /// <summary>Protected reference to last deserialized value.</summary>
30 protected Object _value;
31 /// <summary>Protected reference to last name field.</summary>
32 protected String _name;
33
34
35 /// <summary>Basic constructor.</summary>
36 public XmlRpcDeserializer()
37 {
38 Reset();
39 _dateFormat.FullDateTimePattern = ISO_DATETIME;
40 }
41
42 /// <summary>Static method that parses XML data into a response using the Singleton.</summary>
43 /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param>
44 /// <returns><c>Object</c> object resulting from the deserialization.</returns>
45 virtual public Object Deserialize(TextReader xmlData)
46 {
47 return null;
48 }
49
50 /// <summary>Protected method to parse a node in an XML-RPC XML stream.</summary>
51 /// <remarks>Method deals with elements common to all XML-RPC data, subclasses of
52 /// this object deal with request/response spefic elements.</remarks>
53 /// <param name="reader"><c>XmlTextReader</c> of the in progress parsing data stream.</param>
54 protected void DeserializeNode(XmlTextReader reader)
55 {
56 switch (reader.NodeType)
57 {
58 case XmlNodeType.Element:
59 if (Logger.Delegate != null)
60 Logger.WriteEntry("START " + reader.Name, LogLevel.Information);
61 switch (reader.Name)
62 {
63 case VALUE:
64 _value = null;
65 _text = null;
66 break;
67 case STRUCT:
68 PushContext();
69 _container = new Hashtable();
70 break;
71 case ARRAY:
72 PushContext();
73 _container = new ArrayList();
74 break;
75 }
76 break;
77 case XmlNodeType.EndElement:
78 if (Logger.Delegate != null)
79 Logger.WriteEntry("END " + reader.Name, LogLevel.Information);
80 switch (reader.Name)
81 {
82 case BASE64:
83 _value = Convert.FromBase64String(_text);
84 break;
85 case BOOLEAN:
86 int val = Int16.Parse(_text);
87 if (val == 0)
88 _value = false;
89 else if (val == 1)
90 _value = true;
91 break;
92 case STRING:
93 _value = _text;
94 break;
95 case DOUBLE:
96 _value = Double.Parse(_text);
97 break;
98 case INT:
99 case ALT_INT:
100 _value = Int32.Parse(_text);
101 break;
102 case DATETIME:
103#if __MONO__
104 _value = DateParse(_text);
105#else
106 _value = DateTime.ParseExact(_text, "F", _dateFormat);
107#endif
108 break;
109 case NAME:
110 _name = _text;
111 break;
112 case VALUE:
113 if (_value == null)
114 _value = _text; // some kits don't use <string> tag, they just do <value>
115
116 if ((_container != null) && (_container is IList)) // in an array? If so add value to it.
117 ((IList)_container).Add(_value);
118 break;
119 case MEMBER:
120 if ((_container != null) && (_container is IDictionary)) // in an struct? If so add value to it.
121 ((IDictionary)_container).Add(_name, _value);
122 break;
123 case ARRAY:
124 case STRUCT:
125 _value = _container;
126 PopContext();
127 break;
128 }
129 break;
130 case XmlNodeType.Text:
131 if (Logger.Delegate != null)
132 Logger.WriteEntry("Text " + reader.Value, LogLevel.Information);
133 _text = reader.Value;
134 break;
135 default:
136 break;
137 }
138 }
139
140 /// <summary>Static method that parses XML in a <c>String</c> into a
141 /// request using the Singleton.</summary>
142 /// <param name="xmlData"><c>String</c> containing an XML-RPC request.</param>
143 /// <returns><c>XmlRpcRequest</c> object resulting from the parse.</returns>
144 public Object Deserialize(String xmlData)
145 {
146 StringReader sr = new StringReader(xmlData);
147 return Deserialize(sr);
148 }
149
150 /// <summary>Pop a Context of the stack, an Array or Struct has closed.</summary>
151 private void PopContext()
152 {
153 Context c = (Context)_containerStack.Pop();
154 _container = c.Container;
155 _name = c.Name;
156 }
157
158 /// <summary>Push a Context on the stack, an Array or Struct has opened.</summary>
159 private void PushContext()
160 {
161 Context context;
162
163 context.Container = _container;
164 context.Name = _name;
165
166 _containerStack.Push(context);
167 }
168
169 /// <summary>Reset the internal state of the deserializer.</summary>
170 protected void Reset()
171 {
172 _text = null;
173 _value = null;
174 _name = null;
175 _container = null;
176 _containerStack = new Stack();
177 }
178
179#if __MONO__
180 private DateTime DateParse(String str)
181 {
182 int year = Int32.Parse(str.Substring(0,4));
183 int month = Int32.Parse(str.Substring(4,2));
184 int day = Int32.Parse(str.Substring(6,2));
185 int hour = Int32.Parse(str.Substring(9,2));
186 int min = Int32.Parse(str.Substring(12,2));
187 int sec = Int32.Parse(str.Substring(15,2));
188 return new DateTime(year,month,day,hour,min,sec);
189 }
190#endif
191
192 }
193}
194
195
diff --git a/Common/XmlRpcCS/XmlRpcErrorCodes.cs b/Common/XmlRpcCS/XmlRpcErrorCodes.cs
new file mode 100644
index 0000000..6dec57d
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcErrorCodes.cs
@@ -0,0 +1,51 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4
5 /// <summary>Standard XML-RPC error codes.</summary>
6 public class XmlRpcErrorCodes
7 {
8 /// <summary></summary>
9 public const int PARSE_ERROR_MALFORMED = -32700;
10 /// <summary></summary>
11 public const String PARSE_ERROR_MALFORMED_MSG = "Parse Error, not well formed";
12
13 /// <summary></summary>
14 public const int PARSE_ERROR_ENCODING = -32701;
15 /// <summary></summary>
16 public const String PARSE_ERROR_ENCODING_MSG = "Parse Error, unsupported encoding";
17
18 //
19 // -32702 ---> parse error. invalid character for encoding
20 // -32600 ---> server error. invalid xml-rpc. not conforming to spec.
21 //
22
23 /// <summary></summary>
24 public const int SERVER_ERROR_METHOD = -32601;
25 /// <summary></summary>
26 public const String SERVER_ERROR_METHOD_MSG = "Server Error, requested method not found";
27
28 /// <summary></summary>
29 public const int SERVER_ERROR_PARAMS = -32602;
30 /// <summary></summary>
31 public const String SERVER_ERROR_PARAMS_MSG = "Server Error, invalid method parameters";
32
33 //
34 // -32603 ---> server error. internal xml-rpc error
35 //
36
37 /// <summary></summary>
38 public const int APPLICATION_ERROR = -32500;
39 /// <summary></summary>
40 public const String APPLICATION_ERROR_MSG = "Application Error";
41
42 //
43 // -32400 ---> system error
44 //
45
46 /// <summary></summary>
47 public const int TRANSPORT_ERROR = -32300;
48 /// <summary></summary>
49 public const String TRANSPORT_ERROR_MSG = "Transport Layer Error";
50 }
51}
diff --git a/Common/XmlRpcCS/XmlRpcException.cs b/Common/XmlRpcCS/XmlRpcException.cs
new file mode 100644
index 0000000..fd1f4ae
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcException.cs
@@ -0,0 +1,39 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4
5 /// <summary>An XML-RPC Exception.</summary>
6 /// <remarks>Maps a C# exception to an XML-RPC fault. Normal exceptions
7 /// include a message so this adds the code needed by XML-RPC.</remarks>
8 public class XmlRpcException : Exception
9 {
10 private int _code;
11
12 /// <summary>Instantiate an <c>XmlRpcException</c> with a code and message.</summary>
13 /// <param name="code"><c>Int</c> faultCode associated with this exception.</param>
14 /// <param name="message"><c>String</c> faultMessage associated with this exception.</param>
15 public XmlRpcException(int code, String message)
16 : base(message)
17 {
18 _code = code;
19 }
20
21 /// <summary>The value of the faults message, i.e. the faultString.</summary>
22 public String FaultString
23 {
24 get { return Message; }
25 }
26
27 /// <summary>The value of the faults code, i.e. the faultCode.</summary>
28 public int FaultCode
29 {
30 get { return _code; }
31 }
32
33 /// <summary>Format the message to include the code.</summary>
34 override public String ToString()
35 {
36 return "Code: " + FaultCode + " Message: " + base.ToString();
37 }
38 }
39}
diff --git a/Common/XmlRpcCS/XmlRpcExposedAttribute.cs b/Common/XmlRpcCS/XmlRpcExposedAttribute.cs
new file mode 100644
index 0000000..67b27ae
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcExposedAttribute.cs
@@ -0,0 +1,60 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Reflection;
5
6 /// <summary>
7 /// Simple tagging attribute to indicate participation is XML-RPC exposure.
8 /// </summary>
9 /// <remarks>
10 /// If present at the class level it indicates that this class does explicitly
11 /// expose methods. If present at the method level it denotes that the method
12 /// is exposed.
13 /// </remarks>
14 [AttributeUsage(
15 AttributeTargets.Class | AttributeTargets.Method,
16 AllowMultiple = false,
17 Inherited = true
18 )]
19 public class XmlRpcExposedAttribute : Attribute
20 {
21 /// <summary>Check if <paramref>obj</paramref> is an object utilizing the XML-RPC exposed Attribute.</summary>
22 /// <param name="obj"><c>Object</c> of a class or method to check for attribute.</param>
23 /// <returns><c>Boolean</c> true if attribute present.</returns>
24 public static Boolean ExposedObject(Object obj)
25 {
26 return IsExposed(obj.GetType());
27 }
28
29 /// <summary>Check if <paramref>obj</paramref>.<paramref>methodName</paramref> is an XML-RPC exposed method.</summary>
30 /// <remarks>A method is considered to be exposed if it exists and, either, the object does not use the XmlRpcExposed attribute,
31 /// or the object does use the XmlRpcExposed attribute and the method has the XmlRpcExposed attribute as well.</remarks>
32 /// <returns><c>Boolean</c> true if the method is exposed.</returns>
33 public static Boolean ExposedMethod(Object obj, String methodName)
34 {
35 Type type = obj.GetType();
36 MethodInfo method = type.GetMethod(methodName);
37
38 if (method == null)
39 throw new MissingMethodException("Method " + methodName + " not found.");
40
41 if (!IsExposed(type))
42 return true;
43
44 return IsExposed(method);
45 }
46
47 /// <summary>Check if <paramref>mi</paramref> is XML-RPC exposed.</summary>
48 /// <param name="mi"><c>MemberInfo</c> of a class or method to check for attribute.</param>
49 /// <returns><c>Boolean</c> true if attribute present.</returns>
50 public static Boolean IsExposed(MemberInfo mi)
51 {
52 foreach (Attribute attr in mi.GetCustomAttributes(true))
53 {
54 if (attr is XmlRpcExposedAttribute)
55 return true;
56 }
57 return false;
58 }
59 }
60}
diff --git a/Common/XmlRpcCS/XmlRpcRequest.cs b/Common/XmlRpcCS/XmlRpcRequest.cs
new file mode 100644
index 0000000..18d2182
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcRequest.cs
@@ -0,0 +1,150 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Xml;
7 using System.Net;
8 using System.Text;
9 using System.Reflection;
10 using System.Net.Security;
11 using System.Security.Cryptography.X509Certificates;
12
13 internal class AcceptAllCertificatePolicy : ICertificatePolicy
14 {
15 public AcceptAllCertificatePolicy()
16 {
17 }
18
19 public bool CheckValidationResult(ServicePoint sPoint,
20 System.Security.Cryptography.X509Certificates.X509Certificate cert,
21 WebRequest wRequest, int certProb)
22 {
23 // Always accept
24 return true;
25 }
26 }
27
28 /// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
29 public class XmlRpcRequest
30 {
31 private String _methodName = null;
32 private Encoding _encoding = new ASCIIEncoding();
33 private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
34 private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
35
36 /// <summary><c>ArrayList</c> containing the parameters.</summary>
37 protected IList _params = null;
38
39 /// <summary>Instantiate an <c>XmlRpcRequest</c></summary>
40 public XmlRpcRequest()
41 {
42 _params = new ArrayList();
43 }
44
45 /// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
46 /// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
47 /// should be directed to.</param>
48 /// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
49 public XmlRpcRequest(String methodName, IList parameters)
50 {
51 MethodName = methodName;
52 _params = parameters;
53 }
54
55 /// <summary><c>ArrayList</c> conntaining the parameters for the request.</summary>
56 public virtual IList Params
57 {
58 get { return _params; }
59 }
60
61 /// <summary><c>String</c> conntaining the method name, both object and method, that the request will be sent to.</summary>
62 public virtual String MethodName
63 {
64 get { return _methodName; }
65 set { _methodName = value; }
66 }
67
68 /// <summary><c>String</c> object name portion of the method name.</summary>
69 public String MethodNameObject
70 {
71 get
72 {
73 int index = MethodName.IndexOf(".");
74
75 if (index == -1)
76 return MethodName;
77
78 return MethodName.Substring(0, index);
79 }
80 }
81
82 /// <summary><c>String</c> method name portion of the object.method name.</summary>
83 public String MethodNameMethod
84 {
85 get
86 {
87 int index = MethodName.IndexOf(".");
88
89 if (index == -1)
90 return MethodName;
91
92 return MethodName.Substring(index + 1, MethodName.Length - index - 1);
93 }
94 }
95
96 /// <summary>Invoke this request on the server.</summary>
97 /// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
98 /// <returns><c>Object</c> The value returned from the method invocation on the server.</returns>
99 /// <exception cref="XmlRpcException">If an exception generated on the server side.</exception>
100 public Object Invoke(String url)
101 {
102 XmlRpcResponse res = Send(url, 10000);
103
104 if (res.IsFault)
105 throw new XmlRpcException(res.FaultCode, res.FaultString);
106
107 return res.Value;
108 }
109
110 /// <summary>Send the request to the server.</summary>
111 /// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
112 /// <param name="timeout">Milliseconds before the connection times out.</param>
113 /// <returns><c>XmlRpcResponse</c> The response generated.</returns>
114 public XmlRpcResponse Send(String url, int timeout)
115 {
116 // Override SSL authentication mechanisms
117 ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
118
119 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
120 if (request == null)
121 throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
122 XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
123 request.Method = "POST";
124 request.ContentType = "text/xml";
125 request.AllowWriteStreamBuffering = true;
126 request.Timeout = timeout;
127
128 Stream stream = request.GetRequestStream();
129 XmlTextWriter xml = new XmlTextWriter(stream, _encoding);
130 _serializer.Serialize(xml, this);
131 xml.Flush();
132 xml.Close();
133
134 HttpWebResponse response = (HttpWebResponse)request.GetResponse();
135 StreamReader input = new StreamReader(response.GetResponseStream());
136
137 XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input);
138 input.Close();
139 response.Close();
140 return resp;
141 }
142
143 /// <summary>Produce <c>String</c> representation of the object.</summary>
144 /// <returns><c>String</c> representation of the object.</returns>
145 override public String ToString()
146 {
147 return _serializer.Serialize(this);
148 }
149 }
150}
diff --git a/Common/XmlRpcCS/XmlRpcRequestDeserializer.cs b/Common/XmlRpcCS/XmlRpcRequestDeserializer.cs
new file mode 100644
index 0000000..0770b7e
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcRequestDeserializer.cs
@@ -0,0 +1,64 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.Diagnostics;
6 using System.IO;
7 using System.Xml;
8
9 /// <summary>Class to deserialize XML data representing a request.</summary>
10 public class XmlRpcRequestDeserializer : XmlRpcDeserializer
11 {
12 static private XmlRpcRequestDeserializer _singleton;
13 /// <summary>A static singleton instance of this deserializer.</summary>
14 [Obsolete("This object is now thread safe, just use an instance.", false)]
15 static public XmlRpcRequestDeserializer Singleton
16 {
17 get
18 {
19 if (_singleton == null)
20 _singleton = new XmlRpcRequestDeserializer();
21
22 return _singleton;
23 }
24 }
25
26 /// <summary>Static method that parses XML data into a request using the Singleton.</summary>
27 /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC request.</param>
28 /// <returns><c>XmlRpcRequest</c> object resulting from the parse.</returns>
29 override public Object Deserialize(TextReader xmlData)
30 {
31 XmlTextReader reader = new XmlTextReader(xmlData);
32 XmlRpcRequest request = new XmlRpcRequest();
33 bool done = false;
34
35 lock (this)
36 {
37 Reset();
38 while (!done && reader.Read())
39 {
40 DeserializeNode(reader); // Parent parse...
41 switch (reader.NodeType)
42 {
43 case XmlNodeType.EndElement:
44 switch (reader.Name)
45 {
46 case METHOD_NAME:
47 request.MethodName = _text;
48 break;
49 case METHOD_CALL:
50 done = true;
51 break;
52 case PARAM:
53 request.Params.Add(_value);
54 _text = null;
55 break;
56 }
57 break;
58 }
59 }
60 }
61 return request;
62 }
63 }
64}
diff --git a/Common/XmlRpcCS/XmlRpcRequestSerializer.cs b/Common/XmlRpcCS/XmlRpcRequestSerializer.cs
new file mode 100644
index 0000000..8099bdb
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcRequestSerializer.cs
@@ -0,0 +1,51 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.Xml;
6 using System.IO;
7
8 /// <summary>Class responsible for serializing an XML-RPC request.</summary>
9 /// <remarks>This class handles the request envelope, depending on <c>XmlRpcSerializer</c>
10 /// to serialize the payload.</remarks>
11 /// <seealso cref="XmlRpcSerializer"/>
12 public class XmlRpcRequestSerializer : XmlRpcSerializer
13 {
14 static private XmlRpcRequestSerializer _singleton;
15 /// <summary>A static singleton instance of this deserializer.</summary>
16 static public XmlRpcRequestSerializer Singleton
17 {
18 get
19 {
20 if (_singleton == null)
21 _singleton = new XmlRpcRequestSerializer();
22
23 return _singleton;
24 }
25 }
26
27 /// <summary>Serialize the <c>XmlRpcRequest</c> to the output stream.</summary>
28 /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
29 /// <param name="obj">An <c>XmlRpcRequest</c> to serialize.</param>
30 /// <seealso cref="XmlRpcRequest"/>
31 override public void Serialize(XmlTextWriter output, Object obj)
32 {
33 XmlRpcRequest request = (XmlRpcRequest)obj;
34 output.WriteStartDocument();
35 output.WriteStartElement(METHOD_CALL);
36 output.WriteElementString(METHOD_NAME, request.MethodName);
37 output.WriteStartElement(PARAMS);
38 foreach (Object param in request.Params)
39 {
40 output.WriteStartElement(PARAM);
41 output.WriteStartElement(VALUE);
42 SerializeObject(output, param);
43 output.WriteEndElement();
44 output.WriteEndElement();
45 }
46
47 output.WriteEndElement();
48 output.WriteEndElement();
49 }
50 }
51}
diff --git a/Common/XmlRpcCS/XmlRpcResponder.cs b/Common/XmlRpcCS/XmlRpcResponder.cs
new file mode 100644
index 0000000..0412568
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcResponder.cs
@@ -0,0 +1,98 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Xml;
5 using System.Net.Sockets;
6
7 /// <summary>The class is a container of the context of an XML-RPC dialog on the server side.</summary>
8 /// <remarks>Instances of this class maintain the context for an individual XML-RPC server
9 /// side dialog. Namely they manage an inbound deserializer and an outbound serializer. </remarks>
10 public class XmlRpcResponder
11 {
12 private XmlRpcRequestDeserializer _deserializer = new XmlRpcRequestDeserializer();
13 private XmlRpcResponseSerializer _serializer = new XmlRpcResponseSerializer();
14 private XmlRpcServer _server;
15 private TcpClient _client;
16 private SimpleHttpRequest _httpReq;
17
18 /// <summary>The SimpleHttpRequest based on the TcpClient.</summary>
19 public SimpleHttpRequest HttpReq
20 {
21 get { return _httpReq; }
22 }
23
24 /// <summary>Basic constructor.</summary>
25 /// <param name="server">XmlRpcServer that this XmlRpcResponder services.</param>
26 /// <param name="client">TcpClient with the connection.</param>
27 public XmlRpcResponder(XmlRpcServer server, TcpClient client)
28 {
29 _server = server;
30 _client = client;
31 _httpReq = new SimpleHttpRequest(_client);
32 }
33
34 /// <summary>Call close to insure proper shutdown.</summary>
35 ~XmlRpcResponder()
36 {
37 Close();
38 }
39
40 ///<summary>Respond using this responders HttpReq.</summary>
41 public void Respond()
42 {
43 Respond(HttpReq);
44 }
45
46 /// <summary>Handle an HTTP request containing an XML-RPC request.</summary>
47 /// <remarks>This method deserializes the XML-RPC request, invokes the
48 /// described method, serializes the response (or fault) and sends the XML-RPC response
49 /// back as a valid HTTP page.
50 /// </remarks>
51 /// <param name="httpReq"><c>SimpleHttpRequest</c> containing the request.</param>
52 public void Respond(SimpleHttpRequest httpReq)
53 {
54 XmlRpcRequest xmlRpcReq = (XmlRpcRequest)_deserializer.Deserialize(httpReq.Input);
55 XmlRpcResponse xmlRpcResp = new XmlRpcResponse();
56
57 try
58 {
59 xmlRpcResp.Value = _server.Invoke(xmlRpcReq);
60 }
61 catch (XmlRpcException e)
62 {
63 xmlRpcResp.SetFault(e.FaultCode, e.FaultString);
64 }
65 catch (Exception e2)
66 {
67 xmlRpcResp.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR,
68 XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
69 }
70
71 if (Logger.Delegate != null)
72 Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);
73
74 XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
75 httpReq.Output.Flush();
76 XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
77 _serializer.Serialize(xml, xmlRpcResp);
78 xml.Flush();
79 httpReq.Output.Flush();
80 }
81
82 ///<summary>Close all contained resources, both the HttpReq and client.</summary>
83 public void Close()
84 {
85 if (_httpReq != null)
86 {
87 _httpReq.Close();
88 _httpReq = null;
89 }
90
91 if (_client != null)
92 {
93 _client.Close();
94 _client = null;
95 }
96 }
97 }
98}
diff --git a/Common/XmlRpcCS/XmlRpcResponse.cs b/Common/XmlRpcCS/XmlRpcResponse.cs
new file mode 100644
index 0000000..8ff8354
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcResponse.cs
@@ -0,0 +1,85 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Xml;
7
8 /// <summary>Class designed to represent an XML-RPC response.</summary>
9 public class XmlRpcResponse
10 {
11 private Object _value;
12 /// <summary><c>bool</c> indicating if this response represents a fault.</summary>
13 public bool IsFault;
14
15 /// <summary>Basic constructor</summary>
16 public XmlRpcResponse()
17 {
18 Value = null;
19 IsFault = false;
20 }
21
22 /// <summary>Constructor for a fault.</summary>
23 /// <param name="code"><c>int</c> the numeric faultCode value.</param>
24 /// <param name="message"><c>String</c> the faultString value.</param>
25 public XmlRpcResponse(int code, String message)
26 : this()
27 {
28 SetFault(code, message);
29 }
30
31 /// <summary>The data value of the response, may be fault data.</summary>
32 public Object Value
33 {
34 get { return _value; }
35 set
36 {
37 IsFault = false;
38 _value = value;
39 }
40 }
41
42 /// <summary>The faultCode if this is a fault.</summary>
43 public int FaultCode
44 {
45 get
46 {
47 if (!IsFault)
48 return 0;
49 else
50 return (int)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_CODE];
51 }
52 }
53
54 /// <summary>The faultString if this is a fault.</summary>
55 public String FaultString
56 {
57 get
58 {
59 if (!IsFault)
60 return "";
61 else
62 return (String)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_STRING];
63 }
64 }
65
66 /// <summary>Set this response to be a fault.</summary>
67 /// <param name="code"><c>int</c> the numeric faultCode value.</param>
68 /// <param name="message"><c>String</c> the faultString value.</param>
69 public void SetFault(int code, String message)
70 {
71 Hashtable fault = new Hashtable();
72 fault.Add("faultCode", code);
73 fault.Add("faultString", message);
74 Value = fault;
75 IsFault = true;
76 }
77
78 /// <summary>Form a useful string representation of the object, in this case the XML response.</summary>
79 /// <returns><c>String</c> The XML serialized XML-RPC response.</returns>
80 override public String ToString()
81 {
82 return XmlRpcResponseSerializer.Singleton.Serialize(this);
83 }
84 }
85}
diff --git a/Common/XmlRpcCS/XmlRpcResponseDeserializer.cs b/Common/XmlRpcCS/XmlRpcResponseDeserializer.cs
new file mode 100644
index 0000000..032d8a3
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcResponseDeserializer.cs
@@ -0,0 +1,65 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Xml;
7
8 /// <summary>Class to deserialize XML data representing a response.</summary>
9 public class XmlRpcResponseDeserializer : XmlRpcDeserializer
10 {
11 static private XmlRpcResponseDeserializer _singleton;
12 /// <summary>A static singleton instance of this deserializer.</summary>
13 [Obsolete("This object is now thread safe, just use an instance.", false)]
14 static public XmlRpcResponseDeserializer Singleton
15 {
16 get
17 {
18 if (_singleton == null)
19 _singleton = new XmlRpcResponseDeserializer();
20
21 return _singleton;
22 }
23 }
24
25 /// <summary>Static method that parses XML data into a response using the Singleton.</summary>
26 /// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param>
27 /// <returns><c>XmlRpcResponse</c> object resulting from the parse.</returns>
28 override public Object Deserialize(TextReader xmlData)
29 {
30 XmlTextReader reader = new XmlTextReader(xmlData);
31 XmlRpcResponse response = new XmlRpcResponse();
32 bool done = false;
33
34 lock (this)
35 {
36 Reset();
37
38 while (!done && reader.Read())
39 {
40 DeserializeNode(reader); // Parent parse...
41 switch (reader.NodeType)
42 {
43 case XmlNodeType.EndElement:
44 switch (reader.Name)
45 {
46 case FAULT:
47 response.Value = _value;
48 response.IsFault = true;
49 break;
50 case PARAM:
51 response.Value = _value;
52 _value = null;
53 _text = null;
54 break;
55 }
56 break;
57 default:
58 break;
59 }
60 }
61 }
62 return response;
63 }
64 }
65}
diff --git a/Common/XmlRpcCS/XmlRpcResponseSerializer.cs b/Common/XmlRpcCS/XmlRpcResponseSerializer.cs
new file mode 100644
index 0000000..72ca568
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcResponseSerializer.cs
@@ -0,0 +1,57 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.Xml;
6
7 /// <summary>Class responsible for serializing an XML-RPC response.</summary>
8 /// <remarks>This class handles the response envelope, depending on XmlRpcSerializer
9 /// to serialize the payload.</remarks>
10 /// <seealso cref="XmlRpcSerializer"/>
11 public class XmlRpcResponseSerializer : XmlRpcSerializer
12 {
13 static private XmlRpcResponseSerializer _singleton;
14 /// <summary>A static singleton instance of this deserializer.</summary>
15 static public XmlRpcResponseSerializer Singleton
16 {
17 get
18 {
19 if (_singleton == null)
20 _singleton = new XmlRpcResponseSerializer();
21
22 return _singleton;
23 }
24 }
25
26 /// <summary>Serialize the <c>XmlRpcResponse</c> to the output stream.</summary>
27 /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
28 /// <param name="obj">An <c>Object</c> to serialize.</param>
29 /// <seealso cref="XmlRpcResponse"/>
30 override public void Serialize(XmlTextWriter output, Object obj)
31 {
32 XmlRpcResponse response = (XmlRpcResponse)obj;
33
34 output.WriteStartDocument();
35 output.WriteStartElement(METHOD_RESPONSE);
36
37 if (response.IsFault)
38 output.WriteStartElement(FAULT);
39 else
40 {
41 output.WriteStartElement(PARAMS);
42 output.WriteStartElement(PARAM);
43 }
44
45 output.WriteStartElement(VALUE);
46
47 SerializeObject(output, response.Value);
48
49 output.WriteEndElement();
50
51 output.WriteEndElement();
52 if (!response.IsFault)
53 output.WriteEndElement();
54 output.WriteEndElement();
55 }
56 }
57}
diff --git a/Common/XmlRpcCS/XmlRpcSerializer.cs b/Common/XmlRpcCS/XmlRpcSerializer.cs
new file mode 100644
index 0000000..0643d38
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcSerializer.cs
@@ -0,0 +1,109 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Xml;
7
8 /// <summary>Base class of classes serializing data to XML-RPC's XML format.</summary>
9 /// <remarks>This class handles the basic type conversions like Integer to &lt;i4&gt;. </remarks>
10 /// <seealso cref="XmlRpcXmlTokens"/>
11 public class XmlRpcSerializer : XmlRpcXmlTokens
12 {
13
14 /// <summary>Serialize the <c>XmlRpcRequest</c> to the output stream.</summary>
15 /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
16 /// <param name="obj">An <c>Object</c> to serialize.</param>
17 /// <seealso cref="XmlRpcRequest"/>
18 virtual public void Serialize(XmlTextWriter output, Object obj)
19 {
20 }
21
22 /// <summary>Serialize the <c>XmlRpcRequest</c> to a String.</summary>
23 /// <remarks>Note this may represent a real memory hog for a large request.</remarks>
24 /// <param name="obj">An <c>Object</c> to serialize.</param>
25 /// <returns><c>String</c> containing XML-RPC representation of the request.</returns>
26 /// <seealso cref="XmlRpcRequest"/>
27 public String Serialize(Object obj)
28 {
29 StringWriter strBuf = new StringWriter();
30 XmlTextWriter xml = new XmlTextWriter(strBuf);
31 xml.Formatting = Formatting.Indented;
32 xml.Indentation = 4;
33 Serialize(xml, obj);
34 xml.Flush();
35 String returns = strBuf.ToString();
36 xml.Close();
37 return returns;
38 }
39
40 /// <remarks>Serialize the object to the output stream.</remarks>
41 /// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
42 /// <param name="obj">An <c>Object</c> to serialize.</param>
43 public void SerializeObject(XmlTextWriter output, Object obj)
44 {
45 if (obj == null)
46 return;
47
48 if (obj is byte[])
49 {
50 byte[] ba = (byte[])obj;
51 output.WriteStartElement(BASE64);
52 output.WriteBase64(ba, 0, ba.Length);
53 output.WriteEndElement();
54 }
55 else if (obj is String)
56 {
57 output.WriteElementString(STRING, obj.ToString());
58 }
59 else if (obj is Int32)
60 {
61 output.WriteElementString(INT, obj.ToString());
62 }
63 else if (obj is DateTime)
64 {
65 output.WriteElementString(DATETIME, ((DateTime)obj).ToString(ISO_DATETIME));
66 }
67 else if (obj is Double)
68 {
69 output.WriteElementString(DOUBLE, obj.ToString());
70 }
71 else if (obj is Boolean)
72 {
73 output.WriteElementString(BOOLEAN, ((((Boolean)obj) == true) ? "1" : "0"));
74 }
75 else if (obj is IList)
76 {
77 output.WriteStartElement(ARRAY);
78 output.WriteStartElement(DATA);
79 if (((ArrayList)obj).Count > 0)
80 {
81 foreach (Object member in ((IList)obj))
82 {
83 output.WriteStartElement(VALUE);
84 SerializeObject(output, member);
85 output.WriteEndElement();
86 }
87 }
88 output.WriteEndElement();
89 output.WriteEndElement();
90 }
91 else if (obj is IDictionary)
92 {
93 IDictionary h = (IDictionary)obj;
94 output.WriteStartElement(STRUCT);
95 foreach (String key in h.Keys)
96 {
97 output.WriteStartElement(MEMBER);
98 output.WriteElementString(NAME, key);
99 output.WriteStartElement(VALUE);
100 SerializeObject(output, h[key]);
101 output.WriteEndElement();
102 output.WriteEndElement();
103 }
104 output.WriteEndElement();
105 }
106
107 }
108 }
109}
diff --git a/Common/XmlRpcCS/XmlRpcServer.cs b/Common/XmlRpcCS/XmlRpcServer.cs
new file mode 100644
index 0000000..1c226c1
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcServer.cs
@@ -0,0 +1,239 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.IO;
6 using System.Net;
7 using System.Net.Sockets;
8 using System.Text;
9 using System.Threading;
10 using System.Xml;
11
12 /// <summary>A restricted HTTP server for use with XML-RPC.</summary>
13 /// <remarks>It only handles POST requests, and only POSTs representing XML-RPC calls.
14 /// In addition to dispatching requests it also provides a registry for request handlers.
15 /// </remarks>
16 public class XmlRpcServer : IEnumerable
17 {
18#pragma warning disable 0414 // disable "private field assigned but not used"
19 const int RESPONDER_COUNT = 10;
20 private TcpListener _myListener;
21 private int _port;
22 private IPAddress _address;
23 private IDictionary _handlers;
24 private XmlRpcSystemObject _system;
25 private WaitCallback _wc;
26#pragma warning restore 0414
27
28 ///<summary>Constructor with port and address.</summary>
29 ///<remarks>This constructor sets up a TcpListener listening on the
30 ///given port and address. It also calls a Thread on the method StartListen().</remarks>
31 ///<param name="address"><c>IPAddress</c> value of the address to listen on.</param>
32 ///<param name="port"><c>Int</c> value of the port to listen on.</param>
33 public XmlRpcServer(IPAddress address, int port)
34 {
35 _port = port;
36 _address = address;
37 _handlers = new Hashtable();
38 _system = new XmlRpcSystemObject(this);
39 _wc = new WaitCallback(WaitCallback);
40 }
41
42 ///<summary>Basic constructor.</summary>
43 ///<remarks>This constructor sets up a TcpListener listening on the
44 ///given port. It also calls a Thread on the method StartListen(). IPAddress.Any
45 ///is assumed as the address here.</remarks>
46 ///<param name="port"><c>Int</c> value of the port to listen on.</param>
47 public XmlRpcServer(int port) : this(IPAddress.Any, port) { }
48
49 /// <summary>Start the server.</summary>
50 public void Start()
51 {
52 try
53 {
54 Stop();
55 //start listing on the given port
56 // IPAddress addr = IPAddress.Parse("127.0.0.1");
57 lock (this)
58 {
59 _myListener = new TcpListener(IPAddress.Any, _port);
60 _myListener.Start();
61 //start the thread which calls the method 'StartListen'
62 Thread th = new Thread(new ThreadStart(StartListen));
63 th.Start();
64 }
65 }
66 catch (Exception e)
67 {
68 Logger.WriteEntry("An Exception Occurred while Listening :" + e.ToString(), LogLevel.Error);
69 }
70 }
71
72 /// <summary>Stop the server.</summary>
73 public void Stop()
74 {
75 try
76 {
77 if (_myListener != null)
78 {
79 lock (this)
80 {
81 _myListener.Stop();
82 _myListener = null;
83 }
84 }
85 }
86 catch (Exception e)
87 {
88 Logger.WriteEntry("An Exception Occurred while stopping :" +
89 e.ToString(), LogLevel.Error);
90 }
91 }
92
93 /// <summary>Get an enumeration of my XML-RPC handlers.</summary>
94 /// <returns><c>IEnumerable</c> the handler enumeration.</returns>
95 public IEnumerator GetEnumerator()
96 {
97 return _handlers.GetEnumerator();
98 }
99
100 /// <summary>Retrieve a handler by name.</summary>
101 /// <param name="name"><c>String</c> naming a handler</param>
102 /// <returns><c>Object</c> that is the handler.</returns>
103 public Object this[String name]
104 {
105 get { return _handlers[name]; }
106 }
107
108 ///<summary>
109 ///This method Accepts new connections and dispatches them when appropriate.
110 ///</summary>
111 public void StartListen()
112 {
113 while (true && _myListener != null)
114 {
115 //Accept a new connection
116 XmlRpcResponder responder = new XmlRpcResponder(this, _myListener.AcceptTcpClient());
117 ThreadPool.QueueUserWorkItem(_wc, responder);
118 }
119 }
120
121
122 ///<summary>
123 ///Add an XML-RPC handler object by name.
124 ///</summary>
125 ///<param name="name"><c>String</c> XML-RPC dispatch name of this object.</param>
126 ///<param name="obj"><c>Object</c> The object that is the XML-RPC handler.</param>
127 public void Add(String name, Object obj)
128 {
129 _handlers.Add(name, obj);
130 }
131
132 ///<summary>Return a C# object.method name for and XML-RPC object.method name pair.</summary>
133 ///<param name="methodName">The XML-RPC object.method.</param>
134 ///<returns><c>String</c> of form object.method for the underlying C# method.</returns>
135 public String MethodName(String methodName)
136 {
137 int dotAt = methodName.LastIndexOf('.');
138
139 if (dotAt == -1)
140 {
141 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
142 XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Bad method name " + methodName);
143 }
144
145 String objectName = methodName.Substring(0, dotAt);
146 Object target = _handlers[objectName];
147
148 if (target == null)
149 {
150 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
151 XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Object " + objectName + " not found");
152 }
153
154 return target.GetType().FullName + "." + methodName.Substring(dotAt + 1);
155 }
156
157 ///<summary>Invoke a method described in a request.</summary>
158 ///<param name="req"><c>XmlRpcRequest</c> containing a method descriptions.</param>
159 /// <seealso cref="XmlRpcSystemObject.Invoke"/>
160 /// <seealso cref="XmlRpcServer.Invoke(String,String,IList)"/>
161 public Object Invoke(XmlRpcRequest req)
162 {
163 return Invoke(req.MethodNameObject, req.MethodNameMethod, req.Params);
164 }
165
166 ///<summary>Invoke a method on a named handler.</summary>
167 ///<param name="objectName"><c>String</c> The name of the handler.</param>
168 ///<param name="methodName"><c>String</c> The name of the method to invoke on the handler.</param>
169 ///<param name="parameters"><c>IList</c> The parameters to invoke the method with.</param>
170 /// <seealso cref="XmlRpcSystemObject.Invoke"/>
171 public Object Invoke(String objectName, String methodName, IList parameters)
172 {
173 Object target = _handlers[objectName];
174
175 if (target == null)
176 {
177 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
178 XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Object " + objectName + " not found");
179 }
180
181 return XmlRpcSystemObject.Invoke(target, methodName, parameters);
182 }
183
184 /// <summary>The method the thread pool invokes when a thread is available to handle an HTTP request.</summary>
185 /// <param name="responder">TcpClient from the socket accept.</param>
186 public void WaitCallback(object responder)
187 {
188 XmlRpcResponder resp = (XmlRpcResponder)responder;
189
190 if (resp.HttpReq.HttpMethod == "POST")
191 {
192 try
193 {
194 resp.Respond();
195 }
196 catch (Exception e)
197 {
198 Logger.WriteEntry("Failed on post: " + e, LogLevel.Error);
199 }
200 }
201 else
202 {
203 Logger.WriteEntry("Only POST methods are supported: " + resp.HttpReq.HttpMethod +
204 " ignored", LogLevel.Error);
205 }
206
207 resp.Close();
208 }
209
210 /// <summary>
211 /// This function send the Header Information to the client (Browser)
212 /// </summary>
213 /// <param name="sHttpVersion">HTTP Version</param>
214 /// <param name="sMIMEHeader">Mime Type</param>
215 /// <param name="iTotBytes">Total Bytes to be sent in the body</param>
216 /// <param name="sStatusCode"></param>
217 /// <param name="output">Socket reference</param>
218 static public void HttpHeader(string sHttpVersion, string sMIMEHeader, long iTotBytes, string sStatusCode, TextWriter output)
219 {
220 String sBuffer = "";
221
222 // if Mime type is not provided set default to text/html
223 if (sMIMEHeader.Length == 0)
224 {
225 sMIMEHeader = "text/html"; // Default Mime Type is text/html
226 }
227
228 sBuffer += sHttpVersion + sStatusCode + "\r\n";
229 sBuffer += "Connection: close\r\n";
230 if (iTotBytes > 0)
231 sBuffer += "Content-Length: " + iTotBytes + "\r\n";
232 sBuffer += "Server: XmlRpcServer \r\n";
233 sBuffer += "Content-Type: " + sMIMEHeader + "\r\n";
234 sBuffer += "\r\n";
235
236 output.Write(sBuffer);
237 }
238 }
239}
diff --git a/Common/XmlRpcCS/XmlRpcSystemObject.cs b/Common/XmlRpcCS/XmlRpcSystemObject.cs
new file mode 100644
index 0000000..5f79951
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcSystemObject.cs
@@ -0,0 +1,252 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4 using System.Collections;
5 using System.Reflection;
6
7 /// <summary> XML-RPC System object implementation of extended specifications.</summary>
8 [XmlRpcExposed]
9 public class XmlRpcSystemObject
10 {
11 private XmlRpcServer _server;
12 static private IDictionary _methodHelp = new Hashtable();
13
14 /// <summary>Static <c>IDictionary</c> to hold mappings of method name to associated documentation String</summary>
15 static public IDictionary MethodHelp
16 {
17 get { return _methodHelp; }
18 }
19
20 /// <summary>Constructor.</summary>
21 /// <param name="server"><c>XmlRpcServer</c> server to be the system object for.</param>
22 public XmlRpcSystemObject(XmlRpcServer server)
23 {
24 _server = server;
25 server.Add("system", this);
26 _methodHelp.Add(this.GetType().FullName + ".methodHelp", "Return a string description.");
27 }
28
29 /// <summary>Invoke a method on a given object.</summary>
30 /// <remarks>Using reflection, and respecting the <c>XmlRpcExposed</c> attribute,
31 /// invoke the <paramref>methodName</paramref> method on the <paramref>target</paramref>
32 /// instance with the <paramref>parameters</paramref> provided. All this packages other <c>Invoke</c> methods
33 /// end up calling this.</remarks>
34 /// <returns><c>Object</c> the value the invoked method returns.</returns>
35 /// <exception cref="XmlRpcException">If method does not exist, is not exposed, parameters invalid, or invocation
36 /// results in an exception. Note, the <c>XmlRpcException.Code</c> will indicate cause.</exception>
37 static public Object Invoke(Object target, String methodName, IList parameters)
38 {
39 if (target == null)
40 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
41 XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Invalid target object.");
42
43 Type type = target.GetType();
44 MethodInfo method = type.GetMethod(methodName);
45
46 try
47 {
48 if (!XmlRpcExposedAttribute.ExposedMethod(target, methodName))
49 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
50 XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Method " + methodName + " is not exposed.");
51 }
52 catch (MissingMethodException me)
53 {
54 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
55 XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": " + me.Message);
56 }
57
58 Object[] args = new Object[parameters.Count];
59
60 int index = 0;
61 foreach (Object arg in parameters)
62 {
63 args[index] = arg;
64 index++;
65 }
66
67 try
68 {
69 Object retValue = method.Invoke(target, args);
70 if (retValue == null)
71 throw new XmlRpcException(XmlRpcErrorCodes.APPLICATION_ERROR,
72 XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": Method returned NULL.");
73 return retValue;
74 }
75 catch (XmlRpcException e)
76 {
77 throw e;
78 }
79 catch (ArgumentException ae)
80 {
81 Logger.WriteEntry(XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": " + ae.Message,
82 LogLevel.Information);
83 String call = methodName + "( ";
84 foreach (Object o in args)
85 {
86 call += o.GetType().Name;
87 call += " ";
88 }
89 call += ")";
90 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_PARAMS,
91 XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": Arguement type mismatch invoking " + call);
92 }
93 catch (TargetParameterCountException tpce)
94 {
95 Logger.WriteEntry(XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": " + tpce.Message,
96 LogLevel.Information);
97 throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_PARAMS,
98 XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": Arguement count mismatch invoking " + methodName);
99 }
100 catch (TargetInvocationException tie)
101 {
102 throw new XmlRpcException(XmlRpcErrorCodes.APPLICATION_ERROR,
103 XmlRpcErrorCodes.APPLICATION_ERROR_MSG + " Invoked method " + methodName + ": " + tie.Message);
104 }
105 }
106
107 /// <summary>List methods available on all handlers of this server.</summary>
108 /// <returns><c>IList</c> An array of <c>Strings</c>, each <c>String</c> will have form "object.method".</returns>
109 [XmlRpcExposed]
110 public IList listMethods()
111 {
112 IList methods = new ArrayList();
113 Boolean considerExposure;
114
115 foreach (DictionaryEntry handlerEntry in _server)
116 {
117 considerExposure = XmlRpcExposedAttribute.IsExposed(handlerEntry.Value.GetType());
118
119 foreach (MemberInfo mi in handlerEntry.Value.GetType().GetMembers())
120 {
121 if (mi.MemberType != MemberTypes.Method)
122 continue;
123
124 if (!((MethodInfo)mi).IsPublic)
125 continue;
126
127 if (considerExposure && !XmlRpcExposedAttribute.IsExposed(mi))
128 continue;
129
130 methods.Add(handlerEntry.Key + "." + mi.Name);
131 }
132 }
133
134 return methods;
135 }
136
137 /// <summary>Given a method name return the possible signatures for it.</summary>
138 /// <param name="name"><c>String</c> The object.method name to look up.</param>
139 /// <returns><c>IList</c> Of arrays of signatures.</returns>
140 [XmlRpcExposed]
141 public IList methodSignature(String name)
142 {
143 IList signatures = new ArrayList();
144 int index = name.IndexOf('.');
145
146 if (index < 0)
147 return signatures;
148
149 String oName = name.Substring(0, index);
150 Object obj = _server[oName];
151
152 if (obj == null)
153 return signatures;
154
155 MemberInfo[] mi = obj.GetType().GetMember(name.Substring(index + 1));
156
157 if (mi == null || mi.Length != 1) // for now we want a single signature
158 return signatures;
159
160 MethodInfo method;
161
162 try
163 {
164 method = (MethodInfo)mi[0];
165 }
166 catch (Exception e)
167 {
168 Logger.WriteEntry("Attempted methodSignature call on " + mi[0] + " caused: " + e,
169 LogLevel.Information);
170 return signatures;
171 }
172
173 if (!method.IsPublic)
174 return signatures;
175
176 IList signature = new ArrayList();
177 signature.Add(method.ReturnType.Name);
178
179 foreach (ParameterInfo param in method.GetParameters())
180 {
181 signature.Add(param.ParameterType.Name);
182 }
183
184
185 signatures.Add(signature);
186
187 return signatures;
188 }
189
190 /// <summary>Help for given method signature. Not implemented yet.</summary>
191 /// <param name="name"><c>String</c> The object.method name to look up.</param>
192 /// <returns><c>String</c> help text. Rich HTML text.</returns>
193 [XmlRpcExposed]
194 public String methodHelp(String name)
195 {
196 String help = null;
197
198 try
199 {
200 help = (String)_methodHelp[_server.MethodName(name)];
201 }
202 catch (XmlRpcException e)
203 {
204 throw e;
205 }
206 catch (Exception) { /* ignored */ };
207
208 if (help == null)
209 help = "No help available for: " + name;
210
211 return help;
212 }
213
214 /// <summary>Boxcarring support method.</summary>
215 /// <param name="calls"><c>IList</c> of calls</param>
216 /// <returns><c>ArrayList</c> of results/faults.</returns>
217 [XmlRpcExposed]
218 public IList multiCall(IList calls)
219 {
220 IList responses = new ArrayList();
221 XmlRpcResponse fault = new XmlRpcResponse();
222
223 foreach (IDictionary call in calls)
224 {
225 try
226 {
227 XmlRpcRequest req = new XmlRpcRequest((String)call[XmlRpcXmlTokens.METHOD_NAME],
228 (ArrayList)call[XmlRpcXmlTokens.PARAMS]);
229 Object results = _server.Invoke(req);
230 IList response = new ArrayList();
231 response.Add(results);
232 responses.Add(response);
233 }
234 catch (XmlRpcException e)
235 {
236 fault.SetFault(e.FaultCode, e.FaultString);
237 responses.Add(fault.Value);
238 }
239 catch (Exception e2)
240 {
241 fault.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR,
242 XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
243 responses.Add(fault.Value);
244 }
245 }
246
247 return responses;
248 }
249
250 }
251}
252
diff --git a/Common/XmlRpcCS/XmlRpcXmlTokens.cs b/Common/XmlRpcCS/XmlRpcXmlTokens.cs
new file mode 100644
index 0000000..50788bd
--- /dev/null
+++ b/Common/XmlRpcCS/XmlRpcXmlTokens.cs
@@ -0,0 +1,76 @@
1namespace Nwc.XmlRpc
2{
3 using System;
4
5 /// <summary>Class collecting <c>String</c> tokens that are part of XML-RPC files.</summary>
6 public class XmlRpcXmlTokens
7 {
8 /// <summary>C# formatting string to describe an ISO 8601 date.</summary>
9 public const String ISO_DATETIME = "yyyyMMdd\\THH\\:mm\\:ss";
10 /// <summary>Base64 field indicator.</summary>
11 /// <remarks>Corresponds to the &lt;base64&gt; tag.</remarks>
12 public const String BASE64 = "base64";
13 /// <summary>String field indicator.</summary>
14 /// <remarks>Corresponds to the &lt;string&gt; tag.</remarks>
15 public const String STRING = "string";
16 /// <summary>Integer field integer.</summary>
17 /// <remarks>Corresponds to the &lt;i4&gt; tag.</remarks>
18 public const String INT = "i4";
19 /// <summary>Alternate integer field indicator.</summary>
20 /// <remarks>Corresponds to the &lt;int&gt; tag.</remarks>
21 public const String ALT_INT = "int";
22 /// <summary>Date field indicator.</summary>
23 /// <remarks>Corresponds to the &lt;dateTime.iso8601&gt; tag.</remarks>
24 public const String DATETIME = "dateTime.iso8601";
25 /// <summary>Boolean field indicator.</summary>
26 /// <remarks>Corresponds to the &lt;boolean&gt; tag.</remarks>
27 public const String BOOLEAN = "boolean";
28 /// <summary>Value token.</summary>
29 /// <remarks>Corresponds to the &lt;value&gt; tag.</remarks>
30 public const String VALUE = "value";
31 /// <summary>Name token.</summary>
32 /// <remarks>Corresponds to the &lt;name&gt; tag.</remarks>
33 public const String NAME = "name";
34 /// <summary>Array field indicator..</summary>
35 /// <remarks>Corresponds to the &lt;array&gt; tag.</remarks>
36 public const String ARRAY = "array";
37 /// <summary>Data token.</summary>
38 /// <remarks>Corresponds to the &lt;data&gt; tag.</remarks>
39 public const String DATA = "data";
40 /// <summary>Member token.</summary>
41 /// <remarks>Corresponds to the &lt;member&gt; tag.</remarks>
42 public const String MEMBER = "member";
43 /// <summary>Stuct field indicator.</summary>
44 /// <remarks>Corresponds to the &lt;struct&gt; tag.</remarks>
45 public const String STRUCT = "struct";
46 /// <summary>Double field indicator.</summary>
47 /// <remarks>Corresponds to the &lt;double&gt; tag.</remarks>
48 public const String DOUBLE = "double";
49 /// <summary>Param token.</summary>
50 /// <remarks>Corresponds to the &lt;param&gt; tag.</remarks>
51 public const String PARAM = "param";
52 /// <summary>Params token.</summary>
53 /// <remarks>Corresponds to the &lt;params&gt; tag.</remarks>
54 public const String PARAMS = "params";
55 /// <summary>MethodCall token.</summary>
56 /// <remarks>Corresponds to the &lt;methodCall&gt; tag.</remarks>
57 public const String METHOD_CALL = "methodCall";
58 /// <summary>MethodName token.</summary>
59 /// <remarks>Corresponds to the &lt;methodName&gt; tag.</remarks>
60 public const String METHOD_NAME = "methodName";
61 /// <summary>MethodResponse token</summary>
62 /// <remarks>Corresponds to the &lt;methodResponse&gt; tag.</remarks>
63 public const String METHOD_RESPONSE = "methodResponse";
64 /// <summary>Fault response token.</summary>
65 /// <remarks>Corresponds to the &lt;fault&gt; tag.</remarks>
66 public const String FAULT = "fault";
67 /// <summary>FaultCode token.</summary>
68 /// <remarks>Corresponds to the &lt;faultCode&gt; tag.</remarks>
69 public const String FAULT_CODE = "faultCode";
70 /// <summary>FaultString token.</summary>
71 /// <remarks>Corresponds to the &lt;faultString&gt; tag.</remarks>
72 public const String FAULT_STRING = "faultString";
73 }
74}
75
76