*Moving current, unstable trunk to branch as we revert trunk

zircon
mingchen 2007-06-12 23:22:56 +00:00
commit 3f1d86b4c2
455 changed files with 44712 additions and 6929 deletions

30
CONTRIBUTORS.txt Normal file
View File

@ -0,0 +1,30 @@
The following people have contributed to OpenSim (Thankyou for your effort!)
Add your name in here if you have committed to OpenSim
OpenSim Developers
(in order of appearance)
* MW
* Gareth
* AdamZaius
* MingChen
* lbsa71
* Andy-
* MorphW
* CW
This software uses components from the following developers:
* Sleepycat Software (Berkeley DB)
* DB4objects, Inc. (DB4o)
* SQLite (Public Domain)
* XmlRpcCS (http://xmlrpccs.sf.net/)
* MySQL, Inc. (MySQL Connector/NET)
* AGEIA Inc. (PhysX)
* Russel L. Smith (ODE)
* Prebuild ( http://sourceforge.net/projects/dnpb/ )
In addition, we would like to thank:
* The Mono Project
* The NANT Developers
* Microsoft (.NET, MSSQL-Adapters)

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("ServerConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServerConsole")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,213 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
namespace OpenSim.Framework.Console
{
public enum LogPriority : int
{
CRITICAL,
HIGH,
MEDIUM,
NORMAL,
LOW,
VERBOSE,
EXTRAVERBOSE
}
public class ConsoleBase
{
StreamWriter Log;
public conscmd_callback cmdparser;
public string componentname;
private bool m_silent;
public ConsoleBase(string LogFile, string componentname, conscmd_callback cmdparser, bool silent )
{
this.componentname = componentname;
this.cmdparser = cmdparser;
this.m_silent = silent;
System.Console.WriteLine("ServerConsole.cs - creating new local console");
System.Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log = File.AppendText(LogFile);
Log.WriteLine("========================================================================");
Log.WriteLine(componentname + " Started at " + DateTime.Now.ToString());
}
public void Close()
{
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
Log.Close();
}
public void Write(string format, params object[] args)
{
Notice(format,args);
return;
}
public void Warn(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Yellow, format, args);
return;
}
public void Notice(string format, params object[] args)
{
WriteNewLine(ConsoleColor.White, format, args);
return;
}
public void Error(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Red, format, args);
return;
}
public void Verbose(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Gray, format, args);
return;
}
public void Status(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Blue, format, args);
return;
}
private void WriteNewLine(System.ConsoleColor color, string format, params object[] args)
{
Log.WriteLine(format, args);
Log.Flush();
if (!m_silent)
{
System.Console.ForegroundColor = color;
System.Console.WriteLine(format, args);
System.Console.ResetColor();
}
return;
}
public string ReadLine()
{
string TempStr = System.Console.ReadLine();
Log.WriteLine(TempStr);
return TempStr;
}
public int Read()
{
int TempInt = System.Console.Read();
Log.Write((char)TempInt);
return TempInt;
}
// Displays a prompt and waits for the user to enter a string, then returns that string
// Done with no echo and suitable for passwords
public string PasswdPrompt(string prompt)
{
// FIXME: Needs to be better abstracted
Log.WriteLine(prompt);
this.Write(prompt);
ConsoleColor oldfg = System.Console.ForegroundColor;
System.Console.ForegroundColor = System.Console.BackgroundColor;
string temp = System.Console.ReadLine();
System.Console.ForegroundColor = oldfg;
return temp;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public string CmdPrompt(string prompt)
{
this.Write(String.Format("{0}: ", prompt));
return this.ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
public string CmdPrompt(string prompt, string defaultresponse)
{
string temp = CmdPrompt(String.Format( "{0} [{1}]", prompt, defaultresponse ));
if (temp == "")
{
return defaultresponse;
}
else
{
return temp;
}
}
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB)
{
bool itisdone = false;
string temp = CmdPrompt(prompt, defaultresponse);
while (itisdone == false)
{
if ((temp == OptionA) || (temp == OptionB))
{
itisdone = true;
}
else
{
Notice("Valid options are " + OptionA + " or " + OptionB);
temp = CmdPrompt(prompt, defaultresponse);
}
}
return temp;
}
// Runs a command with a number of parameters
public Object RunCmd(string Cmd, string[] cmdparams)
{
cmdparser.RunCmd(Cmd, cmdparams);
return null;
}
// Shows data about something
public void ShowCommands(string ShowWhat)
{
cmdparser.Show(ShowWhat);
}
public void MainConsolePrompt()
{
string[] tempstrarray;
string tempstr = this.CmdPrompt(this.componentname + "# ");
tempstrarray = tempstr.Split(' ');
string cmd = tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray, tempstrarray.Length - 1);
Array.Reverse(tempstrarray);
string[] cmdparams = (string[])tempstrarray;
RunCmd(cmd, cmdparams);
}
}
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Console
{
public interface conscmd_callback
{
void RunCmd(string cmd, string[] cmdparams);
void Show(string ShowWhat);
}
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -8,14 +9,14 @@
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND

View File

@ -3,7 +3,7 @@
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{C8405E1A-EC19-48B6-9C8C-CA03624B9916}</ProjectGuid>
<ProjectGuid>{A7CD0630-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
@ -32,7 +32,7 @@
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\bin\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
@ -50,7 +50,7 @@
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\bin\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
@ -59,7 +59,8 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>\System.dll</HintPath>
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
@ -71,6 +72,9 @@
<Compile Include="ConsoleBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ConsoleCallbacksBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="MainConsole.cs">
<SubType>Code</SubType>
</Compile>

View File

@ -13,6 +13,7 @@
<sources failonempty="true">
<include name="AssemblyInfo.cs" />
<include name="ConsoleBase.cs" />
<include name="ConsoleCallbacksBase.cs" />
<include name="MainConsole.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
@ -23,9 +24,9 @@
<include name="System.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>

View File

@ -0,0 +1,278 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.Inventory
{
public class AgentInventory
{
//Holds the local copy of Inventory info for a agent
public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
public Dictionary<LLUUID, InventoryItem> InventoryItems;
public InventoryFolder InventoryRoot;
public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server
public LLUUID AgentID;
public AvatarWearable[] Wearables;
public AgentInventory()
{
InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
InventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.Initialise();
}
public virtual void Initialise()
{
Wearables = new AvatarWearable[13]; //should be 12 of these
for (int i = 0; i < 13; i++)
{
Wearables[i] = new AvatarWearable();
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public void CreateRootFolder(LLUUID newAgentID, bool createTextures)
{
this.AgentID = newAgentID;
InventoryRoot = new InventoryFolder();
InventoryRoot.FolderID = LLUUID.Random();
InventoryRoot.ParentID = new LLUUID();
InventoryRoot.Version = 1;
InventoryRoot.DefaultType = 8;
InventoryRoot.OwnerID = this.AgentID;
InventoryRoot.FolderName = "My Inventory";
InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
InventoryRoot.OwnerID = this.AgentID;
if (createTextures)
{
this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID);
}
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName)
{
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
this.InventoryFolders.Add(Folder.FolderID, Folder);
return (true);
}
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
{
if (!this.InventoryFolders.ContainsKey(folderID))
{
Console.WriteLine("creating new folder called " + folderName + " in agents inventory");
InventoryFolder Folder = new InventoryFolder();
Folder.FolderID = folderID;
Folder.OwnerID = this.AgentID;
Folder.DefaultType = type;
Folder.FolderName = folderName;
Folder.ParentID = parent;
this.InventoryFolders.Add(Folder.FolderID, Folder);
}
return (true);
}
public bool HasFolder(LLUUID folderID)
{
if (this.InventoryFolders.ContainsKey(folderID))
{
return true;
}
return false;
}
public LLUUID GetFolderID(string folderName)
{
foreach (InventoryFolder inv in this.InventoryFolders.Values)
{
if (inv.FolderName == folderName)
{
return inv.FolderID;
}
}
return LLUUID.Zero;
}
public bool UpdateItemAsset(LLUUID itemID, AssetBase asset)
{
if(this.InventoryItems.ContainsKey(itemID))
{
InventoryItem Item = this.InventoryItems[itemID];
Item.AssetID = asset.FullID;
Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated());
//TODO need to update the rest of the info
}
return true;
}
public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet)
{
Console.WriteLine("updating inventory item details");
if (this.InventoryItems.ContainsKey(itemID))
{
Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name));
InventoryItem Item = this.InventoryItems[itemID];
Item.Name = Util.FieldToString(packet.Name);
Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated());
//TODO need to update the rest of the info
}
return true;
}
public LLUUID AddToInventory(LLUUID folderID, AssetBase asset)
{
if (this.InventoryFolders.ContainsKey(folderID))
{
LLUUID NewItemID = LLUUID.Random();
InventoryItem Item = new InventoryItem();
Item.FolderID = folderID;
Item.OwnerID = AgentID;
Item.AssetID = asset.FullID;
Item.ItemID = NewItemID;
Item.Type = asset.Type;
Item.Name = asset.Name;
Item.Description = asset.Description;
Item.InvType = asset.InvType;
this.InventoryItems.Add(Item.ItemID, Item);
InventoryFolder Folder = InventoryFolders[Item.FolderID];
Folder.Items.Add(Item);
return (Item.ItemID);
}
else
{
return (null);
}
}
public bool DeleteFromInventory(LLUUID itemID)
{
bool res = false;
if (this.InventoryItems.ContainsKey(itemID))
{
InventoryItem item = this.InventoryItems[itemID];
this.InventoryItems.Remove(itemID);
foreach (InventoryFolder fold in InventoryFolders.Values)
{
if (fold.Items.Contains(item))
{
fold.Items.Remove(item);
break;
}
}
res = true;
}
return res;
}
}
public class InventoryFolder
{
public List<InventoryItem> Items;
//public List<InventoryFolder> Subfolders;
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ParentID = LLUUID.Zero;
public string FolderName;
public ushort DefaultType;
public ushort Version;
public InventoryFolder()
{
Items = new List<InventoryItem>();
//Subfolders = new List<InventoryFolder>();
}
}
public class InventoryItem
{
public LLUUID FolderID;
public LLUUID OwnerID;
public LLUUID ItemID;
public LLUUID AssetID;
public LLUUID CreatorID;
public sbyte InvType;
public sbyte Type;
public string Name ="";
public string Description;
public InventoryItem()
{
this.CreatorID = LLUUID.Zero;
}
public string ExportString()
{
string typ = "notecard";
string result = "";
result += "\tinv_object\t0\n\t{\n";
result += "\t\tobj_id\t%s\n";
result += "\t\tparent_id\t"+ ItemID.ToString() +"\n";
result += "\t\ttype\t"+ typ +"\n";
result += "\t\tname\t" + Name+"|\n";
result += "\t}\n";
return result;
}
}
public class AvatarWearable
{
public LLUUID AssetID = new LLUUID("00000000-0000-0000-0000-000000000000");
public LLUUID ItemID = new LLUUID("00000000-0000-0000-0000-000000000000");
public AvatarWearable()
{
}
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Threading;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Utilities
{
public class BlockingQueue<T>
{
private Queue<T> _queue = new Queue<T>();
private object _queueSync = new object();
public void Enqueue(T value)
{
lock (_queueSync)
{
_queue.Enqueue(value);
Monitor.Pulse(_queueSync);
}
}
public T Dequeue()
{
lock (_queueSync)
{
if (_queue.Count < 1)
Monitor.Wait(_queueSync);
return _queue.Dequeue();
}
}
}
}

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -8,14 +9,14 @@
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND

View File

@ -30,7 +30,7 @@ using System.Net.Sockets;
using System.IO;
using System.Threading;
using libsecondlife;
using OpenSim.Framework.Assets;
using OpenSim.Framework.Types;
namespace OpenSim.Framework.Interfaces
{

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Inventory;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Types;
namespace OpenSim.Framework.Interfaces
{
public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
public delegate void RezObject(AssetBase primAsset, LLVector3 pos);
public delegate void ModifyTerrain(byte action, float north, float west);
public delegate void SetAppearance(byte[] texture, AgentSetAppearancePacket.VisualParamBlock[] visualParam);
public delegate void StartAnim(LLUUID animID, int seq);
public delegate void LinkObjects(uint parent, List<uint> children);
public interface IClientAPI
{
event ChatFromViewer OnChatFromViewer;
event RezObject OnRezObject;
event ModifyTerrain OnModifyTerrain;
event SetAppearance OnSetAppearance;
event StartAnim OnStartAnim;
event LinkObjects OnLinkObjects;
LLVector3 StartPos
{
get;
set;
}
void SendAppearance(AvatarWearable[] wearables);
void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID);
}
}

View File

@ -66,8 +66,6 @@ namespace OpenSim.Framework.Interfaces
public abstract void InitConfig(bool sandboxMode);
public abstract void LoadFromGrid();
public abstract float[] LoadWorld();
public abstract void SaveMap(float[] heightmap);
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Interfaces
{
public interface IGenericConfig
{
void LoadData();
string GetAttribute(string attributeName);
bool SetAttribute(string attributeName, string attributeValue);
void Commit();
void Close();
}
}

View File

@ -1,7 +1,7 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,30 +28,37 @@ Copyright (c) OpenSim project, http://osgrid.org/
*/
using System;
using System.Text;
using ServerConsole;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
//using OpenSim.world;
namespace OpenGridServices
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// </summary>
public class UserConsole : conscmd_callback {
public UserConsole() { }
public override void RunCmd(string cmd, string[] cmdparams) {
switch(cmd) {
case "help":
ServerConsole.MainConsole.Instance.WriteLine("shutdown - shutdown the user server (USE CAUTION!)"
);
break;
public abstract class GridConfig
{
public string GridOwner;
public string DefaultStartupMsg;
public string DefaultAssetServer;
public string AssetSendKey;
public string AssetRecvKey;
public string DefaultUserServer;
public string UserSendKey;
public string UserRecvKey;
public string SimSendKey;
public string SimRecvKey;
case "shutdown":
ServerConsole.MainConsole.Instance.Close();
Environment.Exit(0);
break;
}
}
public override void Show(string ShowWhat) {
}
}
public abstract void InitConfig();
}
public interface IGridConfig
{
GridConfig GetConfigObject();
}
}

View File

@ -27,12 +27,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.IO;
using libsecondlife;
using OpenSim;
using OpenSim.Framework.Types;
namespace OpenSim.Framework.Interfaces
{
@ -48,8 +50,9 @@ namespace OpenSim.Framework.Interfaces
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
string GetName();
bool RequestConnection();
bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
IList RequestMapBlocks(int minX, int minY, int maxX, int maxY);
void Close();
}

View File

@ -27,7 +27,7 @@
using System;
using libsecondlife;
using OpenSim.Framework.Assets;
using OpenSim.Framework.Types;
namespace OpenSim.Framework.Interfaces
{
@ -36,9 +36,21 @@ namespace OpenSim.Framework.Interfaces
/// </summary>
public interface ILocalStorage
{
void Initialise(string datastore);
void StorePrim(PrimData prim);
void RemovePrim(LLUUID primID);
void LoadPrimitives(ILocalStorageReceiver receiver);
float[] LoadWorld();
void SaveMap(float[] heightmap);
void SaveParcels(ParcelData[] parcels);
void SaveParcel(ParcelData parcel);
void RemoveParcel(ParcelData parcel);
void RemoveAllParcels();
void LoadParcels(ILocalStorageParcelReceiver recv);
void ShutDown();
}
@ -47,5 +59,10 @@ namespace OpenSim.Framework.Interfaces
void PrimFromStorage(PrimData prim);
}
public interface ILocalStorageParcelReceiver
{
void ParcelFromStorage(ParcelData data);
void NoParcelDataFromStorage();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework.Types;
namespace OpenSim.Framework.Interfaces
{
public interface IScriptAPI
{
OSVector3 GetEntityPosition(uint localID);
void SetEntityPosition(uint localID, float x, float y, float z);
uint GetRandomAvatarID();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Interfaces
{
public interface IScriptEngine
{
bool Init(IScriptAPI api);
string GetName();
void LoadScript(string script, string scriptName, uint entityID);
void OnFrame();
}
}

View File

@ -1,7 +1,7 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) <year>, <copyright holder>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,30 +28,31 @@ Copyright (c) OpenSim project, http://osgrid.org/
*/
using System;
using System.Text;
using ServerConsole;
using System.Collections.Generic;
using System.IO;
using libsecondlife;
//using OpenSim.world;
namespace OpenGridServices
namespace OpenSim.Framework.Interfaces
{
/// <summary>
/// </summary>
public class GridConsole : conscmd_callback {
public GridConsole() { }
public override void RunCmd(string cmd, string[] cmdparams) {
switch(cmd) {
case "help":
ServerConsole.MainConsole.Instance.WriteLine("shutdown - shutdown the grid (USE CAUTION!)"
);
break;
public abstract class UserConfig
{
public string DefaultStartupMsg;
public string GridServerURL;
public string GridSendKey;
public string GridRecvKey;
case "shutdown":
ServerConsole.MainConsole.Instance.Close();
Environment.Exit(0);
break;
}
}
public override void Show(string ShowWhat) {
}
}
public abstract void InitConfig();
}
public interface IUserConfig
{
UserConfig GetConfigObject();
}
}

View File

@ -10,5 +10,6 @@ namespace OpenSim.Framework.Interfaces
{
AgentInventory RequestAgentsInventory(LLUUID agentID);
void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory);
}
}

View File

@ -2,6 +2,8 @@ using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Types;
using System.Collections;
namespace OpenSim.Framework.Interfaces
{
@ -12,9 +14,10 @@ namespace OpenSim.Framework.Interfaces
public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract string GetName();
public abstract bool RequestConnection();
public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
public abstract void AddNewSession(Login session);
public abstract IList RequestMapBlocks(int minX, int minY, int maxX, int maxY);
public abstract void Close();
}

View File

@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Types;
namespace OpenSim.Framework.Interfaces
{
@ -18,8 +20,18 @@ namespace OpenSim.Framework.Interfaces
public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
public abstract string GetName();
public abstract bool RequestConnection();
public abstract bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port);
public abstract void SetServerInfo(string ServerUrl, string SendKey, string RecvKey);
public abstract IList RequestMapBlocks(int minX, int minY, int maxX, int maxY);
public abstract void Close();
public abstract Hashtable GridData {
get;
set;
}
public abstract ArrayList neighbours {
get;
set;
}
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Nwc.XmlRpc;
using libsecondlife;
namespace OpenSim.Framework.Grid
{
public abstract class LoginService
{
}
}

View File

@ -0,0 +1,200 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8ACA2445-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Framework</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Framework</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
<Name>XMLRPC</Name>
<Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AgentInventory.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Util.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Remoting.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserProfileManagerBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LoginService.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserProfileManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="HeightMapGenHills.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BlockingQueue.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UserProfile.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimProfileBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimProfile.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IGenericConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\LocalGridBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\RemoteGridBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IUserConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IUserServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IAssetServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IClientAPI.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IScriptEngine.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IGridConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IGridServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\IScriptAPI.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Interfaces\ILocalStorage.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\EstateSettings.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\AssetBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\AssetLandmark.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\AssetStorage.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\Login.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\NeighbourInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\OSVector3.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\ParcelData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\PrimData.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Types\AgentCircuitData.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -11,43 +11,57 @@
<resources prefix="OpenSim.Framework" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="AgentCiruitData.cs" />
<include name="AssetBase.cs" />
<include name="BlockingQueue.cs" />
<include name="HeightMapGenHills.cs" />
<include name="IAssetServer.cs" />
<include name="IConfig.cs" />
<include name="IGridServer.cs" />
<include name="ILocalStorage.cs" />
<include name="Inventory.cs" />
<include name="IUserServer.cs" />
<include name="LocalGridBase.cs" />
<include name="Login.cs" />
<include name="LoginService.cs" />
<include name="NeighbourInfo.cs" />
<include name="PrimData.cs" />
<include name="RemoteGridBase.cs" />
<include name="SimProfile.cs" />
<include name="SimProfileBase.cs" />
<include name="UserProfile.cs" />
<include name="UserProfileManager.cs" />
<include name="UserProfileManagerBase.cs" />
<include name="AgentInventory.cs" />
<include name="Util.cs" />
<include name="Remoting.cs" />
<include name="UserProfileManagerBase.cs" />
<include name="LoginService.cs" />
<include name="UserProfileManager.cs" />
<include name="HeightMapGenHills.cs" />
<include name="BlockingQueue.cs" />
<include name="UserProfile.cs" />
<include name="SimProfileBase.cs" />
<include name="SimProfile.cs" />
<include name="Interfaces/IGenericConfig.cs" />
<include name="Interfaces/LocalGridBase.cs" />
<include name="Interfaces/RemoteGridBase.cs" />
<include name="Interfaces/IUserConfig.cs" />
<include name="Interfaces/IConfig.cs" />
<include name="Interfaces/IUserServer.cs" />
<include name="Interfaces/IAssetServer.cs" />
<include name="Interfaces/IClientAPI.cs" />
<include name="Interfaces/IScriptEngine.cs" />
<include name="Interfaces/IGridConfig.cs" />
<include name="Interfaces/IGridServer.cs" />
<include name="Interfaces/IScriptAPI.cs" />
<include name="Interfaces/ILocalStorage.cs" />
<include name="Properties/AssemblyInfo.cs" />
<include name="Types/EstateSettings.cs" />
<include name="Types/AssetBase.cs" />
<include name="Types/AssetLandmark.cs" />
<include name="Types/AssetStorage.cs" />
<include name="Types/Login.cs" />
<include name="Types/NeighbourInfo.cs" />
<include name="Types/OSVector3.cs" />
<include name="Types/ParcelData.cs" />
<include name="Types/PrimData.cs" />
<include name="Types/AgentCircuitData.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll.dll" />
<include name="System.Xml.dll.dll" />
<include name="../bin/libsecondlife.dll" />
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/Db4objects.Db4o.dll" />
<include name="../../bin/XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../bin/" />
<mkdir dir="${project::get-base-directory()}/../bin/"/>
<copy todir="${project::get-base-directory()}/../bin/">
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>

View File

@ -0,0 +1,137 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
namespace OpenSim.Framework
{
/// <summary>
/// NEEDS AUDIT.
/// </summary>
/// <remarks>
/// Suggested implementation
/// <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>
/// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
/// <para>When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
/// <para>Both hosts should be performing these operations for this to be effective.</para>
/// </remarks>
class RemoteDigest
{
private byte[] currentHash;
private byte[] secret;
private SHA512Managed SHA512;
/// <summary>
/// Initialises a new RemoteDigest authentication mechanism
/// </summary>
/// <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>
/// <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>
/// <param name="salt">Binary salt - some common value - to be decided what</param>
/// <param name="challenge">The challenge key provided by the third party</param>
public RemoteDigest(string sharedSecret, byte[] salt, string challenge)
{
SHA512 = new SHA512Managed();
Rfc2898DeriveBytes RFC2898 = new Rfc2898DeriveBytes(sharedSecret,salt);
secret = RFC2898.GetBytes(512);
ASCIIEncoding ASCII = new ASCIIEncoding();
currentHash = SHA512.ComputeHash(AppendArrays(secret, ASCII.GetBytes(challenge)));
}
/// <summary>
/// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented.
/// </summary>
/// <param name="data">The incoming data</param>
/// <param name="digest">The remote digest</param>
/// <returns></returns>
public bool Authenticate(byte[] data, byte[] digest)
{
byte[] newHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
if (digest == newHash)
{
currentHash = newHash;
return true;
}
else
{
throw new Exception("Hash comparison failed. Key resync required.");
}
}
/// <summary>
/// Signs a new bit of data with the current hash. Returns a byte array which should be affixed to the message.
/// Signing a piece of data will automatically increment the hash - if you sign data and do not send it, the
/// hashes will get out of sync and throw an exception when validation is attempted.
/// </summary>
/// <param name="data">The outgoing data</param>
/// <returns>The local digest</returns>
public byte[] Sign(byte[] data)
{
currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data));
return currentHash;
}
/// <summary>
/// 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.
/// </summary>
/// <returns>A 128-character hexadecimal string containing the challenge.</returns>
public static string GenerateChallenge()
{
RNGCryptoServiceProvider RNG = new RNGCryptoServiceProvider();
byte[] bytes = new byte[64];
RNG.GetBytes(bytes);
StringBuilder sb = new StringBuilder(bytes.Length * 2);
foreach (byte b in bytes)
{
sb.AppendFormat("{0:x2}", b);
}
return sb.ToString();
}
/// <summary>
/// Helper function, merges two byte arrays
/// </summary>
/// <remarks>Sourced from MSDN Forum</remarks>
/// <param name="a">A</param>
/// <param name="b">B</param>
/// <returns>C</returns>
private byte[] AppendArrays(byte[] a, byte[] b)
{
byte[] c = new byte[a.Length + b.Length];
Buffer.BlockCopy(a, 0, c, 0, a.Length);
Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
return c;
}
}
}

View File

@ -0,0 +1,110 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Collections;
using System.Xml;
using System.Text;
using libsecondlife;
using Nwc.XmlRpc;
namespace OpenSim.Framework.Sims
{
public class SimProfile : SimProfileBase
{
public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey)
{
try
{
Hashtable GridReqParams = new Hashtable();
GridReqParams["region_handle"] = region_handle.ToString();
GridReqParams["authkey"] = SendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(GridReqParams);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
Hashtable RespData = (Hashtable)GridResp.Value;
this.UUID = new LLUUID((string)RespData["UUID"]);
this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
this.regionname = (string)RespData["regionname"];
this.sim_ip = (string)RespData["sim_ip"];
this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
this.sendkey = SendKey;
this.recvkey = RecvKey;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
return this;
}
public SimProfile LoadFromGrid(LLUUID UUID, string GridURL, string SendKey, string RecvKey)
{
try
{
Hashtable GridReqParams = new Hashtable();
GridReqParams["UUID"] = UUID.ToString();
GridReqParams["authkey"] = SendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(GridReqParams);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp = GridReq.Send(GridURL, 3000);
Hashtable RespData = (Hashtable)GridResp.Value;
this.UUID = new LLUUID((string)RespData["UUID"]);
this.regionhandle = Helpers.UIntsToLong(((uint)Convert.ToUInt32(RespData["region_locx"]) * 256), ((uint)Convert.ToUInt32(RespData["region_locy"]) * 256));
this.regionname = (string)RespData["regionname"];
this.sim_ip = (string)RespData["sim_ip"];
this.sim_port = (uint)Convert.ToUInt16(RespData["sim_port"]);
this.caps_url = "http://" + ((string)RespData["sim_ip"]) + ":" + (string)RespData["sim_port"] + "/";
this.RegionLocX = (uint)Convert.ToUInt32(RespData["region_locx"]);
this.RegionLocY = (uint)Convert.ToUInt32(RespData["region_locy"]);
this.sendkey = SendKey;
this.recvkey = RecvKey;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
return this;
}
public SimProfile()
{
}
}
}

View File

@ -0,0 +1,54 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Sims
{
[System.Obsolete("Depreciated, use SimProfileData instead")]
public class SimProfileBase
{
public LLUUID UUID;
public ulong regionhandle;
public string regionname;
public string sim_ip;
public uint sim_port;
public string caps_url;
public uint RegionLocX;
public uint RegionLocY;
public string sendkey;
public string recvkey;
public bool online;
public SimProfileBase()
{
}
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class AgentCircuitData
{
public AgentCircuitData() { }
public LLUUID AgentID;
public LLUUID SessionID;
public LLUUID SecureSessionID;
public LLVector3 startpos;
public string firstname;
public string lastname;
public uint circuitcode;
public bool child;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class AssetBase
{
public byte[] Data;
public LLUUID FullID;
public sbyte Type;
public sbyte InvType;
public string Name;
public string Description;
public AssetBase()
{
}
}
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class AssetLandmark : AssetBase
{
public int Version;
public LLVector3 Position;
public LLUUID RegionID;
public AssetLandmark(AssetBase a)
{
this.Data = a.Data;
this.FullID = a.FullID;
this.Type = a.Type;
this.InvType = a.InvType;
this.Name = a.Name;
this.Description = a.Description;
InternData();
}
private void InternData()
{
string temp = System.Text.Encoding.UTF8.GetString(Data).Trim();
string[] parts = temp.Split('\n');
int.TryParse(parts[0].Substring(17, 1), out Version);
LLUUID.TryParse(parts[1].Substring(10, 36), out RegionID);
LLVector3.TryParse(parts[2].Substring(11, parts[2].Length - 11), out Position);
}
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class AssetStorage
{
public AssetStorage() {
}
public AssetStorage(LLUUID assetUUID) {
UUID=assetUUID;
}
public byte[] Data;
public sbyte Type;
public string Name;
public LLUUID UUID;
}
}

View File

@ -0,0 +1,96 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class EstateSettings
{
//Settings to this island
public float billableFactor = (float)0.0;
public uint estateID = 0;
public uint parentEstateID = 0;
public byte maxAgents = 40;
public float objectBonusFactor = (float)1.0;
public int redirectGridX = 0; //??
public int redirectGridY = 0; //??
public libsecondlife.Simulator.RegionFlags regionFlags = libsecondlife.Simulator.RegionFlags.None; //Booleam values of various region settings
public libsecondlife.Simulator.SimAccess simAccess = libsecondlife.Simulator.SimAccess.Mature; //Is sim PG, Mature, etc? Mature by default.
public float sunHour = 0;
public float terrainRaiseLimit = 0;
public float terrainLowerLimit = 0;
public bool useFixedSun = false;
public int pricePerMeter = 1;
public ushort regionWaterHeight = 20;
public bool regionAllowTerraform = true;
// Region Information
// Low resolution 'base' textures. No longer used.
public LLUUID terrainBase0 = new LLUUID("b8d3965a-ad78-bf43-699b-bff8eca6c975"); // Default
public LLUUID terrainBase1 = new LLUUID("abb783e6-3e93-26c0-248a-247666855da3"); // Default
public LLUUID terrainBase2 = new LLUUID("179cdabd-398a-9b6b-1391-4dc333ba321f"); // Default
public LLUUID terrainBase3 = new LLUUID("beb169c7-11ea-fff2-efe5-0f24dc881df2"); // Default
// Higher resolution terrain textures
public LLUUID terrainDetail0 = new LLUUID("00000000-0000-0000-0000-000000000000");
public LLUUID terrainDetail1 = new LLUUID("00000000-0000-0000-0000-000000000000");
public LLUUID terrainDetail2 = new LLUUID("00000000-0000-0000-0000-000000000000");
public LLUUID terrainDetail3 = new LLUUID("00000000-0000-0000-0000-000000000000");
// First quad - each point is bilinearly interpolated at each meter of terrain
public float terrainStartHeight0 = 10.0f;
public float terrainStartHeight1 = 10.0f;
public float terrainStartHeight2 = 10.0f;
public float terrainStartHeight3 = 10.0f;
// Second quad - also bilinearly interpolated.
// Terrain texturing is done that:
// 0..3 (0 = base0, 3 = base3) = (terrain[x,y] - start[x,y]) / range[x,y]
public float terrainHeightRange0 = 60.0f; //00
public float terrainHeightRange1 = 60.0f; //01
public float terrainHeightRange2 = 60.0f; //10
public float terrainHeightRange3 = 60.0f; //11
// Terrain Default (Must be in F32 Format!)
public string terrainFile = "default.r32";
public double terrainMultiplier = 60.0;
public float waterHeight = (float)20.0;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class Login
{
public string First = "Test";
public string Last = "User";
public LLUUID Agent;
public LLUUID Session;
public LLUUID SecureSession = LLUUID.Zero;
public LLUUID InventoryFolder;
public LLUUID BaseFolder;
public uint CircuitCode;
public Login()
{
}
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Types
{
public class NeighbourInfo
{
public NeighbourInfo()
{
}
public ulong regionhandle;
public uint RegionLocX;
public uint RegionLocY;
public string sim_ip;
public uint sim_port;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Framework.Types
{
public class OSVector3
{
public float X;
public float Y;
public float Z;
public OSVector3()
{
}
}
}

View File

@ -0,0 +1,115 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class ParcelData
{
public byte[] parcelBitmapByteArray = new byte[512];
public string parcelName = "";
public string parcelDesc = "";
public LLUUID ownerID = new LLUUID();
public bool isGroupOwned = false;
public LLVector3 AABBMin = new LLVector3();
public LLVector3 AABBMax = new LLVector3();
public int area = 0;
public uint auctionID = 0; //Unemplemented. If set to 0, not being auctioned
public LLUUID authBuyerID = new LLUUID(); //Unemplemented. Authorized Buyer's UUID
public libsecondlife.Parcel.ParcelCategory category = new libsecondlife.Parcel.ParcelCategory(); //Unemplemented. Parcel's chosen category
public int claimDate = 0; //Unemplemented
public int claimPrice = 0; //Unemplemented
public LLUUID groupID = new LLUUID(); //Unemplemented
public int groupPrims = 0; //Unemplemented
public int salePrice = 0; //Unemeplemented. Parcels price.
public libsecondlife.Parcel.ParcelStatus parcelStatus = libsecondlife.Parcel.ParcelStatus.None;
public libsecondlife.Parcel.ParcelFlags parcelFlags = libsecondlife.Parcel.ParcelFlags.None;
public byte landingType = 0;
public byte mediaAutoScale = 0;
public LLUUID mediaID = LLUUID.Zero;
public int localID = 0;
public LLUUID globalID = new LLUUID();
public string mediaURL = "";
public string musicURL = "";
public float passHours = 0;
public int passPrice = 0;
public LLUUID snapshotID = LLUUID.Zero;
public LLVector3 userLocation = new LLVector3();
public LLVector3 userLookAt = new LLVector3();
public ParcelData()
{
globalID = LLUUID.Random();
}
public ParcelData Copy()
{
ParcelData parcelData = new ParcelData();
parcelData.AABBMax = this.AABBMax;
parcelData.AABBMin = this.AABBMin;
parcelData.area = this.area;
parcelData.auctionID = this.auctionID;
parcelData.authBuyerID = this.authBuyerID;
parcelData.category = this.category;
parcelData.claimDate = this.claimDate;
parcelData.claimPrice = this.claimPrice;
parcelData.globalID = this.globalID;
parcelData.groupID = this.groupID;
parcelData.groupPrims = this.groupPrims;
parcelData.isGroupOwned = this.isGroupOwned;
parcelData.localID = this.localID;
parcelData.landingType = this.landingType;
parcelData.mediaAutoScale = this.mediaAutoScale;
parcelData.mediaID = this.mediaID;
parcelData.mediaURL = this.mediaURL;
parcelData.musicURL = this.musicURL;
parcelData.ownerID = this.ownerID;
parcelData.parcelBitmapByteArray = (byte[])this.parcelBitmapByteArray.Clone();
parcelData.parcelDesc = this.parcelDesc;
parcelData.parcelFlags = this.parcelFlags;
parcelData.parcelName = this.parcelName;
parcelData.parcelStatus = this.parcelStatus;
parcelData.passHours = this.passHours;
parcelData.passPrice = this.passPrice;
parcelData.salePrice = this.salePrice;
parcelData.snapshotID = this.snapshotID;
parcelData.userLocation = this.userLocation;
parcelData.userLookAt = this.userLookAt;
return parcelData;
}
}
}

View File

@ -0,0 +1,201 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
namespace OpenSim.Framework.Types
{
public class PrimData
{
private const uint FULL_MASK_PERMISSIONS = 2147483647;
public LLUUID OwnerID;
public byte PCode;
public ushort PathBegin;
public ushort PathEnd;
public byte PathScaleX;
public byte PathScaleY;
public byte PathShearX;
public byte PathShearY;
public sbyte PathSkew;
public ushort ProfileBegin;
public ushort ProfileEnd;
public LLVector3 Scale;
public byte PathCurve;
public byte ProfileCurve;
public uint ParentID = 0;
public ushort ProfileHollow;
public sbyte PathRadiusOffset;
public byte PathRevolutions;
public sbyte PathTaperX;
public sbyte PathTaperY;
public sbyte PathTwist;
public sbyte PathTwistBegin;
public byte[] Texture;
public Int32 CreationDate;
public uint OwnerMask = FULL_MASK_PERMISSIONS;
public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
public uint GroupMask = FULL_MASK_PERMISSIONS;
public uint EveryoneMask = FULL_MASK_PERMISSIONS;
public uint BaseMask = FULL_MASK_PERMISSIONS;
//following only used during prim storage
public LLVector3 Position;
public LLQuaternion Rotation = new LLQuaternion(0,1,0,0);
public uint LocalID;
public LLUUID FullID;
public PrimData()
{
}
public PrimData(byte[] data)
{
int i =0;
this.OwnerID = new LLUUID(data, i); i += 16;
this.PCode = data[i++];
this.PathBegin = (ushort)(data[i++] + (data[i++] << 8));
this.PathEnd = (ushort)(data[i++] + (data[i++] << 8));
this.PathScaleX = data[i++];
this.PathScaleY = data[i++];
this.PathShearX = data[i++];
this.PathShearY = data[i++];
this.PathSkew = (sbyte)data[i++];
this.ProfileBegin = (ushort)(data[i++] + (data[i++] << 8));
this.ProfileEnd = (ushort)(data[i++] + (data[i++] << 8));
this.Scale = new LLVector3(data, i); i += 12;
this.PathCurve = data[i++];
this.ProfileCurve = data[i++];
this.ParentID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.ProfileHollow = (ushort)(data[i++] + (data[i++] << 8));
this.PathRadiusOffset = (sbyte)data[i++];
this.PathRevolutions = data[i++];
this.PathTaperX = (sbyte)data[i++];
this.PathTaperY =(sbyte) data[i++];
this.PathTwist = (sbyte) data[i++];
this.PathTwistBegin = (sbyte) data[i++];
ushort length = (ushort)(data[i++] + (data[i++] << 8));
this.Texture = new byte[length];
Array.Copy(data, i, Texture, 0, length); i += length;
this.CreationDate = (Int32)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.OwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.NextOwnerMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.GroupMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.EveryoneMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.BaseMask = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.Position = new LLVector3(data, i); i += 12;
this.Rotation = new LLQuaternion(data,i, true); i += 12;
this.LocalID = (uint)(data[i++] + (data[i++] << 8) + (data[i++] << 16) + (data[i++] << 24));
this.FullID = new LLUUID(data, i); i += 16;
}
public byte[] ToBytes()
{
int i = 0;
byte[] bytes = new byte[126 + Texture.Length];
Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16;
bytes[i++] = this.PCode;
bytes[i++] = (byte)(this.PathBegin % 256);
bytes[i++] = (byte)((this.PathBegin >> 8) % 256);
bytes[i++] = (byte)(this.PathEnd % 256);
bytes[i++] = (byte)((this.PathEnd >> 8) % 256);
bytes[i++] = this.PathScaleX;
bytes[i++] = this.PathScaleY;
bytes[i++] = this.PathShearX;
bytes[i++] = this.PathShearY;
bytes[i++] = (byte)this.PathSkew;
bytes[i++] = (byte)(this.ProfileBegin % 256);
bytes[i++] = (byte)((this.ProfileBegin >> 8) % 256);
bytes[i++] = (byte)(this.ProfileEnd % 256);
bytes[i++] = (byte)((this.ProfileEnd >> 8) % 256);
Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12;
bytes[i++] = this.PathCurve;
bytes[i++] = this.ProfileCurve;
bytes[i++] = (byte)(ParentID % 256);
bytes[i++] = (byte)((ParentID >> 8) % 256);
bytes[i++] = (byte)((ParentID >> 16) % 256);
bytes[i++] = (byte)((ParentID >> 24) % 256);
bytes[i++] = (byte)(this.ProfileHollow %256);
bytes[i++] = (byte)((this.ProfileHollow >> 8)% 256);
bytes[i++] = ((byte)this.PathRadiusOffset);
bytes[i++] = this.PathRevolutions;
bytes[i++] = ((byte) this.PathTaperX);
bytes[i++] = ((byte) this.PathTaperY);
bytes[i++] = ((byte) this.PathTwist);
bytes[i++] = ((byte) this.PathTwistBegin);
bytes[i++] = (byte)(Texture.Length % 256);
bytes[i++] = (byte)((Texture.Length >> 8) % 256);
Array.Copy(Texture, 0, bytes, i, Texture.Length); i += Texture.Length;
bytes[i++] = (byte)(this.CreationDate % 256);
bytes[i++] = (byte)((this.CreationDate >> 8) % 256);
bytes[i++] = (byte)((this.CreationDate >> 16) % 256);
bytes[i++] = (byte)((this.CreationDate >> 24) % 256);
bytes[i++] = (byte)(this.OwnerMask % 256);
bytes[i++] = (byte)((this.OwnerMask >> 8) % 256);
bytes[i++] = (byte)((this.OwnerMask >> 16) % 256);
bytes[i++] = (byte)((this.OwnerMask >> 24) % 256);
bytes[i++] = (byte)(this.NextOwnerMask % 256);
bytes[i++] = (byte)((this.NextOwnerMask >> 8) % 256);
bytes[i++] = (byte)((this.NextOwnerMask >> 16) % 256);
bytes[i++] = (byte)((this.NextOwnerMask >> 24) % 256);
bytes[i++] = (byte)(this.GroupMask % 256);
bytes[i++] = (byte)((this.GroupMask >> 8) % 256);
bytes[i++] = (byte)((this.GroupMask >> 16) % 256);
bytes[i++] = (byte)((this.GroupMask >> 24) % 256);
bytes[i++] = (byte)(this.EveryoneMask % 256);
bytes[i++] = (byte)((this.EveryoneMask >> 8) % 256);
bytes[i++] = (byte)((this.EveryoneMask >> 16) % 256);
bytes[i++] = (byte)((this.EveryoneMask >> 24) % 256);
bytes[i++] = (byte)(this.BaseMask % 256);
bytes[i++] = (byte)((this.BaseMask >> 8) % 256);
bytes[i++] = (byte)((this.BaseMask >> 16) % 256);
bytes[i++] = (byte)((this.BaseMask >> 24) % 256);
Array.Copy(this.Position.GetBytes(), 0, bytes, i, 12); i += 12;
if (this.Rotation == new LLQuaternion(0,0,0,0))
{
this.Rotation = new LLQuaternion(0, 1, 0, 0);
}
Array.Copy(this.Rotation.GetBytes(), 0, bytes, i, 12); i += 12;
bytes[i++] = (byte)(this.LocalID % 256);
bytes[i++] = (byte)((this.LocalID >> 8) % 256);
bytes[i++] = (byte)((this.LocalID >> 16) % 256);
bytes[i++] = (byte)((this.LocalID >> 24) % 256);
Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16;
return bytes;
}
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Inventory;
using System.Security.Cryptography;
namespace OpenSim.Framework.User
{
public class UserProfile
{
public string firstname;
public string lastname;
public ulong homeregionhandle;
public LLVector3 homepos;
public LLVector3 homelookat;
public bool IsGridGod = false;
public bool IsLocal = true; // will be used in future for visitors from foreign grids
public string AssetURL;
public string MD5passwd;
public LLUUID CurrentSessionID;
public LLUUID CurrentSecureSessionID;
public LLUUID UUID;
public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
public AgentInventory Inventory;
public UserProfile()
{
Circuits = new Dictionary<LLUUID, uint>();
Inventory = new AgentInventory();
homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
homepos = new LLVector3();
homelookat = new LLVector3();
}
public void InitSessionData()
{
RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
byte[] randDataS = new byte[16];
byte[] randDataSS = new byte[16];
rand.GetBytes(randDataS);
rand.GetBytes(randDataSS);
CurrentSecureSessionID = new LLUUID(randDataSS,0);
CurrentSessionID = new LLUUID(randDataS,0);
}
public void AddSimCircuit(uint circuitCode, LLUUID regionUUID)
{
if (this.Circuits.ContainsKey(regionUUID) == false)
this.Circuits.Add(regionUUID, circuitCode);
}
}
}

View File

@ -0,0 +1,299 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using libsecondlife;
using Nwc.XmlRpc;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Utilities;
namespace OpenSim.Framework.User
{
public class UserProfileManager : UserProfileManagerBase
{
public string GridURL;
public string GridSendKey;
public string GridRecvKey;
public string DefaultStartupMsg;
public UserProfileManager()
{
}
public void SetKeys(string sendKey, string recvKey, string url, string message)
{
GridRecvKey = recvKey;
GridSendKey = sendKey;
GridURL = url;
DefaultStartupMsg = message;
}
public virtual string ParseXMLRPC(string requestBody)
{
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
switch (request.MethodName)
{
case "login_to_simulator":
XmlRpcResponse response = XmlRpcLoginMethod(request);
return (Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(response), "utf-16", "utf-8"));
}
return "";
}
public string RestDeleteUserSessionMethod( string request, string path, string param )
{
LLUUID sessionid = new LLUUID(param); // get usersessions/sessionid
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
{
if ( UserProfiles[UUID].CurrentSessionID == sessionid)
{
UserProfiles[UUID].CurrentSessionID = null;
UserProfiles[UUID].CurrentSecureSessionID = null;
UserProfiles[UUID].Circuits.Clear();
}
}
return "OK";
}
public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && requestData.Contains("passwd"));
bool GoodLogin = false;
string firstname = "";
string lastname = "";
string passwd = "";
if (GoodXML)
{
firstname = (string)requestData["first"];
lastname = (string)requestData["last"];
passwd = (string)requestData["passwd"];
GoodLogin = AuthenticateUser(firstname, lastname, passwd);
}
if (!(GoodXML && GoodLogin))
{
response = CreateErrorConnectingToGridResponse();
}
else
{
UserProfile TheUser = GetProfileByName(firstname, lastname);
//we need to sort out how sessions are logged out , currently the sim tells the gridserver
//but if as this suggests the userserver handles it then please have the sim telling the userserver instead
//as it really makes things messy for sandbox mode
//if (!((TheUser.CurrentSessionID == null) && (TheUser.CurrentSecureSessionID == null)))
// {
// response = CreateAlreadyLoggedInResponse();
// }
//else
//{
try
{
Hashtable responseData = new Hashtable();
LLUUID AgentID = TheUser.UUID;
TheUser.InitSessionData();
//for loading data from a grid server, make any changes in CustomiseResponse() (or create a sub class of this and override that method)
//SimProfile SimInfo = new SimProfile();
//SimInfo = SimInfo.LoadFromGrid(TheUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
Hashtable GlobalT = new Hashtable();
GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
ArrayList GlobalTextures = new ArrayList();
GlobalTextures.Add(GlobalT);
Hashtable LoginFlagsHash = new Hashtable();
LoginFlagsHash["daylight_savings"] = "N";
LoginFlagsHash["stipend_since_login"] = "N";
LoginFlagsHash["gendered"] = "Y";
LoginFlagsHash["ever_logged_in"] = "Y";
ArrayList LoginFlags = new ArrayList();
LoginFlags.Add(LoginFlagsHash);
Hashtable uiconfig = new Hashtable();
uiconfig["allow_first_life"] = "Y";
ArrayList ui_config = new ArrayList();
ui_config.Add(uiconfig);
Hashtable ClassifiedCategoriesHash = new Hashtable();
ClassifiedCategoriesHash["category_name"] = "bla bla";
ClassifiedCategoriesHash["category_id"] = (Int32)1;
ArrayList ClassifiedCategories = new ArrayList();
ClassifiedCategories.Add(ClassifiedCategoriesHash);
ArrayList AgentInventory = new ArrayList();
Console.WriteLine("adding inventory to response");
Hashtable TempHash;
foreach (InventoryFolder InvFolder in TheUser.Inventory.InventoryFolders.Values)
{
TempHash = new Hashtable();
Console.WriteLine("adding folder " + InvFolder.FolderName + ", ID: " + InvFolder.FolderID.ToStringHyphenated() + " with parent: " + InvFolder.ParentID.ToStringHyphenated());
TempHash["name"] = InvFolder.FolderName;
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.Version;
TempHash["type_default"] = (Int32)InvFolder.DefaultType;
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
AgentInventory.Add(TempHash);
}
Hashtable InventoryRootHash = new Hashtable();
InventoryRootHash["folder_id"] = TheUser.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
ArrayList InventoryRoot = new ArrayList();
InventoryRoot.Add(InventoryRootHash);
Hashtable InitialOutfitHash = new Hashtable();
InitialOutfitHash["folder_name"] = "Nightclub Female";
InitialOutfitHash["gender"] = "female";
ArrayList InitialOutfit = new ArrayList();
InitialOutfit.Add(InitialOutfitHash);
uint circode = (uint)(Util.RandomClass.Next());
//TheUser.AddSimCircuit(circode, SimInfo.UUID);
responseData["last_name"] = TheUser.lastname;
responseData["ui-config"] = ui_config;
responseData["sim_ip"] = "127.0.0.1"; //SimInfo.sim_ip.ToString();
responseData["login-flags"] = LoginFlags;
responseData["global-textures"] = GlobalTextures;
responseData["classified_categories"] = ClassifiedCategories;
responseData["event_categories"] = new ArrayList();
responseData["inventory-skeleton"] = AgentInventory;
responseData["inventory-skel-lib"] = new ArrayList();
responseData["inventory-root"] = InventoryRoot;
responseData["event_notifications"] = new ArrayList();
responseData["gestures"] = new ArrayList();
responseData["inventory-lib-owner"] = new ArrayList();
responseData["initial-outfit"] = InitialOutfit;
responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
responseData["start_location"] = "last";
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() + "]}";
responseData["message"] = DefaultStartupMsg;
responseData["first_name"] = TheUser.firstname;
responseData["circuit_code"] = (Int32)circode;
responseData["sim_port"] = 0; //(Int32)SimInfo.sim_port;
responseData["secure_session_id"] = TheUser.CurrentSecureSessionID.ToStringHyphenated();
responseData["look_at"] = "\n[r" + TheUser.homelookat.X.ToString() + ",r" + TheUser.homelookat.Y.ToString() + ",r" + TheUser.homelookat.Z.ToString() + "]\n";
responseData["agent_id"] = AgentID.ToStringHyphenated();
responseData["region_y"] = (Int32)0 * 256; // (Int32)SimInfo.RegionLocY * 256;
responseData["region_x"] = (Int32)0 * 256; //SimInfo.RegionLocX * 256;
responseData["seed_capability"] = "";
responseData["agent_access"] = "M";
responseData["session_id"] = TheUser.CurrentSessionID.ToStringHyphenated();
responseData["login"] = "true";
this.CustomiseResponse(ref responseData, TheUser);
response.Value = responseData;
// TheUser.SendDataToSim(SimInfo);
return response;
}
catch (Exception E)
{
Console.WriteLine(E.ToString());
}
//}
}
return response;
}
private static XmlRpcResponse CreateErrorConnectingToGridResponse()
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable ErrorRespData = new Hashtable();
ErrorRespData["reason"] = "key";
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";
ErrorRespData["login"] = "false";
response.Value = ErrorRespData;
return response;
}
private static XmlRpcResponse CreateAlreadyLoggedInResponse()
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable PresenceErrorRespData = new Hashtable();
PresenceErrorRespData["reason"] = "presence";
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";
PresenceErrorRespData["login"] = "false";
response.Value = PresenceErrorRespData;
return response;
}
public virtual void CustomiseResponse(ref Hashtable response, UserProfile theUser)
{
//default method set up to act as ogs user server
SimProfile SimInfo= new SimProfile();
//get siminfo from grid server
SimInfo = SimInfo.LoadFromGrid(theUser.homeregionhandle, GridURL, GridSendKey, GridRecvKey);
Int32 circode = (Int32)Convert.ToUInt32(response["circuit_code"]);
theUser.AddSimCircuit((uint)circode, SimInfo.UUID);
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() + "]}";
response["sim_ip"] = SimInfo.sim_ip;
response["sim_port"] = (Int32)SimInfo.sim_port;
response["region_y"] = (Int32)SimInfo.RegionLocY * 256;
response["region_x"] = (Int32)SimInfo.RegionLocX * 256;
//default is ogs user server, so let the sim know about the user via a XmlRpcRequest
Console.WriteLine(SimInfo.caps_url);
Hashtable SimParams = new Hashtable();
SimParams["session_id"] = theUser.CurrentSessionID.ToString();
SimParams["secure_session_id"] = theUser.CurrentSecureSessionID.ToString();
SimParams["firstname"] = theUser.firstname;
SimParams["lastname"] = theUser.lastname;
SimParams["agent_id"] = theUser.UUID.ToString();
SimParams["circuit_code"] = (Int32)circode;
SimParams["startpos_x"] = theUser.homepos.X.ToString();
SimParams["startpos_y"] = theUser.homepos.Y.ToString();
SimParams["startpos_z"] = theUser.homepos.Z.ToString();
ArrayList SendParams = new ArrayList();
SendParams.Add(SimParams);
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
XmlRpcResponse GridResp = GridReq.Send(SimInfo.caps_url, 3000);
}
}
}

View File

@ -0,0 +1,152 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Inventory;
using Db4objects.Db4o;
namespace OpenSim.Framework.User
{
public class UserProfileManagerBase
{
public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
public UserProfileManagerBase()
{
}
public virtual void InitUserProfiles()
{
IObjectContainer db;
db = Db4oFactory.OpenFile("userprofiles.yap");
IObjectSet result = db.Get(typeof(UserProfile));
foreach (UserProfile userprof in result)
{
UserProfiles.Add(userprof.UUID, userprof);
}
Console.WriteLine("UserProfiles.Cs:InitUserProfiles() - Successfully loaded " + result.Count.ToString() + " from database");
db.Close();
}
public virtual void SaveUserProfiles() // ZOMG! INEFFICIENT!
{
IObjectContainer db;
db = Db4oFactory.OpenFile("userprofiles.yap");
IObjectSet result = db.Get(typeof(UserProfile));
foreach (UserProfile userprof in result)
{
db.Delete(userprof);
db.Commit();
}
foreach (UserProfile userprof in UserProfiles.Values)
{
db.Set(userprof);
db.Commit();
}
db.Close();
}
public UserProfile GetProfileByName(string firstname, string lastname)
{
foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys)
{
if (UserProfiles[UUID].firstname.Equals(firstname)) if (UserProfiles[UUID].lastname.Equals(lastname))
{
return UserProfiles[UUID];
}
}
return null;
}
public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID)
{
return UserProfiles[ProfileLLUUID];
}
public virtual bool AuthenticateUser(string firstname, string lastname, string passwd)
{
UserProfile TheUser = GetProfileByName(firstname, lastname);
passwd = passwd.Remove(0, 3); //remove $1$
if (TheUser != null)
{
if (TheUser.MD5passwd == passwd)
{
Console.WriteLine("UserProfile - authorised " + firstname + " " + lastname);
return true;
}
else
{
Console.WriteLine("UserProfile - not authorised, password not match " + TheUser.MD5passwd + " and " + passwd);
return false;
}
}
else
{
Console.WriteLine("UserProfile - not authorised , unkown: " + firstname + " , " + lastname);
return false;
}
}
public void SetGod(LLUUID GodID)
{
this.UserProfiles[GodID].IsGridGod = true;
}
public virtual UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd)
{
Console.WriteLine("creating new profile for : " + firstname + " , " + lastname);
UserProfile newprofile = new UserProfile();
newprofile.homeregionhandle = Helpers.UIntsToLong((997 * 256), (996 * 256));
newprofile.firstname = firstname;
newprofile.lastname = lastname;
newprofile.MD5passwd = MD5passwd;
newprofile.UUID = LLUUID.Random();
newprofile.Inventory.CreateRootFolder(newprofile.UUID, true);
this.UserProfiles.Add(newprofile.UUID, newprofile);
SaveUserProfiles();
return newprofile;
}
public virtual AgentInventory GetUsersInventory(LLUUID agentID)
{
UserProfile user = this.GetProfileByLLUUID(agentID);
if (user != null)
{
return user.Inventory;
}
return null;
}
}
}

View File

@ -0,0 +1,178 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Framework.Utilities
{
public class Util
{
private static Random randomClass = new Random();
private static uint nextXferID = 5000;
private static object XferLock = new object();
public static ulong UIntsToLong(uint X, uint Y)
{
return Helpers.UIntsToLong(X, Y);
}
public static Random RandomClass
{
get
{
return randomClass;
}
}
public static uint GetNextXferID()
{
uint id = 0;
lock(XferLock)
{
id = nextXferID;
nextXferID++;
}
return id;
}
public static int UnixTimeSinceEpoch()
{
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
int timestamp = (int)t.TotalSeconds;
return timestamp;
}
public static string Md5Hash(string pass)
{
MD5 md5 = MD5CryptoServiceProvider.Create();
byte[] dataMd5 = md5.ComputeHash(Encoding.Default.GetBytes(pass));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dataMd5.Length; i++)
sb.AppendFormat("{0:x2}", dataMd5[i]);
return sb.ToString();
}
//public static int fast_distance2d(int x, int y)
//{
// x = System.Math.Abs(x);
// y = System.Math.Abs(y);
// int min = System.Math.Min(x, y);
// return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
//}
public static string FieldToString(byte[] bytes)
{
return FieldToString(bytes, String.Empty);
}
/// <summary>
/// Convert a variable length field (byte array) to a string, with a
/// field name prepended to each line of the output
/// </summary>
/// <remarks>If the byte array has unprintable characters in it, a
/// hex dump will be put in the string instead</remarks>
/// <param name="bytes">The byte array to convert to a string</param>
/// <param name="fieldName">A field name to prepend to each line of output</param>
/// <returns>An ASCII string or a string containing a hex dump, minus
/// the null terminator</returns>
public static string FieldToString(byte[] bytes, string fieldName)
{
// Check for a common case
if (bytes.Length == 0) return String.Empty;
StringBuilder output = new StringBuilder();
bool printable = true;
for (int i = 0; i < bytes.Length; ++i)
{
// Check if there are any unprintable characters in the array
if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09
&& bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00)
{
printable = false;
break;
}
}
if (printable)
{
if (fieldName.Length > 0)
{
output.Append(fieldName);
output.Append(": ");
}
if (bytes[bytes.Length - 1] == 0x00)
output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
else
output.Append(UTF8Encoding.UTF8.GetString(bytes));
}
else
{
for (int i = 0; i < bytes.Length; i += 16)
{
if (i != 0)
output.Append(Environment.NewLine);
if (fieldName.Length > 0)
{
output.Append(fieldName);
output.Append(": ");
}
for (int j = 0; j < 16; j++)
{
if ((i + j) < bytes.Length)
output.Append(String.Format("{0:X2} ", bytes[i + j]));
else
output.Append(" ");
}
for (int j = 0; j < 16 && (i + j) < bytes.Length; j++)
{
if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E)
output.Append((char)bytes[i + j]);
else
output.Append(".");
}
}
}
return output.ToString();
}
public Util()
{
}
}
}

View File

@ -0,0 +1,93 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E88EF749-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.GenericConfig.Xml</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.GenericConfig.Xml</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="XmlConfig.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" ?>
<project name="OpenSim.GenericConfig.Xml" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.GenericConfig.Xml" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="XmlConfig.cs" />
<include name="Properties/AssemblyInfo.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../../../bin/OpenSim.Framework.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../../bin/"/>
<copy todir="${project::get-base-directory()}/../../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OpenSim.GenericConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenSim.GenericConfig")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("285a3047-f165-46c8-8767-b51428738a09")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,136 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using OpenSim.Framework.Interfaces;
namespace OpenSim.GenericConfig
{
public class XmlConfig : IGenericConfig
{
private XmlDocument doc;
private XmlNode rootNode;
private XmlNode configNode;
private string fileName;
private bool createdFile = false;
public XmlConfig(string filename)
{
fileName = filename;
}
public void LoadData()
{
doc = new XmlDocument();
try
{
if (System.IO.File.Exists(fileName))
{
XmlTextReader reader = new XmlTextReader(fileName);
reader.WhitespaceHandling = WhitespaceHandling.None;
doc.Load(reader);
reader.Close();
}
else
{
createdFile = true;
rootNode = doc.CreateNode(XmlNodeType.Element, "Root", "");
doc.AppendChild(rootNode);
configNode = doc.CreateNode(XmlNodeType.Element, "Config", "");
rootNode.AppendChild(configNode);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return;
}
try
{
rootNode = doc.FirstChild;
if (rootNode.Name != "Root")
throw new Exception("Error: Invalid .xml File. Missing <Root>");
configNode = rootNode.FirstChild;
if (configNode.Name != "Config")
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (createdFile)
{
this.Commit();
}
}
public string GetAttribute(string attributeName)
{
string result = "";
if (configNode.Attributes[attributeName] != null)
{
result = ((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value;
}
return result;
}
public bool SetAttribute(string attributeName, string attributeValue)
{
if (configNode.Attributes[attributeName] != null)
{
((XmlAttribute)configNode.Attributes.GetNamedItem(attributeName)).Value = attributeValue;
}
else
{
XmlAttribute attri;
attri = doc.CreateAttribute(attributeName);
attri.Value = attributeValue;
configNode.Attributes.Append(attri);
}
return true;
}
public void Commit()
{
doc.Save(fileName);
}
public void Close()
{
configNode = null;
rootNode = null;
doc = null;
}
}
}

View File

@ -0,0 +1,283 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
//using OpenSim.CAPS;
using Nwc.XmlRpc;
using System.Collections;
using OpenSim.Framework.Console;
namespace OpenSim.Servers
{
public class BaseHttpServer
{
protected class RestMethodEntry
{
private string m_path;
public string Path
{
get { return m_path; }
}
private RestMethod m_restMethod;
public RestMethod RestMethod
{
get { return m_restMethod; }
}
public RestMethodEntry(string path, RestMethod restMethod)
{
m_path = path;
m_restMethod = restMethod;
}
}
protected Thread m_workerThread;
protected HttpListener m_httpListener;
protected Dictionary<string, RestMethodEntry> m_restHandlers = new Dictionary<string, RestMethodEntry>();
protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
protected int m_port;
public BaseHttpServer(int port)
{
m_port = port;
}
public bool AddRestHandler(string method, string path, RestMethod handler)
{
string methodKey = String.Format("{0}: {1}", method, path);
if (!this.m_restHandlers.ContainsKey(methodKey))
{
this.m_restHandlers.Add(methodKey, new RestMethodEntry(path, handler));
return true;
}
//must already have a handler for that path so return false
return false;
}
public bool AddXmlRPCHandler(string method, XmlRpcMethod handler)
{
if (!this.m_rpcHandlers.ContainsKey(method))
{
this.m_rpcHandlers.Add(method, handler);
return true;
}
//must already have a handler for that path so return false
return false;
}
protected virtual string ProcessXMLRPCMethod(string methodName, XmlRpcRequest request)
{
XmlRpcResponse response;
XmlRpcMethod method;
if (this.m_rpcHandlers.TryGetValue(methodName, out method))
{
response = method(request);
}
else
{
response = new XmlRpcResponse();
Hashtable unknownMethodError = new Hashtable();
unknownMethodError["reason"] = "XmlRequest"; ;
unknownMethodError["message"] = "Unknown Rpc request";
unknownMethodError["login"] = "false";
response.Value = unknownMethodError;
}
return XmlRpcResponseSerializer.Singleton.Serialize(response);
}
protected virtual string ParseREST(string request, string path, string method)
{
string response;
string requestKey = String.Format("{0}: {1}", method, path);
string bestMatch = String.Empty;
foreach (string currentKey in m_restHandlers.Keys)
{
if (requestKey.StartsWith(currentKey))
{
if (currentKey.Length > bestMatch.Length)
{
bestMatch = currentKey;
}
}
}
RestMethodEntry restMethodEntry;
if (m_restHandlers.TryGetValue(bestMatch, out restMethodEntry))
{
RestMethod restMethod = restMethodEntry.RestMethod;
string param = path.Substring(restMethodEntry.Path.Length);
response = restMethod(request, path, param);
}
else
{
response = String.Empty;
}
return response;
}
protected virtual string ParseLLSDXML(string requestBody)
{
// dummy function for now - IMPLEMENT ME!
return "";
}
protected virtual string ParseXMLRPC(string requestBody)
{
string responseString = String.Empty;
try
{
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
string methodName = request.MethodName;
responseString = ProcessXMLRPCMethod(methodName, request);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
return responseString;
}
public virtual void HandleRequest(Object stateinfo)
{
try
{
HttpListenerContext context = (HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
response.KeepAlive = false;
response.SendChunked = false;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
//Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType);
//Console.WriteLine(requestBody);
string responseString = "";
switch (request.ContentType)
{
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString = ParseXMLRPC(requestBody);
responseString = Regex.Replace(responseString, "utf-16", "utf-8");
response.AddHeader("Content-type", "text/xml");
break;
case "application/xml":
// probably LLSD we hope, otherwise it should be ignored by the parser
responseString = ParseLLSDXML(requestBody);
response.AddHeader("Content-type", "application/xml");
break;
case "application/x-www-form-urlencoded":
// a form data POST so send to the REST parser
responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
response.AddHeader("Content-type", "text/html");
break;
case null:
// must be REST or invalid crap, so pass to the REST parser
responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod);
response.AddHeader("Content-type", "text/html");
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
output.Write(buffer, 0, buffer.Length);
output.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public void Start()
{
MainConsole.Instance.Verbose("BaseHttpServer.cs: Starting up HTTP Server");
m_workerThread = new Thread(new ThreadStart(StartHTTP));
m_workerThread.IsBackground = true;
m_workerThread.Start();
}
private void StartHTTP()
{
try
{
MainConsole.Instance.Verbose("BaseHttpServer.cs: StartHTTP() - Spawned main thread OK");
m_httpListener = new HttpListener();
m_httpListener.Prefixes.Add("http://+:" + m_port + "/");
m_httpListener.Start();
HttpListenerContext context;
while (true)
{
context = m_httpListener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
catch (Exception e)
{
MainConsole.Instance.Warn(e.Message);
}
}
}
}

View File

@ -1,5 +1,6 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -8,30 +9,29 @@ Copyright (c) OpenSim project, http://osgrid.org/
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenGridServices
namespace OpenSim.Servers
{
/// <summary>
/// </summary>
public class VersionInfo
{
public static string Version = "0.1, Build 1173843165, Revision 193:206M";
}
public class BaseServer
{
}
}

View File

@ -0,0 +1,139 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Text;
using System.IO;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Timers;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework.Console;
namespace OpenSim.Servers
{
public class CheckSumServer : UDPServerBase
{
//protected ConsoleBase m_console;
public CheckSumServer(int port)
: base(port)
{
}
protected override void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
Packet packet = null;
int numBytes = Server.EndReceiveFrom(result, ref epSender);
int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
if (packet.Type == PacketType.SecuredTemplateChecksumRequest)
{
SecuredTemplateChecksumRequestPacket checksum = (SecuredTemplateChecksumRequestPacket)packet;
TemplateChecksumReplyPacket checkreply = new TemplateChecksumReplyPacket();
checkreply.DataBlock.Checksum = 3220703154;//180572585;
checkreply.DataBlock.Flags = 0;
checkreply.DataBlock.MajorVersion = 1;
checkreply.DataBlock.MinorVersion = 15;
checkreply.DataBlock.PatchVersion = 0;
checkreply.DataBlock.ServerVersion = 0;
checkreply.TokenBlock.Token = checksum.TokenBlock.Token;
this.SendPacket(checkreply, epSender);
/*
//if we wanted to echo the the checksum/ version from the client (so that any client worked)
SecuredTemplateChecksumRequestPacket checkrequest = new SecuredTemplateChecksumRequestPacket();
checkrequest.TokenBlock.Token = checksum.TokenBlock.Token;
this.SendPacket(checkrequest, epSender);
*/
}
else if (packet.Type == PacketType.TemplateChecksumReply)
{
//echo back the client checksum reply (Hegemon's method)
TemplateChecksumReplyPacket checksum2 = (TemplateChecksumReplyPacket)packet;
TemplateChecksumReplyPacket checkreply2 = new TemplateChecksumReplyPacket();
checkreply2.DataBlock.Checksum = checksum2.DataBlock.Checksum;
checkreply2.DataBlock.Flags = checksum2.DataBlock.Flags;
checkreply2.DataBlock.MajorVersion = checksum2.DataBlock.MajorVersion;
checkreply2.DataBlock.MinorVersion = checksum2.DataBlock.MinorVersion;
checkreply2.DataBlock.PatchVersion = checksum2.DataBlock.PatchVersion;
checkreply2.DataBlock.ServerVersion = checksum2.DataBlock.ServerVersion;
checkreply2.TokenBlock.Token = checksum2.TokenBlock.Token;
this.SendPacket(checkreply2, epSender);
}
else
{
}
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
private void SendPacket(Packet Pack, EndPoint endp)
{
if (!Pack.Header.Resent)
{
Pack.Header.Sequence = 1;
}
byte[] ZeroOutBuffer = new byte[4096];
byte[] sendbuffer;
sendbuffer = Pack.ToBytes();
try
{
if (Pack.Header.Zerocoded)
{
int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
this.SendPackTo(ZeroOutBuffer, packetsize, SocketFlags.None, endp);
}
else
{
this.SendPackTo(sendbuffer, sendbuffer.Length, SocketFlags.None, endp);
}
}
catch (Exception)
{
MainConsole.Instance.Warn("OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection ");
}
}
private void SendPackTo(byte[] buffer, int size, SocketFlags flags, EndPoint endp)
{
this.Server.SendTo(buffer, size, flags, endp);
}
}
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Servers
{
public delegate string RestMethod( string request, string path, string param );
}

View File

@ -0,0 +1,124 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using OpenSim.Framework.User;
using OpenSim.Framework.Grid;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using libsecondlife;
namespace OpenSim.UserServer
{
public class LocalUserProfileManager : UserProfileManager
{
private IGridServer m_gridServer;
private int m_port;
private string m_ipAddr;
private uint regionX;
private uint regionY;
private AddNewSessionHandler AddSession;
public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr , uint regX, uint regY)
{
m_gridServer = gridServer;
m_port = simPort;
m_ipAddr = ipAddr;
regionX = regX;
regionY = regY;
}
public void SetSessionHandler(AddNewSessionHandler sessionHandler)
{
this.AddSession = sessionHandler;
}
public override void InitUserProfiles()
{
base.InitUserProfiles();
}
public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
{
Int32 circode = (Int32)response["circuit_code"];
theUser.AddSimCircuit((uint)circode, LLUUID.Random());
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() + "]}";
response["sim_port"] = m_port;
response["sim_ip"] = m_ipAddr;
response["region_y"] = (Int32)regionY* 256;
response["region_x"] = (Int32)regionX* 256;
string first;
string last;
if (response.Contains("first_name"))
{
first = (string)response["first_name"];
}
else
{
first = "test";
}
if (response.Contains("last_name"))
{
last = (string)response["last_name"];
}
else
{
last = "User";
}
ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
Hashtable Inventory1 = (Hashtable)InventoryList[0];
Login _login = new Login();
//copy data to login object
_login.First = first;
_login.Last = last;
_login.Agent = new LLUUID((string)response["agent_id"]) ;
_login.Session = new LLUUID((string)response["session_id"]);
_login.SecureSession = new LLUUID((string)response["secure_session_id"]);
_login.CircuitCode =(uint) circode;
_login.BaseFolder = null;
_login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
//working on local computer if so lets add to the gridserver's list of sessions?
/*if (m_gridServer.GetName() == "Local")
{
Console.WriteLine("adding login data to gridserver");
((LocalGridBase)this.m_gridServer).AddNewSession(_login);
}*/
this.AddSession(_login);
}
}
}

View File

@ -0,0 +1,669 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using Nwc.XmlRpc;
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
using libsecondlife;
using OpenSim;
using OpenSim.Framework.User;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Interfaces;
// ?
using OpenSim.Framework.Grid;
namespace OpenSim.UserServer
{
/// <summary>
/// A temp class to handle login response.
/// Should make use of UserProfileManager where possible.
/// </summary>
public class LoginResponse
{
private Hashtable loginFlagsHash;
private Hashtable globalTexturesHash;
private Hashtable loginError;
private Hashtable eventCategoriesHash;
private Hashtable uiConfigHash;
private Hashtable classifiedCategoriesHash;
private ArrayList loginFlags;
private ArrayList globalTextures;
private ArrayList eventCategories;
private ArrayList uiConfig;
private ArrayList classifiedCategories;
private ArrayList inventoryRoot;
private ArrayList initialOutfit;
private ArrayList agentInventory;
private UserProfile userProfile;
private LLUUID agentID;
private LLUUID sessionID;
private LLUUID secureSessionID;
private LLUUID baseFolderID;
private LLUUID inventoryFolderID;
// Login Flags
private string dst;
private string stipendSinceLogin;
private string gendered;
private string everLoggedIn;
private string login;
private string simPort;
private string simAddress;
private string agentAccess;
private Int32 circuitCode;
private uint regionX;
private uint regionY;
// Login
private string firstname;
private string lastname;
// Global Textures
private string sunTexture;
private string cloudTexture;
private string moonTexture;
// Error Flags
private string errorReason;
private string errorMessage;
// Response
private XmlRpcResponse xmlRpcResponse;
private XmlRpcResponse defaultXmlRpcResponse;
private string welcomeMessage;
private string startLocation;
private string allowFirstLife;
private string home;
private string seedCapability;
private string lookAt;
public LoginResponse()
{
this.loginFlags = new ArrayList();
this.globalTextures = new ArrayList();
this.eventCategories = new ArrayList();
this.uiConfig = new ArrayList();
this.classifiedCategories = new ArrayList();
this.loginError = new Hashtable();
this.eventCategoriesHash = new Hashtable();
this.classifiedCategoriesHash = new Hashtable();
this.uiConfigHash = new Hashtable();
this.defaultXmlRpcResponse = new XmlRpcResponse();
this.userProfile = new UserProfile();
this.inventoryRoot = new ArrayList();
this.initialOutfit = new ArrayList();
this.agentInventory = new ArrayList();
this.xmlRpcResponse = new XmlRpcResponse();
this.defaultXmlRpcResponse = new XmlRpcResponse();
this.SetDefaultValues();
} // LoginServer
public void SetDefaultValues()
{
try
{
this.DST = "N";
this.StipendSinceLogin = "N";
this.Gendered = "Y";
this.EverLoggedIn = "Y";
this.login = "false";
this.firstname = "Test";
this.lastname = "User";
this.agentAccess = "M";
this.startLocation = "last";
this.allowFirstLife = "Y";
this.SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
this.CloudTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
this.MoonTexture = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
this.ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
this.ErrorReason = "key";
this.welcomeMessage = "Welcome to OpenSim!";
this.seedCapability = "";
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() + "]}";
this.lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
this.RegionX = (uint)255232;
this.RegionY = (uint)254976;
// Classifieds;
this.AddClassifiedCategory((Int32)1, "Shopping");
this.AddClassifiedCategory((Int32)2, "Land Rental");
this.AddClassifiedCategory((Int32)3, "Property Rental");
this.AddClassifiedCategory((Int32)4, "Special Attraction");
this.AddClassifiedCategory((Int32)5, "New Products");
this.AddClassifiedCategory((Int32)6, "Employment");
this.AddClassifiedCategory((Int32)7, "Wanted");
this.AddClassifiedCategory((Int32)8, "Service");
this.AddClassifiedCategory((Int32)9, "Personal");
int SessionRand = Util.RandomClass.Next(1, 999);
this.SessionID = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
this.SecureSessionID = LLUUID.Random();
this.userProfile.Inventory.CreateRootFolder(this.userProfile.UUID, true);
this.baseFolderID = this.userProfile.Inventory.GetFolderID("Textures");
this.inventoryFolderID = this.userProfile.Inventory.GetFolderID("My Inventory-");
Hashtable InventoryRootHash = new Hashtable();
InventoryRootHash["folder_id"] = this.userProfile.Inventory.InventoryRoot.FolderID.ToStringHyphenated();
this.inventoryRoot.Add(InventoryRootHash);
Hashtable TempHash;
foreach (InventoryFolder InvFolder in this.userProfile.Inventory.InventoryFolders.Values)
{
TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName;
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.Version;
TempHash["type_default"] = (Int32)InvFolder.DefaultType;
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
this.agentInventory.Add(TempHash);
}
Hashtable InitialOutfitHash = new Hashtable();
InitialOutfitHash["folder_name"] = "Nightclub Female";
InitialOutfitHash["gender"] = "female";
this.initialOutfit.Add(InitialOutfitHash);
}
catch (Exception e)
{
OpenSim.Framework.Console.MainConsole.Instance.Warn(
"LoginResponse: Unable to set default values: " + e.Message
);
}
} // SetDefaultValues
protected virtual LLUUID GetAgentId()
{
// todo
LLUUID Agent;
int AgentRand = Util.RandomClass.Next(1, 9999);
Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
return Agent;
} // GetAgentId
private XmlRpcResponse GenerateFailureResponse(string reason, string message, string login)
{
// Overwrite any default values;
this.xmlRpcResponse = new XmlRpcResponse();
// Ensure Login Failed message/reason;
this.ErrorMessage = message;
this.ErrorReason = reason;
this.loginError["reason"] = this.ErrorReason;
this.loginError["message"] = this.ErrorMessage;
this.loginError["login"] = login;
this.xmlRpcResponse.Value = this.loginError;
return (this.xmlRpcResponse);
} // GenerateResponse
public XmlRpcResponse LoginFailedResponse()
{
return (this.GenerateFailureResponse("key", "You have entered an invalid name/password combination. Check Caps/lock.", "false"));
} // LoginFailedResponse
public XmlRpcResponse ConnectionFailedResponse()
{
return (this.LoginFailedResponse());
} // CreateErrorConnectingToGridResponse()
public XmlRpcResponse CreateAlreadyLoggedInResponse()
{
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"));
} // CreateAlreadyLoggedInResponse()
public XmlRpcResponse ToXmlRpcResponse()
{
try
{
Hashtable responseData = new Hashtable();
this.loginFlagsHash = new Hashtable();
this.loginFlagsHash["daylight_savings"] = this.DST;
this.loginFlagsHash["stipend_since_login"] = this.StipendSinceLogin;
this.loginFlagsHash["gendered"] = this.Gendered;
this.loginFlagsHash["ever_logged_in"] = this.EverLoggedIn;
this.loginFlags.Add(this.loginFlagsHash);
responseData["first_name"] = this.Firstname;
responseData["last_name"] = this.Lastname;
responseData["agent_access"] = this.agentAccess;
this.globalTexturesHash = new Hashtable();
this.globalTexturesHash["sun_texture_id"] = this.SunTexture;
this.globalTexturesHash["cloud_texture_id"] = this.CloudTexture;
this.globalTexturesHash["moon_texture_id"] = this.MoonTexture;
this.globalTextures.Add(this.globalTexturesHash);
this.eventCategories.Add(this.eventCategoriesHash);
this.AddToUIConfig("allow_first_life", this.allowFirstLife);
this.uiConfig.Add(this.uiConfigHash);
// Create a agent and session LLUUID
this.agentID = this.GetAgentId();
responseData["sim_port"] = this.SimPort;
responseData["sim_ip"] = this.SimAddress;
responseData["agent_id"] = this.AgentID.ToStringHyphenated();
responseData["session_id"] = this.SessionID.ToStringHyphenated();
responseData["secure_session_id"] = this.SecureSessionID.ToStringHyphenated();
responseData["circuit_code"] = this.CircuitCode;
responseData["seconds_since_epoch"] = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
responseData["login-flags"] = this.loginFlags;
responseData["global-textures"] = this.globalTextures;
responseData["seed_capability"] = this.seedCapability;
responseData["event_categories"] = this.eventCategories;
responseData["event_notifications"] = new ArrayList(); // todo
responseData["classified_categories"] = this.classifiedCategories;
responseData["ui-config"] = this.uiConfig;
responseData["inventory-skeleton"] = this.agentInventory;
responseData["inventory-skel-lib"] = new ArrayList(); // todo
responseData["inventory-root"] = this.inventoryRoot;
responseData["gestures"] = new ArrayList(); // todo
responseData["inventory-lib-owner"] = new ArrayList(); // todo
responseData["initial-outfit"] = this.initialOutfit;
responseData["start_location"] = this.startLocation;
responseData["seed_capability"] = this.seedCapability;
responseData["home"] = this.home;
responseData["look_at"] = this.lookAt;
responseData["message"] = this.welcomeMessage;
responseData["region_x"] = (Int32)this.RegionX * 256;
responseData["region_y"] = (Int32)this.RegionY * 256;
responseData["login"] = "true";
this.xmlRpcResponse.Value = responseData;
return (this.xmlRpcResponse);
}
catch (Exception e)
{
OpenSim.Framework.Console.MainConsole.Instance.Error(
"LoginResponse: Error creating XML-RPC Response: " + e.Message
);
return (this.GenerateFailureResponse("Internal Error", "Error generating Login Response", "false"));
}
} // ToXmlRpcResponse
public void SetEventCategories(string category, string value)
{
this.eventCategoriesHash[category] = value;
} // SetEventCategories
public void AddToUIConfig(string itemName, string item)
{
this.uiConfigHash[itemName] = item;
} // SetUIConfig
public void AddClassifiedCategory(Int32 ID, string categoryName)
{
this.classifiedCategoriesHash["category_name"] = categoryName;
this.classifiedCategoriesHash["category_id"] = ID;
this.classifiedCategories.Add(this.classifiedCategoriesHash);
// this.classifiedCategoriesHash.Clear();
} // SetClassifiedCategory
public string Login
{
get
{
return this.login;
}
set
{
this.login = value;
}
} // Login
public string DST
{
get
{
return this.dst;
}
set
{
this.dst = value;
}
} // DST
public string StipendSinceLogin
{
get
{
return this.stipendSinceLogin;
}
set
{
this.stipendSinceLogin = value;
}
} // StipendSinceLogin
public string Gendered
{
get
{
return this.gendered;
}
set
{
this.gendered = value;
}
} // Gendered
public string EverLoggedIn
{
get
{
return this.everLoggedIn;
}
set
{
this.everLoggedIn = value;
}
} // EverLoggedIn
public string SimPort
{
get
{
return this.simPort;
}
set
{
this.simPort = value;
}
} // SimPort
public string SimAddress
{
get
{
return this.simAddress;
}
set
{
this.simAddress = value;
}
} // SimAddress
public LLUUID AgentID
{
get
{
return this.agentID;
}
set
{
this.agentID = value;
}
} // AgentID
public LLUUID SessionID
{
get
{
return this.sessionID;
}
set
{
this.sessionID = value;
}
} // SessionID
public LLUUID SecureSessionID
{
get
{
return this.secureSessionID;
}
set
{
this.secureSessionID = value;
}
} // SecureSessionID
public LLUUID BaseFolderID
{
get
{
return this.baseFolderID;
}
set
{
this.baseFolderID = value;
}
} // BaseFolderID
public LLUUID InventoryFolderID
{
get
{
return this.inventoryFolderID;
}
set
{
this.inventoryFolderID = value;
}
} // InventoryFolderID
public Int32 CircuitCode
{
get
{
return this.circuitCode;
}
set
{
this.circuitCode = value;
}
} // CircuitCode
public uint RegionX
{
get
{
return this.regionX;
}
set
{
this.regionX = value;
}
} // RegionX
public uint RegionY
{
get
{
return this.regionY;
}
set
{
this.regionY = value;
}
} // RegionY
public string SunTexture
{
get
{
return this.sunTexture;
}
set
{
this.sunTexture = value;
}
} // SunTexture
public string CloudTexture
{
get
{
return this.cloudTexture;
}
set
{
this.cloudTexture = value;
}
} // CloudTexture
public string MoonTexture
{
get
{
return this.moonTexture;
}
set
{
this.moonTexture = value;
}
} // MoonTexture
public string Firstname
{
get
{
return this.firstname;
}
set
{
this.firstname = value;
}
} // Firstname
public string Lastname
{
get
{
return this.lastname;
}
set
{
this.lastname = value;
}
} // Lastname
public string AgentAccess
{
get
{
return this.agentAccess;
}
set
{
this.agentAccess = value;
}
}
public string StartLocation
{
get
{
return this.startLocation;
}
set
{
this.startLocation = value;
}
} // StartLocation
public string LookAt
{
get
{
return this.lookAt;
}
set
{
this.lookAt = value;
}
}
public string SeedCapability
{
get
{
return this.seedCapability;
}
set
{
this.seedCapability = value;
}
} // SeedCapability
public string ErrorReason
{
get
{
return this.errorReason;
}
set
{
this.errorReason = value;
}
} // ErrorReason
public string ErrorMessage
{
get
{
return this.errorMessage;
}
set
{
this.errorMessage = value;
}
} // ErrorMessage
} // LoginResponse
} // namespace OpenSim.UserServer

View File

@ -0,0 +1,296 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using Nwc.XmlRpc;
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections;
using System.Security.Cryptography;
using System.Xml;
using libsecondlife;
using OpenSim;
using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Grid;
using OpenSim.Framework.Inventory;
using OpenSim.Framework.User;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Types;
namespace OpenSim.UserServer
{
public delegate void AddNewSessionHandler(Login loginData);
/// <summary>
/// When running in local (default) mode , handles client logins.
/// </summary>
public class LoginServer : LoginService, IUserServer
{
private IGridServer m_gridServer;
public IPAddress clientAddress = IPAddress.Loopback;
public IPAddress remoteAddress = IPAddress.Any;
private int NumClients;
private bool userAccounts = false;
private string _mpasswd;
private bool _needPasswd = false;
private LocalUserProfileManager userManager;
private int m_simPort;
private string m_simAddr;
private uint regionX;
private uint regionY;
private AddNewSessionHandler AddSession;
public LocalUserProfileManager LocalUserManager
{
get
{
return userManager;
}
}
public LoginServer( string simAddr, int simPort, uint regX, uint regY, bool useAccounts)
{
m_simPort = simPort;
m_simAddr = simAddr;
regionX = regX;
regionY = regY;
this.userAccounts = useAccounts;
}
public void SetSessionHandler(AddNewSessionHandler sessionHandler)
{
this.AddSession = sessionHandler;
this.userManager.SetSessionHandler(sessionHandler);
}
public void Startup()
{
this._needPasswd = false;
this._mpasswd = EncodePassword("testpass");
userManager = new LocalUserProfileManager(this.m_gridServer, m_simPort, m_simAddr, regionX, regionY);
userManager.InitUserProfiles();
userManager.SetKeys("", "", "", "Welcome to OpenSim");
}
public XmlRpcResponse XmlRpcLoginMethod(XmlRpcRequest request)
{
Console.WriteLine("login attempt");
Hashtable requestData = (Hashtable)request.Params[0];
string first;
string last;
string passwd;
LoginResponse loginResponse = new LoginResponse();
loginResponse.RegionX = regionX;
loginResponse.RegionY = regionY;
//get login name
if (requestData.Contains("first"))
{
first = (string)requestData["first"];
}
else
{
first = "test";
}
if (requestData.Contains("last"))
{
last = (string)requestData["last"];
}
else
{
last = "User" + NumClients.ToString();
}
if (requestData.Contains("passwd"))
{
passwd = (string)requestData["passwd"];
}
else
{
passwd = "notfound";
}
if (!Authenticate(first, last, passwd))
{
return loginResponse.LoginFailedResponse();
}
NumClients++;
// Create a agent and session LLUUID
// Agent = GetAgentId(first, last);
// int SessionRand = Util.RandomClass.Next(1, 999);
// Session = new LLUUID("aaaabbbb-0200-" + SessionRand.ToString("0000") + "-8664-58f53e442797");
// LLUUID secureSess = LLUUID.Random();
loginResponse.SimPort = m_simPort.ToString();
// 7 June 2007, AJD:
// [10:03:05] (@AdamZaius) Sandbox should work listening on 0.0.0.0 if you can fix the login XML reply
// OLD: loginResponse.SimAddress = m_simAddr.ToString();
loginResponse.SimAddress = "0.0.0.0";
// loginResponse.AgentID = Agent.ToStringHyphenated();
// loginResponse.SessionID = Session.ToStringHyphenated();
// loginResponse.SecureSessionID = secureSess.ToStringHyphenated();
loginResponse.CircuitCode = (Int32)(Util.RandomClass.Next());
XmlRpcResponse response = loginResponse.ToXmlRpcResponse();
Hashtable responseData = (Hashtable)response.Value;
//inventory
/* ArrayList InventoryList = (ArrayList)responseData["inventory-skeleton"];
Hashtable Inventory1 = (Hashtable)InventoryList[0];
Hashtable Inventory2 = (Hashtable)InventoryList[1];
LLUUID BaseFolderID = LLUUID.Random();
LLUUID InventoryFolderID = LLUUID.Random();
Inventory2["name"] = "Textures";
Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
Inventory2["type_default"] = 0;
Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
ArrayList InventoryRoot = (ArrayList)responseData["inventory-root"];
Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
*/
CustomiseLoginResponse(responseData, first, last);
Login _login = new Login();
//copy data to login object
_login.First = first;
_login.Last = last;
_login.Agent = loginResponse.AgentID;
_login.Session = loginResponse.SessionID;
_login.SecureSession = loginResponse.SecureSessionID;
_login.CircuitCode = (uint) loginResponse.CircuitCode;
_login.BaseFolder = loginResponse.BaseFolderID;
_login.InventoryFolder = loginResponse.InventoryFolderID;
//working on local computer if so lets add to the gridserver's list of sessions?
/* if (m_gridServer.GetName() == "Local")
{
((LocalGridBase)m_gridServer).AddNewSession(_login);
}*/
AddSession(_login);
return response;
}
protected virtual void CustomiseLoginResponse(Hashtable responseData, string first, string last)
{
}
protected virtual LLUUID GetAgentId(string firstName, string lastName)
{
LLUUID Agent;
int AgentRand = Util.RandomClass.Next(1, 9999);
Agent = new LLUUID("99998888-0100-" + AgentRand.ToString("0000") + "-8ec1-0b1d5cd6aead");
return Agent;
}
protected virtual bool Authenticate(string first, string last, string passwd)
{
if (this._needPasswd)
{
//every user needs the password to login
string encodedPass = passwd.Remove(0, 3); //remove $1$
if (encodedPass == this._mpasswd)
{
return true;
}
else
{
return false;
}
}
else
{
//do not need password to login
return true;
}
}
private static string EncodePassword(string passwd)
{
Byte[] originalBytes;
Byte[] encodedBytes;
MD5 md5;
md5 = new MD5CryptoServiceProvider();
originalBytes = ASCIIEncoding.Default.GetBytes(passwd);
encodedBytes = md5.ComputeHash(originalBytes);
return Regex.Replace(BitConverter.ToString(encodedBytes), "-", "").ToLower();
}
public bool CreateUserAccount(string firstName, string lastName, string password)
{
Console.WriteLine("creating new user account");
string mdPassword = EncodePassword(password);
Console.WriteLine("with password: " + mdPassword);
this.userManager.CreateNewProfile(firstName, lastName, mdPassword);
return true;
}
public UserProfile GetProfileByName(string firstName, string lastName)
{
return this.userManager.GetProfileByName(firstName, lastName);
}
//IUserServer implementation
public AgentInventory RequestAgentsInventory(LLUUID agentID)
{
AgentInventory aInventory = null;
if (this.userAccounts)
{
aInventory = this.userManager.GetUsersInventory(agentID);
}
return aInventory;
}
public bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory)
{
return true;
}
public void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
{
}
}
}

View File

@ -0,0 +1,130 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8BB20F0A-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenSim.Servers</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenSim.Servers</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenSim.Framework\OpenSim.Framework.csproj">
<Name>OpenSim.Framework</Name>
<Project>{8ACA2445-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenSim.Framework.Console\OpenSim.Framework.Console.csproj">
<Name>OpenSim.Framework.Console</Name>
<Project>{A7CD0630-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\XmlRpcCS\XMLRPC.csproj">
<Name>XMLRPC</Name>
<Project>{8E81D43C-0000-0000-0000-000000000000}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="LoginServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BaseHttpServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="BaseServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="IRestHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LocalUserProfileManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcMethod.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="LoginResponse.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="CheckSumServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="UDPServerBase.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" ?>
<project name="OpenSim.Servers" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="OpenSim.Servers" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="LoginServer.cs" />
<include name="BaseHttpServer.cs" />
<include name="BaseServer.cs" />
<include name="IRestHandler.cs" />
<include name="LocalUserProfileManager.cs" />
<include name="XmlRpcMethod.cs" />
<include name="LoginResponse.cs" />
<include name="CheckSumServer.cs" />
<include name="UDPServerBase.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
<include name="../../bin/OpenSim.Framework.dll" />
<include name="../../bin/OpenSim.Framework.Console.dll" />
<include name="../../bin/libsecondlife.dll" />
<include name="../../bin/XMLRPC.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Text;
using System.IO;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using System.Timers;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Servers
{
public class UDPServerBase
{
public Socket Server;
protected IPEndPoint ServerIncoming;
protected byte[] RecvBuffer = new byte[4096];
protected byte[] ZeroBuffer = new byte[8192];
protected IPEndPoint ipeSender;
protected EndPoint epSender;
protected AsyncCallback ReceivedData;
protected int listenPort;
public UDPServerBase(int port)
{
listenPort = port;
}
protected virtual void OnReceivedData(IAsyncResult result)
{
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
Packet packet = null;
int numBytes = Server.EndReceiveFrom(result, ref epSender);
int packetEnd = numBytes - 1;
packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
protected virtual void AddNewClient(Packet packet)
{
}
public virtual void ServerListener()
{
ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
Server.Bind(ServerIncoming);
ipeSender = new IPEndPoint(IPAddress.Any, 0);
epSender = (EndPoint)ipeSender;
ReceivedData = new AsyncCallback(this.OnReceivedData);
Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
}
public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
{
}
}
}

View File

@ -1,5 +1,6 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -8,30 +9,26 @@ Copyright (c) OpenSim project, http://osgrid.org/
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using Nwc.XmlRpc;
namespace OpenGridServices
namespace OpenSim.Servers
{
/// <summary>
/// </summary>
public class VersionInfo
{
public static string Version = "@@VERSION";
}
public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request );
}

46
Common/XmlRpcCS/Logger.cs Normal file
View File

@ -0,0 +1,46 @@
namespace Nwc.XmlRpc
{
using System;
/// <summary>Define levels of logging.</summary><remarks> This duplicates
/// similar enumerations in System.Diagnostics.EventLogEntryType. The
/// duplication was merited because .NET Compact Framework lacked the EventLogEntryType enum.</remarks>
public enum LogLevel
{
/// <summary>Information level, log entry for informational reasons only.</summary>
Information,
/// <summary>Warning level, indicates a possible problem.</summary>
Warning,
/// <summary>Error level, implies a significant problem.</summary>
Error
}
///<summary>
///Logging singleton with swappable output delegate.
///</summary>
///<remarks>
///This singleton provides a centralized log. The actual WriteEntry calls are passed
///off to a delegate however. Having a delegate do the actual logginh allows you to
///implement different logging mechanism and have them take effect throughout the system.
///</remarks>
public class Logger
{
///<summary>Delegate definition for logging.</summary>
///<param name="message">The message <c>String</c> to log.</param>
///<param name="level">The <c>LogLevel</c> of your message.</param>
public delegate void LoggerDelegate(String message, LogLevel level);
///<summary>The LoggerDelegate that will recieve WriteEntry requests.</summary>
static public LoggerDelegate Delegate = null;
///<summary>
///Method logging events are sent to.
///</summary>
///<param name="message">The message <c>String</c> to log.</param>
///<param name="level">The <c>LogLevel</c> of your message.</param>
static public void WriteEntry(String message, LogLevel level)
{
if (Delegate != null)
Delegate(message, level);
}
}
}

View File

@ -0,0 +1,231 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.IO;
using System.Net.Sockets;
using System.Collections;
///<summary>Very basic HTTP request handler.</summary>
///<remarks>This class is designed to accept a TcpClient and treat it as an HTTP request.
/// It will do some basic header parsing and manage the input and output streams associated
/// with the request.</remarks>
public class SimpleHttpRequest
{
private String _httpMethod = null;
private String _protocol;
private String _filePathFile = null;
private String _filePathDir = null;
private String __filePath;
private TcpClient _client;
private StreamReader _input;
private StreamWriter _output;
private Hashtable _headers;
/// <summary>A constructor which accepts the TcpClient.</summary>
/// <remarks>It creates the associated input and output streams, determines the request type,
/// and parses the remaining HTTP header.</remarks>
/// <param name="client">The <c>TcpClient</c> associated with the HTTP connection.</param>
public SimpleHttpRequest(TcpClient client)
{
_client = client;
_output = new StreamWriter(client.GetStream());
_input = new StreamReader(client.GetStream());
GetRequestMethod();
GetRequestHeaders();
}
/// <summary>The output <c>StreamWriter</c> associated with the request.</summary>
public StreamWriter Output
{
get { return _output; }
}
/// <summary>The input <c>StreamReader</c> associated with the request.</summary>
public StreamReader Input
{
get { return _input; }
}
/// <summary>The <c>TcpClient</c> with the request.</summary>
public TcpClient Client
{
get { return _client; }
}
private String _filePath
{
get { return __filePath; }
set
{
__filePath = value;
_filePathDir = null;
_filePathFile = null;
}
}
/// <summary>The type of HTTP request (i.e. PUT, GET, etc.).</summary>
public String HttpMethod
{
get { return _httpMethod; }
}
/// <summary>The level of the HTTP protocol.</summary>
public String Protocol
{
get { return _protocol; }
}
/// <summary>The "path" which is part of any HTTP request.</summary>
public String FilePath
{
get { return _filePath; }
}
/// <summary>The file portion of the "path" which is part of any HTTP request.</summary>
public String FilePathFile
{
get
{
if (_filePathFile != null)
return _filePathFile;
int i = FilePath.LastIndexOf("/");
if (i == -1)
return "";
i++;
_filePathFile = FilePath.Substring(i, FilePath.Length - i);
return _filePathFile;
}
}
/// <summary>The directory portion of the "path" which is part of any HTTP request.</summary>
public String FilePathDir
{
get
{
if (_filePathDir != null)
return _filePathDir;
int i = FilePath.LastIndexOf("/");
if (i == -1)
return "";
i++;
_filePathDir = FilePath.Substring(0, i);
return _filePathDir;
}
}
private void GetRequestMethod()
{
string req = _input.ReadLine();
if (req == null)
throw new ApplicationException("Void request.");
if (0 == String.Compare("GET ", req.Substring(0, 4), true))
_httpMethod = "GET";
else if (0 == String.Compare("POST ", req.Substring(0, 5), true))
_httpMethod = "POST";
else
throw new InvalidOperationException("Unrecognized method in query: " + req);
req = req.TrimEnd();
int idx = req.IndexOf(' ') + 1;
if (idx >= req.Length)
throw new ApplicationException("What do you want?");
string page_protocol = req.Substring(idx);
int idx2 = page_protocol.IndexOf(' ');
if (idx2 == -1)
idx2 = page_protocol.Length;
_filePath = page_protocol.Substring(0, idx2).Trim();
_protocol = page_protocol.Substring(idx2).Trim();
}
private void GetRequestHeaders()
{
String line;
int idx;
_headers = new Hashtable();
while ((line = _input.ReadLine()) != "")
{
if (line == null)
{
break;
}
idx = line.IndexOf(':');
if (idx == -1 || idx == line.Length - 1)
{
Logger.WriteEntry("Malformed header line: " + line, LogLevel.Information);
continue;
}
String key = line.Substring(0, idx);
String value = line.Substring(idx + 1);
try
{
_headers.Add(key, value);
}
catch (Exception)
{
Logger.WriteEntry("Duplicate header key in line: " + line, LogLevel.Information);
}
}
}
/// <summary>
/// Format the object contents into a useful string representation.
/// </summary>
///<returns><c>String</c> representation of the <c>SimpleHttpRequest</c> as the <i>HttpMethod FilePath Protocol</i>.</returns>
override public String ToString()
{
return HttpMethod + " " + FilePath + " " + Protocol;
}
/// <summary>
/// Close the <c>SimpleHttpRequest</c>. This flushes and closes all associated io streams.
/// </summary>
public void Close()
{
_output.Flush();
_output.Close();
_input.Close();
_client.Close();
}
}
}

View File

@ -0,0 +1,138 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8E81D43C-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>XMLRPC</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>XMLRPC</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Compile Include="XmlRpcBoxcarRequest.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcRequest.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcResponseSerializer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Logger.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcRequestDeserializer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcExposedAttribute.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcResponse.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcException.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcResponseDeserializer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcResponder.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcServer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcErrorCodes.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcSerializer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcSystemObject.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="SimpleHttpRequest.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcClientProxy.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcRequestSerializer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcDeserializer.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="XmlRpcXmlTokens.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,58 @@
<?xml version="1.0" ?>
<project name="XMLRPC" default="build">
<target name="build">
<echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" />
<mkdir dir="${project::get-base-directory()}/${build.dir}" />
<copy todir="${project::get-base-directory()}/${build.dir}">
<fileset basedir="${project::get-base-directory()}">
</fileset>
</copy>
<csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll">
<resources prefix="XMLRPC" dynamicprefix="true" >
</resources>
<sources failonempty="true">
<include name="XmlRpcBoxcarRequest.cs" />
<include name="XmlRpcRequest.cs" />
<include name="XmlRpcResponseSerializer.cs" />
<include name="Logger.cs" />
<include name="XmlRpcRequestDeserializer.cs" />
<include name="XmlRpcExposedAttribute.cs" />
<include name="XmlRpcResponse.cs" />
<include name="XmlRpcException.cs" />
<include name="XmlRpcResponseDeserializer.cs" />
<include name="XmlRpcResponder.cs" />
<include name="XmlRpcServer.cs" />
<include name="XmlRpcErrorCodes.cs" />
<include name="XmlRpcSerializer.cs" />
<include name="XmlRpcSystemObject.cs" />
<include name="SimpleHttpRequest.cs" />
<include name="XmlRpcClientProxy.cs" />
<include name="XmlRpcRequestSerializer.cs" />
<include name="XmlRpcDeserializer.cs" />
<include name="XmlRpcXmlTokens.cs" />
</sources>
<references basedir="${project::get-base-directory()}">
<lib>
<include name="${project::get-base-directory()}" />
<include name="${project::get-base-directory()}/${build.dir}" />
</lib>
<include name="System.dll" />
<include name="System.Xml.dll" />
</references>
</csc>
<echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" />
<mkdir dir="${project::get-base-directory()}/../../bin/"/>
<copy todir="${project::get-base-directory()}/../../bin/">
<fileset basedir="${project::get-base-directory()}/${build.dir}/" >
<include name="*.dll"/>
<include name="*.exe"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
</target>
<target name="doc" description="Creates documentation.">
</target>
</project>

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Net;
using System.Text;
using System.Reflection;
/// <summary>Class that collects individual <c>XmlRpcRequest</c> objects and submits them as a <i>boxcarred</i> request.</summary>
/// <remarks>A boxcared request is when a number of request are collected before being sent via XML-RPC, and then are sent via
/// a single HTTP connection. This results in a speed up from reduced connection time. The results are then retuned collectively
/// as well.
///</remarks>
/// <seealso cref="XmlRpcRequest"/>
public class XmlRpcBoxcarRequest : XmlRpcRequest
{
/// <summary>ArrayList to collect the requests to boxcar.</summary>
public IList Requests = new ArrayList();
/// <summary>Basic constructor.</summary>
public XmlRpcBoxcarRequest()
{
}
/// <summary>Returns the <c>String</c> "system.multiCall" which is the server method that handles boxcars.</summary>
public override String MethodName
{
get { return "system.multiCall"; }
}
/// <summary>The <c>ArrayList</c> of boxcarred <paramref>Requests</paramref> as properly formed parameters.</summary>
public override IList Params
{
get {
_params.Clear();
ArrayList reqArray = new ArrayList();
foreach (XmlRpcRequest request in Requests)
{
Hashtable requestEntry = new Hashtable();
requestEntry.Add(XmlRpcXmlTokens.METHOD_NAME, request.MethodName);
requestEntry.Add(XmlRpcXmlTokens.PARAMS, request.Params);
reqArray.Add(requestEntry);
}
_params.Add(reqArray);
return _params;
}
}
}
}

View File

@ -0,0 +1,88 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Runtime.Remoting.Proxies;
using System.Runtime.Remoting.Messaging;
/// <summary>This class provides support for creating local proxies of XML-RPC remote objects</summary>
/// <remarks>
/// To create a local proxy you need to create a local C# interface and then, via <i>createProxy</i>
/// associate that interface with a remote object at a given URL.
/// </remarks>
public class XmlRpcClientProxy : RealProxy
{
private String _remoteObjectName;
private String _url;
private XmlRpcRequest _client = new XmlRpcRequest();
/// <summary>Factory method to create proxies.</summary>
/// <remarks>
/// To create a local proxy you need to create a local C# interface with methods that mirror those of the server object.
/// Next, pass that interface into <c>createProxy</c> along with the object name and URL of the remote object and
/// cast the resulting object to the specifice interface.
/// </remarks>
/// <param name="remoteObjectName"><c>String</c> The name of the remote object.</param>
/// <param name="url"><c>String</c> The URL of the remote object.</param>
/// <param name="anInterface"><c>Type</c> The typeof() of a C# interface.</param>
/// <returns><c>Object</c> A proxy for your specified interface. Cast to appropriate type.</returns>
public static Object createProxy(String remoteObjectName, String url, Type anInterface)
{
return new XmlRpcClientProxy(remoteObjectName, url, anInterface).GetTransparentProxy();
}
private XmlRpcClientProxy(String remoteObjectName, String url, Type t) : base(t)
{
_remoteObjectName = remoteObjectName;
_url = url;
}
/// <summary>The local method dispatcher - do not invoke.</summary>
override public IMessage Invoke(IMessage msg)
{
IMethodCallMessage methodMessage = (IMethodCallMessage)msg;
_client.MethodName = _remoteObjectName + "." + methodMessage.MethodName;
_client.Params.Clear();
foreach (Object o in methodMessage.Args)
_client.Params.Add(o);
try
{
Object ret = _client.Invoke(_url);
return new ReturnMessage(ret,null,0,
methodMessage.LogicalCallContext, methodMessage);
}
catch (Exception e)
{
return new ReturnMessage(e, methodMessage);
}
}
}
}

View File

@ -0,0 +1,222 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Globalization;
/// <summary>Parser context, we maintain contexts in a stack to avoiding recursion. </summary>
struct Context
{
public String Name;
public Object Container;
}
/// <summary>Basic XML-RPC data deserializer.</summary>
/// <remarks>Uses <c>XmlTextReader</c> to parse the XML data. This level of the class
/// only handles the tokens common to both Requests and Responses. This class is not useful in and of itself
/// but is designed to be subclassed.</remarks>
public class XmlRpcDeserializer : XmlRpcXmlTokens
{
private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo();
private Object _container;
private Stack _containerStack;
/// <summary>Protected reference to last text.</summary>
protected String _text;
/// <summary>Protected reference to last deserialized value.</summary>
protected Object _value;
/// <summary>Protected reference to last name field.</summary>
protected String _name;
/// <summary>Basic constructor.</summary>
public XmlRpcDeserializer()
{
Reset();
_dateFormat.FullDateTimePattern = ISO_DATETIME;
}
/// <summary>Static method that parses XML data into a response using the Singleton.</summary>
/// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param>
/// <returns><c>Object</c> object resulting from the deserialization.</returns>
virtual public Object Deserialize(TextReader xmlData)
{
return null;
}
/// <summary>Protected method to parse a node in an XML-RPC XML stream.</summary>
/// <remarks>Method deals with elements common to all XML-RPC data, subclasses of
/// this object deal with request/response spefic elements.</remarks>
/// <param name="reader"><c>XmlTextReader</c> of the in progress parsing data stream.</param>
protected void DeserializeNode(XmlTextReader reader)
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (Logger.Delegate != null)
Logger.WriteEntry("START " + reader.Name, LogLevel.Information);
switch (reader.Name)
{
case VALUE:
_value = null;
_text = null;
break;
case STRUCT:
PushContext();
_container = new Hashtable();
break;
case ARRAY:
PushContext();
_container = new ArrayList();
break;
}
break;
case XmlNodeType.EndElement:
if (Logger.Delegate != null)
Logger.WriteEntry("END " + reader.Name, LogLevel.Information);
switch (reader.Name)
{
case BASE64:
_value = Convert.FromBase64String(_text);
break;
case BOOLEAN:
int val = Int16.Parse(_text);
if (val == 0)
_value = false;
else if (val == 1)
_value = true;
break;
case STRING:
_value = _text;
break;
case DOUBLE:
_value = Double.Parse(_text);
break;
case INT:
case ALT_INT:
_value = Int32.Parse(_text);
break;
case DATETIME:
#if __MONO__
_value = DateParse(_text);
#else
_value = DateTime.ParseExact(_text, "F", _dateFormat);
#endif
break;
case NAME:
_name = _text;
break;
case VALUE:
if (_value == null)
_value = _text; // some kits don't use <string> tag, they just do <value>
if ((_container != null) && (_container is IList)) // in an array? If so add value to it.
((IList)_container).Add(_value);
break;
case MEMBER:
if ((_container != null) && (_container is IDictionary)) // in an struct? If so add value to it.
((IDictionary)_container).Add(_name, _value);
break;
case ARRAY:
case STRUCT:
_value = _container;
PopContext();
break;
}
break;
case XmlNodeType.Text:
if (Logger.Delegate != null)
Logger.WriteEntry("Text " + reader.Value, LogLevel.Information);
_text = reader.Value;
break;
default:
break;
}
}
/// <summary>Static method that parses XML in a <c>String</c> into a
/// request using the Singleton.</summary>
/// <param name="xmlData"><c>String</c> containing an XML-RPC request.</param>
/// <returns><c>XmlRpcRequest</c> object resulting from the parse.</returns>
public Object Deserialize(String xmlData)
{
StringReader sr = new StringReader(xmlData);
return Deserialize(sr);
}
/// <summary>Pop a Context of the stack, an Array or Struct has closed.</summary>
private void PopContext()
{
Context c = (Context)_containerStack.Pop();
_container = c.Container;
_name = c.Name;
}
/// <summary>Push a Context on the stack, an Array or Struct has opened.</summary>
private void PushContext()
{
Context context;
context.Container = _container;
context.Name = _name;
_containerStack.Push(context);
}
/// <summary>Reset the internal state of the deserializer.</summary>
protected void Reset()
{
_text = null;
_value = null;
_name = null;
_container = null;
_containerStack = new Stack();
}
#if __MONO__
private DateTime DateParse(String str)
{
int year = Int32.Parse(str.Substring(0,4));
int month = Int32.Parse(str.Substring(4,2));
int day = Int32.Parse(str.Substring(6,2));
int hour = Int32.Parse(str.Substring(9,2));
int min = Int32.Parse(str.Substring(12,2));
int sec = Int32.Parse(str.Substring(15,2));
return new DateTime(year,month,day,hour,min,sec);
}
#endif
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
/// <summary>Standard XML-RPC error codes.</summary>
public class XmlRpcErrorCodes
{
/// <summary></summary>
public const int PARSE_ERROR_MALFORMED = -32700;
/// <summary></summary>
public const String PARSE_ERROR_MALFORMED_MSG = "Parse Error, not well formed";
/// <summary></summary>
public const int PARSE_ERROR_ENCODING = -32701;
/// <summary></summary>
public const String PARSE_ERROR_ENCODING_MSG = "Parse Error, unsupported encoding";
//
// -32702 ---> parse error. invalid character for encoding
// -32600 ---> server error. invalid xml-rpc. not conforming to spec.
//
/// <summary></summary>
public const int SERVER_ERROR_METHOD = -32601;
/// <summary></summary>
public const String SERVER_ERROR_METHOD_MSG = "Server Error, requested method not found";
/// <summary></summary>
public const int SERVER_ERROR_PARAMS = -32602;
/// <summary></summary>
public const String SERVER_ERROR_PARAMS_MSG = "Server Error, invalid method parameters";
//
// -32603 ---> server error. internal xml-rpc error
//
/// <summary></summary>
public const int APPLICATION_ERROR = -32500;
/// <summary></summary>
public const String APPLICATION_ERROR_MSG = "Application Error";
//
// -32400 ---> system error
//
/// <summary></summary>
public const int TRANSPORT_ERROR = -32300;
/// <summary></summary>
public const String TRANSPORT_ERROR_MSG = "Transport Layer Error";
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
/// <summary>An XML-RPC Exception.</summary>
/// <remarks>Maps a C# exception to an XML-RPC fault. Normal exceptions
/// include a message so this adds the code needed by XML-RPC.</remarks>
public class XmlRpcException : Exception
{
private int _code;
/// <summary>Instantiate an <c>XmlRpcException</c> with a code and message.</summary>
/// <param name="code"><c>Int</c> faultCode associated with this exception.</param>
/// <param name="message"><c>String</c> faultMessage associated with this exception.</param>
public XmlRpcException(int code, String message)
: base(message)
{
_code = code;
}
/// <summary>The value of the faults message, i.e. the faultString.</summary>
public String FaultString
{
get { return Message; }
}
/// <summary>The value of the faults code, i.e. the faultCode.</summary>
public int FaultCode
{
get { return _code; }
}
/// <summary>Format the message to include the code.</summary>
override public String ToString()
{
return "Code: " + FaultCode + " Message: " + base.ToString();
}
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Reflection;
/// <summary>
/// Simple tagging attribute to indicate participation is XML-RPC exposure.
/// </summary>
/// <remarks>
/// If present at the class level it indicates that this class does explicitly
/// expose methods. If present at the method level it denotes that the method
/// is exposed.
/// </remarks>
[AttributeUsage(
AttributeTargets.Class | AttributeTargets.Method,
AllowMultiple = false,
Inherited = true
)]
public class XmlRpcExposedAttribute : Attribute
{
/// <summary>Check if <paramref>obj</paramref> is an object utilizing the XML-RPC exposed Attribute.</summary>
/// <param name="obj"><c>Object</c> of a class or method to check for attribute.</param>
/// <returns><c>Boolean</c> true if attribute present.</returns>
public static Boolean ExposedObject(Object obj)
{
return IsExposed(obj.GetType());
}
/// <summary>Check if <paramref>obj</paramref>.<paramref>methodName</paramref> is an XML-RPC exposed method.</summary>
/// <remarks>A method is considered to be exposed if it exists and, either, the object does not use the XmlRpcExposed attribute,
/// or the object does use the XmlRpcExposed attribute and the method has the XmlRpcExposed attribute as well.</remarks>
/// <returns><c>Boolean</c> true if the method is exposed.</returns>
public static Boolean ExposedMethod(Object obj, String methodName)
{
Type type = obj.GetType();
MethodInfo method = type.GetMethod(methodName);
if (method == null)
throw new MissingMethodException("Method " + methodName + " not found.");
if (!IsExposed(type))
return true;
return IsExposed(method);
}
/// <summary>Check if <paramref>mi</paramref> is XML-RPC exposed.</summary>
/// <param name="mi"><c>MemberInfo</c> of a class or method to check for attribute.</param>
/// <returns><c>Boolean</c> true if attribute present.</returns>
public static Boolean IsExposed(MemberInfo mi)
{
foreach (Attribute attr in mi.GetCustomAttributes(true))
{
if (attr is XmlRpcExposedAttribute)
return true;
}
return false;
}
}
}

View File

@ -0,0 +1,177 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Xml;
using System.Net;
using System.Text;
using System.Reflection;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
internal class AcceptAllCertificatePolicy : ICertificatePolicy
{
public AcceptAllCertificatePolicy()
{
}
public bool CheckValidationResult(ServicePoint sPoint,
System.Security.Cryptography.X509Certificates.X509Certificate cert,
WebRequest wRequest, int certProb)
{
// Always accept
return true;
}
}
/// <summary>Class supporting the request side of an XML-RPC transaction.</summary>
public class XmlRpcRequest
{
private String _methodName = null;
private Encoding _encoding = new ASCIIEncoding();
private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
/// <summary><c>ArrayList</c> containing the parameters.</summary>
protected IList _params = null;
/// <summary>Instantiate an <c>XmlRpcRequest</c></summary>
public XmlRpcRequest()
{
_params = new ArrayList();
}
/// <summary>Instantiate an <c>XmlRpcRequest</c> for a specified method and parameters.</summary>
/// <param name="methodName"><c>String</c> designating the <i>object.method</i> on the server the request
/// should be directed to.</param>
/// <param name="parameters"><c>ArrayList</c> of XML-RPC type parameters to invoke the request with.</param>
public XmlRpcRequest(String methodName, IList parameters)
{
MethodName = methodName;
_params = parameters;
}
/// <summary><c>ArrayList</c> conntaining the parameters for the request.</summary>
public virtual IList Params
{
get { return _params; }
}
/// <summary><c>String</c> conntaining the method name, both object and method, that the request will be sent to.</summary>
public virtual String MethodName
{
get { return _methodName; }
set { _methodName = value; }
}
/// <summary><c>String</c> object name portion of the method name.</summary>
public String MethodNameObject
{
get
{
int index = MethodName.IndexOf(".");
if (index == -1)
return MethodName;
return MethodName.Substring(0, index);
}
}
/// <summary><c>String</c> method name portion of the object.method name.</summary>
public String MethodNameMethod
{
get
{
int index = MethodName.IndexOf(".");
if (index == -1)
return MethodName;
return MethodName.Substring(index + 1, MethodName.Length - index - 1);
}
}
/// <summary>Invoke this request on the server.</summary>
/// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
/// <returns><c>Object</c> The value returned from the method invocation on the server.</returns>
/// <exception cref="XmlRpcException">If an exception generated on the server side.</exception>
public Object Invoke(String url)
{
XmlRpcResponse res = Send(url, 10000);
if (res.IsFault)
throw new XmlRpcException(res.FaultCode, res.FaultString);
return res.Value;
}
/// <summary>Send the request to the server.</summary>
/// <param name="url"><c>String</c> The url of the XML-RPC server.</param>
/// <param name="timeout">Milliseconds before the connection times out.</param>
/// <returns><c>XmlRpcResponse</c> The response generated.</returns>
public XmlRpcResponse Send(String url, int timeout)
{
// Override SSL authentication mechanisms
ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
if (request == null)
throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR,
XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url);
request.Method = "POST";
request.ContentType = "text/xml";
request.AllowWriteStreamBuffering = true;
request.Timeout = timeout;
Stream stream = request.GetRequestStream();
XmlTextWriter xml = new XmlTextWriter(stream, _encoding);
_serializer.Serialize(xml, this);
xml.Flush();
xml.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader input = new StreamReader(response.GetResponseStream());
XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input);
input.Close();
response.Close();
return resp;
}
/// <summary>Produce <c>String</c> representation of the object.</summary>
/// <returns><c>String</c> representation of the object.</returns>
override public String ToString()
{
return _serializer.Serialize(this);
}
}
}

View File

@ -0,0 +1,91 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Xml;
/// <summary>Class to deserialize XML data representing a request.</summary>
public class XmlRpcRequestDeserializer : XmlRpcDeserializer
{
static private XmlRpcRequestDeserializer _singleton;
/// <summary>A static singleton instance of this deserializer.</summary>
[Obsolete("This object is now thread safe, just use an instance.", false)]
static public XmlRpcRequestDeserializer Singleton
{
get
{
if (_singleton == null)
_singleton = new XmlRpcRequestDeserializer();
return _singleton;
}
}
/// <summary>Static method that parses XML data into a request using the Singleton.</summary>
/// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC request.</param>
/// <returns><c>XmlRpcRequest</c> object resulting from the parse.</returns>
override public Object Deserialize(TextReader xmlData)
{
XmlTextReader reader = new XmlTextReader(xmlData);
XmlRpcRequest request = new XmlRpcRequest();
bool done = false;
lock (this)
{
Reset();
while (!done && reader.Read())
{
DeserializeNode(reader); // Parent parse...
switch (reader.NodeType)
{
case XmlNodeType.EndElement:
switch (reader.Name)
{
case METHOD_NAME:
request.MethodName = _text;
break;
case METHOD_CALL:
done = true;
break;
case PARAM:
request.Params.Add(_value);
_text = null;
break;
}
break;
}
}
}
return request;
}
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.Xml;
using System.IO;
/// <summary>Class responsible for serializing an XML-RPC request.</summary>
/// <remarks>This class handles the request envelope, depending on <c>XmlRpcSerializer</c>
/// to serialize the payload.</remarks>
/// <seealso cref="XmlRpcSerializer"/>
public class XmlRpcRequestSerializer : XmlRpcSerializer
{
static private XmlRpcRequestSerializer _singleton;
/// <summary>A static singleton instance of this deserializer.</summary>
static public XmlRpcRequestSerializer Singleton
{
get
{
if (_singleton == null)
_singleton = new XmlRpcRequestSerializer();
return _singleton;
}
}
/// <summary>Serialize the <c>XmlRpcRequest</c> to the output stream.</summary>
/// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
/// <param name="obj">An <c>XmlRpcRequest</c> to serialize.</param>
/// <seealso cref="XmlRpcRequest"/>
override public void Serialize(XmlTextWriter output, Object obj)
{
XmlRpcRequest request = (XmlRpcRequest)obj;
output.WriteStartDocument();
output.WriteStartElement(METHOD_CALL);
output.WriteElementString(METHOD_NAME, request.MethodName);
output.WriteStartElement(PARAMS);
foreach (Object param in request.Params)
{
output.WriteStartElement(PARAM);
output.WriteStartElement(VALUE);
SerializeObject(output, param);
output.WriteEndElement();
output.WriteEndElement();
}
output.WriteEndElement();
output.WriteEndElement();
}
}
}

View File

@ -0,0 +1,125 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Xml;
using System.Net.Sockets;
/// <summary>The class is a container of the context of an XML-RPC dialog on the server side.</summary>
/// <remarks>Instances of this class maintain the context for an individual XML-RPC server
/// side dialog. Namely they manage an inbound deserializer and an outbound serializer. </remarks>
public class XmlRpcResponder
{
private XmlRpcRequestDeserializer _deserializer = new XmlRpcRequestDeserializer();
private XmlRpcResponseSerializer _serializer = new XmlRpcResponseSerializer();
private XmlRpcServer _server;
private TcpClient _client;
private SimpleHttpRequest _httpReq;
/// <summary>The SimpleHttpRequest based on the TcpClient.</summary>
public SimpleHttpRequest HttpReq
{
get { return _httpReq; }
}
/// <summary>Basic constructor.</summary>
/// <param name="server">XmlRpcServer that this XmlRpcResponder services.</param>
/// <param name="client">TcpClient with the connection.</param>
public XmlRpcResponder(XmlRpcServer server, TcpClient client)
{
_server = server;
_client = client;
_httpReq = new SimpleHttpRequest(_client);
}
/// <summary>Call close to insure proper shutdown.</summary>
~XmlRpcResponder()
{
Close();
}
///<summary>Respond using this responders HttpReq.</summary>
public void Respond()
{
Respond(HttpReq);
}
/// <summary>Handle an HTTP request containing an XML-RPC request.</summary>
/// <remarks>This method deserializes the XML-RPC request, invokes the
/// described method, serializes the response (or fault) and sends the XML-RPC response
/// back as a valid HTTP page.
/// </remarks>
/// <param name="httpReq"><c>SimpleHttpRequest</c> containing the request.</param>
public void Respond(SimpleHttpRequest httpReq)
{
XmlRpcRequest xmlRpcReq = (XmlRpcRequest)_deserializer.Deserialize(httpReq.Input);
XmlRpcResponse xmlRpcResp = new XmlRpcResponse();
try
{
xmlRpcResp.Value = _server.Invoke(xmlRpcReq);
}
catch (XmlRpcException e)
{
xmlRpcResp.SetFault(e.FaultCode, e.FaultString);
}
catch (Exception e2)
{
xmlRpcResp.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR,
XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
}
if (Logger.Delegate != null)
Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);
XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
httpReq.Output.Flush();
XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
_serializer.Serialize(xml, xmlRpcResp);
xml.Flush();
httpReq.Output.Flush();
}
///<summary>Close all contained resources, both the HttpReq and client.</summary>
public void Close()
{
if (_httpReq != null)
{
_httpReq.Close();
_httpReq = null;
}
if (_client != null)
{
_client.Close();
_client = null;
}
}
}
}

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Xml;
/// <summary>Class designed to represent an XML-RPC response.</summary>
public class XmlRpcResponse
{
private Object _value;
/// <summary><c>bool</c> indicating if this response represents a fault.</summary>
public bool IsFault;
/// <summary>Basic constructor</summary>
public XmlRpcResponse()
{
Value = null;
IsFault = false;
}
/// <summary>Constructor for a fault.</summary>
/// <param name="code"><c>int</c> the numeric faultCode value.</param>
/// <param name="message"><c>String</c> the faultString value.</param>
public XmlRpcResponse(int code, String message)
: this()
{
SetFault(code, message);
}
/// <summary>The data value of the response, may be fault data.</summary>
public Object Value
{
get { return _value; }
set
{
IsFault = false;
_value = value;
}
}
/// <summary>The faultCode if this is a fault.</summary>
public int FaultCode
{
get
{
if (!IsFault)
return 0;
else
return (int)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_CODE];
}
}
/// <summary>The faultString if this is a fault.</summary>
public String FaultString
{
get
{
if (!IsFault)
return "";
else
return (String)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_STRING];
}
}
/// <summary>Set this response to be a fault.</summary>
/// <param name="code"><c>int</c> the numeric faultCode value.</param>
/// <param name="message"><c>String</c> the faultString value.</param>
public void SetFault(int code, String message)
{
Hashtable fault = new Hashtable();
fault.Add("faultCode", code);
fault.Add("faultString", message);
Value = fault;
IsFault = true;
}
/// <summary>Form a useful string representation of the object, in this case the XML response.</summary>
/// <returns><c>String</c> The XML serialized XML-RPC response.</returns>
override public String ToString()
{
return XmlRpcResponseSerializer.Singleton.Serialize(this);
}
}
}

View File

@ -0,0 +1,92 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Xml;
/// <summary>Class to deserialize XML data representing a response.</summary>
public class XmlRpcResponseDeserializer : XmlRpcDeserializer
{
static private XmlRpcResponseDeserializer _singleton;
/// <summary>A static singleton instance of this deserializer.</summary>
[Obsolete("This object is now thread safe, just use an instance.", false)]
static public XmlRpcResponseDeserializer Singleton
{
get
{
if (_singleton == null)
_singleton = new XmlRpcResponseDeserializer();
return _singleton;
}
}
/// <summary>Static method that parses XML data into a response using the Singleton.</summary>
/// <param name="xmlData"><c>StreamReader</c> containing an XML-RPC response.</param>
/// <returns><c>XmlRpcResponse</c> object resulting from the parse.</returns>
override public Object Deserialize(TextReader xmlData)
{
XmlTextReader reader = new XmlTextReader(xmlData);
XmlRpcResponse response = new XmlRpcResponse();
bool done = false;
lock (this)
{
Reset();
while (!done && reader.Read())
{
DeserializeNode(reader); // Parent parse...
switch (reader.NodeType)
{
case XmlNodeType.EndElement:
switch (reader.Name)
{
case FAULT:
response.Value = _value;
response.IsFault = true;
break;
case PARAM:
response.Value = _value;
_value = null;
_text = null;
break;
}
break;
default:
break;
}
}
}
return response;
}
}
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.Xml;
/// <summary>Class responsible for serializing an XML-RPC response.</summary>
/// <remarks>This class handles the response envelope, depending on XmlRpcSerializer
/// to serialize the payload.</remarks>
/// <seealso cref="XmlRpcSerializer"/>
public class XmlRpcResponseSerializer : XmlRpcSerializer
{
static private XmlRpcResponseSerializer _singleton;
/// <summary>A static singleton instance of this deserializer.</summary>
static public XmlRpcResponseSerializer Singleton
{
get
{
if (_singleton == null)
_singleton = new XmlRpcResponseSerializer();
return _singleton;
}
}
/// <summary>Serialize the <c>XmlRpcResponse</c> to the output stream.</summary>
/// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
/// <param name="obj">An <c>Object</c> to serialize.</param>
/// <seealso cref="XmlRpcResponse"/>
override public void Serialize(XmlTextWriter output, Object obj)
{
XmlRpcResponse response = (XmlRpcResponse)obj;
output.WriteStartDocument();
output.WriteStartElement(METHOD_RESPONSE);
if (response.IsFault)
output.WriteStartElement(FAULT);
else
{
output.WriteStartElement(PARAMS);
output.WriteStartElement(PARAM);
}
output.WriteStartElement(VALUE);
SerializeObject(output, response.Value);
output.WriteEndElement();
output.WriteEndElement();
if (!response.IsFault)
output.WriteEndElement();
output.WriteEndElement();
}
}
}

View File

@ -0,0 +1,136 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Xml;
/// <summary>Base class of classes serializing data to XML-RPC's XML format.</summary>
/// <remarks>This class handles the basic type conversions like Integer to &lt;i4&gt;. </remarks>
/// <seealso cref="XmlRpcXmlTokens"/>
public class XmlRpcSerializer : XmlRpcXmlTokens
{
/// <summary>Serialize the <c>XmlRpcRequest</c> to the output stream.</summary>
/// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
/// <param name="obj">An <c>Object</c> to serialize.</param>
/// <seealso cref="XmlRpcRequest"/>
virtual public void Serialize(XmlTextWriter output, Object obj)
{
}
/// <summary>Serialize the <c>XmlRpcRequest</c> to a String.</summary>
/// <remarks>Note this may represent a real memory hog for a large request.</remarks>
/// <param name="obj">An <c>Object</c> to serialize.</param>
/// <returns><c>String</c> containing XML-RPC representation of the request.</returns>
/// <seealso cref="XmlRpcRequest"/>
public String Serialize(Object obj)
{
StringWriter strBuf = new StringWriter();
XmlTextWriter xml = new XmlTextWriter(strBuf);
xml.Formatting = Formatting.Indented;
xml.Indentation = 4;
Serialize(xml, obj);
xml.Flush();
String returns = strBuf.ToString();
xml.Close();
return returns;
}
/// <remarks>Serialize the object to the output stream.</remarks>
/// <param name="output">An <c>XmlTextWriter</c> stream to write data to.</param>
/// <param name="obj">An <c>Object</c> to serialize.</param>
public void SerializeObject(XmlTextWriter output, Object obj)
{
if (obj == null)
return;
if (obj is byte[])
{
byte[] ba = (byte[])obj;
output.WriteStartElement(BASE64);
output.WriteBase64(ba, 0, ba.Length);
output.WriteEndElement();
}
else if (obj is String)
{
output.WriteElementString(STRING, obj.ToString());
}
else if (obj is Int32)
{
output.WriteElementString(INT, obj.ToString());
}
else if (obj is DateTime)
{
output.WriteElementString(DATETIME, ((DateTime)obj).ToString(ISO_DATETIME));
}
else if (obj is Double)
{
output.WriteElementString(DOUBLE, obj.ToString());
}
else if (obj is Boolean)
{
output.WriteElementString(BOOLEAN, ((((Boolean)obj) == true) ? "1" : "0"));
}
else if (obj is IList)
{
output.WriteStartElement(ARRAY);
output.WriteStartElement(DATA);
if (((ArrayList)obj).Count > 0)
{
foreach (Object member in ((IList)obj))
{
output.WriteStartElement(VALUE);
SerializeObject(output, member);
output.WriteEndElement();
}
}
output.WriteEndElement();
output.WriteEndElement();
}
else if (obj is IDictionary)
{
IDictionary h = (IDictionary)obj;
output.WriteStartElement(STRUCT);
foreach (String key in h.Keys)
{
output.WriteStartElement(MEMBER);
output.WriteElementString(NAME, key);
output.WriteStartElement(VALUE);
SerializeObject(output, h[key]);
output.WriteEndElement();
output.WriteEndElement();
}
output.WriteEndElement();
}
}
}
}

View File

@ -0,0 +1,266 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Xml;
/// <summary>A restricted HTTP server for use with XML-RPC.</summary>
/// <remarks>It only handles POST requests, and only POSTs representing XML-RPC calls.
/// In addition to dispatching requests it also provides a registry for request handlers.
/// </remarks>
public class XmlRpcServer : IEnumerable
{
#pragma warning disable 0414 // disable "private field assigned but not used"
const int RESPONDER_COUNT = 10;
private TcpListener _myListener;
private int _port;
private IPAddress _address;
private IDictionary _handlers;
private XmlRpcSystemObject _system;
private WaitCallback _wc;
#pragma warning restore 0414
///<summary>Constructor with port and address.</summary>
///<remarks>This constructor sets up a TcpListener listening on the
///given port and address. It also calls a Thread on the method StartListen().</remarks>
///<param name="address"><c>IPAddress</c> value of the address to listen on.</param>
///<param name="port"><c>Int</c> value of the port to listen on.</param>
public XmlRpcServer(IPAddress address, int port)
{
_port = port;
_address = address;
_handlers = new Hashtable();
_system = new XmlRpcSystemObject(this);
_wc = new WaitCallback(WaitCallback);
}
///<summary>Basic constructor.</summary>
///<remarks>This constructor sets up a TcpListener listening on the
///given port. It also calls a Thread on the method StartListen(). IPAddress.Any
///is assumed as the address here.</remarks>
///<param name="port"><c>Int</c> value of the port to listen on.</param>
public XmlRpcServer(int port) : this(IPAddress.Any, port) { }
/// <summary>Start the server.</summary>
public void Start()
{
try
{
Stop();
//start listing on the given port
// IPAddress addr = IPAddress.Parse("127.0.0.1");
lock (this)
{
_myListener = new TcpListener(IPAddress.Any, _port);
_myListener.Start();
//start the thread which calls the method 'StartListen'
Thread th = new Thread(new ThreadStart(StartListen));
th.Start();
}
}
catch (Exception e)
{
Logger.WriteEntry("An Exception Occurred while Listening :" + e.ToString(), LogLevel.Error);
}
}
/// <summary>Stop the server.</summary>
public void Stop()
{
try
{
if (_myListener != null)
{
lock (this)
{
_myListener.Stop();
_myListener = null;
}
}
}
catch (Exception e)
{
Logger.WriteEntry("An Exception Occurred while stopping :" +
e.ToString(), LogLevel.Error);
}
}
/// <summary>Get an enumeration of my XML-RPC handlers.</summary>
/// <returns><c>IEnumerable</c> the handler enumeration.</returns>
public IEnumerator GetEnumerator()
{
return _handlers.GetEnumerator();
}
/// <summary>Retrieve a handler by name.</summary>
/// <param name="name"><c>String</c> naming a handler</param>
/// <returns><c>Object</c> that is the handler.</returns>
public Object this[String name]
{
get { return _handlers[name]; }
}
///<summary>
///This method Accepts new connections and dispatches them when appropriate.
///</summary>
public void StartListen()
{
while (true && _myListener != null)
{
//Accept a new connection
XmlRpcResponder responder = new XmlRpcResponder(this, _myListener.AcceptTcpClient());
ThreadPool.QueueUserWorkItem(_wc, responder);
}
}
///<summary>
///Add an XML-RPC handler object by name.
///</summary>
///<param name="name"><c>String</c> XML-RPC dispatch name of this object.</param>
///<param name="obj"><c>Object</c> The object that is the XML-RPC handler.</param>
public void Add(String name, Object obj)
{
_handlers.Add(name, obj);
}
///<summary>Return a C# object.method name for and XML-RPC object.method name pair.</summary>
///<param name="methodName">The XML-RPC object.method.</param>
///<returns><c>String</c> of form object.method for the underlying C# method.</returns>
public String MethodName(String methodName)
{
int dotAt = methodName.LastIndexOf('.');
if (dotAt == -1)
{
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Bad method name " + methodName);
}
String objectName = methodName.Substring(0, dotAt);
Object target = _handlers[objectName];
if (target == null)
{
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Object " + objectName + " not found");
}
return target.GetType().FullName + "." + methodName.Substring(dotAt + 1);
}
///<summary>Invoke a method described in a request.</summary>
///<param name="req"><c>XmlRpcRequest</c> containing a method descriptions.</param>
/// <seealso cref="XmlRpcSystemObject.Invoke"/>
/// <seealso cref="XmlRpcServer.Invoke(String,String,IList)"/>
public Object Invoke(XmlRpcRequest req)
{
return Invoke(req.MethodNameObject, req.MethodNameMethod, req.Params);
}
///<summary>Invoke a method on a named handler.</summary>
///<param name="objectName"><c>String</c> The name of the handler.</param>
///<param name="methodName"><c>String</c> The name of the method to invoke on the handler.</param>
///<param name="parameters"><c>IList</c> The parameters to invoke the method with.</param>
/// <seealso cref="XmlRpcSystemObject.Invoke"/>
public Object Invoke(String objectName, String methodName, IList parameters)
{
Object target = _handlers[objectName];
if (target == null)
{
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Object " + objectName + " not found");
}
return XmlRpcSystemObject.Invoke(target, methodName, parameters);
}
/// <summary>The method the thread pool invokes when a thread is available to handle an HTTP request.</summary>
/// <param name="responder">TcpClient from the socket accept.</param>
public void WaitCallback(object responder)
{
XmlRpcResponder resp = (XmlRpcResponder)responder;
if (resp.HttpReq.HttpMethod == "POST")
{
try
{
resp.Respond();
}
catch (Exception e)
{
Logger.WriteEntry("Failed on post: " + e, LogLevel.Error);
}
}
else
{
Logger.WriteEntry("Only POST methods are supported: " + resp.HttpReq.HttpMethod +
" ignored", LogLevel.Error);
}
resp.Close();
}
/// <summary>
/// This function send the Header Information to the client (Browser)
/// </summary>
/// <param name="sHttpVersion">HTTP Version</param>
/// <param name="sMIMEHeader">Mime Type</param>
/// <param name="iTotBytes">Total Bytes to be sent in the body</param>
/// <param name="sStatusCode"></param>
/// <param name="output">Socket reference</param>
static public void HttpHeader(string sHttpVersion, string sMIMEHeader, long iTotBytes, string sStatusCode, TextWriter output)
{
String sBuffer = "";
// if Mime type is not provided set default to text/html
if (sMIMEHeader.Length == 0)
{
sMIMEHeader = "text/html"; // Default Mime Type is text/html
}
sBuffer += sHttpVersion + sStatusCode + "\r\n";
sBuffer += "Connection: close\r\n";
if (iTotBytes > 0)
sBuffer += "Content-Length: " + iTotBytes + "\r\n";
sBuffer += "Server: XmlRpcServer \r\n";
sBuffer += "Content-Type: " + sMIMEHeader + "\r\n";
sBuffer += "\r\n";
output.Write(sBuffer);
}
}
}

View File

@ -0,0 +1,279 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
using System.Collections;
using System.Reflection;
/// <summary> XML-RPC System object implementation of extended specifications.</summary>
[XmlRpcExposed]
public class XmlRpcSystemObject
{
private XmlRpcServer _server;
static private IDictionary _methodHelp = new Hashtable();
/// <summary>Static <c>IDictionary</c> to hold mappings of method name to associated documentation String</summary>
static public IDictionary MethodHelp
{
get { return _methodHelp; }
}
/// <summary>Constructor.</summary>
/// <param name="server"><c>XmlRpcServer</c> server to be the system object for.</param>
public XmlRpcSystemObject(XmlRpcServer server)
{
_server = server;
server.Add("system", this);
_methodHelp.Add(this.GetType().FullName + ".methodHelp", "Return a string description.");
}
/// <summary>Invoke a method on a given object.</summary>
/// <remarks>Using reflection, and respecting the <c>XmlRpcExposed</c> attribute,
/// invoke the <paramref>methodName</paramref> method on the <paramref>target</paramref>
/// instance with the <paramref>parameters</paramref> provided. All this packages other <c>Invoke</c> methods
/// end up calling this.</remarks>
/// <returns><c>Object</c> the value the invoked method returns.</returns>
/// <exception cref="XmlRpcException">If method does not exist, is not exposed, parameters invalid, or invocation
/// results in an exception. Note, the <c>XmlRpcException.Code</c> will indicate cause.</exception>
static public Object Invoke(Object target, String methodName, IList parameters)
{
if (target == null)
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Invalid target object.");
Type type = target.GetType();
MethodInfo method = type.GetMethod(methodName);
try
{
if (!XmlRpcExposedAttribute.ExposedMethod(target, methodName))
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": Method " + methodName + " is not exposed.");
}
catch (MissingMethodException me)
{
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_METHOD,
XmlRpcErrorCodes.SERVER_ERROR_METHOD_MSG + ": " + me.Message);
}
Object[] args = new Object[parameters.Count];
int index = 0;
foreach (Object arg in parameters)
{
args[index] = arg;
index++;
}
try
{
Object retValue = method.Invoke(target, args);
if (retValue == null)
throw new XmlRpcException(XmlRpcErrorCodes.APPLICATION_ERROR,
XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": Method returned NULL.");
return retValue;
}
catch (XmlRpcException e)
{
throw e;
}
catch (ArgumentException ae)
{
Logger.WriteEntry(XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": " + ae.Message,
LogLevel.Information);
String call = methodName + "( ";
foreach (Object o in args)
{
call += o.GetType().Name;
call += " ";
}
call += ")";
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_PARAMS,
XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": Arguement type mismatch invoking " + call);
}
catch (TargetParameterCountException tpce)
{
Logger.WriteEntry(XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": " + tpce.Message,
LogLevel.Information);
throw new XmlRpcException(XmlRpcErrorCodes.SERVER_ERROR_PARAMS,
XmlRpcErrorCodes.SERVER_ERROR_PARAMS_MSG + ": Arguement count mismatch invoking " + methodName);
}
catch (TargetInvocationException tie)
{
throw new XmlRpcException(XmlRpcErrorCodes.APPLICATION_ERROR,
XmlRpcErrorCodes.APPLICATION_ERROR_MSG + " Invoked method " + methodName + ": " + tie.Message);
}
}
/// <summary>List methods available on all handlers of this server.</summary>
/// <returns><c>IList</c> An array of <c>Strings</c>, each <c>String</c> will have form "object.method".</returns>
[XmlRpcExposed]
public IList listMethods()
{
IList methods = new ArrayList();
Boolean considerExposure;
foreach (DictionaryEntry handlerEntry in _server)
{
considerExposure = XmlRpcExposedAttribute.IsExposed(handlerEntry.Value.GetType());
foreach (MemberInfo mi in handlerEntry.Value.GetType().GetMembers())
{
if (mi.MemberType != MemberTypes.Method)
continue;
if (!((MethodInfo)mi).IsPublic)
continue;
if (considerExposure && !XmlRpcExposedAttribute.IsExposed(mi))
continue;
methods.Add(handlerEntry.Key + "." + mi.Name);
}
}
return methods;
}
/// <summary>Given a method name return the possible signatures for it.</summary>
/// <param name="name"><c>String</c> The object.method name to look up.</param>
/// <returns><c>IList</c> Of arrays of signatures.</returns>
[XmlRpcExposed]
public IList methodSignature(String name)
{
IList signatures = new ArrayList();
int index = name.IndexOf('.');
if (index < 0)
return signatures;
String oName = name.Substring(0, index);
Object obj = _server[oName];
if (obj == null)
return signatures;
MemberInfo[] mi = obj.GetType().GetMember(name.Substring(index + 1));
if (mi == null || mi.Length != 1) // for now we want a single signature
return signatures;
MethodInfo method;
try
{
method = (MethodInfo)mi[0];
}
catch (Exception e)
{
Logger.WriteEntry("Attempted methodSignature call on " + mi[0] + " caused: " + e,
LogLevel.Information);
return signatures;
}
if (!method.IsPublic)
return signatures;
IList signature = new ArrayList();
signature.Add(method.ReturnType.Name);
foreach (ParameterInfo param in method.GetParameters())
{
signature.Add(param.ParameterType.Name);
}
signatures.Add(signature);
return signatures;
}
/// <summary>Help for given method signature. Not implemented yet.</summary>
/// <param name="name"><c>String</c> The object.method name to look up.</param>
/// <returns><c>String</c> help text. Rich HTML text.</returns>
[XmlRpcExposed]
public String methodHelp(String name)
{
String help = null;
try
{
help = (String)_methodHelp[_server.MethodName(name)];
}
catch (XmlRpcException e)
{
throw e;
}
catch (Exception) { /* ignored */ };
if (help == null)
help = "No help available for: " + name;
return help;
}
/// <summary>Boxcarring support method.</summary>
/// <param name="calls"><c>IList</c> of calls</param>
/// <returns><c>ArrayList</c> of results/faults.</returns>
[XmlRpcExposed]
public IList multiCall(IList calls)
{
IList responses = new ArrayList();
XmlRpcResponse fault = new XmlRpcResponse();
foreach (IDictionary call in calls)
{
try
{
XmlRpcRequest req = new XmlRpcRequest((String)call[XmlRpcXmlTokens.METHOD_NAME],
(ArrayList)call[XmlRpcXmlTokens.PARAMS]);
Object results = _server.Invoke(req);
IList response = new ArrayList();
response.Add(results);
responses.Add(response);
}
catch (XmlRpcException e)
{
fault.SetFault(e.FaultCode, e.FaultString);
responses.Add(fault.Value);
}
catch (Exception e2)
{
fault.SetFault(XmlRpcErrorCodes.APPLICATION_ERROR,
XmlRpcErrorCodes.APPLICATION_ERROR_MSG + ": " + e2.Message);
responses.Add(fault.Value);
}
}
return responses;
}
}
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace Nwc.XmlRpc
{
using System;
/// <summary>Class collecting <c>String</c> tokens that are part of XML-RPC files.</summary>
public class XmlRpcXmlTokens
{
/// <summary>C# formatting string to describe an ISO 8601 date.</summary>
public const String ISO_DATETIME = "yyyyMMdd\\THH\\:mm\\:ss";
/// <summary>Base64 field indicator.</summary>
/// <remarks>Corresponds to the &lt;base64&gt; tag.</remarks>
public const String BASE64 = "base64";
/// <summary>String field indicator.</summary>
/// <remarks>Corresponds to the &lt;string&gt; tag.</remarks>
public const String STRING = "string";
/// <summary>Integer field integer.</summary>
/// <remarks>Corresponds to the &lt;i4&gt; tag.</remarks>
public const String INT = "i4";
/// <summary>Alternate integer field indicator.</summary>
/// <remarks>Corresponds to the &lt;int&gt; tag.</remarks>
public const String ALT_INT = "int";
/// <summary>Date field indicator.</summary>
/// <remarks>Corresponds to the &lt;dateTime.iso8601&gt; tag.</remarks>
public const String DATETIME = "dateTime.iso8601";
/// <summary>Boolean field indicator.</summary>
/// <remarks>Corresponds to the &lt;boolean&gt; tag.</remarks>
public const String BOOLEAN = "boolean";
/// <summary>Value token.</summary>
/// <remarks>Corresponds to the &lt;value&gt; tag.</remarks>
public const String VALUE = "value";
/// <summary>Name token.</summary>
/// <remarks>Corresponds to the &lt;name&gt; tag.</remarks>
public const String NAME = "name";
/// <summary>Array field indicator..</summary>
/// <remarks>Corresponds to the &lt;array&gt; tag.</remarks>
public const String ARRAY = "array";
/// <summary>Data token.</summary>
/// <remarks>Corresponds to the &lt;data&gt; tag.</remarks>
public const String DATA = "data";
/// <summary>Member token.</summary>
/// <remarks>Corresponds to the &lt;member&gt; tag.</remarks>
public const String MEMBER = "member";
/// <summary>Stuct field indicator.</summary>
/// <remarks>Corresponds to the &lt;struct&gt; tag.</remarks>
public const String STRUCT = "struct";
/// <summary>Double field indicator.</summary>
/// <remarks>Corresponds to the &lt;double&gt; tag.</remarks>
public const String DOUBLE = "double";
/// <summary>Param token.</summary>
/// <remarks>Corresponds to the &lt;param&gt; tag.</remarks>
public const String PARAM = "param";
/// <summary>Params token.</summary>
/// <remarks>Corresponds to the &lt;params&gt; tag.</remarks>
public const String PARAMS = "params";
/// <summary>MethodCall token.</summary>
/// <remarks>Corresponds to the &lt;methodCall&gt; tag.</remarks>
public const String METHOD_CALL = "methodCall";
/// <summary>MethodName token.</summary>
/// <remarks>Corresponds to the &lt;methodName&gt; tag.</remarks>
public const String METHOD_NAME = "methodName";
/// <summary>MethodResponse token</summary>
/// <remarks>Corresponds to the &lt;methodResponse&gt; tag.</remarks>
public const String METHOD_RESPONSE = "methodResponse";
/// <summary>Fault response token.</summary>
/// <remarks>Corresponds to the &lt;fault&gt; tag.</remarks>
public const String FAULT = "fault";
/// <summary>FaultCode token.</summary>
/// <remarks>Corresponds to the &lt;faultCode&gt; tag.</remarks>
public const String FAULT_CODE = "faultCode";
/// <summary>FaultString token.</summary>
/// <remarks>Corresponds to the &lt;faultString&gt; tag.</remarks>
public const String FAULT_STRING = "faultString";
}
}

View File

@ -1,38 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C# Express 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OGS-UserServer", "userserver\src\OGS-UserServer.csproj", "{D45B6E48-5668-478D-B9CB-6D46E665FACF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OGS-GridServer", "gridserver\src\OGS-GridServer.csproj", "{FE50A574-C8ED-433B-95F0-213A5EED2AB2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerConsole", "ServerConsole\ServerConsole.csproj", "{7667E6E2-F227-41A2-B1B2-315613E1BAFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework", "..\OpenSim.FrameWork\OpenSim.Framework.csproj", "{2E46A825-3168-492F-93BC-637126B5B72B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D45B6E48-5668-478D-B9CB-6D46E665FACF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D45B6E48-5668-478D-B9CB-6D46E665FACF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D45B6E48-5668-478D-B9CB-6D46E665FACF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D45B6E48-5668-478D-B9CB-6D46E665FACF}.Release|Any CPU.Build.0 = Release|Any CPU
{FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE50A574-C8ED-433B-95F0-213A5EED2AB2}.Release|Any CPU.Build.0 = Release|Any CPU
{7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7667E6E2-F227-41A2-B1B2-315613E1BAFC}.Release|Any CPU.Build.0 = Release|Any CPU
{2E46A825-3168-492F-93BC-637126B5B72B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E46A825-3168-492F-93BC-637126B5B72B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E46A825-3168-492F-93BC-637126B5B72B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E46A825-3168-492F-93BC-637126B5B72B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,98 +0,0 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
namespace ServerConsole
{
public class MainConsole {
private static ConsoleBase instance;
public static ConsoleBase Instance
{
get
{
return instance;
}
set
{
instance = value;
}
}
public MainConsole()
{
}
}
public abstract class conscmd_callback {
public abstract void RunCmd(string cmd, string[] cmdparams);
public abstract void Show(string ShowWhat);
}
public abstract class ConsoleBase
{
public enum ConsoleType {
Local, // Use stdio
TCP, // Use TCP/telnet
SimChat // Use in-world chat (for gods)
}
public abstract void Close();
// You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here
public abstract void WriteLine(string Line) ;
public abstract string ReadLine();
public abstract int Read() ;
public abstract void Write(string Line) ;
public abstract string PasswdPrompt(string prompt);
// Displays a command prompt and waits for the user to enter a string, then returns that string
public abstract string CmdPrompt(string prompt) ;
// Displays a command prompt and returns a default value if the user simply presses enter
public abstract string CmdPrompt(string prompt, string defaultresponse);
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public abstract string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) ;
// Runs a command with a number of parameters
public abstract Object RunCmd(string Cmd, string[] cmdparams) ;
// Shows data about something
public abstract void ShowCommands(string ShowWhat) ;
// Displays a prompt to the user and then runs the command they entered
public abstract void MainConsolePrompt() ;
}
}

View File

@ -1,48 +0,0 @@
<?xml version="1.0"?>
<project name="ServerConsole" default="build" basedir=".">
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="../common/bin/ServerConsole.dll" failonerror="false" />
<delete file="../common/bin/ServerConsole.dll.mdb" failonerror="false" />
</target>
<target name="svnupdate" description="updates to latest SVN">
<exec program="svn">
<arg value="update" />
</exec>
</target>
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
</target>
<target name="build" description="compiles the source code">
<loadfile file="../VERSION" property="svnver"/>
<asminfo output="AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.InteropServices" />
</imports>
<attributes>
<attribute type="ComVisibleAttribute" value="false" />
<attribute type="CLSCompliantAttribute" value="false" />
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
<attribute type="AssemblyTitleAttribute" value="ogs-serverconsole" />
<attribute type="AssemblyDescriptionAttribute" value="The default server console" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="library" output="../common/bin/ServerConsole.dll" debug="${debug}" verbose="true" warninglevel="4">
<references>
<include name="System" />
<include name="System.Xml" />
</references>
<sources>
<include name="*.cs" />
</sources>
</csc>
</target>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,181 +0,0 @@
/*
* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.IO;
using System.Net;
using ServerConsole;
namespace OpenGridServices
{
/// <summary>
/// Description of ServerConsole.
/// </summary>
public class MServerConsole : ConsoleBase
{
private ConsoleType ConsType;
StreamWriter Log;
public conscmd_callback cmdparser;
public string componentname;
// STUPID HACK ALERT!!!! STUPID HACK ALERT!!!!!
// constype - the type of console to use (see enum ConsoleType)
// sparam - depending on the console type:
// TCP - the IP to bind to (127.0.0.1 if blank)
// Local - param ignored
// and for the iparam:
// TCP - the port to bind to
// Local - param ignored
// LogFile - duh
// componentname - which component of the OGS system? (user, asset etc)
// cmdparser - a reference to a conscmd_callback object
public MServerConsole(ConsoleType constype, string sparam, int iparam, string LogFile, string componentname, conscmd_callback cmdparser) {
ConsType = constype;
this.componentname = componentname;
this.cmdparser = cmdparser;
switch(constype) {
case ConsoleType.Local:
Console.WriteLine("ServerConsole.cs - creating new local console");
Console.WriteLine("Logs will be saved to current directory in " + LogFile);
Log=File.AppendText(LogFile);
Log.WriteLine("========================================================================");
Log.WriteLine(componentname + " " + VersionInfo.Version + " Started at " + DateTime.Now.ToString());
break;
case ConsoleType.TCP:
break;
default:
Console.WriteLine("ServerConsole.cs - what are you smoking? that isn't a valid console type!");
break;
}
}
public override void Close() {
Log.WriteLine("Shutdown at " + DateTime.Now.ToString());
Log.Close();
}
// You know what ReadLine() and WriteLine() do, right? And Read() and Write()? Right, you do actually know C#, right? Are you actually a programmer? Do you know english? Do you find my sense of humour in comments irritating? Good, glad you're still here
public override void WriteLine(string Line) {
Log.WriteLine(Line);
Console.WriteLine(Line);
return;
}
public override string ReadLine() {
string TempStr=Console.ReadLine();
Log.WriteLine(TempStr);
return TempStr;
}
public override int Read() {
int TempInt= Console.Read();
Log.Write((char)TempInt);
return TempInt;
}
public override void Write(string Line) {
Console.Write(Line);
Log.Write(Line);
return;
}
// Displays a prompt and waits for the user to enter a string, then returns that string
// Done with no echo and suitable for passwords
public override string PasswdPrompt(string prompt) {
// FIXME: Needs to be better abstracted
Log.WriteLine(prompt);
this.Write(prompt);
ConsoleColor oldfg=Console.ForegroundColor;
Console.ForegroundColor=Console.BackgroundColor;
string temp=Console.ReadLine();
Console.ForegroundColor=oldfg;
return temp;
}
// Displays a command prompt and waits for the user to enter a string, then returns that string
public override string CmdPrompt(string prompt) {
this.Write(prompt);
return this.ReadLine();
}
// Displays a command prompt and returns a default value if the user simply presses enter
public override string CmdPrompt(string prompt, string defaultresponse) {
string temp=CmdPrompt(prompt);
if(temp=="") {
return defaultresponse;
} else {
return temp;
}
}
// Displays a command prompt and returns a default value, user may only enter 1 of 2 options
public override string CmdPrompt(string prompt, string defaultresponse, string OptionA, string OptionB) {
bool itisdone=false;
string temp=CmdPrompt(prompt,defaultresponse);
while(itisdone==false) {
if((temp==OptionA) || (temp==OptionB)) {
itisdone=true;
} else {
this.WriteLine("Valid options are " + OptionA + " or " + OptionB);
temp=CmdPrompt(prompt,defaultresponse);
}
}
return temp;
}
// Runs a command with a number of parameters
public override Object RunCmd(string Cmd, string[] cmdparams) {
cmdparser.RunCmd(Cmd, cmdparams);
return null;
}
// Shows data about something
public override void ShowCommands(string ShowWhat) {
cmdparser.Show(ShowWhat);
}
public override void MainConsolePrompt() {
string[] tempstrarray;
string tempstr = this.CmdPrompt(this.componentname + "# ");
tempstrarray = tempstr.Split(' ');
string cmd=tempstrarray[0];
Array.Reverse(tempstrarray);
Array.Resize<string>(ref tempstrarray,tempstrarray.Length-1);
Array.Reverse(tempstrarray);
string[] cmdparams=(string[])tempstrarray;
RunCmd(cmd,cmdparams);
}
}
}

View File

@ -1,64 +0,0 @@
<?xml version="1.0"?>
<project name="GridServer" default="build" basedir="./">
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete>
<fileset failonempty="false">
<include name="bin/*.dll" />
<include name="bin/*.exe" />
<include name="bin/*.mdb" />
</fileset>
</delete>
</target>
<target name="svnupdate" description="updates to latest SVN">
<exec program="svn">
<arg value="update" />
</exec>
</target>
<target name="upgrade" description="updates from SVN and then builds" depends="clean,svnupdate,build">
</target>
<target name="build" description="compiles the source code">
<loadfile file="../VERSION" property="svnver"/>
<asminfo output="src/AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.InteropServices" />
</imports>
<attributes>
<attribute type="ComVisibleAttribute" value="false" />
<attribute type="CLSCompliantAttribute" value="false" />
<attribute type="AssemblyVersionAttribute" value="${svnver}" />
<attribute type="AssemblyTitleAttribute" value="ogs-GridServer" />
<attribute type="AssemblyDescriptionAttribute" value="The core OGS Grid Server" />
<attribute type="AssemblyCopyrightAttribute" value="Copyright © OGS development team 2007"/>
</attributes>
</asminfo>
<csc target="exe" output="bin/GridServer.exe" debug="${debug}" verbose="true" warninglevel="4">
<references failonempty="true">
<include name="System" />
<include name="System.Xml" />
<include name="../common/bin/ServerConsole.dll" />
<include name="../common/bin/libsecondlife.dll" />
</references>
<sources>
<include name="../common/src/VersionInfo.cs" />
<include name="../common/src/OGS-Console.cs" />
<include name="../common/src/Util.cs" />
<include name="src/*.cs" />
</sources>
</csc>
<copy todir="bin/">
<fileset basedir="../common/bin">
<include name="*.*" />
</fileset>
</copy>
</target>
</project>

View File

@ -1,166 +0,0 @@
/*
Copyright (c) OpenGrid project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using Nwc.XmlRpc;
using System.Threading;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using ServerConsole;
using OpenSim.Framework.Sims;
namespace OpenGridServices
{
public class GridHTTPServer {
public Thread HTTPD;
public HttpListener Listener;
public GridHTTPServer() {
ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
public void StartHTTP() {
ServerConsole.MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
Listener.Prefixes.Add("http://+:8001/gridserver/");
Listener.Start();
HttpListenerContext context;
while(true) {
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
static string ParseXMLRPC(string requestBody) {
try{
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody);
Hashtable requestData = (Hashtable)request.Params[0];
switch(request.MethodName) {
case "get_sim_info":
ulong req_handle=(ulong)Convert.ToInt64(requestData["region_handle"]);
SimProfileBase TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(req_handle);
string RecvKey="";
string caller=(string)requestData["caller"];
switch(caller) {
case "userserver":
RecvKey=OpenGrid_Main.thegrid.UserRecvKey;
break;
case "assetserver":
RecvKey=OpenGrid_Main.thegrid.AssetRecvKey;
break;
}
if((TheSim!=null) && (string)requestData["authkey"]==RecvKey) {
XmlRpcResponse SimInfoResp = new XmlRpcResponse();
Hashtable SimInfoData = new Hashtable();
SimInfoData["UUID"]=TheSim.UUID.ToString();
SimInfoData["regionhandle"]=TheSim.regionhandle.ToString();
SimInfoData["regionname"]=TheSim.regionname;
SimInfoData["sim_ip"]=TheSim.sim_ip;
SimInfoData["sim_port"]=TheSim.sim_port.ToString();
SimInfoData["caps_url"]=TheSim.caps_url;
SimInfoData["RegionLocX"]=TheSim.RegionLocX.ToString();
SimInfoData["RegionLocY"]=TheSim.RegionLocY.ToString();
SimInfoData["sendkey"]=TheSim.sendkey;
SimInfoData["recvkey"]=TheSim.recvkey;
SimInfoResp.Value=SimInfoData;
return(Regex.Replace(XmlRpcResponseSerializer.Singleton.Serialize(SimInfoResp),"utf-16","utf-8"));
} else {
XmlRpcResponse SimErrorResp = new XmlRpcResponse();
Hashtable SimErrorData = new Hashtable();
SimErrorData["error"]="sim not found";
SimErrorResp.Value=SimErrorData;
return(XmlRpcResponseSerializer.Singleton.Serialize(SimErrorResp));
}
break;
}
} catch(Exception e) {
Console.WriteLine(e.ToString());
}
return "";
}
static string ParseREST(string requestBody, string requestURL) {
return "";
}
static void HandleRequest(Object stateinfo) {
HttpListenerContext context=(HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
response.KeepAlive=false;
response.SendChunked=false;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
string responseString="";
switch(request.ContentType) {
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString=ParseXMLRPC(requestBody);
response.AddHeader("Content-type","text/xml");
break;
case null:
// must be REST or invalid crap, so pass to the REST parser
responseString=ParseREST(request.Url.OriginalString,requestBody);
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked=false;
response.ContentLength64=buffer.Length;
output.Write(buffer,0,buffer.Length);
output.Close();
}
}
}

View File

@ -1,94 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using libsecondlife;
using ServerConsole;
namespace OpenGridServices
{
/// <summary>
/// </summary>
public class OpenGrid_Main
{
public static OpenGrid_Main thegrid;
public string GridOwner;
public string DefaultStartupMsg;
public string DefaultAssetServer;
public string AssetSendKey;
public string AssetRecvKey;
public string DefaultUserServer;
public string UserSendKey;
public string UserRecvKey;
public GridHTTPServer _httpd;
public SimProfileManager _regionmanager;
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("OpenGrid " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenGrid", new GridConsole());
thegrid = new OpenGrid_Main();
thegrid.Startup();
ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n");
while(true) {
ServerConsole.MainConsole.Instance.MainConsolePrompt();
}
}
public void Startup() {
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
this.GridOwner=ServerConsole.MainConsole.Instance.CmdPrompt("Grid owner [OGS development team]: ","OGS development team");
this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!]: ","Welcome to OGS!");
this.DefaultAssetServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default asset server [no default]: ");
this.AssetSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to asset server: ");
this.AssetRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from asset server: ");
this.DefaultUserServer=ServerConsole.MainConsole.Instance.CmdPrompt("Default user server [no default]: ");
this.UserSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to user server: ");
this.UserRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from user server: ");
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
_httpd = new GridHTTPServer();
this._regionmanager=new SimProfileManager();
_regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey);
}
}
}

View File

@ -1,63 +0,0 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FE50A574-C8ED-433B-95F0-213A5EED2AB2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OGS_GridServer</RootNamespace>
<AssemblyName>OGS-GridServer</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="libsecondlife, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\common\bin\libsecondlife.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\common\src\OGS-Console.cs">
<Link>OGS-Console.cs</Link>
</Compile>
<Compile Include="..\..\common\VersionInfo\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
<Compile Include="ConsoleCmds.cs" />
<Compile Include="GridHttp.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimProfiles.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\OpenSim.FrameWork\OpenSim.Framework.csproj">
<Project>{2E46A825-3168-492F-93BC-637126B5B72B}</Project>
<Name>OpenSim.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\ServerConsole\ServerConsole.csproj">
<Project>{7667E6E2-F227-41A2-B1B2-315613E1BAFC}</Project>
<Name>ServerConsole</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,114 +0,0 @@
/*
Copyright (c) OpenGrid project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using ServerConsole;
using OpenSim.Framework.Utilities;
using OpenSim.Framework.Sims;
namespace OpenGridServices
{
/// <summary>
/// </summary>
public class SimProfileManager {
public Dictionary<LLUUID, SimProfileBase> SimProfiles = new Dictionary<LLUUID, SimProfileBase>();
public SimProfileManager() {
}
public void InitSimProfiles() {
// TODO: need to load from database
}
public SimProfileBase GetProfileByHandle(ulong reqhandle) {
foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) {
if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID];
}
return null;
}
public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) {
return SimProfiles[ProfileLLUUID];
}
public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) {
SimProfileBase TheSim=GetProfileByHandle(regionhandle);
if(TheSim != null)
if(TheSim.recvkey==simrecvkey) {
return true;
} else {
return false;
} else return false;
}
public SimProfileBase CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) {
SimProfileBase newprofile = new SimProfileBase();
newprofile.regionname=regionname;
newprofile.sim_ip=sim_ip;
newprofile.sim_port=sim_port;
newprofile.RegionLocX=RegionLocX;
newprofile.RegionLocY=RegionLocY;
newprofile.caps_url="http://" + sim_ip + ":9000/";
newprofile.sendkey=sendkey;
newprofile.recvkey=recvkey;
newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
newprofile.UUID=LLUUID.Random();
this.SimProfiles.Add(newprofile.UUID,newprofile);
return newprofile;
}
}
/* is in OpenSim.Framework
public class SimProfileBase {
public LLUUID UUID;
public ulong regionhandle;
public string regionname;
public string sim_ip;
public uint sim_port;
public string caps_url;
public uint RegionLocX;
public uint RegionLocY;
public string sendkey;
public string recvkey;
public SimProfileBase() {
}
}*/
}

View File

@ -1,118 +0,0 @@
/*
Copyright (c) OpenSim project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using ServerConsole;
using OpenSim.Framework.User;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
namespace OpenGridServices
{
/// <summary>
/// </summary>
public class OpenUser_Main
{
public static OpenUser_Main userserver;
public UserHTTPServer _httpd;
public UserProfileManager _profilemanager;
public UserProfile GridGod;
public string DefaultStartupMsg;
public string GridURL;
public string GridSendKey;
public string GridRecvKey;
public Dictionary<LLUUID, UserProfile> UserSessions = new Dictionary<LLUUID, UserProfile>();
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("OpenUser " + VersionInfo.Version + "\n");
Console.WriteLine("Starting...\n");
ServerConsole.MainConsole.Instance = new MServerConsole(ServerConsole.ConsoleBase.ConsoleType.Local, "", 0, "opengrid-console.log", "OpenUser", new UserConsole());
userserver = new OpenUser_Main();
userserver.Startup();
ServerConsole.MainConsole.Instance.WriteLine("\nEnter help for a list of commands\n");
while(true) {
ServerConsole.MainConsole.Instance.MainConsolePrompt();
}
}
public void Startup() {
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: ");
this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid: ");
this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid: ");
this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!");
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
_profilemanager = new UserProfileManager();
_profilemanager.InitUserProfiles();
_profilemanager.SetKeys(GridSendKey, GridRecvKey, GridURL, DefaultStartupMsg);
string tempfirstname;
string templastname;
string tempMD5Passwd;
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please configure the grid god user:");
tempfirstname=ServerConsole.MainConsole.Instance.CmdPrompt("First name: ");
templastname=ServerConsole.MainConsole.Instance.CmdPrompt("Last name: ");
tempMD5Passwd=ServerConsole.MainConsole.Instance.PasswdPrompt("Password: ");
System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(tempMD5Passwd);
bs = x.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}
tempMD5Passwd = "$1$" + s.ToString();
GridGod=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd);
_profilemanager.SetGod(GridGod.UUID);
GridGod.homelookat = new LLVector3(-0.57343f, -0.819255f, 0f);
GridGod.homepos = new LLVector3(128f,128f,23f);
ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process");
_httpd = new UserHTTPServer();
}
}
}

View File

@ -1,8 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<ApplicationRevision>0</ApplicationRevision>
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

View File

@ -1,146 +0,0 @@
/*
Copyright (c) OpenGrid project, http://osgrid.org/
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Text;
using Nwc.XmlRpc;
using System.Threading;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using ServerConsole;
using OpenSim.Framework.User;
using OpenSim.Framework.Sims;
using OpenSim.Framework.Inventory;
namespace OpenGridServices
{
public class UserHTTPServer {
public Thread HTTPD;
public HttpListener Listener;
public UserHTTPServer() {
ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
public void StartHTTP() {
ServerConsole.MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
Listener.Prefixes.Add("http://+:8002/userserver/");
Listener.Prefixes.Add("http://+:8002/usersessions/");
Listener.Start();
HttpListenerContext context;
while(true) {
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
static string ParseXMLRPC(string requestBody) {
return OpenGridServices.OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
}
static string ParseREST(HttpListenerRequest www_req) {
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
char[] splitter = {'/'};
string[] rest_params = www_req.RawUrl.Split(splitter);
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
switch(req_type) {
case "usersessions":
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
if(www_req.HttpMethod=="DELETE") {
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) {
if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) {
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
}
}
}
return "OK";
break;
}
return "";
}
static void HandleRequest(Object stateinfo) {
HttpListenerContext context=(HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
response.KeepAlive=false;
response.SendChunked=false;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
string responseString="";
switch(request.ContentType) {
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString=ParseXMLRPC(requestBody);
response.AddHeader("Content-type","text/xml");
break;
case "text/plaintext":
responseString=ParseREST(request);
response.AddHeader("Content-type","text/plaintext");
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked=false;
response.ContentLength64=buffer.Length;
output.Write(buffer,0,buffer.Length);
output.Close();
}
}
}

103
OpenGridServices.build Normal file
View File

@ -0,0 +1,103 @@
<?xml version="1.0" ?>
<project name="OpenGridServices" default="build">
<echo message="Using '${nant.settings.currentframework}' Framework"/>
<property name="bin.dir" value="bin" />
<property name="obj.dir" value="obj" />
<property name="doc.dir" value="doc" />
<property name="project.main.dir" value="${project::get-base-directory()}" />
<target name="Debug" description="">
<property name="project.config" value="Debug" />
<property name="build.debug" value="true" />
</target>
<property name="project.config" value="Release" />
<target name="Release" description="">
<property name="project.config" value="Release" />
<property name="build.debug" value="false" />
</target>
<target name="net-1.1" description="Sets framework to .NET 1.1">
<property name="nant.settings.currentframework" value="net-1.1" />
</target>
<target name="net-2.0" description="Sets framework to .NET 2.0">
<property name="nant.settings.currentframework" value="net-2.0" />
</target>
<target name="mono-2.0" description="Sets framework to mono 2.0">
<property name="nant.settings.currentframework" value="mono-2.0" />
</target>
<target name="mono-1.0" description="Sets framework to mono 1.0">
<property name="nant.settings.currentframework" value="mono-1.0" />
</target>
<target name="init" description="">
<call target="${project.config}" />
<sysinfo />
<echo message="Platform ${sys.os.platform}" />
<property name="build.dir" value="${bin.dir}/${project.config}" />
</target>
<target name="clean" description="">
<echo message="Deleting all builds from all configurations" />
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${obj.dir}" failonerror="false" />
<nant buildfile="OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.dll.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build" target="clean" />
<nant buildfile="OpenGridServices/ServiceManager/ServiceManager.exe.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.dll.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.dll.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build" target="clean" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.dll.build" target="clean" />
</target>
<target name="build" depends="init" description="">
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.dll.build" target="build" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.dll.build" target="build" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build" target="build" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.dll.build" target="build" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.dll.build" target="build" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build" target="build" />
<nant buildfile="OpenGridServices/ServiceManager/ServiceManager.exe.build" target="build" />
<nant buildfile="OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build" target="build" />
<nant buildfile="OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build" target="build" />
<nant buildfile="OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build" target="build" />
<nant buildfile="OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build" target="build" />
<nant buildfile="OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build" target="build" />
<nant buildfile="OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build" target="build" />
</target>
<target name="build-release" depends="Release, init, build" description="Builds in Release mode" />
<target name="build-debug" depends="Debug, init, build" description="Builds in Debug mode" />
<target name="package" depends="clean, doc" description="Builds all" />
<target name="doc" depends="build-release">
<echo message="Generating all documentation from all builds" />
<nant buildfile="OpenGridServices/OpenUser.Config/UserConfigDb4o/OpenUser.Config.UserConfigDb4o.dll.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGridServices.AssetServer/OpenGridServices.AssetServer.exe.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Config/GridConfigDb4o/OpenGrid.Config.GridConfigDb4o.dll.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.dll.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build" target="doc" />
<nant buildfile="OpenGridServices/ServiceManager/ServiceManager.exe.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Manager/OpenGrid.Framework.Manager.dll.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGridServices.GridServer/OpenGridServices.GridServer.exe.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.dll.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.dll.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGridServices.InventoryServer/OpenGridServices.InventoryServer.exe.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGridServices.UserServer/OpenGridServices.UserServer.exe.build" target="doc" />
<nant buildfile="OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.dll.build" target="doc" />
</target>
</project>

91
OpenGridServices.sln Normal file
View File

@ -0,0 +1,91 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenUser.Config.UserConfigDb4o", "OpenGridServices\OpenUser.Config\UserConfigDb4o\OpenUser.Config.UserConfigDb4o.csproj", "{7E494328-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.AssetServer", "OpenGridServices\OpenGridServices.AssetServer\OpenGridServices.AssetServer.csproj", "{0021261B-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Config.GridConfigDb4o", "OpenGridServices\OpenGrid.Config\GridConfigDb4o\OpenGrid.Config.GridConfigDb4o.csproj", "{B0027747-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Framework.Data.SQLite", "OpenGridServices\OpenGrid.Framework.Data.SQLite\OpenGrid.Framework.Data.SQLite.csproj", "{1E3F341A-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Framework.Data.DB4o", "OpenGridServices\OpenGrid.Framework.Data.DB4o\OpenGrid.Framework.Data.DB4o.csproj", "{39BD9497-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceManager", "OpenGridServices\ServiceManager\ServiceManager.csproj", "{E141F4EE-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Framework.Manager", "OpenGridServices\OpenGrid.Framework.Manager\OpenGrid.Framework.Manager.csproj", "{7924FD35-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.GridServer", "OpenGridServices\OpenGridServices.GridServer\OpenGridServices.GridServer.csproj", "{21BFC8E2-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Framework.Data.MSSQL", "OpenGridServices\OpenGrid.Framework.Data.MSSQL\OpenGrid.Framework.Data.MSSQL.csproj", "{0A563AC1-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Framework.Data", "OpenGridServices\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj", "{62CDF671-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.InventoryServer", "OpenGridServices\OpenGridServices.InventoryServer\OpenGridServices.InventoryServer.csproj", "{338FA00B-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.UserServer", "OpenGridServices\OpenGridServices.UserServer\OpenGridServices.UserServer.csproj", "{66591469-0000-0000-0000-000000000000}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGrid.Framework.Data.MySQL", "OpenGridServices\OpenGrid.Framework.Data.MySQL\OpenGrid.Framework.Data.MySQL.csproj", "{0F3C3AC1-0000-0000-0000-000000000000}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7E494328-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E494328-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E494328-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E494328-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{0021261B-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0021261B-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0021261B-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0021261B-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{B0027747-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0027747-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0027747-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0027747-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{1E3F341A-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E3F341A-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E3F341A-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E3F341A-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{39BD9497-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39BD9497-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39BD9497-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39BD9497-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{E141F4EE-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E141F4EE-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E141F4EE-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E141F4EE-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{7924FD35-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7924FD35-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7924FD35-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7924FD35-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{21BFC8E2-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21BFC8E2-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21BFC8E2-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21BFC8E2-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{0A563AC1-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A563AC1-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A563AC1-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A563AC1-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{62CDF671-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62CDF671-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62CDF671-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62CDF671-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{338FA00B-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{338FA00B-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{338FA00B-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{338FA00B-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{66591469-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66591469-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66591469-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66591469-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
{0F3C3AC1-0000-0000-0000-000000000000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F3C3AC1-0000-0000-0000-000000000000}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F3C3AC1-0000-0000-0000-000000000000}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F3C3AC1-0000-0000-0000-000000000000}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("GridConfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GridConfig")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

View File

@ -0,0 +1,161 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces;
using Db4objects.Db4o;
namespace OpenGrid.Config.GridConfigDb4o
{
/// <summary>
/// A grid configuration interface for returning the DB4o Config Provider
/// </summary>
public class Db40ConfigPlugin: IGridConfig
{
/// <summary>
/// Loads and returns a configuration objeect
/// </summary>
/// <returns>A grid configuration object</returns>
public GridConfig GetConfigObject()
{
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Loading Db40Config dll");
return ( new DbGridConfig());
}
}
/// <summary>
/// A DB4o based Gridserver configuration object
/// </summary>
public class DbGridConfig : GridConfig
{
/// <summary>
/// The DB4o Database
/// </summary>
private IObjectContainer db;
/// <summary>
/// User configuration for the Grid Config interfaces
/// </summary>
public void LoadDefaults() {
OpenSim.Framework.Console.MainConsole.Instance.Notice("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
// About the grid options
this.GridOwner = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid owner", "OGS development team");
// Asset Options
this.DefaultAssetServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default asset server","http://127.0.0.1:8003/");
this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to asset server","null");
this.AssetRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from asset server","null");
// User Server Options
this.DefaultUserServer = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Default user server","http://127.0.0.1:8002/");
this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server","null");
this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server","null");
// Region Server Options
this.SimSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to sims","null");
this.SimRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from sims","null");
}
/// <summary>
/// Initialises a new configuration object
/// </summary>
public override void InitConfig() {
try {
// Perform Db4o initialisation
db = Db4oFactory.OpenFile("opengrid.yap");
// Locate the grid configuration object
IObjectSet result = db.Get(typeof(DbGridConfig));
// Found?
if(result.Count==1) {
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Config.cs:InitConfig() - Found a GridConfig object in the local database, loading");
foreach (DbGridConfig cfg in result) {
// Import each setting into this class
// Grid Settings
this.GridOwner=cfg.GridOwner;
// Asset Settings
this.DefaultAssetServer=cfg.DefaultAssetServer;
this.AssetSendKey=cfg.AssetSendKey;
this.AssetRecvKey=cfg.AssetRecvKey;
// User Settings
this.DefaultUserServer=cfg.DefaultUserServer;
this.UserSendKey=cfg.UserSendKey;
this.UserRecvKey=cfg.UserRecvKey;
// Region Settings
this.SimSendKey=cfg.SimSendKey;
this.SimRecvKey=cfg.SimRecvKey;
}
// Create a new configuration object from this class
} else {
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Config.cs:InitConfig() - Could not find object in database, loading precompiled defaults");
// Load default settings into this class
LoadDefaults();
// Saves to the database file...
OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Writing out default settings to local database");
db.Set(this);
// Closes file locks
db.Close();
}
} catch(Exception e) {
OpenSim.Framework.Console.MainConsole.Instance.Warn("Config.cs:InitConfig() - Exception occured");
OpenSim.Framework.Console.MainConsole.Instance.Warn(e.ToString());
}
// Grid Settings
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Grid settings loaded:");
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Grid owner: " + this.GridOwner);
// Asset Settings
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Default asset server: " + this.DefaultAssetServer);
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Key to send to asset server: " + this.AssetSendKey);
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Key to expect from asset server: " + this.AssetRecvKey);
// User Settings
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Default user server: " + this.DefaultUserServer);
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Key to send to user server: " + this.UserSendKey);
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Key to expect from user server: " + this.UserRecvKey);
// Region Settings
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Key to send to sims: " + this.SimSendKey);
OpenSim.Framework.Console.MainConsole.Instance.Verbose("Key to expect from sims: " + this.SimRecvKey);
}
/// <summary>
/// Closes down the database and releases filesystem locks
/// </summary>
public void Shutdown() {
db.Close();
}
}
}

View File

@ -0,0 +1,107 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectType>Local</ProjectType>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{B0027747-0000-0000-0000-000000000000}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ApplicationIcon></ApplicationIcon>
<AssemblyKeyContainerName>
</AssemblyKeyContainerName>
<AssemblyName>OpenGrid.Config.GridConfigDb4o</AssemblyName>
<DefaultClientScript>JScript</DefaultClientScript>
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
<DefaultTargetSchema>IE50</DefaultTargetSchema>
<DelaySign>false</DelaySign>
<OutputType>Library</OutputType>
<AppDesignerFolder></AppDesignerFolder>
<RootNamespace>OpenGrid.Config.GridConfigDb4o</RootNamespace>
<StartupObject></StartupObject>
<FileUpgradeFlags>
</FileUpgradeFlags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>True</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>False</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<BaseAddress>285212672</BaseAddress>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<ConfigurationOverrideFile>
</ConfigurationOverrideFile>
<DefineConstants>TRACE</DefineConstants>
<DocumentationFile></DocumentationFile>
<DebugSymbols>False</DebugSymbols>
<FileAlignment>4096</FileAlignment>
<Optimize>True</Optimize>
<OutputPath>..\..\..\bin\</OutputPath>
<RegisterForComInterop>False</RegisterForComInterop>
<RemoveIntegerChecks>False</RemoveIntegerChecks>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<WarningLevel>4</WarningLevel>
<NoWarn></NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" >
<HintPath>System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Data.dll" >
<HintPath>..\..\..\bin\System.Data.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml" >
<HintPath>System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="libsecondlife.dll" >
<HintPath>..\..\..\bin\libsecondlife.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Db4objects.Db4o.dll" >
<HintPath>..\..\..\bin\Db4objects.Db4o.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="OpenSim.Framework" >
<HintPath>OpenSim.Framework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="OpenSim.Framework.Console" >
<HintPath>OpenSim.Framework.Console.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="DbGridConfig.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

Some files were not shown because too many files have changed in this diff Show More