From f95b6081cba084d1b067acea99c0effa2b3bf42c Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 24 May 2007 12:35:32 +0000 Subject: Renamed the new Directories. (removed the "-Source" from the end of them) --- Common/OpenSim.Framework.Console/AssemblyInfo.cs | 31 + Common/OpenSim.Framework.Console/ConsoleBase.cs | 166 +++++ .../ConsoleCallbacksBase.cs | 12 + Common/OpenSim.Framework.Console/MainConsole.cs | 48 ++ .../OpenSim.Framework.Console.csproj | 89 +++ .../OpenSim.Framework.Console.csproj.user | 12 + .../OpenSim.Framework.Console.dll.build | 42 ++ Common/OpenSim.Framework/AgentInventory.cs | 251 ++++++++ Common/OpenSim.Framework/BlockingQueue.cs | 33 + Common/OpenSim.Framework/HeightMapGenHills.cs | 149 +++++ .../OpenSim.Framework/Interfaces/IAssetServer.cs | 68 +++ Common/OpenSim.Framework/Interfaces/IClientAPI.cs | 30 + Common/OpenSim.Framework/Interfaces/IConfig.cs | 76 +++ .../OpenSim.Framework/Interfaces/IGenericConfig.cs | 15 + Common/OpenSim.Framework/Interfaces/IGridConfig.cs | 64 ++ Common/OpenSim.Framework/Interfaces/IGridServer.cs | 81 +++ .../OpenSim.Framework/Interfaces/ILocalStorage.cs | 54 ++ Common/OpenSim.Framework/Interfaces/IScriptAPI.cs | 14 + .../OpenSim.Framework/Interfaces/IScriptEngine.cs | 14 + Common/OpenSim.Framework/Interfaces/IUserConfig.cs | 58 ++ Common/OpenSim.Framework/Interfaces/IUserServer.cs | 15 + .../OpenSim.Framework/Interfaces/LocalGridBase.cs | 24 + .../OpenSim.Framework/Interfaces/RemoteGridBase.cs | 37 ++ Common/OpenSim.Framework/LoginService.cs | 14 + Common/OpenSim.Framework/OpenSim.Framework.csproj | 200 ++++++ .../OpenSim.Framework.csproj.user | 12 + .../OpenSim.Framework/OpenSim.Framework.dll.build | 75 +++ .../OpenSim.Framework/Properties/AssemblyInfo.cs | 33 + Common/OpenSim.Framework/Remoting.cs | 109 ++++ Common/OpenSim.Framework/SimProfile.cs | 83 +++ Common/OpenSim.Framework/SimProfileBase.cs | 27 + Common/OpenSim.Framework/Types/AgentCiruitData.cs | 22 + Common/OpenSim.Framework/Types/AssetBase.cs | 22 + Common/OpenSim.Framework/Types/AssetLandmark.cs | 34 ++ Common/OpenSim.Framework/Types/AssetStorage.cs | 23 + Common/OpenSim.Framework/Types/Login.cs | 24 + Common/OpenSim.Framework/Types/NeighbourInfo.cs | 19 + Common/OpenSim.Framework/Types/OSVector3.cs | 18 + Common/OpenSim.Framework/Types/PrimData.cs | 173 ++++++ Common/OpenSim.Framework/UserProfile.cs | 62 ++ Common/OpenSim.Framework/UserProfileManager.cs | 272 +++++++++ Common/OpenSim.Framework/UserProfileManagerBase.cs | 124 ++++ Common/OpenSim.Framework/Util.cs | 151 +++++ .../Xml/OpenSim.GenericConfig.Xml.csproj | 93 +++ .../Xml/OpenSim.GenericConfig.Xml.csproj.user | 12 + .../Xml/OpenSim.GenericConfig.Xml.dll.build | 42 ++ .../Xml/Properties/AssemblyInfo.cs | 35 ++ Common/OpenSim.GenericConfig/Xml/XmlConfig.cs | 109 ++++ Common/OpenSim.Servers/BaseHttpServer.cs | 256 ++++++++ Common/OpenSim.Servers/BaseServer.cs | 10 + Common/OpenSim.Servers/CheckSumServer.cs | 113 ++++ Common/OpenSim.Servers/IRestHandler.cs | 8 + Common/OpenSim.Servers/LocalUserProfileManager.cs | 123 ++++ Common/OpenSim.Servers/LoginResponse.cs | 670 +++++++++++++++++++++ Common/OpenSim.Servers/LoginServer.cs | 284 +++++++++ Common/OpenSim.Servers/OpenSim.Servers.csproj | 130 ++++ Common/OpenSim.Servers/OpenSim.Servers.csproj.user | 12 + Common/OpenSim.Servers/OpenSim.Servers.dll.build | 52 ++ Common/OpenSim.Servers/UDPServerBase.cs | 68 +++ Common/OpenSim.Servers/XmlRpcMethod.cs | 7 + Common/XmlRpcCS/Logger.cs | 46 ++ Common/XmlRpcCS/SimpleHttpRequest.cs | 204 +++++++ Common/XmlRpcCS/XMLRPC.csproj | 138 +++++ Common/XmlRpcCS/XMLRPC.csproj.user | 12 + Common/XmlRpcCS/XMLRPC.dll.build | 58 ++ Common/XmlRpcCS/XmlRpcBoxcarRequest.cs | 51 ++ Common/XmlRpcCS/XmlRpcClientProxy.cs | 61 ++ Common/XmlRpcCS/XmlRpcDeserializer.cs | 195 ++++++ Common/XmlRpcCS/XmlRpcErrorCodes.cs | 51 ++ Common/XmlRpcCS/XmlRpcException.cs | 39 ++ Common/XmlRpcCS/XmlRpcExposedAttribute.cs | 60 ++ Common/XmlRpcCS/XmlRpcRequest.cs | 150 +++++ Common/XmlRpcCS/XmlRpcRequestDeserializer.cs | 64 ++ Common/XmlRpcCS/XmlRpcRequestSerializer.cs | 51 ++ Common/XmlRpcCS/XmlRpcResponder.cs | 98 +++ Common/XmlRpcCS/XmlRpcResponse.cs | 85 +++ Common/XmlRpcCS/XmlRpcResponseDeserializer.cs | 65 ++ Common/XmlRpcCS/XmlRpcResponseSerializer.cs | 57 ++ Common/XmlRpcCS/XmlRpcSerializer.cs | 109 ++++ Common/XmlRpcCS/XmlRpcServer.cs | 239 ++++++++ Common/XmlRpcCS/XmlRpcSystemObject.cs | 252 ++++++++ Common/XmlRpcCS/XmlRpcXmlTokens.cs | 76 +++ 82 files changed, 7065 insertions(+) create mode 100644 Common/OpenSim.Framework.Console/AssemblyInfo.cs create mode 100644 Common/OpenSim.Framework.Console/ConsoleBase.cs create mode 100644 Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs create mode 100644 Common/OpenSim.Framework.Console/MainConsole.cs create mode 100644 Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj create mode 100644 Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user create mode 100644 Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build create mode 100644 Common/OpenSim.Framework/AgentInventory.cs create mode 100644 Common/OpenSim.Framework/BlockingQueue.cs create mode 100644 Common/OpenSim.Framework/HeightMapGenHills.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IAssetServer.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IClientAPI.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IConfig.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IGenericConfig.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IGridConfig.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IGridServer.cs create mode 100644 Common/OpenSim.Framework/Interfaces/ILocalStorage.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IScriptAPI.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IScriptEngine.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IUserConfig.cs create mode 100644 Common/OpenSim.Framework/Interfaces/IUserServer.cs create mode 100644 Common/OpenSim.Framework/Interfaces/LocalGridBase.cs create mode 100644 Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs create mode 100644 Common/OpenSim.Framework/LoginService.cs create mode 100644 Common/OpenSim.Framework/OpenSim.Framework.csproj create mode 100644 Common/OpenSim.Framework/OpenSim.Framework.csproj.user create mode 100644 Common/OpenSim.Framework/OpenSim.Framework.dll.build create mode 100644 Common/OpenSim.Framework/Properties/AssemblyInfo.cs create mode 100644 Common/OpenSim.Framework/Remoting.cs create mode 100644 Common/OpenSim.Framework/SimProfile.cs create mode 100644 Common/OpenSim.Framework/SimProfileBase.cs create mode 100644 Common/OpenSim.Framework/Types/AgentCiruitData.cs create mode 100644 Common/OpenSim.Framework/Types/AssetBase.cs create mode 100644 Common/OpenSim.Framework/Types/AssetLandmark.cs create mode 100644 Common/OpenSim.Framework/Types/AssetStorage.cs create mode 100644 Common/OpenSim.Framework/Types/Login.cs create mode 100644 Common/OpenSim.Framework/Types/NeighbourInfo.cs create mode 100644 Common/OpenSim.Framework/Types/OSVector3.cs create mode 100644 Common/OpenSim.Framework/Types/PrimData.cs create mode 100644 Common/OpenSim.Framework/UserProfile.cs create mode 100644 Common/OpenSim.Framework/UserProfileManager.cs create mode 100644 Common/OpenSim.Framework/UserProfileManagerBase.cs create mode 100644 Common/OpenSim.Framework/Util.cs create mode 100644 Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj create mode 100644 Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user create mode 100644 Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build create mode 100644 Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs create mode 100644 Common/OpenSim.GenericConfig/Xml/XmlConfig.cs create mode 100644 Common/OpenSim.Servers/BaseHttpServer.cs create mode 100644 Common/OpenSim.Servers/BaseServer.cs create mode 100644 Common/OpenSim.Servers/CheckSumServer.cs create mode 100644 Common/OpenSim.Servers/IRestHandler.cs create mode 100644 Common/OpenSim.Servers/LocalUserProfileManager.cs create mode 100644 Common/OpenSim.Servers/LoginResponse.cs create mode 100644 Common/OpenSim.Servers/LoginServer.cs create mode 100644 Common/OpenSim.Servers/OpenSim.Servers.csproj create mode 100644 Common/OpenSim.Servers/OpenSim.Servers.csproj.user create mode 100644 Common/OpenSim.Servers/OpenSim.Servers.dll.build create mode 100644 Common/OpenSim.Servers/UDPServerBase.cs create mode 100644 Common/OpenSim.Servers/XmlRpcMethod.cs create mode 100644 Common/XmlRpcCS/Logger.cs create mode 100644 Common/XmlRpcCS/SimpleHttpRequest.cs create mode 100644 Common/XmlRpcCS/XMLRPC.csproj create mode 100644 Common/XmlRpcCS/XMLRPC.csproj.user create mode 100644 Common/XmlRpcCS/XMLRPC.dll.build create mode 100644 Common/XmlRpcCS/XmlRpcBoxcarRequest.cs create mode 100644 Common/XmlRpcCS/XmlRpcClientProxy.cs create mode 100644 Common/XmlRpcCS/XmlRpcDeserializer.cs create mode 100644 Common/XmlRpcCS/XmlRpcErrorCodes.cs create mode 100644 Common/XmlRpcCS/XmlRpcException.cs create mode 100644 Common/XmlRpcCS/XmlRpcExposedAttribute.cs create mode 100644 Common/XmlRpcCS/XmlRpcRequest.cs create mode 100644 Common/XmlRpcCS/XmlRpcRequestDeserializer.cs create mode 100644 Common/XmlRpcCS/XmlRpcRequestSerializer.cs create mode 100644 Common/XmlRpcCS/XmlRpcResponder.cs create mode 100644 Common/XmlRpcCS/XmlRpcResponse.cs create mode 100644 Common/XmlRpcCS/XmlRpcResponseDeserializer.cs create mode 100644 Common/XmlRpcCS/XmlRpcResponseSerializer.cs create mode 100644 Common/XmlRpcCS/XmlRpcSerializer.cs create mode 100644 Common/XmlRpcCS/XmlRpcServer.cs create mode 100644 Common/XmlRpcCS/XmlRpcSystemObject.cs create mode 100644 Common/XmlRpcCS/XmlRpcXmlTokens.cs (limited to 'Common') diff --git a/Common/OpenSim.Framework.Console/AssemblyInfo.cs b/Common/OpenSim.Framework.Console/AssemblyInfo.cs new file mode 100644 index 0000000..00a9b7d --- /dev/null +++ b/Common/OpenSim.Framework.Console/AssemblyInfo.cs @@ -0,0 +1,31 @@ +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.*")] diff --git a/Common/OpenSim.Framework.Console/ConsoleBase.cs b/Common/OpenSim.Framework.Console/ConsoleBase.cs new file mode 100644 index 0000000..6a1c53c --- /dev/null +++ b/Common/OpenSim.Framework.Console/ConsoleBase.cs @@ -0,0 +1,166 @@ +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) + { + WriteLine(LogPriority.NORMAL,format,args); + return; + } + + [Obsolete("WriteLine(msg,args) has been depreciated, use WriteLine(priority,msg,args) instead.")] + public void WriteLine(string format, params object[] args) + { + Log.WriteLine(format, args); + Log.Flush(); + if(!m_silent) + { + System.Console.WriteLine(format, args); + } + return; + } + + public void WriteLine(LogPriority importance, string format, params object[] args) + { + Log.WriteLine(format, args); + Log.Flush(); + if (!m_silent) + { + System.Console.WriteLine(format, args); + } + 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 + { + this.WriteLine(LogPriority.MEDIUM,"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(ref tempstrarray, tempstrarray.Length - 1); + Array.Reverse(tempstrarray); + string[] cmdparams = (string[])tempstrarray; + RunCmd(cmd, cmdparams); + } + } +} diff --git a/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs b/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs new file mode 100644 index 0000000..bb589d2 --- /dev/null +++ b/Common/OpenSim.Framework.Console/ConsoleCallbacksBase.cs @@ -0,0 +1,12 @@ +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); + } +} diff --git a/Common/OpenSim.Framework.Console/MainConsole.cs b/Common/OpenSim.Framework.Console/MainConsole.cs new file mode 100644 index 0000000..02c4ae8 --- /dev/null +++ b/Common/OpenSim.Framework.Console/MainConsole.cs @@ -0,0 +1,48 @@ +/* +* 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 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 ``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 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 OpenSim.Framework.Console +{ + public class MainConsole { + + private static ConsoleBase instance; + + public static ConsoleBase Instance + { + get + { + return instance; + } + set + { + instance = value; + } + } + } + +} diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj new file mode 100644 index 0000000..0961492 --- /dev/null +++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj @@ -0,0 +1,89 @@ + + + Local + 8.0.50727 + 2.0 + {A7CD0630-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Framework.Console + JScript + Grid + IE50 + false + Library + + OpenSim.Framework.Console + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + + + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build new file mode 100644 index 0000000..fa90bb6 --- /dev/null +++ b/Common/OpenSim.Framework.Console/OpenSim.Framework.Console.dll.build @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/OpenSim.Framework/AgentInventory.cs b/Common/OpenSim.Framework/AgentInventory.cs new file mode 100644 index 0000000..b28645e --- /dev/null +++ b/Common/OpenSim.Framework/AgentInventory.cs @@ -0,0 +1,251 @@ +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 InventoryFolders; + public Dictionary 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(); + InventoryItems = new Dictionary(); + 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 Items; + //public List 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(); + //Subfolders = new List(); + } + + } + + 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() + { + + } + } +} diff --git a/Common/OpenSim.Framework/BlockingQueue.cs b/Common/OpenSim.Framework/BlockingQueue.cs new file mode 100644 index 0000000..f840354 --- /dev/null +++ b/Common/OpenSim.Framework/BlockingQueue.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Framework.Utilities +{ + public class BlockingQueue + { + private Queue _queue = new Queue(); + 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(); + } + } + } +} diff --git a/Common/OpenSim.Framework/HeightMapGenHills.cs b/Common/OpenSim.Framework/HeightMapGenHills.cs new file mode 100644 index 0000000..6a729da --- /dev/null +++ b/Common/OpenSim.Framework/HeightMapGenHills.cs @@ -0,0 +1,149 @@ +/* +* 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 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 ``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 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 OpenSim.Framework.Terrain +{ + public class HeightmapGenHills + { + private Random Rand = new Random(); + private int NumHills; + private float HillMin; + private float HillMax; + private bool Island; + private float[] heightmap; + + public float[] GenerateHeightmap(int numHills, float hillMin, float hillMax, bool island) + { + NumHills = numHills; + HillMin = hillMin; + HillMax = hillMax; + Island = island; + + heightmap = new float[256 * 256]; + + for (int i = 0; i < numHills; i++) + { + AddHill(); + } + + Normalize(); + + return heightmap; + } + + private void AddHill() + { + float x, y; + float radius = RandomRange(HillMin, HillMax); + + if (Island) + { + // Which direction from the center of the map the hill is placed + float theta = RandomRange(0, 6.28f); + + // How far from the center of the map to place the hill. The radius + // is subtracted from the range to prevent any part of the hill from + // reaching the edge of the map + float distance = RandomRange(radius / 2.0f, 128.0f - radius); + + x = 128.0f + (float)Math.Cos(theta) * distance; + y = 128.0f + (float)Math.Sin(theta) * distance; + } + else + { + x = RandomRange(-radius, 256.0f + radius); + y = RandomRange(-radius, 256.0f + radius); + } + + float radiusSq = radius * radius; + float distSq; + float height; + + int xMin = (int)(x - radius) - 1; + int xMax = (int)(x + radius) + 1; + if (xMin < 0) xMin = 0; + if (xMax > 255) xMax = 255; + + int yMin = (int)(y - radius) - 1; + int yMax = (int)(y + radius) + 1; + if (yMin < 0) yMin = 0; + if (yMax > 255) yMax = 255; + + // Loop through each affected cell and determine the height at that point + for (int v = yMin; v <= yMax; ++v) + { + float fv = (float)v; + + for (int h = xMin; h <= xMax; ++h) + { + float fh = (float)h; + + // Determine how far from the center of this hill this point is + distSq = (x - fh) * (x - fh) + (y - fv) * (y - fv); + height = radiusSq - distSq; + + // Don't add negative hill values + if (height > 0.0f) heightmap[h + v * 256] += height; + } + } + } + + private void Normalize() + { + float min = heightmap[0]; + float max = heightmap[0]; + + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + if (heightmap[x + y * 256] < min) min = heightmap[x + y * 256]; + if (heightmap[x + y * 256] > max) max = heightmap[x + y * 256]; + } + } + + // Avoid a rare divide by zero + if (min != max) + { + for (int x = 0; x < 256; x++) + { + for (int y = 0; y < 256; y++) + { + heightmap[x + y * 256] = ((heightmap[x + y * 256] - min) / (max - min)) * (HillMax - HillMin); + } + } + } + } + + private float RandomRange(float min, float max) + { + return (float)Rand.NextDouble() * (max - min) + min; + } + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IAssetServer.cs b/Common/OpenSim.Framework/Interfaces/IAssetServer.cs new file mode 100644 index 0000000..3f86acc --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IAssetServer.cs @@ -0,0 +1,68 @@ +/* +* 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 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 ``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 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.Net; +using System.Net.Sockets; +using System.IO; +using System.Threading; +using libsecondlife; +using OpenSim.Framework.Types; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Description of IAssetServer. + /// + + public interface IAssetServer + { + void SetReceiver(IAssetReceiver receiver); + void RequestAsset(LLUUID assetID, bool isTexture); + void UpdateAsset(AssetBase asset); + void UploadNewAsset(AssetBase asset); + void SetServerInfo(string ServerUrl, string ServerKey); + void Close(); + } + + // could change to delegate? + public interface IAssetReceiver + { + void AssetReceived(AssetBase asset, bool IsTexture); + void AssetNotFound(AssetBase asset); + } + + public interface IAssetPlugin + { + IAssetServer GetAssetServer(); + } + + public struct ARequest + { + public LLUUID AssetID; + public bool IsTexture; + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IClientAPI.cs b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs new file mode 100644 index 0000000..a991fb6 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs @@ -0,0 +1,30 @@ +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 children); + + public interface IClientAPI + { + event ChatFromViewer OnChatFromViewer; + event RezObject OnRezObject; + event ModifyTerrain OnModifyTerrain; + event SetAppearance OnSetAppearance; + event StartAnim OnStartAnim; + event LinkObjects OnLinkObjects; + + void SendAppearance(AvatarWearable[] wearables); + void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IConfig.cs b/Common/OpenSim.Framework/Interfaces/IConfig.cs new file mode 100644 index 0000000..7b4c040 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IConfig.cs @@ -0,0 +1,76 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* 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 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 ``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 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.IO; +using libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// This class handles connection to the underlying database used for configuration of the region. + /// Region content is also stored by this class. The main entry point is InitConfig() which attempts to locate + /// opensim.yap in the current working directory. If opensim.yap can not be found, default settings are loaded from + /// what is hardcoded here and then saved into opensim.yap for future startups. + /// + + + public abstract class SimConfig + { + public string RegionName; + + public uint RegionLocX; + public uint RegionLocY; + public ulong RegionHandle; + + public int IPListenPort; + public string IPListenAddr; + + public string AssetURL; + public string AssetSendKey; + + public string GridURL; + public string GridSendKey; + public string GridRecvKey; + public string UserURL; + public string UserSendKey; + public string UserRecvKey; + + public abstract void InitConfig(bool sandboxMode); + public abstract void LoadFromGrid(); + + } + + public interface ISimConfig + { + SimConfig GetConfigObject(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IGenericConfig.cs b/Common/OpenSim.Framework/Interfaces/IGenericConfig.cs new file mode 100644 index 0000000..a853fe4 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IGenericConfig.cs @@ -0,0 +1,15 @@ +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(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IGridConfig.cs b/Common/OpenSim.Framework/Interfaces/IGridConfig.cs new file mode 100644 index 0000000..b2f26da --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IGridConfig.cs @@ -0,0 +1,64 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* 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 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 ``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 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.IO; +using libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// + + + 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; + + + public abstract void InitConfig(); + + } + + public interface IGridConfig + { + GridConfig GetConfigObject(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IGridServer.cs b/Common/OpenSim.Framework/Interfaces/IGridServer.cs new file mode 100644 index 0000000..e67ea98 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IGridServer.cs @@ -0,0 +1,81 @@ +/* +* 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 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 ``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 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.Net; +using System.Net.Sockets; +using System.IO; +using libsecondlife; +using OpenSim; +using OpenSim.Framework.Types; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// Handles connection to Grid Servers. + /// also Sim to Sim connections? + /// + + public interface IGridServer + { + UUIDBlock RequestUUIDBlock(); + NeighbourInfo[] RequestNeighbours(); //should return a array of neighbouring regions + AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); + string GetName(); + 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(); + } + + public struct UUIDBlock + { + public LLUUID BlockStart; + public LLUUID BlockEnd; + } + + public class AuthenticateResponse + { + public bool Authorised; + public Login LoginInfo; + + public AuthenticateResponse() + { + + } + + } + + public interface IGridPlugin + { + IGridServer GetGridServer(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/ILocalStorage.cs b/Common/OpenSim.Framework/Interfaces/ILocalStorage.cs new file mode 100644 index 0000000..4dd8868 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/ILocalStorage.cs @@ -0,0 +1,54 @@ +/* +* 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 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 ``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 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 libsecondlife; +using OpenSim.Framework.Types; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// ILocalStorage. Really hacked together right now needs cleaning up + /// + 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 ShutDown(); + } + + public interface ILocalStorageReceiver + { + void PrimFromStorage(PrimData prim); + } + +} + diff --git a/Common/OpenSim.Framework/Interfaces/IScriptAPI.cs b/Common/OpenSim.Framework/Interfaces/IScriptAPI.cs new file mode 100644 index 0000000..3ad0f06 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IScriptAPI.cs @@ -0,0 +1,14 @@ +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(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IScriptEngine.cs b/Common/OpenSim.Framework/Interfaces/IScriptEngine.cs new file mode 100644 index 0000000..ed8974c --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IScriptEngine.cs @@ -0,0 +1,14 @@ +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(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IUserConfig.cs b/Common/OpenSim.Framework/Interfaces/IUserConfig.cs new file mode 100644 index 0000000..e15867d --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IUserConfig.cs @@ -0,0 +1,58 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* 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 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 ``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 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.IO; +using libsecondlife; +//using OpenSim.world; + +namespace OpenSim.Framework.Interfaces +{ + /// + /// + + + public abstract class UserConfig + { + public string DefaultStartupMsg; + public string GridServerURL; + public string GridSendKey; + public string GridRecvKey; + + + public abstract void InitConfig(); + + } + + public interface IUserConfig + { + UserConfig GetConfigObject(); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/IUserServer.cs b/Common/OpenSim.Framework/Interfaces/IUserServer.cs new file mode 100644 index 0000000..21f2721 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/IUserServer.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Framework.Inventory; +using libsecondlife; + +namespace OpenSim.Framework.Interfaces +{ + public interface IUserServer + { + AgentInventory RequestAgentsInventory(LLUUID agentID); + void SetServerInfo(string ServerUrl, string SendKey, string RecvKey); + bool UpdateAgentsInventory(LLUUID agentID, AgentInventory inventory); + } +} diff --git a/Common/OpenSim.Framework/Interfaces/LocalGridBase.cs b/Common/OpenSim.Framework/Interfaces/LocalGridBase.cs new file mode 100644 index 0000000..ff46502 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/LocalGridBase.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Types; +using System.Collections; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class LocalGridBase : IGridServer + { + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + 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(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(); + } + +} diff --git a/Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs b/Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs new file mode 100644 index 0000000..ed13ed5 --- /dev/null +++ b/Common/OpenSim.Framework/Interfaces/RemoteGridBase.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using OpenSim.Framework.Types; + +namespace OpenSim.Framework.Interfaces +{ + public abstract class RemoteGridBase : IGridServer + { + public abstract Dictionary agentcircuits + { + get; + set; + } + + public abstract UUIDBlock RequestUUIDBlock(); + public abstract NeighbourInfo[] RequestNeighbours(); + 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(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; + } + } +} diff --git a/Common/OpenSim.Framework/LoginService.cs b/Common/OpenSim.Framework/LoginService.cs new file mode 100644 index 0000000..eba0281 --- /dev/null +++ b/Common/OpenSim.Framework/LoginService.cs @@ -0,0 +1,14 @@ +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 + { + + } +} \ No newline at end of file diff --git a/Common/OpenSim.Framework/OpenSim.Framework.csproj b/Common/OpenSim.Framework/OpenSim.Framework.csproj new file mode 100644 index 0000000..1b7f3c0 --- /dev/null +++ b/Common/OpenSim.Framework/OpenSim.Framework.csproj @@ -0,0 +1,200 @@ + + + Local + 8.0.50727 + 2.0 + {8ACA2445-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + + OpenSim.Framework + JScript + Grid + IE50 + false + Library + + + OpenSim.Framework + + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + + False + 285212672 + False + + + TRACE + + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + + System.dll + False + + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + ..\bin\Db4objects.Db4o.dll + False + + + + + XMLRPC + {8E81D43C-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/Common/OpenSim.Framework/OpenSim.Framework.csproj.user b/Common/OpenSim.Framework/OpenSim.Framework.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/OpenSim.Framework/OpenSim.Framework.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/Common/OpenSim.Framework/OpenSim.Framework.dll.build b/Common/OpenSim.Framework/OpenSim.Framework.dll.build new file mode 100644 index 0000000..fecd382 --- /dev/null +++ b/Common/OpenSim.Framework/OpenSim.Framework.dll.build @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/OpenSim.Framework/Properties/AssemblyInfo.cs b/Common/OpenSim.Framework/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..86f5cdb --- /dev/null +++ b/Common/OpenSim.Framework/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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.FrameWork")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.FrameWork")] +[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("a08e20c7-f191-4137-b1f0-9291408fa521")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Common/OpenSim.Framework/Remoting.cs b/Common/OpenSim.Framework/Remoting.cs new file mode 100644 index 0000000..1212ee5 --- /dev/null +++ b/Common/OpenSim.Framework/Remoting.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Security.Cryptography; + +namespace OpenSim.Framework +{ + /// + /// NEEDS AUDIT. + /// + /// + /// Suggested implementation + /// 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. + /// When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message. + /// When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[]. + /// Both hosts should be performing these operations for this to be effective. + /// + class RemoteDigest + { + private byte[] currentHash; + private byte[] secret; + + private SHA512Managed SHA512; + + /// + /// Initialises a new RemoteDigest authentication mechanism + /// + /// 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 + /// The shared secret between systems (for inter-sim, this is provided in encrypted form during connection, for grid this is input manually in setup) + /// Binary salt - some common value - to be decided what + /// The challenge key provided by the third party + 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))); + } + + /// + /// Authenticates a piece of incoming data against the local digest. Upon successful authentication, digest string is incremented. + /// + /// The incoming data + /// The remote digest + /// + 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."); + } + } + + /// + /// 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. + /// + /// The outgoing data + /// The local digest + public byte[] Sign(byte[] data) + { + currentHash = SHA512.ComputeHash(AppendArrays(AppendArrays(currentHash, secret), data)); + return currentHash; + } + + /// + /// 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. + /// + /// A 128-character hexadecimal string containing the challenge. + 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(); + } + + /// + /// Helper function, merges two byte arrays + /// + /// Sourced from MSDN Forum + /// A + /// B + /// C + 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; + } + + } +} diff --git a/Common/OpenSim.Framework/SimProfile.cs b/Common/OpenSim.Framework/SimProfile.cs new file mode 100644 index 0000000..8acb20b --- /dev/null +++ b/Common/OpenSim.Framework/SimProfile.cs @@ -0,0 +1,83 @@ +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() + { + } + } + +} diff --git a/Common/OpenSim.Framework/SimProfileBase.cs b/Common/OpenSim.Framework/SimProfileBase.cs new file mode 100644 index 0000000..30e2e0f --- /dev/null +++ b/Common/OpenSim.Framework/SimProfileBase.cs @@ -0,0 +1,27 @@ +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() + { + } + } +} diff --git a/Common/OpenSim.Framework/Types/AgentCiruitData.cs b/Common/OpenSim.Framework/Types/AgentCiruitData.cs new file mode 100644 index 0000000..7314586 --- /dev/null +++ b/Common/OpenSim.Framework/Types/AgentCiruitData.cs @@ -0,0 +1,22 @@ +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; + } +} diff --git a/Common/OpenSim.Framework/Types/AssetBase.cs b/Common/OpenSim.Framework/Types/AssetBase.cs new file mode 100644 index 0000000..f6104f8 --- /dev/null +++ b/Common/OpenSim.Framework/Types/AssetBase.cs @@ -0,0 +1,22 @@ +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() + { + + } + } +} diff --git a/Common/OpenSim.Framework/Types/AssetLandmark.cs b/Common/OpenSim.Framework/Types/AssetLandmark.cs new file mode 100644 index 0000000..9d1a326 --- /dev/null +++ b/Common/OpenSim.Framework/Types/AssetLandmark.cs @@ -0,0 +1,34 @@ +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); + } + } +} diff --git a/Common/OpenSim.Framework/Types/AssetStorage.cs b/Common/OpenSim.Framework/Types/AssetStorage.cs new file mode 100644 index 0000000..5b5b3b2 --- /dev/null +++ b/Common/OpenSim.Framework/Types/AssetStorage.cs @@ -0,0 +1,23 @@ +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; + } +} diff --git a/Common/OpenSim.Framework/Types/Login.cs b/Common/OpenSim.Framework/Types/Login.cs new file mode 100644 index 0000000..71f9de3 --- /dev/null +++ b/Common/OpenSim.Framework/Types/Login.cs @@ -0,0 +1,24 @@ +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() + { + + } + } +} diff --git a/Common/OpenSim.Framework/Types/NeighbourInfo.cs b/Common/OpenSim.Framework/Types/NeighbourInfo.cs new file mode 100644 index 0000000..58b6cb1 --- /dev/null +++ b/Common/OpenSim.Framework/Types/NeighbourInfo.cs @@ -0,0 +1,19 @@ +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; + } +} diff --git a/Common/OpenSim.Framework/Types/OSVector3.cs b/Common/OpenSim.Framework/Types/OSVector3.cs new file mode 100644 index 0000000..8fb840b --- /dev/null +++ b/Common/OpenSim.Framework/Types/OSVector3.cs @@ -0,0 +1,18 @@ +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() + { + + } + } +} diff --git a/Common/OpenSim.Framework/Types/PrimData.cs b/Common/OpenSim.Framework/Types/PrimData.cs new file mode 100644 index 0000000..68e2a22 --- /dev/null +++ b/Common/OpenSim.Framework/Types/PrimData.cs @@ -0,0 +1,173 @@ +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; + } + } +} diff --git a/Common/OpenSim.Framework/UserProfile.cs b/Common/OpenSim.Framework/UserProfile.cs new file mode 100644 index 0000000..f95a8fa --- /dev/null +++ b/Common/OpenSim.Framework/UserProfile.cs @@ -0,0 +1,62 @@ +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 Circuits = new Dictionary(); // tracks circuit codes + + public AgentInventory Inventory; + + public UserProfile() + { + Circuits = new Dictionary(); + 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); + } + + } +} diff --git a/Common/OpenSim.Framework/UserProfileManager.cs b/Common/OpenSim.Framework/UserProfileManager.cs new file mode 100644 index 0000000..18b3513 --- /dev/null +++ b/Common/OpenSim.Framework/UserProfileManager.cs @@ -0,0 +1,272 @@ +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); + } + } +} diff --git a/Common/OpenSim.Framework/UserProfileManagerBase.cs b/Common/OpenSim.Framework/UserProfileManagerBase.cs new file mode 100644 index 0000000..d1307a5 --- /dev/null +++ b/Common/OpenSim.Framework/UserProfileManagerBase.cs @@ -0,0 +1,124 @@ +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 UserProfiles = new Dictionary(); + + 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); + return newprofile; + } + + public virtual AgentInventory GetUsersInventory(LLUUID agentID) + { + UserProfile user = this.GetProfileByLLUUID(agentID); + if (user != null) + { + return user.Inventory; + } + + return null; + } + + } +} diff --git a/Common/OpenSim.Framework/Util.cs b/Common/OpenSim.Framework/Util.cs new file mode 100644 index 0000000..400f415 --- /dev/null +++ b/Common/OpenSim.Framework/Util.cs @@ -0,0 +1,151 @@ +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); + } + + /// + /// Convert a variable length field (byte array) to a string, with a + /// field name prepended to each line of the output + /// + /// If the byte array has unprintable characters in it, a + /// hex dump will be put in the string instead + /// The byte array to convert to a string + /// A field name to prepend to each line of output + /// An ASCII string or a string containing a hex dump, minus + /// the null terminator + 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() + { + + } + } +} diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj new file mode 100644 index 0000000..98e813e --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj @@ -0,0 +1,93 @@ + + + Local + 8.0.50727 + 2.0 + {E88EF749-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.GenericConfig.Xml + JScript + Grid + IE50 + false + Library + + OpenSim.GenericConfig.Xml + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build new file mode 100644 index 0000000..f34e4ac --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/OpenSim.GenericConfig.Xml.dll.build @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs b/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..de5f48d --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +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")] diff --git a/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs new file mode 100644 index 0000000..62e3cbf --- /dev/null +++ b/Common/OpenSim.GenericConfig/Xml/XmlConfig.cs @@ -0,0 +1,109 @@ +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 "); + + configNode = rootNode.FirstChild; + if (configNode.Name != "Config") + throw new Exception("Error: Invalid .xml File. first child should be "); + + } + 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; + } + + } +} diff --git a/Common/OpenSim.Servers/BaseHttpServer.cs b/Common/OpenSim.Servers/BaseHttpServer.cs new file mode 100644 index 0000000..38f4370 --- /dev/null +++ b/Common/OpenSim.Servers/BaseHttpServer.cs @@ -0,0 +1,256 @@ +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 m_restHandlers = new Dictionary(); + protected Dictionary m_rpcHandlers = new Dictionary(); + 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() + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW, "BaseHttpServer.cs: Starting up HTTP Server"); + + m_workerThread = new Thread(new ThreadStart(StartHTTP)); + m_workerThread.IsBackground = true; + m_workerThread.Start(); + } + + private void StartHTTP() + { + try + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.LOW, "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) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(LogPriority.MEDIUM, e.Message); + } + } + } +} diff --git a/Common/OpenSim.Servers/BaseServer.cs b/Common/OpenSim.Servers/BaseServer.cs new file mode 100644 index 0000000..0a4c498 --- /dev/null +++ b/Common/OpenSim.Servers/BaseServer.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Servers +{ + public class BaseServer + { + } +} diff --git a/Common/OpenSim.Servers/CheckSumServer.cs b/Common/OpenSim.Servers/CheckSumServer.cs new file mode 100644 index 0000000..ae1724f --- /dev/null +++ b/Common/OpenSim.Servers/CheckSumServer.cs @@ -0,0 +1,113 @@ +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 = 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) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "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); + } + } +} \ No newline at end of file diff --git a/Common/OpenSim.Servers/IRestHandler.cs b/Common/OpenSim.Servers/IRestHandler.cs new file mode 100644 index 0000000..c322505 --- /dev/null +++ b/Common/OpenSim.Servers/IRestHandler.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Servers +{ + public delegate string RestMethod( string request, string path, string param ); +} diff --git a/Common/OpenSim.Servers/LocalUserProfileManager.cs b/Common/OpenSim.Servers/LocalUserProfileManager.cs new file mode 100644 index 0000000..a8b5f1f --- /dev/null +++ b/Common/OpenSim.Servers/LocalUserProfileManager.cs @@ -0,0 +1,123 @@ +/* +* 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 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 ``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 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() + { + // TODO: need to load from database + } + + 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); + } + } +} diff --git a/Common/OpenSim.Servers/LoginResponse.cs b/Common/OpenSim.Servers/LoginResponse.cs new file mode 100644 index 0000000..7333d1f --- /dev/null +++ b/Common/OpenSim.Servers/LoginResponse.cs @@ -0,0 +1,670 @@ +/* +* 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 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 ``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 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 +{ + /// + /// A temp class to handle login response. + /// Should make use of UserProfileManager where possible. + /// + + 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.WriteLine( + OpenSim.Framework.Console.LogPriority.LOW, + "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.WriteLine( + OpenSim.Framework.Console.LogPriority.LOW, + "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 \ No newline at end of file diff --git a/Common/OpenSim.Servers/LoginServer.cs b/Common/OpenSim.Servers/LoginServer.cs new file mode 100644 index 0000000..6fd174b --- /dev/null +++ b/Common/OpenSim.Servers/LoginServer.cs @@ -0,0 +1,284 @@ +/* +* 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 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 ``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 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); + /// + /// When running in local (default) mode , handles client logins. + /// + 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(); + loginResponse.SimAddress = m_simAddr.ToString(); + // 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; + } + + //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) + { + + } + } + + +} diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj b/Common/OpenSim.Servers/OpenSim.Servers.csproj new file mode 100644 index 0000000..72f637b --- /dev/null +++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj @@ -0,0 +1,130 @@ + + + Local + 8.0.50727 + 2.0 + {8BB20F0A-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Servers + JScript + Grid + IE50 + false + Library + + OpenSim.Servers + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + ..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + XMLRPC + {8E81D43C-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/Common/OpenSim.Servers/OpenSim.Servers.csproj.user b/Common/OpenSim.Servers/OpenSim.Servers.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/OpenSim.Servers/OpenSim.Servers.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/Common/OpenSim.Servers/OpenSim.Servers.dll.build b/Common/OpenSim.Servers/OpenSim.Servers.dll.build new file mode 100644 index 0000000..5afd9e1 --- /dev/null +++ b/Common/OpenSim.Servers/OpenSim.Servers.dll.build @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/OpenSim.Servers/UDPServerBase.cs b/Common/OpenSim.Servers/UDPServerBase.cs new file mode 100644 index 0000000..a308052 --- /dev/null +++ b/Common/OpenSim.Servers/UDPServerBase.cs @@ -0,0 +1,68 @@ +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) + { + + } + } +} + diff --git a/Common/OpenSim.Servers/XmlRpcMethod.cs b/Common/OpenSim.Servers/XmlRpcMethod.cs new file mode 100644 index 0000000..2295405 --- /dev/null +++ b/Common/OpenSim.Servers/XmlRpcMethod.cs @@ -0,0 +1,7 @@ +using System; +using Nwc.XmlRpc; + +namespace OpenSim.Servers +{ + public delegate XmlRpcResponse XmlRpcMethod( XmlRpcRequest request ); +} diff --git a/Common/XmlRpcCS/Logger.cs b/Common/XmlRpcCS/Logger.cs new file mode 100644 index 0000000..ebf804b --- /dev/null +++ b/Common/XmlRpcCS/Logger.cs @@ -0,0 +1,46 @@ +namespace Nwc.XmlRpc +{ + using System; + + /// Define levels of logging. This duplicates + /// similar enumerations in System.Diagnostics.EventLogEntryType. The + /// duplication was merited because .NET Compact Framework lacked the EventLogEntryType enum. + public enum LogLevel + { + /// Information level, log entry for informational reasons only. + Information, + /// Warning level, indicates a possible problem. + Warning, + /// Error level, implies a significant problem. + Error + } + + /// + ///Logging singleton with swappable output delegate. + /// + /// + ///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. + /// + public class Logger + { + ///Delegate definition for logging. + ///The message String to log. + ///The LogLevel of your message. + public delegate void LoggerDelegate(String message, LogLevel level); + ///The LoggerDelegate that will recieve WriteEntry requests. + static public LoggerDelegate Delegate = null; + + /// + ///Method logging events are sent to. + /// + ///The message String to log. + ///The LogLevel of your message. + static public void WriteEntry(String message, LogLevel level) + { + if (Delegate != null) + Delegate(message, level); + } + } +} diff --git a/Common/XmlRpcCS/SimpleHttpRequest.cs b/Common/XmlRpcCS/SimpleHttpRequest.cs new file mode 100644 index 0000000..e5326c3 --- /dev/null +++ b/Common/XmlRpcCS/SimpleHttpRequest.cs @@ -0,0 +1,204 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.IO; + using System.Net.Sockets; + using System.Collections; + + ///Very basic HTTP request handler. + ///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. + 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; + + /// A constructor which accepts the TcpClient. + /// It creates the associated input and output streams, determines the request type, + /// and parses the remaining HTTP header. + /// The TcpClient associated with the HTTP connection. + public SimpleHttpRequest(TcpClient client) + { + _client = client; + _output = new StreamWriter(client.GetStream()); + _input = new StreamReader(client.GetStream()); + GetRequestMethod(); + GetRequestHeaders(); + } + + /// The output StreamWriter associated with the request. + public StreamWriter Output + { + get { return _output; } + } + + /// The input StreamReader associated with the request. + public StreamReader Input + { + get { return _input; } + } + + /// The TcpClient with the request. + public TcpClient Client + { + get { return _client; } + } + + private String _filePath + { + get { return __filePath; } + set + { + __filePath = value; + _filePathDir = null; + _filePathFile = null; + } + } + + /// The type of HTTP request (i.e. PUT, GET, etc.). + public String HttpMethod + { + get { return _httpMethod; } + } + + /// The level of the HTTP protocol. + public String Protocol + { + get { return _protocol; } + } + + /// The "path" which is part of any HTTP request. + public String FilePath + { + get { return _filePath; } + } + + /// The file portion of the "path" which is part of any HTTP request. + 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; + } + } + + /// The directory portion of the "path" which is part of any HTTP request. + 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); + } + } + } + + /// + /// Format the object contents into a useful string representation. + /// + ///String representation of the SimpleHttpRequest as the HttpMethod FilePath Protocol. + override public String ToString() + { + return HttpMethod + " " + FilePath + " " + Protocol; + } + + /// + /// Close the SimpleHttpRequest. This flushes and closes all associated io streams. + /// + public void Close() + { + _output.Flush(); + _output.Close(); + _input.Close(); + _client.Close(); + } + } +} diff --git a/Common/XmlRpcCS/XMLRPC.csproj b/Common/XmlRpcCS/XMLRPC.csproj new file mode 100644 index 0000000..2c7ef94 --- /dev/null +++ b/Common/XmlRpcCS/XMLRPC.csproj @@ -0,0 +1,138 @@ + + + Local + 8.0.50727 + 2.0 + {8E81D43C-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + XMLRPC + JScript + Grid + IE50 + false + Library + + XMLRPC + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/Common/XmlRpcCS/XMLRPC.csproj.user b/Common/XmlRpcCS/XMLRPC.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/Common/XmlRpcCS/XMLRPC.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/Common/XmlRpcCS/XMLRPC.dll.build b/Common/XmlRpcCS/XMLRPC.dll.build new file mode 100644 index 0000000..d734d19 --- /dev/null +++ b/Common/XmlRpcCS/XMLRPC.dll.build @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Common/XmlRpcCS/XmlRpcBoxcarRequest.cs b/Common/XmlRpcCS/XmlRpcBoxcarRequest.cs new file mode 100644 index 0000000..f87f7a5 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcBoxcarRequest.cs @@ -0,0 +1,51 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + using System.Net; + using System.Text; + using System.Reflection; + + /// Class that collects individual XmlRpcRequest objects and submits them as a boxcarred request. + /// 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. + /// + /// + public class XmlRpcBoxcarRequest : XmlRpcRequest + { + /// ArrayList to collect the requests to boxcar. + public IList Requests = new ArrayList(); + + /// Basic constructor. + public XmlRpcBoxcarRequest() + { + } + + /// Returns the String "system.multiCall" which is the server method that handles boxcars. + public override String MethodName + { + get { return "system.multiCall"; } + } + + /// The ArrayList of boxcarred Requests as properly formed parameters. + 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; + } + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcClientProxy.cs b/Common/XmlRpcCS/XmlRpcClientProxy.cs new file mode 100644 index 0000000..f52273a --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcClientProxy.cs @@ -0,0 +1,61 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Runtime.Remoting.Proxies; + using System.Runtime.Remoting.Messaging; + + /// This class provides support for creating local proxies of XML-RPC remote objects + /// + /// To create a local proxy you need to create a local C# interface and then, via createProxy + /// associate that interface with a remote object at a given URL. + /// +public class XmlRpcClientProxy : RealProxy +{ + private String _remoteObjectName; + private String _url; + private XmlRpcRequest _client = new XmlRpcRequest(); + + /// Factory method to create proxies. + /// + /// 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 createProxy along with the object name and URL of the remote object and + /// cast the resulting object to the specifice interface. + /// + /// String The name of the remote object. + /// String The URL of the remote object. + /// Type The typeof() of a C# interface. + /// Object A proxy for your specified interface. Cast to appropriate type. + 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; + } + + /// The local method dispatcher - do not invoke. + 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); + } + } +} +} diff --git a/Common/XmlRpcCS/XmlRpcDeserializer.cs b/Common/XmlRpcCS/XmlRpcDeserializer.cs new file mode 100644 index 0000000..bd736c0 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcDeserializer.cs @@ -0,0 +1,195 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + using System.Globalization; + + /// Parser context, we maintain contexts in a stack to avoiding recursion. + struct Context + { + public String Name; + public Object Container; + } + + /// Basic XML-RPC data deserializer. + /// Uses XmlTextReader 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. + public class XmlRpcDeserializer : XmlRpcXmlTokens + { + private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo(); + + private Object _container; + private Stack _containerStack; + + /// Protected reference to last text. + protected String _text; + /// Protected reference to last deserialized value. + protected Object _value; + /// Protected reference to last name field. + protected String _name; + + + /// Basic constructor. + public XmlRpcDeserializer() + { + Reset(); + _dateFormat.FullDateTimePattern = ISO_DATETIME; + } + + /// Static method that parses XML data into a response using the Singleton. + /// StreamReader containing an XML-RPC response. + /// Object object resulting from the deserialization. + virtual public Object Deserialize(TextReader xmlData) + { + return null; + } + + /// Protected method to parse a node in an XML-RPC XML stream. + /// Method deals with elements common to all XML-RPC data, subclasses of + /// this object deal with request/response spefic elements. + /// XmlTextReader of the in progress parsing data stream. + 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 tag, they just do + + 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; + } + } + + /// Static method that parses XML in a String into a + /// request using the Singleton. + /// String containing an XML-RPC request. + /// XmlRpcRequest object resulting from the parse. + public Object Deserialize(String xmlData) + { + StringReader sr = new StringReader(xmlData); + return Deserialize(sr); + } + + /// Pop a Context of the stack, an Array or Struct has closed. + private void PopContext() + { + Context c = (Context)_containerStack.Pop(); + _container = c.Container; + _name = c.Name; + } + + /// Push a Context on the stack, an Array or Struct has opened. + private void PushContext() + { + Context context; + + context.Container = _container; + context.Name = _name; + + _containerStack.Push(context); + } + + /// Reset the internal state of the deserializer. + 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 + + } +} + + diff --git a/Common/XmlRpcCS/XmlRpcErrorCodes.cs b/Common/XmlRpcCS/XmlRpcErrorCodes.cs new file mode 100644 index 0000000..6dec57d --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcErrorCodes.cs @@ -0,0 +1,51 @@ +namespace Nwc.XmlRpc +{ + using System; + + /// Standard XML-RPC error codes. + public class XmlRpcErrorCodes + { + /// + public const int PARSE_ERROR_MALFORMED = -32700; + /// + public const String PARSE_ERROR_MALFORMED_MSG = "Parse Error, not well formed"; + + /// + public const int PARSE_ERROR_ENCODING = -32701; + /// + 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. + // + + /// + public const int SERVER_ERROR_METHOD = -32601; + /// + public const String SERVER_ERROR_METHOD_MSG = "Server Error, requested method not found"; + + /// + public const int SERVER_ERROR_PARAMS = -32602; + /// + public const String SERVER_ERROR_PARAMS_MSG = "Server Error, invalid method parameters"; + + // + // -32603 ---> server error. internal xml-rpc error + // + + /// + public const int APPLICATION_ERROR = -32500; + /// + public const String APPLICATION_ERROR_MSG = "Application Error"; + + // + // -32400 ---> system error + // + + /// + public const int TRANSPORT_ERROR = -32300; + /// + public const String TRANSPORT_ERROR_MSG = "Transport Layer Error"; + } +} diff --git a/Common/XmlRpcCS/XmlRpcException.cs b/Common/XmlRpcCS/XmlRpcException.cs new file mode 100644 index 0000000..fd1f4ae --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcException.cs @@ -0,0 +1,39 @@ +namespace Nwc.XmlRpc +{ + using System; + + /// An XML-RPC Exception. + /// Maps a C# exception to an XML-RPC fault. Normal exceptions + /// include a message so this adds the code needed by XML-RPC. + public class XmlRpcException : Exception + { + private int _code; + + /// Instantiate an XmlRpcException with a code and message. + /// Int faultCode associated with this exception. + /// String faultMessage associated with this exception. + public XmlRpcException(int code, String message) + : base(message) + { + _code = code; + } + + /// The value of the faults message, i.e. the faultString. + public String FaultString + { + get { return Message; } + } + + /// The value of the faults code, i.e. the faultCode. + public int FaultCode + { + get { return _code; } + } + + /// Format the message to include the code. + override public String ToString() + { + return "Code: " + FaultCode + " Message: " + base.ToString(); + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcExposedAttribute.cs b/Common/XmlRpcCS/XmlRpcExposedAttribute.cs new file mode 100644 index 0000000..67b27ae --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcExposedAttribute.cs @@ -0,0 +1,60 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Reflection; + + /// + /// Simple tagging attribute to indicate participation is XML-RPC exposure. + /// + /// + /// 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. + /// + [AttributeUsage( + AttributeTargets.Class | AttributeTargets.Method, + AllowMultiple = false, + Inherited = true + )] + public class XmlRpcExposedAttribute : Attribute + { + /// Check if obj is an object utilizing the XML-RPC exposed Attribute. + /// Object of a class or method to check for attribute. + /// Boolean true if attribute present. + public static Boolean ExposedObject(Object obj) + { + return IsExposed(obj.GetType()); + } + + /// Check if obj.methodName is an XML-RPC exposed method. + /// 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. + /// Boolean true if the method is exposed. + 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); + } + + /// Check if mi is XML-RPC exposed. + /// MemberInfo of a class or method to check for attribute. + /// Boolean true if attribute present. + public static Boolean IsExposed(MemberInfo mi) + { + foreach (Attribute attr in mi.GetCustomAttributes(true)) + { + if (attr is XmlRpcExposedAttribute) + return true; + } + return false; + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcRequest.cs b/Common/XmlRpcCS/XmlRpcRequest.cs new file mode 100644 index 0000000..18d2182 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcRequest.cs @@ -0,0 +1,150 @@ +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; + } + } + + /// Class supporting the request side of an XML-RPC transaction. + public class XmlRpcRequest + { + private String _methodName = null; + private Encoding _encoding = new ASCIIEncoding(); + private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); + private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); + + /// ArrayList containing the parameters. + protected IList _params = null; + + /// Instantiate an XmlRpcRequest + public XmlRpcRequest() + { + _params = new ArrayList(); + } + + /// Instantiate an XmlRpcRequest for a specified method and parameters. + /// String designating the object.method on the server the request + /// should be directed to. + /// ArrayList of XML-RPC type parameters to invoke the request with. + public XmlRpcRequest(String methodName, IList parameters) + { + MethodName = methodName; + _params = parameters; + } + + /// ArrayList conntaining the parameters for the request. + public virtual IList Params + { + get { return _params; } + } + + /// String conntaining the method name, both object and method, that the request will be sent to. + public virtual String MethodName + { + get { return _methodName; } + set { _methodName = value; } + } + + /// String object name portion of the method name. + public String MethodNameObject + { + get + { + int index = MethodName.IndexOf("."); + + if (index == -1) + return MethodName; + + return MethodName.Substring(0, index); + } + } + + /// String method name portion of the object.method name. + public String MethodNameMethod + { + get + { + int index = MethodName.IndexOf("."); + + if (index == -1) + return MethodName; + + return MethodName.Substring(index + 1, MethodName.Length - index - 1); + } + } + + /// Invoke this request on the server. + /// String The url of the XML-RPC server. + /// Object The value returned from the method invocation on the server. + /// If an exception generated on the server side. + public Object Invoke(String url) + { + XmlRpcResponse res = Send(url, 10000); + + if (res.IsFault) + throw new XmlRpcException(res.FaultCode, res.FaultString); + + return res.Value; + } + + /// Send the request to the server. + /// String The url of the XML-RPC server. + /// Milliseconds before the connection times out. + /// XmlRpcResponse The response generated. + 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; + } + + /// Produce String representation of the object. + /// String representation of the object. + override public String ToString() + { + return _serializer.Serialize(this); + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcRequestDeserializer.cs b/Common/XmlRpcCS/XmlRpcRequestDeserializer.cs new file mode 100644 index 0000000..0770b7e --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcRequestDeserializer.cs @@ -0,0 +1,64 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Diagnostics; + using System.IO; + using System.Xml; + + /// Class to deserialize XML data representing a request. + public class XmlRpcRequestDeserializer : XmlRpcDeserializer + { + static private XmlRpcRequestDeserializer _singleton; + /// A static singleton instance of this deserializer. + [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; + } + } + + /// Static method that parses XML data into a request using the Singleton. + /// StreamReader containing an XML-RPC request. + /// XmlRpcRequest object resulting from the parse. + 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; + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcRequestSerializer.cs b/Common/XmlRpcCS/XmlRpcRequestSerializer.cs new file mode 100644 index 0000000..8099bdb --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcRequestSerializer.cs @@ -0,0 +1,51 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Xml; + using System.IO; + + /// Class responsible for serializing an XML-RPC request. + /// This class handles the request envelope, depending on XmlRpcSerializer + /// to serialize the payload. + /// + public class XmlRpcRequestSerializer : XmlRpcSerializer + { + static private XmlRpcRequestSerializer _singleton; + /// A static singleton instance of this deserializer. + static public XmlRpcRequestSerializer Singleton + { + get + { + if (_singleton == null) + _singleton = new XmlRpcRequestSerializer(); + + return _singleton; + } + } + + /// Serialize the XmlRpcRequest to the output stream. + /// An XmlTextWriter stream to write data to. + /// An XmlRpcRequest to serialize. + /// + 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(); + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcResponder.cs b/Common/XmlRpcCS/XmlRpcResponder.cs new file mode 100644 index 0000000..0412568 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcResponder.cs @@ -0,0 +1,98 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Xml; + using System.Net.Sockets; + + /// The class is a container of the context of an XML-RPC dialog on the server side. + /// 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. + public class XmlRpcResponder + { + private XmlRpcRequestDeserializer _deserializer = new XmlRpcRequestDeserializer(); + private XmlRpcResponseSerializer _serializer = new XmlRpcResponseSerializer(); + private XmlRpcServer _server; + private TcpClient _client; + private SimpleHttpRequest _httpReq; + + /// The SimpleHttpRequest based on the TcpClient. + public SimpleHttpRequest HttpReq + { + get { return _httpReq; } + } + + /// Basic constructor. + /// XmlRpcServer that this XmlRpcResponder services. + /// TcpClient with the connection. + public XmlRpcResponder(XmlRpcServer server, TcpClient client) + { + _server = server; + _client = client; + _httpReq = new SimpleHttpRequest(_client); + } + + /// Call close to insure proper shutdown. + ~XmlRpcResponder() + { + Close(); + } + + ///Respond using this responders HttpReq. + public void Respond() + { + Respond(HttpReq); + } + + /// Handle an HTTP request containing an XML-RPC request. + /// 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. + /// + /// SimpleHttpRequest containing the request. + 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(); + } + + ///Close all contained resources, both the HttpReq and client. + public void Close() + { + if (_httpReq != null) + { + _httpReq.Close(); + _httpReq = null; + } + + if (_client != null) + { + _client.Close(); + _client = null; + } + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcResponse.cs b/Common/XmlRpcCS/XmlRpcResponse.cs new file mode 100644 index 0000000..8ff8354 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcResponse.cs @@ -0,0 +1,85 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + + /// Class designed to represent an XML-RPC response. + public class XmlRpcResponse + { + private Object _value; + /// bool indicating if this response represents a fault. + public bool IsFault; + + /// Basic constructor + public XmlRpcResponse() + { + Value = null; + IsFault = false; + } + + /// Constructor for a fault. + /// int the numeric faultCode value. + /// String the faultString value. + public XmlRpcResponse(int code, String message) + : this() + { + SetFault(code, message); + } + + /// The data value of the response, may be fault data. + public Object Value + { + get { return _value; } + set + { + IsFault = false; + _value = value; + } + } + + /// The faultCode if this is a fault. + public int FaultCode + { + get + { + if (!IsFault) + return 0; + else + return (int)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_CODE]; + } + } + + /// The faultString if this is a fault. + public String FaultString + { + get + { + if (!IsFault) + return ""; + else + return (String)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_STRING]; + } + } + + /// Set this response to be a fault. + /// int the numeric faultCode value. + /// String the faultString value. + public void SetFault(int code, String message) + { + Hashtable fault = new Hashtable(); + fault.Add("faultCode", code); + fault.Add("faultString", message); + Value = fault; + IsFault = true; + } + + /// Form a useful string representation of the object, in this case the XML response. + /// String The XML serialized XML-RPC response. + override public String ToString() + { + return XmlRpcResponseSerializer.Singleton.Serialize(this); + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcResponseDeserializer.cs b/Common/XmlRpcCS/XmlRpcResponseDeserializer.cs new file mode 100644 index 0000000..032d8a3 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcResponseDeserializer.cs @@ -0,0 +1,65 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + + /// Class to deserialize XML data representing a response. + public class XmlRpcResponseDeserializer : XmlRpcDeserializer + { + static private XmlRpcResponseDeserializer _singleton; + /// A static singleton instance of this deserializer. + [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; + } + } + + /// Static method that parses XML data into a response using the Singleton. + /// StreamReader containing an XML-RPC response. + /// XmlRpcResponse object resulting from the parse. + 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; + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcResponseSerializer.cs b/Common/XmlRpcCS/XmlRpcResponseSerializer.cs new file mode 100644 index 0000000..72ca568 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcResponseSerializer.cs @@ -0,0 +1,57 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Xml; + + /// Class responsible for serializing an XML-RPC response. + /// This class handles the response envelope, depending on XmlRpcSerializer + /// to serialize the payload. + /// + public class XmlRpcResponseSerializer : XmlRpcSerializer + { + static private XmlRpcResponseSerializer _singleton; + /// A static singleton instance of this deserializer. + static public XmlRpcResponseSerializer Singleton + { + get + { + if (_singleton == null) + _singleton = new XmlRpcResponseSerializer(); + + return _singleton; + } + } + + /// Serialize the XmlRpcResponse to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + /// + 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(); + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcSerializer.cs b/Common/XmlRpcCS/XmlRpcSerializer.cs new file mode 100644 index 0000000..0643d38 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcSerializer.cs @@ -0,0 +1,109 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + + /// Base class of classes serializing data to XML-RPC's XML format. + /// This class handles the basic type conversions like Integer to <i4>. + /// + public class XmlRpcSerializer : XmlRpcXmlTokens + { + + /// Serialize the XmlRpcRequest to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + /// + virtual public void Serialize(XmlTextWriter output, Object obj) + { + } + + /// Serialize the XmlRpcRequest to a String. + /// Note this may represent a real memory hog for a large request. + /// An Object to serialize. + /// String containing XML-RPC representation of the request. + /// + 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; + } + + /// Serialize the object to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + 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(); + } + + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcServer.cs b/Common/XmlRpcCS/XmlRpcServer.cs new file mode 100644 index 0000000..1c226c1 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcServer.cs @@ -0,0 +1,239 @@ +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; + + /// A restricted HTTP server for use with XML-RPC. + /// 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. + /// + 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 + + ///Constructor with port and address. + ///This constructor sets up a TcpListener listening on the + ///given port and address. It also calls a Thread on the method StartListen(). + ///IPAddress value of the address to listen on. + ///Int value of the port to listen on. + public XmlRpcServer(IPAddress address, int port) + { + _port = port; + _address = address; + _handlers = new Hashtable(); + _system = new XmlRpcSystemObject(this); + _wc = new WaitCallback(WaitCallback); + } + + ///Basic constructor. + ///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. + ///Int value of the port to listen on. + public XmlRpcServer(int port) : this(IPAddress.Any, port) { } + + /// Start the server. + 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); + } + } + + /// Stop the server. + 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); + } + } + + /// Get an enumeration of my XML-RPC handlers. + /// IEnumerable the handler enumeration. + public IEnumerator GetEnumerator() + { + return _handlers.GetEnumerator(); + } + + /// Retrieve a handler by name. + /// String naming a handler + /// Object that is the handler. + public Object this[String name] + { + get { return _handlers[name]; } + } + + /// + ///This method Accepts new connections and dispatches them when appropriate. + /// + public void StartListen() + { + while (true && _myListener != null) + { + //Accept a new connection + XmlRpcResponder responder = new XmlRpcResponder(this, _myListener.AcceptTcpClient()); + ThreadPool.QueueUserWorkItem(_wc, responder); + } + } + + + /// + ///Add an XML-RPC handler object by name. + /// + ///String XML-RPC dispatch name of this object. + ///Object The object that is the XML-RPC handler. + public void Add(String name, Object obj) + { + _handlers.Add(name, obj); + } + + ///Return a C# object.method name for and XML-RPC object.method name pair. + ///The XML-RPC object.method. + ///String of form object.method for the underlying C# method. + 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); + } + + ///Invoke a method described in a request. + ///XmlRpcRequest containing a method descriptions. + /// + /// + public Object Invoke(XmlRpcRequest req) + { + return Invoke(req.MethodNameObject, req.MethodNameMethod, req.Params); + } + + ///Invoke a method on a named handler. + ///String The name of the handler. + ///String The name of the method to invoke on the handler. + ///IList The parameters to invoke the method with. + /// + 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); + } + + /// The method the thread pool invokes when a thread is available to handle an HTTP request. + /// TcpClient from the socket accept. + 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(); + } + + /// + /// This function send the Header Information to the client (Browser) + /// + /// HTTP Version + /// Mime Type + /// Total Bytes to be sent in the body + /// + /// Socket reference + 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); + } + } +} diff --git a/Common/XmlRpcCS/XmlRpcSystemObject.cs b/Common/XmlRpcCS/XmlRpcSystemObject.cs new file mode 100644 index 0000000..5f79951 --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcSystemObject.cs @@ -0,0 +1,252 @@ +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Reflection; + + /// XML-RPC System object implementation of extended specifications. + [XmlRpcExposed] + public class XmlRpcSystemObject + { + private XmlRpcServer _server; + static private IDictionary _methodHelp = new Hashtable(); + + /// Static IDictionary to hold mappings of method name to associated documentation String + static public IDictionary MethodHelp + { + get { return _methodHelp; } + } + + /// Constructor. + /// XmlRpcServer server to be the system object for. + public XmlRpcSystemObject(XmlRpcServer server) + { + _server = server; + server.Add("system", this); + _methodHelp.Add(this.GetType().FullName + ".methodHelp", "Return a string description."); + } + + /// Invoke a method on a given object. + /// Using reflection, and respecting the XmlRpcExposed attribute, + /// invoke the methodName method on the target + /// instance with the parameters provided. All this packages other Invoke methods + /// end up calling this. + /// Object the value the invoked method returns. + /// If method does not exist, is not exposed, parameters invalid, or invocation + /// results in an exception. Note, the XmlRpcException.Code will indicate cause. + 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); + } + } + + /// List methods available on all handlers of this server. + /// IList An array of Strings, each String will have form "object.method". + [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; + } + + /// Given a method name return the possible signatures for it. + /// String The object.method name to look up. + /// IList Of arrays of signatures. + [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; + } + + /// Help for given method signature. Not implemented yet. + /// String The object.method name to look up. + /// String help text. Rich HTML text. + [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; + } + + /// Boxcarring support method. + /// IList of calls + /// ArrayList of results/faults. + [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; + } + + } +} + diff --git a/Common/XmlRpcCS/XmlRpcXmlTokens.cs b/Common/XmlRpcCS/XmlRpcXmlTokens.cs new file mode 100644 index 0000000..50788bd --- /dev/null +++ b/Common/XmlRpcCS/XmlRpcXmlTokens.cs @@ -0,0 +1,76 @@ +namespace Nwc.XmlRpc +{ + using System; + + /// Class collecting String tokens that are part of XML-RPC files. + public class XmlRpcXmlTokens + { + /// C# formatting string to describe an ISO 8601 date. + public const String ISO_DATETIME = "yyyyMMdd\\THH\\:mm\\:ss"; + /// Base64 field indicator. + /// Corresponds to the <base64> tag. + public const String BASE64 = "base64"; + /// String field indicator. + /// Corresponds to the <string> tag. + public const String STRING = "string"; + /// Integer field integer. + /// Corresponds to the <i4> tag. + public const String INT = "i4"; + /// Alternate integer field indicator. + /// Corresponds to the <int> tag. + public const String ALT_INT = "int"; + /// Date field indicator. + /// Corresponds to the <dateTime.iso8601> tag. + public const String DATETIME = "dateTime.iso8601"; + /// Boolean field indicator. + /// Corresponds to the <boolean> tag. + public const String BOOLEAN = "boolean"; + /// Value token. + /// Corresponds to the <value> tag. + public const String VALUE = "value"; + /// Name token. + /// Corresponds to the <name> tag. + public const String NAME = "name"; + /// Array field indicator.. + /// Corresponds to the <array> tag. + public const String ARRAY = "array"; + /// Data token. + /// Corresponds to the <data> tag. + public const String DATA = "data"; + /// Member token. + /// Corresponds to the <member> tag. + public const String MEMBER = "member"; + /// Stuct field indicator. + /// Corresponds to the <struct> tag. + public const String STRUCT = "struct"; + /// Double field indicator. + /// Corresponds to the <double> tag. + public const String DOUBLE = "double"; + /// Param token. + /// Corresponds to the <param> tag. + public const String PARAM = "param"; + /// Params token. + /// Corresponds to the <params> tag. + public const String PARAMS = "params"; + /// MethodCall token. + /// Corresponds to the <methodCall> tag. + public const String METHOD_CALL = "methodCall"; + /// MethodName token. + /// Corresponds to the <methodName> tag. + public const String METHOD_NAME = "methodName"; + /// MethodResponse token + /// Corresponds to the <methodResponse> tag. + public const String METHOD_RESPONSE = "methodResponse"; + /// Fault response token. + /// Corresponds to the <fault> tag. + public const String FAULT = "fault"; + /// FaultCode token. + /// Corresponds to the <faultCode> tag. + public const String FAULT_CODE = "faultCode"; + /// FaultString token. + /// Corresponds to the <faultString> tag. + public const String FAULT_STRING = "faultString"; + } +} + + -- cgit v1.1