diff options
author | MW | 2007-05-26 13:40:19 +0000 |
---|---|---|
committer | MW | 2007-05-26 13:40:19 +0000 |
commit | 3436961bb5c01d659d09be134368f4f69460cef9 (patch) | |
tree | 3753ba4d7818df2a6bce0bbe863ff033cdfd568a /OpenGridServices/OpenGrid.Framework.Data | |
download | opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.zip opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2 opensim-SC-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz |
Start of rewrite 5279!
Diffstat (limited to '')
35 files changed, 2936 insertions, 0 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs new file mode 100644 index 0000000..546713e --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs | |||
@@ -0,0 +1,83 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | using libsecondlife; | ||
6 | |||
7 | |||
8 | namespace OpenGrid.Framework.Data.DB4o | ||
9 | { | ||
10 | class DB4oGridData : IGridData | ||
11 | { | ||
12 | DB4oGridManager manager; | ||
13 | |||
14 | public void Initialise() { | ||
15 | manager = new DB4oGridManager("gridserver.yap"); | ||
16 | } | ||
17 | |||
18 | public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) | ||
19 | { | ||
20 | return null; | ||
21 | } | ||
22 | |||
23 | public SimProfileData GetProfileByHandle(ulong handle) { | ||
24 | lock (manager.simProfiles) | ||
25 | { | ||
26 | foreach (LLUUID UUID in manager.simProfiles.Keys) | ||
27 | { | ||
28 | if (manager.simProfiles[UUID].regionHandle == handle) | ||
29 | { | ||
30 | return manager.simProfiles[UUID]; | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")"); | ||
35 | } | ||
36 | |||
37 | public SimProfileData GetProfileByLLUUID(LLUUID uuid) | ||
38 | { | ||
39 | lock (manager.simProfiles) | ||
40 | { | ||
41 | if (manager.simProfiles.ContainsKey(uuid)) | ||
42 | return manager.simProfiles[uuid]; | ||
43 | } | ||
44 | throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")"); | ||
45 | } | ||
46 | |||
47 | public DataResponse AddProfile(SimProfileData profile) | ||
48 | { | ||
49 | lock (manager.simProfiles) | ||
50 | { | ||
51 | if (manager.AddRow(profile)) | ||
52 | { | ||
53 | return DataResponse.RESPONSE_OK; | ||
54 | } | ||
55 | else | ||
56 | { | ||
57 | return DataResponse.RESPONSE_ERROR; | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { | ||
63 | if (manager.simProfiles[uuid].regionRecvKey == key) | ||
64 | return true; | ||
65 | return false; | ||
66 | } | ||
67 | |||
68 | public void Close() | ||
69 | { | ||
70 | manager = null; | ||
71 | } | ||
72 | |||
73 | public string getName() | ||
74 | { | ||
75 | return "DB4o Grid Provider"; | ||
76 | } | ||
77 | |||
78 | public string getVersion() | ||
79 | { | ||
80 | return "0.1"; | ||
81 | } | ||
82 | } | ||
83 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs new file mode 100644 index 0000000..1606765 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs | |||
@@ -0,0 +1,111 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using Db4objects.Db4o; | ||
5 | using OpenGrid.Framework.Data; | ||
6 | using libsecondlife; | ||
7 | |||
8 | namespace OpenGrid.Framework.Data.DB4o | ||
9 | { | ||
10 | class DB4oGridManager | ||
11 | { | ||
12 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); | ||
13 | string dbfl; | ||
14 | |||
15 | public DB4oGridManager(string db4odb) | ||
16 | { | ||
17 | dbfl = db4odb; | ||
18 | IObjectContainer database; | ||
19 | database = Db4oFactory.OpenFile(dbfl); | ||
20 | IObjectSet result = database.Get(typeof(SimProfileData)); | ||
21 | foreach(SimProfileData row in result) { | ||
22 | simProfiles.Add(row.UUID, row); | ||
23 | } | ||
24 | database.Close(); | ||
25 | } | ||
26 | |||
27 | /// <summary> | ||
28 | /// Adds a new profile to the database (Warning: Probably slow.) | ||
29 | /// </summary> | ||
30 | /// <param name="row">The profile to add</param> | ||
31 | /// <returns>Successful?</returns> | ||
32 | public bool AddRow(SimProfileData row) | ||
33 | { | ||
34 | if (simProfiles.ContainsKey(row.UUID)) | ||
35 | { | ||
36 | simProfiles[row.UUID] = row; | ||
37 | } | ||
38 | else | ||
39 | { | ||
40 | simProfiles.Add(row.UUID, row); | ||
41 | } | ||
42 | |||
43 | try | ||
44 | { | ||
45 | IObjectContainer database; | ||
46 | database = Db4oFactory.OpenFile(dbfl); | ||
47 | database.Set(row); | ||
48 | database.Close(); | ||
49 | return true; | ||
50 | } | ||
51 | catch (Exception e) | ||
52 | { | ||
53 | return false; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | |||
58 | } | ||
59 | |||
60 | class DB4oUserManager | ||
61 | { | ||
62 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); | ||
63 | string dbfl; | ||
64 | |||
65 | public DB4oUserManager(string db4odb) | ||
66 | { | ||
67 | dbfl = db4odb; | ||
68 | IObjectContainer database; | ||
69 | database = Db4oFactory.OpenFile(dbfl); | ||
70 | IObjectSet result = database.Get(typeof(UserProfileData)); | ||
71 | foreach (UserProfileData row in result) | ||
72 | { | ||
73 | userProfiles.Add(row.UUID, row); | ||
74 | } | ||
75 | database.Close(); | ||
76 | } | ||
77 | |||
78 | /// <summary> | ||
79 | /// Adds a new profile to the database (Warning: Probably slow.) | ||
80 | /// </summary> | ||
81 | /// <param name="row">The profile to add</param> | ||
82 | /// <returns>Successful?</returns> | ||
83 | public bool AddRow(UserProfileData row) | ||
84 | { | ||
85 | Console.WriteLine("adding profile to database" + row.username); | ||
86 | if (userProfiles.ContainsKey(row.UUID)) | ||
87 | { | ||
88 | userProfiles[row.UUID] = row; | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | userProfiles.Add(row.UUID, row); | ||
93 | } | ||
94 | |||
95 | try | ||
96 | { | ||
97 | IObjectContainer database; | ||
98 | database = Db4oFactory.OpenFile(dbfl); | ||
99 | database.Set(row); | ||
100 | database.Close(); | ||
101 | return true; | ||
102 | } | ||
103 | catch (Exception e) | ||
104 | { | ||
105 | return false; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | |||
110 | } | ||
111 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs new file mode 100644 index 0000000..b95219c --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | |||
@@ -0,0 +1,100 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | using libsecondlife; | ||
6 | |||
7 | namespace OpenGrid.Framework.Data.DB4o | ||
8 | { | ||
9 | public class DB4oUserData : IUserData | ||
10 | { | ||
11 | DB4oUserManager manager; | ||
12 | |||
13 | public void Initialise() | ||
14 | { | ||
15 | manager = new DB4oUserManager("userprofiles.yap"); | ||
16 | } | ||
17 | |||
18 | public UserProfileData getUserByUUID(LLUUID uuid) | ||
19 | { | ||
20 | if(manager.userProfiles.ContainsKey(uuid)) | ||
21 | return manager.userProfiles[uuid]; | ||
22 | return null; | ||
23 | } | ||
24 | |||
25 | public UserProfileData getUserByName(string name) | ||
26 | { | ||
27 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
28 | } | ||
29 | |||
30 | public UserProfileData getUserByName(string fname, string lname) | ||
31 | { | ||
32 | foreach (UserProfileData profile in manager.userProfiles.Values) | ||
33 | { | ||
34 | if (profile.username == fname && profile.surname == lname) | ||
35 | return profile; | ||
36 | } | ||
37 | return null; | ||
38 | } | ||
39 | |||
40 | public UserAgentData getAgentByUUID(LLUUID uuid) | ||
41 | { | ||
42 | try | ||
43 | { | ||
44 | return getUserByUUID(uuid).currentAgent; | ||
45 | } | ||
46 | catch (Exception e) | ||
47 | { | ||
48 | return null; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | public UserAgentData getAgentByName(string name) | ||
53 | { | ||
54 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
55 | } | ||
56 | |||
57 | public UserAgentData getAgentByName(string fname, string lname) | ||
58 | { | ||
59 | try | ||
60 | { | ||
61 | return getUserByName(fname,lname).currentAgent; | ||
62 | } | ||
63 | catch (Exception e) | ||
64 | { | ||
65 | return null; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public void addNewUserProfile(UserProfileData user) | ||
70 | { | ||
71 | manager.AddRow(user); | ||
72 | } | ||
73 | |||
74 | public void addNewUserAgent(UserAgentData agent) | ||
75 | { | ||
76 | // Do nothing. yet. | ||
77 | } | ||
78 | |||
79 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | ||
80 | { | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | ||
85 | { | ||
86 | return true; | ||
87 | } | ||
88 | |||
89 | |||
90 | public string getName() | ||
91 | { | ||
92 | return "DB4o Userdata"; | ||
93 | } | ||
94 | |||
95 | public string getVersion() | ||
96 | { | ||
97 | return "0.1"; | ||
98 | } | ||
99 | } | ||
100 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj b/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj new file mode 100644 index 0000000..82d4f5f --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj | |||
@@ -0,0 +1,111 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{39BD9497-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenGrid.Framework.Data.DB4o</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenGrid.Framework.Data.DB4o</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System.Data" > | ||
70 | <HintPath>System.Data.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="libsecondlife.dll" > | ||
74 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | <Reference Include="Db4objects.Db4o.dll" > | ||
78 | <HintPath>..\..\bin\Db4objects.Db4o.dll</HintPath> | ||
79 | <Private>False</Private> | ||
80 | </Reference> | ||
81 | </ItemGroup> | ||
82 | <ItemGroup> | ||
83 | <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj"> | ||
84 | <Name>OpenGrid.Framework.Data</Name> | ||
85 | <Project>{62CDF671-0000-0000-0000-000000000000}</Project> | ||
86 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
87 | <Private>False</Private> | ||
88 | </ProjectReference> | ||
89 | </ItemGroup> | ||
90 | <ItemGroup> | ||
91 | <Compile Include="DB4oGridData.cs"> | ||
92 | <SubType>Code</SubType> | ||
93 | </Compile> | ||
94 | <Compile Include="DB4oManager.cs"> | ||
95 | <SubType>Code</SubType> | ||
96 | </Compile> | ||
97 | <Compile Include="DB4oUserData.cs"> | ||
98 | <SubType>Code</SubType> | ||
99 | </Compile> | ||
100 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
101 | <SubType>Code</SubType> | ||
102 | </Compile> | ||
103 | </ItemGroup> | ||
104 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
105 | <PropertyGroup> | ||
106 | <PreBuildEvent> | ||
107 | </PreBuildEvent> | ||
108 | <PostBuildEvent> | ||
109 | </PostBuildEvent> | ||
110 | </PropertyGroup> | ||
111 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj.user b/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build b/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build new file mode 100644 index 0000000..8e0f53a --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build | |||
@@ -0,0 +1,47 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenGrid.Framework.Data.DB4o" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenGrid.Framework.Data.DB4o" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="DB4oGridData.cs" /> | ||
15 | <include name="DB4oManager.cs" /> | ||
16 | <include name="DB4oUserData.cs" /> | ||
17 | <include name="Properties/AssemblyInfo.cs" /> | ||
18 | </sources> | ||
19 | <references basedir="${project::get-base-directory()}"> | ||
20 | <lib> | ||
21 | <include name="${project::get-base-directory()}" /> | ||
22 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
23 | </lib> | ||
24 | <include name="System.dll" /> | ||
25 | <include name="System.Xml.dll" /> | ||
26 | <include name="System.Data.dll" /> | ||
27 | <include name="../../bin/OpenGrid.Framework.Data.dll" /> | ||
28 | <include name="../../bin/libsecondlife.dll" /> | ||
29 | <include name="../../bin/Db4objects.Db4o.dll" /> | ||
30 | </references> | ||
31 | </csc> | ||
32 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
33 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
34 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
35 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
36 | <include name="*.dll"/> | ||
37 | <include name="*.exe"/> | ||
38 | </fileset> | ||
39 | </copy> | ||
40 | </target> | ||
41 | <target name="clean"> | ||
42 | <delete dir="${bin.dir}" failonerror="false" /> | ||
43 | <delete dir="${obj.dir}" failonerror="false" /> | ||
44 | </target> | ||
45 | <target name="doc" description="Creates documentation."> | ||
46 | </target> | ||
47 | </project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dc4a9a1 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenGrid.Framework.Data.DB4o")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenGrid.Framework.Data.DB4o")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs new file mode 100644 index 0000000..0925df1 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLGridData.cs | |||
@@ -0,0 +1,136 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | |||
6 | namespace OpenGrid.Framework.Data.MSSQL | ||
7 | { | ||
8 | public class SqlGridData : IGridData | ||
9 | { | ||
10 | private MSSqlManager database; | ||
11 | |||
12 | /// <summary> | ||
13 | /// Initialises the Grid Interface | ||
14 | /// </summary> | ||
15 | public void Initialise() | ||
16 | { | ||
17 | database = new MSSqlManager("localhost", "db", "user", "password", "false"); | ||
18 | } | ||
19 | |||
20 | /// <summary> | ||
21 | /// Shuts down the grid interface | ||
22 | /// </summary> | ||
23 | public void Close() | ||
24 | { | ||
25 | database.Close(); | ||
26 | } | ||
27 | |||
28 | public string getName() | ||
29 | { | ||
30 | return "Sql OpenGridData"; | ||
31 | } | ||
32 | |||
33 | public string getVersion() | ||
34 | { | ||
35 | return "0.1"; | ||
36 | } | ||
37 | |||
38 | public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) | ||
39 | { | ||
40 | return null; | ||
41 | } | ||
42 | |||
43 | /// <summary> | ||
44 | /// Returns a sim profile from it's location | ||
45 | /// </summary> | ||
46 | /// <param name="handle">Region location handle</param> | ||
47 | /// <returns>Sim profile</returns> | ||
48 | public SimProfileData GetProfileByHandle(ulong handle) | ||
49 | { | ||
50 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
51 | param["handle"] = handle.ToString(); | ||
52 | |||
53 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param); | ||
54 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
55 | |||
56 | SimProfileData row = database.getRow(reader); | ||
57 | reader.Close(); | ||
58 | result.Dispose(); | ||
59 | |||
60 | return row; | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Returns a sim profile from it's UUID | ||
65 | /// </summary> | ||
66 | /// <param name="uuid">The region UUID</param> | ||
67 | /// <returns>The sim profile</returns> | ||
68 | public SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID uuid) | ||
69 | { | ||
70 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
71 | param["uuid"] = uuid.ToStringHyphenated(); | ||
72 | |||
73 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param); | ||
74 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
75 | |||
76 | SimProfileData row = database.getRow(reader); | ||
77 | reader.Close(); | ||
78 | result.Dispose(); | ||
79 | |||
80 | return row; | ||
81 | } | ||
82 | |||
83 | public DataResponse AddProfile(SimProfileData profile) | ||
84 | { | ||
85 | if (database.insertRow(profile)) | ||
86 | { | ||
87 | return DataResponse.RESPONSE_OK; | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | return DataResponse.RESPONSE_ERROR; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret. | ||
97 | /// </summary> | ||
98 | /// <param name="uuid">The UUID of the challenger</param> | ||
99 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
100 | /// <param name="authkey">The secret</param> | ||
101 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
102 | public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authkey) | ||
103 | { | ||
104 | bool throwHissyFit = false; // Should be true by 1.0 | ||
105 | |||
106 | if (throwHissyFit) | ||
107 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
108 | |||
109 | SimProfileData data = GetProfileByLLUUID(uuid); | ||
110 | |||
111 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
116 | /// </summary> | ||
117 | /// <remarks>This requires a security audit.</remarks> | ||
118 | /// <param name="uuid"></param> | ||
119 | /// <param name="handle"></param> | ||
120 | /// <param name="authhash"></param> | ||
121 | /// <param name="challenge"></param> | ||
122 | /// <returns></returns> | ||
123 | public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authhash, string challenge) | ||
124 | { | ||
125 | System.Security.Cryptography.SHA512Managed HashProvider = new System.Security.Cryptography.SHA512Managed(); | ||
126 | System.Text.ASCIIEncoding TextProvider = new ASCIIEncoding(); | ||
127 | |||
128 | byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge); | ||
129 | byte[] hash = HashProvider.ComputeHash(stream); | ||
130 | |||
131 | return false; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | |||
136 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs new file mode 100644 index 0000000..12c166c --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/MSSQLManager.cs | |||
@@ -0,0 +1,171 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Data; | ||
5 | |||
6 | using System.Data.SqlClient; | ||
7 | |||
8 | using OpenGrid.Framework.Data; | ||
9 | |||
10 | namespace OpenGrid.Framework.Data.MSSQL | ||
11 | { | ||
12 | class MSSqlManager | ||
13 | { | ||
14 | IDbConnection dbcon; | ||
15 | |||
16 | /// <summary> | ||
17 | /// Initialises and creates a new Sql connection and maintains it. | ||
18 | /// </summary> | ||
19 | /// <param name="hostname">The Sql server being connected to</param> | ||
20 | /// <param name="database">The name of the Sql database being used</param> | ||
21 | /// <param name="username">The username logging into the database</param> | ||
22 | /// <param name="password">The password for the user logging in</param> | ||
23 | /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> | ||
24 | public MSSqlManager(string hostname, string database, string username, string password, string cpooling) | ||
25 | { | ||
26 | try | ||
27 | { | ||
28 | string connectionString = "Server=" + hostname + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; | ||
29 | dbcon = new SqlConnection(connectionString); | ||
30 | |||
31 | dbcon.Open(); | ||
32 | } | ||
33 | catch (Exception e) | ||
34 | { | ||
35 | throw new Exception("Error initialising Sql Database: " + e.ToString()); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | /// <summary> | ||
40 | /// Shuts down the database connection | ||
41 | /// </summary> | ||
42 | public void Close() | ||
43 | { | ||
44 | dbcon.Close(); | ||
45 | dbcon = null; | ||
46 | } | ||
47 | |||
48 | /// <summary> | ||
49 | /// Runs a query with protection against SQL Injection by using parameterised input. | ||
50 | /// </summary> | ||
51 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | ||
52 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> | ||
53 | /// <returns>A Sql DB Command</returns> | ||
54 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) | ||
55 | { | ||
56 | SqlCommand dbcommand = (SqlCommand)dbcon.CreateCommand(); | ||
57 | dbcommand.CommandText = sql; | ||
58 | foreach (KeyValuePair<string, string> param in parameters) | ||
59 | { | ||
60 | dbcommand.Parameters.AddWithValue(param.Key, param.Value); | ||
61 | } | ||
62 | |||
63 | return (IDbCommand)dbcommand; | ||
64 | } | ||
65 | |||
66 | public SimProfileData getRow(IDataReader reader) | ||
67 | { | ||
68 | SimProfileData retval = new SimProfileData(); | ||
69 | |||
70 | if (reader.Read()) | ||
71 | { | ||
72 | // Region Main | ||
73 | retval.regionHandle = (ulong)reader["regionHandle"]; | ||
74 | retval.regionName = (string)reader["regionName"]; | ||
75 | retval.UUID = new libsecondlife.LLUUID((string)reader["uuid"]); | ||
76 | |||
77 | // Secrets | ||
78 | retval.regionRecvKey = (string)reader["regionRecvKey"]; | ||
79 | retval.regionSecret = (string)reader["regionSecret"]; | ||
80 | retval.regionSendKey = (string)reader["regionSendKey"]; | ||
81 | |||
82 | // Region Server | ||
83 | retval.regionDataURI = (string)reader["regionDataURI"]; | ||
84 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
85 | retval.serverIP = (string)reader["serverIP"]; | ||
86 | retval.serverPort = (uint)reader["serverPort"]; | ||
87 | retval.serverURI = (string)reader["serverURI"]; | ||
88 | |||
89 | // Location | ||
90 | retval.regionLocX = (uint)((int)reader["locX"]); | ||
91 | retval.regionLocY = (uint)((int)reader["locY"]); | ||
92 | retval.regionLocZ = (uint)((int)reader["locZ"]); | ||
93 | |||
94 | // Neighbours - 0 = No Override | ||
95 | retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; | ||
96 | retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; | ||
97 | retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; | ||
98 | retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; | ||
99 | |||
100 | // Assets | ||
101 | retval.regionAssetURI = (string)reader["regionAssetURI"]; | ||
102 | retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; | ||
103 | retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; | ||
104 | |||
105 | // Userserver | ||
106 | retval.regionUserURI = (string)reader["regionUserURI"]; | ||
107 | retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; | ||
108 | retval.regionUserSendKey = (string)reader["regionUserSendKey"]; | ||
109 | } | ||
110 | else | ||
111 | { | ||
112 | throw new Exception("No rows to return"); | ||
113 | } | ||
114 | return retval; | ||
115 | } | ||
116 | |||
117 | public bool insertRow(SimProfileData profile) | ||
118 | { | ||
119 | string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | ||
120 | sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | ||
121 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; | ||
122 | |||
123 | sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; | ||
124 | sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; | ||
125 | sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; | ||
126 | |||
127 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
128 | |||
129 | parameters["regionHandle"] = profile.regionHandle.ToString(); | ||
130 | parameters["regionName"] = profile.regionName; | ||
131 | parameters["uuid"] = profile.UUID.ToString(); | ||
132 | parameters["regionRecvKey"] = profile.regionRecvKey; | ||
133 | parameters["regionSendKey"] = profile.regionSendKey; | ||
134 | parameters["regionDataURI"] = profile.regionDataURI; | ||
135 | parameters["serverIP"] = profile.serverIP; | ||
136 | parameters["serverPort"] = profile.serverPort.ToString(); | ||
137 | parameters["serverURI"] = profile.serverURI; | ||
138 | parameters["locX"] = profile.regionLocX.ToString(); | ||
139 | parameters["locY"] = profile.regionLocY.ToString(); | ||
140 | parameters["locZ"] = profile.regionLocZ.ToString(); | ||
141 | parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString(); | ||
142 | parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString(); | ||
143 | parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString(); | ||
144 | parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString(); | ||
145 | parameters["regionAssetURI"] = profile.regionAssetURI; | ||
146 | parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey; | ||
147 | parameters["regionAssetSendKey"] = profile.regionAssetSendKey; | ||
148 | parameters["regionUserURI"] = profile.regionUserURI; | ||
149 | parameters["regionUserRecvKey"] = profile.regionUserRecvKey; | ||
150 | parameters["regionUserSendKey"] = profile.regionUserSendKey; | ||
151 | |||
152 | bool returnval = false; | ||
153 | |||
154 | try | ||
155 | { | ||
156 | IDbCommand result = Query(sql, parameters); | ||
157 | |||
158 | if (result.ExecuteNonQuery() == 1) | ||
159 | returnval = true; | ||
160 | |||
161 | result.Dispose(); | ||
162 | } | ||
163 | catch (Exception e) | ||
164 | { | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | return returnval; | ||
169 | } | ||
170 | } | ||
171 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj new file mode 100644 index 0000000..8d53692 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj | |||
@@ -0,0 +1,104 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{0A563AC1-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenGrid.Framework.Data.MSSQL</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenGrid.Framework.Data.MSSQL</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System.Data" > | ||
70 | <HintPath>System.Data.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="libsecondlife.dll" > | ||
74 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | </ItemGroup> | ||
78 | <ItemGroup> | ||
79 | <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj"> | ||
80 | <Name>OpenGrid.Framework.Data</Name> | ||
81 | <Project>{62CDF671-0000-0000-0000-000000000000}</Project> | ||
82 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
83 | <Private>False</Private> | ||
84 | </ProjectReference> | ||
85 | </ItemGroup> | ||
86 | <ItemGroup> | ||
87 | <Compile Include="MSSQLGridData.cs"> | ||
88 | <SubType>Code</SubType> | ||
89 | </Compile> | ||
90 | <Compile Include="MSSQLManager.cs"> | ||
91 | <SubType>Code</SubType> | ||
92 | </Compile> | ||
93 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
94 | <SubType>Code</SubType> | ||
95 | </Compile> | ||
96 | </ItemGroup> | ||
97 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
98 | <PropertyGroup> | ||
99 | <PreBuildEvent> | ||
100 | </PreBuildEvent> | ||
101 | <PostBuildEvent> | ||
102 | </PostBuildEvent> | ||
103 | </PropertyGroup> | ||
104 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj.user b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.dll.build b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.dll.build new file mode 100644 index 0000000..5b6b75b --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/OpenGrid.Framework.Data.MSSQL.dll.build | |||
@@ -0,0 +1,45 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenGrid.Framework.Data.MSSQL" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenGrid.Framework.Data.MSSQL" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="MSSQLGridData.cs" /> | ||
15 | <include name="MSSQLManager.cs" /> | ||
16 | <include name="Properties/AssemblyInfo.cs" /> | ||
17 | </sources> | ||
18 | <references basedir="${project::get-base-directory()}"> | ||
19 | <lib> | ||
20 | <include name="${project::get-base-directory()}" /> | ||
21 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
22 | </lib> | ||
23 | <include name="System.dll" /> | ||
24 | <include name="System.Xml.dll" /> | ||
25 | <include name="System.Data.dll" /> | ||
26 | <include name="../../bin/OpenGrid.Framework.Data.dll" /> | ||
27 | <include name="../../bin/libsecondlife.dll" /> | ||
28 | </references> | ||
29 | </csc> | ||
30 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
31 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
32 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
33 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
34 | <include name="*.dll"/> | ||
35 | <include name="*.exe"/> | ||
36 | </fileset> | ||
37 | </copy> | ||
38 | </target> | ||
39 | <target name="clean"> | ||
40 | <delete dir="${bin.dir}" failonerror="false" /> | ||
41 | <delete dir="${obj.dir}" failonerror="false" /> | ||
42 | </target> | ||
43 | <target name="doc" description="Creates documentation."> | ||
44 | </target> | ||
45 | </project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MSSQL/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bbe3cdf --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MSSQL/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenGrid.Framework.Data.MSSQL")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenGrid.Framework.Data.MSSQL")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs new file mode 100644 index 0000000..6ac8cc3 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLGridData.cs | |||
@@ -0,0 +1,201 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | |||
6 | namespace OpenGrid.Framework.Data.MySQL | ||
7 | { | ||
8 | public class MySQLGridData : IGridData | ||
9 | { | ||
10 | private MySQLManager database; | ||
11 | |||
12 | /// <summary> | ||
13 | /// Initialises the Grid Interface | ||
14 | /// </summary> | ||
15 | public void Initialise() | ||
16 | { | ||
17 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | ||
18 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | ||
19 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | ||
20 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | ||
21 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | ||
22 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | ||
23 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | ||
24 | |||
25 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | ||
26 | } | ||
27 | |||
28 | /// <summary> | ||
29 | /// Shuts down the grid interface | ||
30 | /// </summary> | ||
31 | public void Close() | ||
32 | { | ||
33 | database.Close(); | ||
34 | } | ||
35 | |||
36 | public string getName() | ||
37 | { | ||
38 | return "MySql OpenGridData"; | ||
39 | } | ||
40 | |||
41 | public string getVersion() | ||
42 | { | ||
43 | return "0.1"; | ||
44 | } | ||
45 | |||
46 | public SimProfileData[] GetProfilesInRange(uint xmin, uint ymin, uint xmax, uint ymax) | ||
47 | { | ||
48 | try | ||
49 | { | ||
50 | lock (database) | ||
51 | { | ||
52 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
53 | param["?xmin"] = xmin.ToString(); | ||
54 | param["?ymin"] = ymin.ToString(); | ||
55 | param["?xmax"] = xmax.ToString(); | ||
56 | param["?ymax"] = ymax.ToString(); | ||
57 | |||
58 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax", param); | ||
59 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
60 | |||
61 | SimProfileData row; | ||
62 | |||
63 | List<SimProfileData> rows = new List<SimProfileData>(); | ||
64 | |||
65 | while ((row = database.getSimRow(reader)) != null) | ||
66 | { | ||
67 | rows.Add(row); | ||
68 | } | ||
69 | reader.Close(); | ||
70 | result.Dispose(); | ||
71 | |||
72 | return rows.ToArray(); | ||
73 | |||
74 | } | ||
75 | } | ||
76 | catch (Exception e) | ||
77 | { | ||
78 | Console.WriteLine(e.ToString()); | ||
79 | return null; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Returns a sim profile from it's location | ||
85 | /// </summary> | ||
86 | /// <param name="handle">Region location handle</param> | ||
87 | /// <returns>Sim profile</returns> | ||
88 | public SimProfileData GetProfileByHandle(ulong handle) | ||
89 | { | ||
90 | try | ||
91 | { | ||
92 | lock (database) | ||
93 | { | ||
94 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
95 | param["?handle"] = handle.ToString(); | ||
96 | |||
97 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param); | ||
98 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
99 | |||
100 | SimProfileData row = database.getSimRow(reader); | ||
101 | reader.Close(); | ||
102 | result.Dispose(); | ||
103 | |||
104 | return row; | ||
105 | } | ||
106 | } | ||
107 | catch (Exception e) | ||
108 | { | ||
109 | Console.WriteLine(e.ToString()); | ||
110 | return null; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// Returns a sim profile from it's UUID | ||
116 | /// </summary> | ||
117 | /// <param name="uuid">The region UUID</param> | ||
118 | /// <returns>The sim profile</returns> | ||
119 | public SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID uuid) | ||
120 | { | ||
121 | try | ||
122 | { | ||
123 | lock (database) | ||
124 | { | ||
125 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
126 | param["?uuid"] = uuid.ToStringHyphenated(); | ||
127 | |||
128 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = ?uuid", param); | ||
129 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
130 | |||
131 | SimProfileData row = database.getSimRow(reader); | ||
132 | reader.Close(); | ||
133 | result.Dispose(); | ||
134 | |||
135 | return row; | ||
136 | } | ||
137 | } | ||
138 | catch (Exception e) | ||
139 | { | ||
140 | Console.WriteLine(e.ToString()); | ||
141 | return null; | ||
142 | } | ||
143 | } | ||
144 | |||
145 | public DataResponse AddProfile(SimProfileData profile) | ||
146 | { | ||
147 | lock (database) | ||
148 | { | ||
149 | if (database.insertRow(profile)) | ||
150 | { | ||
151 | return DataResponse.RESPONSE_OK; | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | return DataResponse.RESPONSE_ERROR; | ||
156 | } | ||
157 | } | ||
158 | } | ||
159 | |||
160 | /// <summary> | ||
161 | /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret. | ||
162 | /// </summary> | ||
163 | /// <param name="uuid">The UUID of the challenger</param> | ||
164 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
165 | /// <param name="authkey">The secret</param> | ||
166 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
167 | public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authkey) | ||
168 | { | ||
169 | bool throwHissyFit = false; // Should be true by 1.0 | ||
170 | |||
171 | if (throwHissyFit) | ||
172 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
173 | |||
174 | SimProfileData data = GetProfileByLLUUID(uuid); | ||
175 | |||
176 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
177 | } | ||
178 | |||
179 | /// <summary> | ||
180 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
181 | /// </summary> | ||
182 | /// <remarks>This requires a security audit.</remarks> | ||
183 | /// <param name="uuid"></param> | ||
184 | /// <param name="handle"></param> | ||
185 | /// <param name="authhash"></param> | ||
186 | /// <param name="challenge"></param> | ||
187 | /// <returns></returns> | ||
188 | public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authhash, string challenge) | ||
189 | { | ||
190 | System.Security.Cryptography.SHA512Managed HashProvider = new System.Security.Cryptography.SHA512Managed(); | ||
191 | System.Text.ASCIIEncoding TextProvider = new ASCIIEncoding(); | ||
192 | |||
193 | byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge); | ||
194 | byte[] hash = HashProvider.ComputeHash(stream); | ||
195 | |||
196 | return false; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | |||
201 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs new file mode 100644 index 0000000..ea7e2ac --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLManager.cs | |||
@@ -0,0 +1,270 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Data; | ||
5 | |||
6 | // MySQL Native | ||
7 | using MySql; | ||
8 | using MySql.Data; | ||
9 | using MySql.Data.Types; | ||
10 | using MySql.Data.MySqlClient; | ||
11 | |||
12 | using OpenGrid.Framework.Data; | ||
13 | |||
14 | namespace OpenGrid.Framework.Data.MySQL | ||
15 | { | ||
16 | class MySQLManager | ||
17 | { | ||
18 | IDbConnection dbcon; | ||
19 | |||
20 | /// <summary> | ||
21 | /// Initialises and creates a new MySQL connection and maintains it. | ||
22 | /// </summary> | ||
23 | /// <param name="hostname">The MySQL server being connected to</param> | ||
24 | /// <param name="database">The name of the MySQL database being used</param> | ||
25 | /// <param name="username">The username logging into the database</param> | ||
26 | /// <param name="password">The password for the user logging in</param> | ||
27 | /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> | ||
28 | public MySQLManager(string hostname, string database, string username, string password, string cpooling, string port) | ||
29 | { | ||
30 | try | ||
31 | { | ||
32 | string connectionString = "Server=" + hostname + ";Port=" + port + ";Database=" + database + ";User ID=" + username + ";Password=" + password + ";Pooling=" + cpooling + ";"; | ||
33 | dbcon = new MySqlConnection(connectionString); | ||
34 | |||
35 | dbcon.Open(); | ||
36 | } | ||
37 | catch (Exception e) | ||
38 | { | ||
39 | throw new Exception("Error initialising MySql Database: " + e.ToString()); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | /// <summary> | ||
44 | /// Shuts down the database connection | ||
45 | /// </summary> | ||
46 | public void Close() | ||
47 | { | ||
48 | dbcon.Close(); | ||
49 | dbcon = null; | ||
50 | } | ||
51 | |||
52 | /// <summary> | ||
53 | /// Runs a query with protection against SQL Injection by using parameterised input. | ||
54 | /// </summary> | ||
55 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | ||
56 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> | ||
57 | /// <returns>A MySQL DB Command</returns> | ||
58 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) | ||
59 | { | ||
60 | try | ||
61 | { | ||
62 | MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand(); | ||
63 | dbcommand.CommandText = sql; | ||
64 | foreach (KeyValuePair<string, string> param in parameters) | ||
65 | { | ||
66 | dbcommand.Parameters.Add(param.Key, param.Value); | ||
67 | } | ||
68 | |||
69 | return (IDbCommand)dbcommand; | ||
70 | } | ||
71 | catch (Exception e) | ||
72 | { | ||
73 | Console.WriteLine("Failed during Query generation: " + e.ToString()); | ||
74 | return null; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public SimProfileData getSimRow(IDataReader reader) | ||
79 | { | ||
80 | SimProfileData retval = new SimProfileData(); | ||
81 | |||
82 | if (reader.Read()) | ||
83 | { | ||
84 | // Region Main | ||
85 | retval.regionHandle = Convert.ToUInt64(reader["regionHandle"].ToString()); | ||
86 | retval.regionName = (string)reader["regionName"]; | ||
87 | retval.UUID = new libsecondlife.LLUUID((string)reader["uuid"]); | ||
88 | |||
89 | // Secrets | ||
90 | retval.regionRecvKey = (string)reader["regionRecvKey"]; | ||
91 | retval.regionSecret = (string)reader["regionSecret"]; | ||
92 | retval.regionSendKey = (string)reader["regionSendKey"]; | ||
93 | |||
94 | // Region Server | ||
95 | retval.regionDataURI = (string)reader["regionDataURI"]; | ||
96 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
97 | retval.serverIP = (string)reader["serverIP"]; | ||
98 | retval.serverPort = (uint)reader["serverPort"]; | ||
99 | retval.serverURI = (string)reader["serverURI"]; | ||
100 | |||
101 | // Location | ||
102 | retval.regionLocX = Convert.ToUInt32(reader["locX"].ToString()); | ||
103 | retval.regionLocY = Convert.ToUInt32(reader["locY"].ToString()); | ||
104 | retval.regionLocZ = Convert.ToUInt32(reader["locZ"].ToString()); | ||
105 | |||
106 | // Neighbours - 0 = No Override | ||
107 | retval.regionEastOverrideHandle = Convert.ToUInt64(reader["eastOverrideHandle"].ToString()); | ||
108 | retval.regionWestOverrideHandle = Convert.ToUInt64(reader["westOverrideHandle"].ToString()); | ||
109 | retval.regionSouthOverrideHandle = Convert.ToUInt64(reader["southOverrideHandle"].ToString()); | ||
110 | retval.regionNorthOverrideHandle = Convert.ToUInt64(reader["northOverrideHandle"].ToString()); | ||
111 | |||
112 | // Assets | ||
113 | retval.regionAssetURI = (string)reader["regionAssetURI"]; | ||
114 | retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; | ||
115 | retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; | ||
116 | |||
117 | // Userserver | ||
118 | retval.regionUserURI = (string)reader["regionUserURI"]; | ||
119 | retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; | ||
120 | retval.regionUserSendKey = (string)reader["regionUserSendKey"]; | ||
121 | |||
122 | // World Map Addition | ||
123 | retval.regionMapTextureID = new libsecondlife.LLUUID((string)reader["regionMapTexture"]); | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | return null; | ||
128 | } | ||
129 | return retval; | ||
130 | } | ||
131 | |||
132 | public UserAgentData getAgentRow(IDataReader reader) | ||
133 | { | ||
134 | UserAgentData retval = new UserAgentData(); | ||
135 | |||
136 | if (reader.Read()) | ||
137 | { | ||
138 | // Agent IDs | ||
139 | retval.UUID = new libsecondlife.LLUUID((string)reader["UUID"]); | ||
140 | retval.sessionID = new libsecondlife.LLUUID((string)reader["sessionID"]); | ||
141 | retval.secureSessionID = new libsecondlife.LLUUID((string)reader["secureSessionID"]); | ||
142 | |||
143 | // Agent Who? | ||
144 | retval.agentIP = (string)reader["agentIP"]; | ||
145 | retval.agentPort = Convert.ToUInt32(reader["agentPort"].ToString()); | ||
146 | retval.agentOnline = Convert.ToBoolean(reader["agentOnline"].ToString()); | ||
147 | |||
148 | // Login/Logout times (UNIX Epoch) | ||
149 | retval.loginTime = Convert.ToInt32(reader["loginTime"].ToString()); | ||
150 | retval.logoutTime = Convert.ToInt32(reader["logoutTime"].ToString()); | ||
151 | |||
152 | // Current position | ||
153 | retval.currentRegion = (string)reader["currentRegion"]; | ||
154 | retval.currentHandle = Convert.ToUInt64(reader["currentHandle"].ToString()); | ||
155 | libsecondlife.LLVector3.TryParse((string)reader["currentPos"], out retval.currentPos); | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | return null; | ||
160 | } | ||
161 | return retval; | ||
162 | } | ||
163 | |||
164 | public UserProfileData getUserRow(IDataReader reader) | ||
165 | { | ||
166 | UserProfileData retval = new UserProfileData(); | ||
167 | |||
168 | if (reader.Read()) | ||
169 | { | ||
170 | retval.UUID = new libsecondlife.LLUUID((string)reader["UUID"]); | ||
171 | retval.username = (string)reader["username"]; | ||
172 | retval.surname = (string)reader["lastname"]; | ||
173 | |||
174 | retval.passwordHash = (string)reader["passwordHash"]; | ||
175 | retval.passwordSalt = (string)reader["passwordSalt"]; | ||
176 | |||
177 | retval.homeRegion = Convert.ToUInt64(reader["homeRegion"].ToString()); | ||
178 | retval.homeLocation = new libsecondlife.LLVector3( | ||
179 | Convert.ToSingle(reader["homeLocationX"].ToString()), | ||
180 | Convert.ToSingle(reader["homeLocationY"].ToString()), | ||
181 | Convert.ToSingle(reader["homeLocationZ"].ToString())); | ||
182 | retval.homeLookAt = new libsecondlife.LLVector3( | ||
183 | Convert.ToSingle(reader["homeLookAtX"].ToString()), | ||
184 | Convert.ToSingle(reader["homeLookAtY"].ToString()), | ||
185 | Convert.ToSingle(reader["homeLookAtZ"].ToString())); | ||
186 | |||
187 | retval.created = Convert.ToInt32(reader["created"].ToString()); | ||
188 | retval.lastLogin = Convert.ToInt32(reader["lastLogin"].ToString()); | ||
189 | |||
190 | retval.userInventoryURI = (string)reader["userInventoryURI"]; | ||
191 | retval.userAssetURI = (string)reader["userAssetURI"]; | ||
192 | |||
193 | retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); | ||
194 | retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); | ||
195 | |||
196 | retval.profileAboutText = (string)reader["profileAboutText"]; | ||
197 | retval.profileFirstText = (string)reader["profileFirstText"]; | ||
198 | |||
199 | retval.profileImage = new libsecondlife.LLUUID((string)reader["profileImage"]); | ||
200 | retval.profileFirstImage = new libsecondlife.LLUUID((string)reader["profileFirstImage"]); | ||
201 | |||
202 | } | ||
203 | else | ||
204 | { | ||
205 | return null; | ||
206 | } | ||
207 | return retval; | ||
208 | } | ||
209 | |||
210 | public bool insertRow(SimProfileData profile) | ||
211 | { | ||
212 | string sql = "REPLACE INTO regions (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | ||
213 | sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | ||
214 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey, regionMapTexture) VALUES "; | ||
215 | |||
216 | sql += "(?regionHandle, ?regionName, ?uuid, ?regionRecvKey, ?regionSecret, ?regionSendKey, ?regionDataURI, "; | ||
217 | sql += "?serverIP, ?serverPort, ?serverURI, ?locX, ?locY, ?locZ, ?eastOverrideHandle, ?westOverrideHandle, ?southOverrideHandle, ?northOverrideHandle, ?regionAssetURI, ?regionAssetRecvKey, "; | ||
218 | sql += "?regionAssetSendKey, ?regionUserURI, ?regionUserRecvKey, ?regionUserSendKey, ?regionMapTexture);"; | ||
219 | |||
220 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
221 | |||
222 | parameters["?regionHandle"] = profile.regionHandle.ToString(); | ||
223 | parameters["?regionName"] = profile.regionName.ToString(); | ||
224 | parameters["?uuid"] = profile.UUID.ToStringHyphenated(); | ||
225 | parameters["?regionRecvKey"] = profile.regionRecvKey.ToString(); | ||
226 | parameters["?regionSecret"] = profile.regionSecret.ToString(); | ||
227 | parameters["?regionSendKey"] = profile.regionSendKey.ToString(); | ||
228 | parameters["?regionDataURI"] = profile.regionDataURI.ToString(); | ||
229 | parameters["?serverIP"] = profile.serverIP.ToString(); | ||
230 | parameters["?serverPort"] = profile.serverPort.ToString(); | ||
231 | parameters["?serverURI"] = profile.serverURI.ToString(); | ||
232 | parameters["?locX"] = profile.regionLocX.ToString(); | ||
233 | parameters["?locY"] = profile.regionLocY.ToString(); | ||
234 | parameters["?locZ"] = profile.regionLocZ.ToString(); | ||
235 | parameters["?eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString(); | ||
236 | parameters["?westOverrideHandle"] = profile.regionWestOverrideHandle.ToString(); | ||
237 | parameters["?northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString(); | ||
238 | parameters["?southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString(); | ||
239 | parameters["?regionAssetURI"] = profile.regionAssetURI.ToString(); | ||
240 | parameters["?regionAssetRecvKey"] = profile.regionAssetRecvKey.ToString(); | ||
241 | parameters["?regionAssetSendKey"] = profile.regionAssetSendKey.ToString(); | ||
242 | parameters["?regionUserURI"] = profile.regionUserURI.ToString(); | ||
243 | parameters["?regionUserRecvKey"] = profile.regionUserRecvKey.ToString(); | ||
244 | parameters["?regionUserSendKey"] = profile.regionUserSendKey.ToString(); | ||
245 | parameters["?regionMapTexture"] = profile.regionMapTextureID.ToStringHyphenated(); | ||
246 | |||
247 | bool returnval = false; | ||
248 | |||
249 | try | ||
250 | { | ||
251 | |||
252 | IDbCommand result = Query(sql, parameters); | ||
253 | |||
254 | //Console.WriteLine(result.CommandText); | ||
255 | |||
256 | if (result.ExecuteNonQuery() == 1) | ||
257 | returnval = true; | ||
258 | |||
259 | result.Dispose(); | ||
260 | } | ||
261 | catch (Exception e) | ||
262 | { | ||
263 | Console.WriteLine(e.ToString()); | ||
264 | return false; | ||
265 | } | ||
266 | |||
267 | return returnval; | ||
268 | } | ||
269 | } | ||
270 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs new file mode 100644 index 0000000..57dbfc6 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/MySQLUserData.cs | |||
@@ -0,0 +1,153 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | using libsecondlife; | ||
6 | |||
7 | namespace OpenGrid.Framework.Data.MySQL | ||
8 | { | ||
9 | class MySQLUserData : IUserData | ||
10 | { | ||
11 | public MySQLManager database; | ||
12 | |||
13 | public void Initialise() | ||
14 | { | ||
15 | IniFile GridDataMySqlFile = new IniFile("mysql_connection.ini"); | ||
16 | string settingHostname = GridDataMySqlFile.ParseFileReadValue("hostname"); | ||
17 | string settingDatabase = GridDataMySqlFile.ParseFileReadValue("database"); | ||
18 | string settingUsername = GridDataMySqlFile.ParseFileReadValue("username"); | ||
19 | string settingPassword = GridDataMySqlFile.ParseFileReadValue("password"); | ||
20 | string settingPooling = GridDataMySqlFile.ParseFileReadValue("pooling"); | ||
21 | string settingPort = GridDataMySqlFile.ParseFileReadValue("port"); | ||
22 | |||
23 | database = new MySQLManager(settingHostname, settingDatabase, settingUsername, settingPassword, settingPooling, settingPort); | ||
24 | } | ||
25 | |||
26 | public UserProfileData getUserByName(string name) | ||
27 | { | ||
28 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
29 | } | ||
30 | |||
31 | public UserProfileData getUserByName(string user, string last) | ||
32 | { | ||
33 | try | ||
34 | { | ||
35 | lock (database) | ||
36 | { | ||
37 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
38 | param["?first"] = user; | ||
39 | param["?second"] = last; | ||
40 | |||
41 | System.Data.IDbCommand result = database.Query("SELECT * FROM users WHERE username = ?first AND lastname = ?second", param); | ||
42 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
43 | |||
44 | UserProfileData row = database.getUserRow(reader); | ||
45 | |||
46 | reader.Close(); | ||
47 | result.Dispose(); | ||
48 | |||
49 | return row; | ||
50 | } | ||
51 | } | ||
52 | catch (Exception e) | ||
53 | { | ||
54 | Console.WriteLine(e.ToString()); | ||
55 | return null; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | public UserProfileData getUserByUUID(LLUUID uuid) | ||
60 | { | ||
61 | try | ||
62 | { | ||
63 | lock (database) | ||
64 | { | ||
65 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
66 | param["?uuid"] = uuid.ToStringHyphenated(); | ||
67 | |||
68 | System.Data.IDbCommand result = database.Query("SELECT * FROM users WHERE UUID = ?uuid", param); | ||
69 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
70 | |||
71 | UserProfileData row = database.getUserRow(reader); | ||
72 | |||
73 | reader.Close(); | ||
74 | result.Dispose(); | ||
75 | |||
76 | return row; | ||
77 | } | ||
78 | } | ||
79 | catch (Exception e) | ||
80 | { | ||
81 | Console.WriteLine(e.ToString()); | ||
82 | return null; | ||
83 | } | ||
84 | } | ||
85 | |||
86 | public UserAgentData getAgentByName(string name) | ||
87 | { | ||
88 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
89 | } | ||
90 | |||
91 | public UserAgentData getAgentByName(string user, string last) | ||
92 | { | ||
93 | UserProfileData profile = getUserByName(user, last); | ||
94 | return getAgentByUUID(profile.UUID); | ||
95 | } | ||
96 | |||
97 | public UserAgentData getAgentByUUID(LLUUID uuid) | ||
98 | { | ||
99 | try | ||
100 | { | ||
101 | lock (database) | ||
102 | { | ||
103 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
104 | param["?uuid"] = uuid.ToStringHyphenated(); | ||
105 | |||
106 | System.Data.IDbCommand result = database.Query("SELECT * FROM agents WHERE UUID = ?uuid", param); | ||
107 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
108 | |||
109 | UserAgentData row = database.getAgentRow(reader); | ||
110 | |||
111 | reader.Close(); | ||
112 | result.Dispose(); | ||
113 | |||
114 | return row; | ||
115 | } | ||
116 | } | ||
117 | catch (Exception e) | ||
118 | { | ||
119 | Console.WriteLine(e.ToString()); | ||
120 | return null; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | public void addNewUserProfile(UserProfileData user) | ||
125 | { | ||
126 | } | ||
127 | |||
128 | public void addNewUserAgent(UserAgentData agent) | ||
129 | { | ||
130 | // Do nothing. | ||
131 | } | ||
132 | |||
133 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | ||
134 | { | ||
135 | return false; | ||
136 | } | ||
137 | |||
138 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | ||
139 | { | ||
140 | return false; | ||
141 | } | ||
142 | |||
143 | public string getName() | ||
144 | { | ||
145 | return "MySQL Userdata Interface"; | ||
146 | } | ||
147 | |||
148 | public string getVersion() | ||
149 | { | ||
150 | return "0.1"; | ||
151 | } | ||
152 | } | ||
153 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj b/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj new file mode 100644 index 0000000..9a1703a --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj | |||
@@ -0,0 +1,111 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{0F3C3AC1-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenGrid.Framework.Data.MySQL</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenGrid.Framework.Data.MySQL</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System.Data" > | ||
70 | <HintPath>System.Data.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="libsecondlife.dll" > | ||
74 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | <Reference Include="MySql.Data.dll" > | ||
78 | <HintPath>..\..\bin\MySql.Data.dll</HintPath> | ||
79 | <Private>False</Private> | ||
80 | </Reference> | ||
81 | </ItemGroup> | ||
82 | <ItemGroup> | ||
83 | <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj"> | ||
84 | <Name>OpenGrid.Framework.Data</Name> | ||
85 | <Project>{62CDF671-0000-0000-0000-000000000000}</Project> | ||
86 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
87 | <Private>False</Private> | ||
88 | </ProjectReference> | ||
89 | </ItemGroup> | ||
90 | <ItemGroup> | ||
91 | <Compile Include="MySQLGridData.cs"> | ||
92 | <SubType>Code</SubType> | ||
93 | </Compile> | ||
94 | <Compile Include="MySQLManager.cs"> | ||
95 | <SubType>Code</SubType> | ||
96 | </Compile> | ||
97 | <Compile Include="MySQLUserData.cs"> | ||
98 | <SubType>Code</SubType> | ||
99 | </Compile> | ||
100 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
101 | <SubType>Code</SubType> | ||
102 | </Compile> | ||
103 | </ItemGroup> | ||
104 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
105 | <PropertyGroup> | ||
106 | <PreBuildEvent> | ||
107 | </PreBuildEvent> | ||
108 | <PostBuildEvent> | ||
109 | </PostBuildEvent> | ||
110 | </PropertyGroup> | ||
111 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj.user b/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.dll.build b/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.dll.build new file mode 100644 index 0000000..2d425b4 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/OpenGrid.Framework.Data.MySQL.dll.build | |||
@@ -0,0 +1,47 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenGrid.Framework.Data.MySQL" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenGrid.Framework.Data.MySQL" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="MySQLGridData.cs" /> | ||
15 | <include name="MySQLManager.cs" /> | ||
16 | <include name="MySQLUserData.cs" /> | ||
17 | <include name="Properties/AssemblyInfo.cs" /> | ||
18 | </sources> | ||
19 | <references basedir="${project::get-base-directory()}"> | ||
20 | <lib> | ||
21 | <include name="${project::get-base-directory()}" /> | ||
22 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
23 | </lib> | ||
24 | <include name="System.dll" /> | ||
25 | <include name="System.Xml.dll" /> | ||
26 | <include name="System.Data.dll" /> | ||
27 | <include name="../../bin/OpenGrid.Framework.Data.dll" /> | ||
28 | <include name="../../bin/libsecondlife.dll" /> | ||
29 | <include name="../../bin/MySql.Data.dll" /> | ||
30 | </references> | ||
31 | </csc> | ||
32 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
33 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
34 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
35 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
36 | <include name="*.dll"/> | ||
37 | <include name="*.exe"/> | ||
38 | </fileset> | ||
39 | </copy> | ||
40 | </target> | ||
41 | <target name="clean"> | ||
42 | <delete dir="${bin.dir}" failonerror="false" /> | ||
43 | <delete dir="${obj.dir}" failonerror="false" /> | ||
44 | </target> | ||
45 | <target name="doc" description="Creates documentation."> | ||
46 | </target> | ||
47 | </project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0bfd1d6 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.MySQL/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenGrid.Framework.Data.MySQL")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenGrid.Framework.Data.MySQL")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("e49826b2-dcef-41be-a5bd-596733fa3304")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.csproj b/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.csproj new file mode 100644 index 0000000..463cf86 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.csproj | |||
@@ -0,0 +1,108 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{1E3F341A-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenGrid.Framework.Data.SQLite</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenGrid.Framework.Data.SQLite</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System.Data" > | ||
70 | <HintPath>System.Data.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="System.Data.SQLite.dll" > | ||
74 | <HintPath>..\..\bin\System.Data.SQLite.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | <Reference Include="libsecondlife.dll" > | ||
78 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
79 | <Private>False</Private> | ||
80 | </Reference> | ||
81 | </ItemGroup> | ||
82 | <ItemGroup> | ||
83 | <ProjectReference Include="..\OpenGrid.Framework.Data\OpenGrid.Framework.Data.csproj"> | ||
84 | <Name>OpenGrid.Framework.Data</Name> | ||
85 | <Project>{62CDF671-0000-0000-0000-000000000000}</Project> | ||
86 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
87 | <Private>False</Private> | ||
88 | </ProjectReference> | ||
89 | </ItemGroup> | ||
90 | <ItemGroup> | ||
91 | <Compile Include="SQLiteGridData.cs"> | ||
92 | <SubType>Code</SubType> | ||
93 | </Compile> | ||
94 | <Compile Include="SQLiteManager.cs"> | ||
95 | <SubType>Code</SubType> | ||
96 | </Compile> | ||
97 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
98 | <SubType>Code</SubType> | ||
99 | </Compile> | ||
100 | </ItemGroup> | ||
101 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
102 | <PropertyGroup> | ||
103 | <PreBuildEvent> | ||
104 | </PreBuildEvent> | ||
105 | <PostBuildEvent> | ||
106 | </PostBuildEvent> | ||
107 | </PropertyGroup> | ||
108 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.csproj.user b/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.dll.build b/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.dll.build new file mode 100644 index 0000000..1be9b43 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.SQLite/OpenGrid.Framework.Data.SQLite.dll.build | |||
@@ -0,0 +1,46 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenGrid.Framework.Data.SQLite" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenGrid.Framework.Data.SQLite" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="SQLiteGridData.cs" /> | ||
15 | <include name="SQLiteManager.cs" /> | ||
16 | <include name="Properties/AssemblyInfo.cs" /> | ||
17 | </sources> | ||
18 | <references basedir="${project::get-base-directory()}"> | ||
19 | <lib> | ||
20 | <include name="${project::get-base-directory()}" /> | ||
21 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
22 | </lib> | ||
23 | <include name="System.dll" /> | ||
24 | <include name="System.Xml.dll" /> | ||
25 | <include name="System.Data.dll" /> | ||
26 | <include name="../../bin/System.Data.SQLite.dll" /> | ||
27 | <include name="../../bin/OpenGrid.Framework.Data.dll" /> | ||
28 | <include name="../../bin/libsecondlife.dll" /> | ||
29 | </references> | ||
30 | </csc> | ||
31 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
32 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
33 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
34 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
35 | <include name="*.dll"/> | ||
36 | <include name="*.exe"/> | ||
37 | </fileset> | ||
38 | </copy> | ||
39 | </target> | ||
40 | <target name="clean"> | ||
41 | <delete dir="${bin.dir}" failonerror="false" /> | ||
42 | <delete dir="${obj.dir}" failonerror="false" /> | ||
43 | </target> | ||
44 | <target name="doc" description="Creates documentation."> | ||
45 | </target> | ||
46 | </project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.SQLite/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGrid.Framework.Data.SQLite/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..57c4bae --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.SQLite/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenGrid.Framework.Data.SQLite")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenGrid.Framework.Data.SQLite")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("6113d5ce-4547-49f4-9236-0dcc503457b1")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.SQLite/SQLiteGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.SQLite/SQLiteGridData.cs new file mode 100644 index 0000000..4850f12 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.SQLite/SQLiteGridData.cs | |||
@@ -0,0 +1,136 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | |||
6 | namespace OpenGrid.Framework.Data.SQLite | ||
7 | { | ||
8 | public class SQLiteGridData : IGridData | ||
9 | { | ||
10 | private SQLiteManager database; | ||
11 | |||
12 | /// <summary> | ||
13 | /// Initialises the Grid Interface | ||
14 | /// </summary> | ||
15 | public void Initialise() | ||
16 | { | ||
17 | database = new SQLiteManager("localhost", "db", "user", "password", "false"); | ||
18 | } | ||
19 | |||
20 | /// <summary> | ||
21 | /// Shuts down the grid interface | ||
22 | /// </summary> | ||
23 | public void Close() | ||
24 | { | ||
25 | database.Close(); | ||
26 | } | ||
27 | |||
28 | public string getName() | ||
29 | { | ||
30 | return "SQLite OpenGridData"; | ||
31 | } | ||
32 | |||
33 | public string getVersion() | ||
34 | { | ||
35 | return "0.1"; | ||
36 | } | ||
37 | |||
38 | public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) | ||
39 | { | ||
40 | return null; | ||
41 | } | ||
42 | |||
43 | /// <summary> | ||
44 | /// Returns a sim profile from it's location | ||
45 | /// </summary> | ||
46 | /// <param name="handle">Region location handle</param> | ||
47 | /// <returns>Sim profile</returns> | ||
48 | public SimProfileData GetProfileByHandle(ulong handle) | ||
49 | { | ||
50 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
51 | param["handle"] = handle.ToString(); | ||
52 | |||
53 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE handle = @handle", param); | ||
54 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
55 | |||
56 | SimProfileData row = database.getRow(reader); | ||
57 | reader.Close(); | ||
58 | result.Dispose(); | ||
59 | |||
60 | return row; | ||
61 | } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Returns a sim profile from it's UUID | ||
65 | /// </summary> | ||
66 | /// <param name="uuid">The region UUID</param> | ||
67 | /// <returns>The sim profile</returns> | ||
68 | public SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID uuid) | ||
69 | { | ||
70 | Dictionary<string, string> param = new Dictionary<string, string>(); | ||
71 | param["uuid"] = uuid.ToStringHyphenated(); | ||
72 | |||
73 | System.Data.IDbCommand result = database.Query("SELECT * FROM regions WHERE uuid = @uuid", param); | ||
74 | System.Data.IDataReader reader = result.ExecuteReader(); | ||
75 | |||
76 | SimProfileData row = database.getRow(reader); | ||
77 | reader.Close(); | ||
78 | result.Dispose(); | ||
79 | |||
80 | return row; | ||
81 | } | ||
82 | |||
83 | public DataResponse AddProfile(SimProfileData profile) | ||
84 | { | ||
85 | if (database.insertRow(profile)) | ||
86 | { | ||
87 | return DataResponse.RESPONSE_OK; | ||
88 | } | ||
89 | else | ||
90 | { | ||
91 | return DataResponse.RESPONSE_ERROR; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// DEPRECIATED. Attempts to authenticate a region by comparing a shared secret. | ||
97 | /// </summary> | ||
98 | /// <param name="uuid">The UUID of the challenger</param> | ||
99 | /// <param name="handle">The attempted regionHandle of the challenger</param> | ||
100 | /// <param name="authkey">The secret</param> | ||
101 | /// <returns>Whether the secret and regionhandle match the database entry for UUID</returns> | ||
102 | public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authkey) | ||
103 | { | ||
104 | bool throwHissyFit = false; // Should be true by 1.0 | ||
105 | |||
106 | if (throwHissyFit) | ||
107 | throw new Exception("CRYPTOWEAK AUTHENTICATE: Refusing to authenticate due to replay potential."); | ||
108 | |||
109 | SimProfileData data = GetProfileByLLUUID(uuid); | ||
110 | |||
111 | return (handle == data.regionHandle && authkey == data.regionSecret); | ||
112 | } | ||
113 | |||
114 | /// <summary> | ||
115 | /// NOT YET FUNCTIONAL. Provides a cryptographic authentication of a region | ||
116 | /// </summary> | ||
117 | /// <remarks>This requires a security audit.</remarks> | ||
118 | /// <param name="uuid"></param> | ||
119 | /// <param name="handle"></param> | ||
120 | /// <param name="authhash"></param> | ||
121 | /// <param name="challenge"></param> | ||
122 | /// <returns></returns> | ||
123 | public bool AuthenticateSim(libsecondlife.LLUUID uuid, ulong handle, string authhash, string challenge) | ||
124 | { | ||
125 | System.Security.Cryptography.SHA512Managed HashProvider = new System.Security.Cryptography.SHA512Managed(); | ||
126 | System.Text.ASCIIEncoding TextProvider = new ASCIIEncoding(); | ||
127 | |||
128 | byte[] stream = TextProvider.GetBytes(uuid.ToStringHyphenated() + ":" + handle.ToString() + ":" + challenge); | ||
129 | byte[] hash = HashProvider.ComputeHash(stream); | ||
130 | |||
131 | return false; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | |||
136 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data.SQLite/SQLiteManager.cs b/OpenGridServices/OpenGrid.Framework.Data.SQLite/SQLiteManager.cs new file mode 100644 index 0000000..408a582 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data.SQLite/SQLiteManager.cs | |||
@@ -0,0 +1,172 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.Data; | ||
5 | |||
6 | using System.Data.SQLite; | ||
7 | |||
8 | using OpenGrid.Framework.Data; | ||
9 | |||
10 | namespace OpenGrid.Framework.Data.SQLite | ||
11 | { | ||
12 | class SQLiteManager | ||
13 | { | ||
14 | IDbConnection dbcon; | ||
15 | |||
16 | /// <summary> | ||
17 | /// Initialises and creates a new SQLite connection and maintains it. | ||
18 | /// </summary> | ||
19 | /// <param name="hostname">The SQLite server being connected to</param> | ||
20 | /// <param name="database">The name of the SQLite database being used</param> | ||
21 | /// <param name="username">The username logging into the database</param> | ||
22 | /// <param name="password">The password for the user logging in</param> | ||
23 | /// <param name="cpooling">Whether to use connection pooling or not, can be one of the following: 'yes', 'true', 'no' or 'false', if unsure use 'false'.</param> | ||
24 | public SQLiteManager(string hostname, string database, string username, string password, string cpooling) | ||
25 | { | ||
26 | try | ||
27 | { | ||
28 | string connectionString = "URI=file:GridServerSqlite.db;"; | ||
29 | dbcon = new SQLiteConnection(connectionString); | ||
30 | |||
31 | dbcon.Open(); | ||
32 | } | ||
33 | catch (Exception e) | ||
34 | { | ||
35 | throw new Exception("Error initialising SQLite Database: " + e.ToString()); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | /// <summary> | ||
40 | /// Shuts down the database connection | ||
41 | /// </summary> | ||
42 | public void Close() | ||
43 | { | ||
44 | dbcon.Close(); | ||
45 | dbcon = null; | ||
46 | } | ||
47 | |||
48 | /// <summary> | ||
49 | /// Runs a query with protection against SQL Injection by using parameterised input. | ||
50 | /// </summary> | ||
51 | /// <param name="sql">The SQL string - replace any variables such as WHERE x = "y" with WHERE x = @y</param> | ||
52 | /// <param name="parameters">The parameters - index so that @y is indexed as 'y'</param> | ||
53 | /// <returns>A SQLite DB Command</returns> | ||
54 | public IDbCommand Query(string sql, Dictionary<string, string> parameters) | ||
55 | { | ||
56 | SQLiteCommand dbcommand = (SQLiteCommand)dbcon.CreateCommand(); | ||
57 | dbcommand.CommandText = sql; | ||
58 | foreach (KeyValuePair<string, string> param in parameters) | ||
59 | { | ||
60 | SQLiteParameter paramx = new SQLiteParameter(param.Key,param.Value); | ||
61 | dbcommand.Parameters.Add(paramx); | ||
62 | } | ||
63 | |||
64 | return (IDbCommand)dbcommand; | ||
65 | } | ||
66 | |||
67 | public SimProfileData getRow(IDataReader reader) | ||
68 | { | ||
69 | SimProfileData retval = new SimProfileData(); | ||
70 | |||
71 | if (reader.Read()) | ||
72 | { | ||
73 | // Region Main | ||
74 | retval.regionHandle = (ulong)reader["regionHandle"]; | ||
75 | retval.regionName = (string)reader["regionName"]; | ||
76 | retval.UUID = new libsecondlife.LLUUID((string)reader["uuid"]); | ||
77 | |||
78 | // Secrets | ||
79 | retval.regionRecvKey = (string)reader["regionRecvKey"]; | ||
80 | retval.regionSecret = (string)reader["regionSecret"]; | ||
81 | retval.regionSendKey = (string)reader["regionSendKey"]; | ||
82 | |||
83 | // Region Server | ||
84 | retval.regionDataURI = (string)reader["regionDataURI"]; | ||
85 | retval.regionOnline = false; // Needs to be pinged before this can be set. | ||
86 | retval.serverIP = (string)reader["serverIP"]; | ||
87 | retval.serverPort = (uint)reader["serverPort"]; | ||
88 | retval.serverURI = (string)reader["serverURI"]; | ||
89 | |||
90 | // Location | ||
91 | retval.regionLocX = (uint)((int)reader["locX"]); | ||
92 | retval.regionLocY = (uint)((int)reader["locY"]); | ||
93 | retval.regionLocZ = (uint)((int)reader["locZ"]); | ||
94 | |||
95 | // Neighbours - 0 = No Override | ||
96 | retval.regionEastOverrideHandle = (ulong)reader["eastOverrideHandle"]; | ||
97 | retval.regionWestOverrideHandle = (ulong)reader["westOverrideHandle"]; | ||
98 | retval.regionSouthOverrideHandle = (ulong)reader["southOverrideHandle"]; | ||
99 | retval.regionNorthOverrideHandle = (ulong)reader["northOverrideHandle"]; | ||
100 | |||
101 | // Assets | ||
102 | retval.regionAssetURI = (string)reader["regionAssetURI"]; | ||
103 | retval.regionAssetRecvKey = (string)reader["regionAssetRecvKey"]; | ||
104 | retval.regionAssetSendKey = (string)reader["regionAssetSendKey"]; | ||
105 | |||
106 | // Userserver | ||
107 | retval.regionUserURI = (string)reader["regionUserURI"]; | ||
108 | retval.regionUserRecvKey = (string)reader["regionUserRecvKey"]; | ||
109 | retval.regionUserSendKey = (string)reader["regionUserSendKey"]; | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | throw new Exception("No rows to return"); | ||
114 | } | ||
115 | return retval; | ||
116 | } | ||
117 | |||
118 | public bool insertRow(SimProfileData profile) | ||
119 | { | ||
120 | string sql = "REPLACE INTO regions VALUES (regionHandle, regionName, uuid, regionRecvKey, regionSecret, regionSendKey, regionDataURI, "; | ||
121 | sql += "serverIP, serverPort, serverURI, locX, locY, locZ, eastOverrideHandle, westOverrideHandle, southOverrideHandle, northOverrideHandle, regionAssetURI, regionAssetRecvKey, "; | ||
122 | sql += "regionAssetSendKey, regionUserURI, regionUserRecvKey, regionUserSendKey) VALUES "; | ||
123 | |||
124 | sql += "(@regionHandle, @regionName, @uuid, @regionRecvKey, @regionSecret, @regionSendKey, @regionDataURI, "; | ||
125 | sql += "@serverIP, @serverPort, @serverURI, @locX, @locY, @locZ, @eastOverrideHandle, @westOverrideHandle, @southOverrideHandle, @northOverrideHandle, @regionAssetURI, @regionAssetRecvKey, "; | ||
126 | sql += "@regionAssetSendKey, @regionUserURI, @regionUserRecvKey, @regionUserSendKey);"; | ||
127 | |||
128 | Dictionary<string, string> parameters = new Dictionary<string, string>(); | ||
129 | |||
130 | parameters["regionHandle"] = profile.regionHandle.ToString(); | ||
131 | parameters["regionName"] = profile.regionName; | ||
132 | parameters["uuid"] = profile.UUID.ToString(); | ||
133 | parameters["regionRecvKey"] = profile.regionRecvKey; | ||
134 | parameters["regionSendKey"] = profile.regionSendKey; | ||
135 | parameters["regionDataURI"] = profile.regionDataURI; | ||
136 | parameters["serverIP"] = profile.serverIP; | ||
137 | parameters["serverPort"] = profile.serverPort.ToString(); | ||
138 | parameters["serverURI"] = profile.serverURI; | ||
139 | parameters["locX"] = profile.regionLocX.ToString(); | ||
140 | parameters["locY"] = profile.regionLocY.ToString(); | ||
141 | parameters["locZ"] = profile.regionLocZ.ToString(); | ||
142 | parameters["eastOverrideHandle"] = profile.regionEastOverrideHandle.ToString(); | ||
143 | parameters["westOverrideHandle"] = profile.regionWestOverrideHandle.ToString(); | ||
144 | parameters["northOverrideHandle"] = profile.regionNorthOverrideHandle.ToString(); | ||
145 | parameters["southOverrideHandle"] = profile.regionSouthOverrideHandle.ToString(); | ||
146 | parameters["regionAssetURI"] = profile.regionAssetURI; | ||
147 | parameters["regionAssetRecvKey"] = profile.regionAssetRecvKey; | ||
148 | parameters["regionAssetSendKey"] = profile.regionAssetSendKey; | ||
149 | parameters["regionUserURI"] = profile.regionUserURI; | ||
150 | parameters["regionUserRecvKey"] = profile.regionUserRecvKey; | ||
151 | parameters["regionUserSendKey"] = profile.regionUserSendKey; | ||
152 | |||
153 | bool returnval = false; | ||
154 | |||
155 | try | ||
156 | { | ||
157 | IDbCommand result = Query(sql, parameters); | ||
158 | |||
159 | if (result.ExecuteNonQuery() == 1) | ||
160 | returnval = true; | ||
161 | |||
162 | result.Dispose(); | ||
163 | } | ||
164 | catch (Exception e) | ||
165 | { | ||
166 | return false; | ||
167 | } | ||
168 | |||
169 | return returnval; | ||
170 | } | ||
171 | } | ||
172 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/GridData.cs b/OpenGridServices/OpenGrid.Framework.Data/GridData.cs new file mode 100644 index 0000000..6dad37e --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/GridData.cs | |||
@@ -0,0 +1,83 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenGrid.Framework.Data | ||
6 | { | ||
7 | public enum DataResponse | ||
8 | { | ||
9 | RESPONSE_OK, | ||
10 | RESPONSE_AUTHREQUIRED, | ||
11 | RESPONSE_INVALIDCREDENTIALS, | ||
12 | RESPONSE_ERROR | ||
13 | } | ||
14 | |||
15 | /// <summary> | ||
16 | /// A standard grid interface | ||
17 | /// </summary> | ||
18 | public interface IGridData | ||
19 | { | ||
20 | /// <summary> | ||
21 | /// Returns a sim profile from a regionHandle | ||
22 | /// </summary> | ||
23 | /// <param name="regionHandle">A 64bit Region Handle</param> | ||
24 | /// <returns>A simprofile</returns> | ||
25 | SimProfileData GetProfileByHandle(ulong regionHandle); | ||
26 | |||
27 | /// <summary> | ||
28 | /// Returns a sim profile from a UUID | ||
29 | /// </summary> | ||
30 | /// <param name="UUID">A 128bit UUID</param> | ||
31 | /// <returns>A sim profile</returns> | ||
32 | SimProfileData GetProfileByLLUUID(libsecondlife.LLUUID UUID); | ||
33 | |||
34 | /// <summary> | ||
35 | /// Returns all profiles within the specified range | ||
36 | /// </summary> | ||
37 | /// <param name="Xmin">Minimum sim coordinate (X)</param> | ||
38 | /// <param name="Ymin">Minimum sim coordinate (Y)</param> | ||
39 | /// <param name="Xmax">Maximum sim coordinate (X)</param> | ||
40 | /// <param name="Ymin">Maximum sim coordinate (Y)</param> | ||
41 | /// <returns>An array containing all the sim profiles in the specified range</returns> | ||
42 | SimProfileData[] GetProfilesInRange(uint Xmin, uint Ymin, uint Xmax, uint Ymax); | ||
43 | |||
44 | /// <summary> | ||
45 | /// Authenticates a sim by use of it's recv key. | ||
46 | /// WARNING: Insecure | ||
47 | /// </summary> | ||
48 | /// <param name="UUID">The UUID sent by the sim</param> | ||
49 | /// <param name="regionHandle">The regionhandle sent by the sim</param> | ||
50 | /// <param name="simrecvkey">The recieving key sent by the sim</param> | ||
51 | /// <returns>Whether the sim has been authenticated</returns> | ||
52 | bool AuthenticateSim(libsecondlife.LLUUID UUID, ulong regionHandle, string simrecvkey); | ||
53 | |||
54 | /// <summary> | ||
55 | /// Initialises the interface | ||
56 | /// </summary> | ||
57 | void Initialise(); | ||
58 | |||
59 | /// <summary> | ||
60 | /// Closes the interface | ||
61 | /// </summary> | ||
62 | void Close(); | ||
63 | |||
64 | /// <summary> | ||
65 | /// The plugin being loaded | ||
66 | /// </summary> | ||
67 | /// <returns>A string containing the plugin name</returns> | ||
68 | string getName(); | ||
69 | |||
70 | /// <summary> | ||
71 | /// The plugins version | ||
72 | /// </summary> | ||
73 | /// <returns>A string containing the plugin version</returns> | ||
74 | string getVersion(); | ||
75 | |||
76 | /// <summary> | ||
77 | /// Adds a new profile to the database | ||
78 | /// </summary> | ||
79 | /// <param name="profile">The profile to add</param> | ||
80 | /// <returns>RESPONSE_OK if successful, error if not.</returns> | ||
81 | DataResponse AddProfile(SimProfileData profile); | ||
82 | } | ||
83 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/IniConfig.cs b/OpenGridServices/OpenGrid.Framework.Data/IniConfig.cs new file mode 100644 index 0000000..58597d2 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/IniConfig.cs | |||
@@ -0,0 +1,73 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.IO; | ||
5 | using System.Text.RegularExpressions; | ||
6 | |||
7 | /* | ||
8 | Taken from public code listing at by Alex Pinsker | ||
9 | http://alexpinsker.blogspot.com/2005/12/reading-ini-file-from-c_113432097333021549.html | ||
10 | */ | ||
11 | |||
12 | namespace OpenGrid.Framework.Data | ||
13 | { | ||
14 | /// <summary> | ||
15 | /// Parse settings from ini-like files | ||
16 | /// </summary> | ||
17 | public class IniFile | ||
18 | { | ||
19 | static IniFile() | ||
20 | { | ||
21 | _iniKeyValuePatternRegex = new Regex( | ||
22 | @"((\s)*(?<Key>([^\=^\s^\n]+))[\s^\n]* | ||
23 | # key part (surrounding whitespace stripped) | ||
24 | \= | ||
25 | (\s)*(?<Value>([^\n^\s]+(\n){0,1}))) | ||
26 | # value part (surrounding whitespace stripped) | ||
27 | ", | ||
28 | RegexOptions.IgnorePatternWhitespace | | ||
29 | RegexOptions.Compiled | | ||
30 | RegexOptions.CultureInvariant); | ||
31 | } | ||
32 | static private Regex _iniKeyValuePatternRegex; | ||
33 | |||
34 | public IniFile(string iniFileName) | ||
35 | { | ||
36 | _iniFileName = iniFileName; | ||
37 | } | ||
38 | |||
39 | public string ParseFileReadValue(string key) | ||
40 | { | ||
41 | using (StreamReader reader = | ||
42 | new StreamReader(_iniFileName)) | ||
43 | { | ||
44 | do | ||
45 | { | ||
46 | string line = reader.ReadLine(); | ||
47 | Match match = | ||
48 | _iniKeyValuePatternRegex.Match(line); | ||
49 | if (match.Success) | ||
50 | { | ||
51 | string currentKey = | ||
52 | match.Groups["Key"].Value as string; | ||
53 | if (currentKey != null && | ||
54 | currentKey.Trim().CompareTo(key) == 0) | ||
55 | { | ||
56 | string value = | ||
57 | match.Groups["Value"].Value as string; | ||
58 | return value; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | } | ||
63 | while (reader.Peek() != -1); | ||
64 | } | ||
65 | return null; | ||
66 | } | ||
67 | |||
68 | public string IniFileName | ||
69 | { | ||
70 | get { return _iniFileName; } | ||
71 | } private string _iniFileName; | ||
72 | } | ||
73 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj b/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj new file mode 100644 index 0000000..b033c6c --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj | |||
@@ -0,0 +1,107 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{62CDF671-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenGrid.Framework.Data</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenGrid.Framework.Data</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="System.Data" > | ||
70 | <HintPath>System.Data.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | <Reference Include="libsecondlife.dll" > | ||
74 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
75 | <Private>False</Private> | ||
76 | </Reference> | ||
77 | </ItemGroup> | ||
78 | <ItemGroup> | ||
79 | </ItemGroup> | ||
80 | <ItemGroup> | ||
81 | <Compile Include="GridData.cs"> | ||
82 | <SubType>Code</SubType> | ||
83 | </Compile> | ||
84 | <Compile Include="IniConfig.cs"> | ||
85 | <SubType>Code</SubType> | ||
86 | </Compile> | ||
87 | <Compile Include="SimProfileData.cs"> | ||
88 | <SubType>Code</SubType> | ||
89 | </Compile> | ||
90 | <Compile Include="UserData.cs"> | ||
91 | <SubType>Code</SubType> | ||
92 | </Compile> | ||
93 | <Compile Include="UserProfileData.cs"> | ||
94 | <SubType>Code</SubType> | ||
95 | </Compile> | ||
96 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
97 | <SubType>Code</SubType> | ||
98 | </Compile> | ||
99 | </ItemGroup> | ||
100 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
101 | <PropertyGroup> | ||
102 | <PreBuildEvent> | ||
103 | </PreBuildEvent> | ||
104 | <PostBuildEvent> | ||
105 | </PostBuildEvent> | ||
106 | </PropertyGroup> | ||
107 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj.user b/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj.user new file mode 100644 index 0000000..d47d65d --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.csproj.user | |||
@@ -0,0 +1,12 @@ | |||
1 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
4 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
5 | <ReferencePath>C:\New Folder\second-life-viewer\opensim-dailys2\opensim15-07\bin\</ReferencePath> | ||
6 | <LastOpenVersion>8.0.50727</LastOpenVersion> | ||
7 | <ProjectView>ProjectFiles</ProjectView> | ||
8 | <ProjectTrust>0</ProjectTrust> | ||
9 | </PropertyGroup> | ||
10 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> | ||
11 | <PropertyGroup Condition = " '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> | ||
12 | </Project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.dll.build b/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.dll.build new file mode 100644 index 0000000..281295f --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/OpenGrid.Framework.Data.dll.build | |||
@@ -0,0 +1,47 @@ | |||
1 | <?xml version="1.0" ?> | ||
2 | <project name="OpenGrid.Framework.Data" default="build"> | ||
3 | <target name="build"> | ||
4 | <echo message="Build Directory is ${project::get-base-directory()}/${build.dir}" /> | ||
5 | <mkdir dir="${project::get-base-directory()}/${build.dir}" /> | ||
6 | <copy todir="${project::get-base-directory()}/${build.dir}"> | ||
7 | <fileset basedir="${project::get-base-directory()}"> | ||
8 | </fileset> | ||
9 | </copy> | ||
10 | <csc target="library" debug="${build.debug}" unsafe="False" define="TRACE;DEBUG" output="${project::get-base-directory()}/${build.dir}/${project::get-name()}.dll"> | ||
11 | <resources prefix="OpenGrid.Framework.Data" dynamicprefix="true" > | ||
12 | </resources> | ||
13 | <sources failonempty="true"> | ||
14 | <include name="GridData.cs" /> | ||
15 | <include name="IniConfig.cs" /> | ||
16 | <include name="SimProfileData.cs" /> | ||
17 | <include name="UserData.cs" /> | ||
18 | <include name="UserProfileData.cs" /> | ||
19 | <include name="Properties/AssemblyInfo.cs" /> | ||
20 | </sources> | ||
21 | <references basedir="${project::get-base-directory()}"> | ||
22 | <lib> | ||
23 | <include name="${project::get-base-directory()}" /> | ||
24 | <include name="${project::get-base-directory()}/${build.dir}" /> | ||
25 | </lib> | ||
26 | <include name="System.dll" /> | ||
27 | <include name="System.Xml.dll" /> | ||
28 | <include name="System.Data.dll" /> | ||
29 | <include name="../../bin/libsecondlife.dll" /> | ||
30 | </references> | ||
31 | </csc> | ||
32 | <echo message="Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/../../bin/" /> | ||
33 | <mkdir dir="${project::get-base-directory()}/../../bin/"/> | ||
34 | <copy todir="${project::get-base-directory()}/../../bin/"> | ||
35 | <fileset basedir="${project::get-base-directory()}/${build.dir}/" > | ||
36 | <include name="*.dll"/> | ||
37 | <include name="*.exe"/> | ||
38 | </fileset> | ||
39 | </copy> | ||
40 | </target> | ||
41 | <target name="clean"> | ||
42 | <delete dir="${bin.dir}" failonerror="false" /> | ||
43 | <delete dir="${obj.dir}" failonerror="false" /> | ||
44 | </target> | ||
45 | <target name="doc" description="Creates documentation."> | ||
46 | </target> | ||
47 | </project> | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/Properties/AssemblyInfo.cs b/OpenGridServices/OpenGrid.Framework.Data/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1446673 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenGrid.Framework.Data")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenGrid.Framework.Data")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("3a711c34-b0c0-4264-b0fe-f366eabf9d7b")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/SimProfileData.cs b/OpenGridServices/OpenGrid.Framework.Data/SimProfileData.cs new file mode 100644 index 0000000..c66610e --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/SimProfileData.cs | |||
@@ -0,0 +1,84 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenGrid.Framework.Data | ||
6 | { | ||
7 | public class SimProfileData | ||
8 | { | ||
9 | /// <summary> | ||
10 | /// The name of the region | ||
11 | /// </summary> | ||
12 | public string regionName = ""; | ||
13 | |||
14 | /// <summary> | ||
15 | /// A 64-bit number combining map position into a (mostly) unique ID | ||
16 | /// </summary> | ||
17 | public ulong regionHandle; | ||
18 | |||
19 | /// <summary> | ||
20 | /// OGS/OpenSim Specific ID for a region | ||
21 | /// </summary> | ||
22 | public libsecondlife.LLUUID UUID; | ||
23 | |||
24 | /// <summary> | ||
25 | /// Coordinates of the region | ||
26 | /// </summary> | ||
27 | public uint regionLocX; | ||
28 | public uint regionLocY; | ||
29 | public uint regionLocZ; // Reserved (round-robin, layers, etc) | ||
30 | |||
31 | /// <summary> | ||
32 | /// Authentication secrets | ||
33 | /// </summary> | ||
34 | /// <remarks>Not very secure, needs improvement.</remarks> | ||
35 | public string regionSendKey = ""; | ||
36 | public string regionRecvKey = ""; | ||
37 | public string regionSecret = ""; | ||
38 | |||
39 | /// <summary> | ||
40 | /// Whether the region is online | ||
41 | /// </summary> | ||
42 | public bool regionOnline; | ||
43 | |||
44 | /// <summary> | ||
45 | /// Information about the server that the region is currently hosted on | ||
46 | /// </summary> | ||
47 | public string serverIP = ""; | ||
48 | public uint serverPort; | ||
49 | public string serverURI = ""; | ||
50 | |||
51 | /// <summary> | ||
52 | /// Set of optional overrides. Can be used to create non-eulicidean spaces. | ||
53 | /// </summary> | ||
54 | public ulong regionNorthOverrideHandle; | ||
55 | public ulong regionSouthOverrideHandle; | ||
56 | public ulong regionEastOverrideHandle; | ||
57 | public ulong regionWestOverrideHandle; | ||
58 | |||
59 | /// <summary> | ||
60 | /// Optional: URI Location of the region database | ||
61 | /// </summary> | ||
62 | /// <remarks>Used for floating sim pools where the region data is not nessecarily coupled to a specific server</remarks> | ||
63 | public string regionDataURI = ""; | ||
64 | |||
65 | /// <summary> | ||
66 | /// Region Asset Details | ||
67 | /// </summary> | ||
68 | public string regionAssetURI = ""; | ||
69 | public string regionAssetSendKey = ""; | ||
70 | public string regionAssetRecvKey = ""; | ||
71 | |||
72 | /// <summary> | ||
73 | /// Region Userserver Details | ||
74 | /// </summary> | ||
75 | public string regionUserURI = ""; | ||
76 | public string regionUserSendKey = ""; | ||
77 | public string regionUserRecvKey = ""; | ||
78 | |||
79 | /// <summary> | ||
80 | /// Region Map Texture Asset | ||
81 | /// </summary> | ||
82 | public libsecondlife.LLUUID regionMapTextureID = new libsecondlife.LLUUID("00000000-0000-0000-9999-000000000006"); | ||
83 | } | ||
84 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/UserData.cs b/OpenGridServices/OpenGrid.Framework.Data/UserData.cs new file mode 100644 index 0000000..4802c5f --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/UserData.cs | |||
@@ -0,0 +1,101 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace OpenGrid.Framework.Data | ||
7 | { | ||
8 | public interface IUserData | ||
9 | { | ||
10 | /// <summary> | ||
11 | /// Returns a user profile from a database via their UUID | ||
12 | /// </summary> | ||
13 | /// <param name="user">The accounts UUID</param> | ||
14 | /// <returns>The user data profile</returns> | ||
15 | UserProfileData getUserByUUID(LLUUID user); | ||
16 | |||
17 | /// <summary> | ||
18 | /// Returns a users profile by searching their username | ||
19 | /// </summary> | ||
20 | /// <param name="name">The users username</param> | ||
21 | /// <returns>The user data profile</returns> | ||
22 | UserProfileData getUserByName(string name); | ||
23 | |||
24 | /// <summary> | ||
25 | /// Returns a users profile by searching their username parts | ||
26 | /// </summary> | ||
27 | /// <param name="fname">Account firstname</param> | ||
28 | /// <param name="lname">Account lastname</param> | ||
29 | /// <returns>The user data profile</returns> | ||
30 | UserProfileData getUserByName(string fname, string lname); | ||
31 | |||
32 | /// <summary> | ||
33 | /// Returns the current agent for a user searching by it's UUID | ||
34 | /// </summary> | ||
35 | /// <param name="user">The users UUID</param> | ||
36 | /// <returns>The current agent session</returns> | ||
37 | UserAgentData getAgentByUUID(LLUUID user); | ||
38 | |||
39 | /// <summary> | ||
40 | /// Returns the current session agent for a user searching by username | ||
41 | /// </summary> | ||
42 | /// <param name="name">The users account name</param> | ||
43 | /// <returns>The current agent session</returns> | ||
44 | UserAgentData getAgentByName(string name); | ||
45 | |||
46 | /// <summary> | ||
47 | /// Returns the current session agent for a user searching by username parts | ||
48 | /// </summary> | ||
49 | /// <param name="fname">The users first account name</param> | ||
50 | /// <param name="lname">The users account surname</param> | ||
51 | /// <returns>The current agent session</returns> | ||
52 | UserAgentData getAgentByName(string fname, string lname); | ||
53 | |||
54 | /// <summary> | ||
55 | /// Adds a new User profile to the database | ||
56 | /// </summary> | ||
57 | /// <param name="user">UserProfile to add</param> | ||
58 | void addNewUserProfile(UserProfileData user); | ||
59 | |||
60 | /// <summary> | ||
61 | /// Adds a new agent to the database | ||
62 | /// </summary> | ||
63 | /// <param name="agent">The agent to add</param> | ||
64 | void addNewUserAgent(UserAgentData agent); | ||
65 | |||
66 | /// <summary> | ||
67 | /// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES) | ||
68 | /// </summary> | ||
69 | /// <param name="from">The account to transfer from</param> | ||
70 | /// <param name="to">The account to transfer to</param> | ||
71 | /// <param name="amount">The amount to transfer</param> | ||
72 | /// <returns>Successful?</returns> | ||
73 | bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount); | ||
74 | |||
75 | /// <summary> | ||
76 | /// Attempts to move inventory between accounts, if inventory is copyable it will be copied into the target account. | ||
77 | /// </summary> | ||
78 | /// <param name="from">User to transfer from</param> | ||
79 | /// <param name="to">User to transfer to</param> | ||
80 | /// <param name="inventory">Specified inventory item</param> | ||
81 | /// <returns>Successful?</returns> | ||
82 | bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory); | ||
83 | |||
84 | /// <summary> | ||
85 | /// Returns the plugin version | ||
86 | /// </summary> | ||
87 | /// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns> | ||
88 | string getVersion(); | ||
89 | |||
90 | /// <summary> | ||
91 | /// Returns the plugin name | ||
92 | /// </summary> | ||
93 | /// <returns>Plugin name, eg MySQL User Provider</returns> | ||
94 | string getName(); | ||
95 | |||
96 | /// <summary> | ||
97 | /// Initialises the plugin (artificial constructor) | ||
98 | /// </summary> | ||
99 | void Initialise(); | ||
100 | } | ||
101 | } | ||
diff --git a/OpenGridServices/OpenGrid.Framework.Data/UserProfileData.cs b/OpenGridServices/OpenGrid.Framework.Data/UserProfileData.cs new file mode 100644 index 0000000..3f42762 --- /dev/null +++ b/OpenGridServices/OpenGrid.Framework.Data/UserProfileData.cs | |||
@@ -0,0 +1,54 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace OpenGrid.Framework.Data | ||
7 | { | ||
8 | public class UserProfileData | ||
9 | { | ||
10 | public LLUUID UUID; | ||
11 | public string username; // The configurable part of the users username | ||
12 | public string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin') | ||
13 | |||
14 | public string passwordHash; // Hash of the users password | ||
15 | public string passwordSalt; // Salt for the users password | ||
16 | |||
17 | public ulong homeRegion; // RegionHandle of home | ||
18 | public LLVector3 homeLocation; // Home Location inside the sim | ||
19 | public LLVector3 homeLookAt; // Coordinates where the user is looking | ||
20 | |||
21 | |||
22 | public int created; // UNIX Epoch Timestamp (User Creation) | ||
23 | public int lastLogin; // UNIX Epoch Timestamp (Last Login Time) | ||
24 | |||
25 | public string userInventoryURI; // URI to inventory server for this user | ||
26 | public string userAssetURI; // URI to asset server for this user | ||
27 | |||
28 | public uint profileCanDoMask; // Profile window "I can do" mask | ||
29 | public uint profileWantDoMask; // Profile window "I want to" mask | ||
30 | |||
31 | public string profileAboutText; // My about window text | ||
32 | public string profileFirstText; // First Life Text | ||
33 | |||
34 | public LLUUID profileImage; // My avatars profile image | ||
35 | public LLUUID profileFirstImage; // First-life image | ||
36 | public UserAgentData currentAgent; // The users last agent | ||
37 | } | ||
38 | |||
39 | public class UserAgentData | ||
40 | { | ||
41 | public LLUUID UUID; // Account ID | ||
42 | public string agentIP; // The IP of the agent | ||
43 | public uint agentPort; // The port of the agent | ||
44 | public bool agentOnline; // The online status of the agent | ||
45 | public LLUUID sessionID; // The session ID for the agent (used by client) | ||
46 | public LLUUID secureSessionID; // The secure session ID for the agent (used by client) | ||
47 | public LLUUID regionID; // The region ID the agent occupies | ||
48 | public int loginTime; // EPOCH based Timestamp | ||
49 | public int logoutTime; // Timestamp or 0 if N/A | ||
50 | public LLUUID currentRegion; // UUID of the users current region | ||
51 | public ulong currentHandle; // RegionHandle of the users current region | ||
52 | public LLVector3 currentPos; // Current position in the region | ||
53 | } | ||
54 | } | ||