aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Data.DB4o/DB4oGridData.cs')
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oGridData.cs162
1 files changed, 162 insertions, 0 deletions
diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
new file mode 100644
index 0000000..5fec367
--- /dev/null
+++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs
@@ -0,0 +1,162 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using libsecondlife;
31
32namespace OpenSim.Framework.Data.DB4o
33{
34 /// <summary>
35 /// A grid server storage mechanism employing the DB4o database system
36 /// </summary>
37 class DB4oGridData : IGridData
38 {
39 /// <summary>
40 /// The database manager object
41 /// </summary>
42 DB4oGridManager manager;
43
44 /// <summary>
45 /// Called when the plugin is first loaded (as constructors are not called)
46 /// </summary>
47 public void Initialise() {
48 manager = new DB4oGridManager("gridserver.yap");
49 }
50
51 /// <summary>
52 /// Returns a list of regions within the specified ranges
53 /// </summary>
54 /// <param name="a">minimum X coordinate</param>
55 /// <param name="b">minimum Y coordinate</param>
56 /// <param name="c">maximum X coordinate</param>
57 /// <param name="d">maximum Y coordinate</param>
58 /// <returns>An array of region profiles</returns>
59 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
60 {
61 return null;
62 }
63
64 /// <summary>
65 /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned)
66 /// </summary>
67 /// <param name="handle">The handle to search for</param>
68 /// <returns>A region profile</returns>
69 public SimProfileData GetProfileByHandle(ulong handle) {
70 lock (manager.simProfiles)
71 {
72 foreach (LLUUID UUID in manager.simProfiles.Keys)
73 {
74 if (manager.simProfiles[UUID].regionHandle == handle)
75 {
76 return manager.simProfiles[UUID];
77 }
78 }
79 }
80 throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
81 }
82
83 /// <summary>
84 /// Returns a specific region
85 /// </summary>
86 /// <param name="uuid">The region ID code</param>
87 /// <returns>A region profile</returns>
88 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
89 {
90 lock (manager.simProfiles)
91 {
92 if (manager.simProfiles.ContainsKey(uuid))
93 return manager.simProfiles[uuid];
94 }
95 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count);
96 }
97
98 /// <summary>
99 /// Adds a new specified region to the database
100 /// </summary>
101 /// <param name="profile">The profile to add</param>
102 /// <returns>A dataresponse enum indicating success</returns>
103 public DataResponse AddProfile(SimProfileData profile)
104 {
105 lock (manager.simProfiles)
106 {
107 if (manager.AddRow(profile))
108 {
109 return DataResponse.RESPONSE_OK;
110 }
111 else
112 {
113 return DataResponse.RESPONSE_ERROR;
114 }
115 }
116 }
117
118 /// <summary>
119 /// Authenticates a new region using the shared secrets. NOT SECURE.
120 /// </summary>
121 /// <param name="uuid">The UUID the region is authenticating with</param>
122 /// <param name="handle">The location the region is logging into (unused in Db4o)</param>
123 /// <param name="key">The shared secret</param>
124 /// <returns>Authenticated?</returns>
125 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
126 if (manager.simProfiles[uuid].regionRecvKey == key)
127 return true;
128 return false;
129 }
130
131 /// <summary>
132 /// Shuts down the database
133 /// </summary>
134 public void Close()
135 {
136 manager = null;
137 }
138
139 /// <summary>
140 /// Returns the providers name
141 /// </summary>
142 /// <returns>The name of the storage system</returns>
143 public string getName()
144 {
145 return "DB4o Grid Provider";
146 }
147
148 /// <summary>
149 /// Returns the providers version
150 /// </summary>
151 /// <returns>The version of the storage system</returns>
152 public string getVersion()
153 {
154 return "0.1";
155 }
156
157 public ReservationData GetReservationAtPoint(uint x, uint y)
158 {
159 return null;
160 }
161 }
162}