aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices/OpenGrid.Framework.Data.DB4o
diff options
context:
space:
mode:
authorMW2007-05-26 13:40:19 +0000
committerMW2007-05-26 13:40:19 +0000
commit3436961bb5c01d659d09be134368f4f69460cef9 (patch)
tree3753ba4d7818df2a6bce0bbe863ff033cdfd568a /OpenGridServices/OpenGrid.Framework.Data.DB4o
downloadopensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.zip
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz
Start of rewrite 5279!
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Data.DB4o')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs83
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs111
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs100
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj111
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.csproj.user12
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/OpenGrid.Framework.Data.DB4o.dll.build47
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/Properties/AssemblyInfo.cs35
7 files changed, 499 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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenGrid.Framework.Data;
5using libsecondlife;
6
7
8namespace 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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Db4objects.Db4o;
5using OpenGrid.Framework.Data;
6using libsecondlife;
7
8namespace 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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenGrid.Framework.Data;
5using libsecondlife;
6
7namespace 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 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// General Information about an assembly is controlled through the following
6// set of attributes. Change these attribute values to modify the information
7// associated with an assembly.
8[assembly: AssemblyTitle("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")]