diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Framework/Data.DB4o | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Framework/Data.DB4o')
-rw-r--r-- | OpenSim/Framework/Data.DB4o/DB4oGridData.cs | 324 | ||||
-rw-r--r-- | OpenSim/Framework/Data.DB4o/DB4oManager.cs | 326 | ||||
-rw-r--r-- | OpenSim/Framework/Data.DB4o/DB4oUserData.cs | 404 | ||||
-rw-r--r-- | OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs | 66 |
4 files changed, 560 insertions, 560 deletions
diff --git a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs index 5fec367..e57a3aa 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oGridData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oGridData.cs | |||
@@ -1,162 +1,162 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using libsecondlife; | 30 | using libsecondlife; |
31 | 31 | ||
32 | namespace OpenSim.Framework.Data.DB4o | 32 | namespace OpenSim.Framework.Data.DB4o |
33 | { | 33 | { |
34 | /// <summary> | 34 | /// <summary> |
35 | /// A grid server storage mechanism employing the DB4o database system | 35 | /// A grid server storage mechanism employing the DB4o database system |
36 | /// </summary> | 36 | /// </summary> |
37 | class DB4oGridData : IGridData | 37 | class DB4oGridData : IGridData |
38 | { | 38 | { |
39 | /// <summary> | 39 | /// <summary> |
40 | /// The database manager object | 40 | /// The database manager object |
41 | /// </summary> | 41 | /// </summary> |
42 | DB4oGridManager manager; | 42 | DB4oGridManager manager; |
43 | 43 | ||
44 | /// <summary> | 44 | /// <summary> |
45 | /// Called when the plugin is first loaded (as constructors are not called) | 45 | /// Called when the plugin is first loaded (as constructors are not called) |
46 | /// </summary> | 46 | /// </summary> |
47 | public void Initialise() { | 47 | public void Initialise() { |
48 | manager = new DB4oGridManager("gridserver.yap"); | 48 | manager = new DB4oGridManager("gridserver.yap"); |
49 | } | 49 | } |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Returns a list of regions within the specified ranges | 52 | /// Returns a list of regions within the specified ranges |
53 | /// </summary> | 53 | /// </summary> |
54 | /// <param name="a">minimum X coordinate</param> | 54 | /// <param name="a">minimum X coordinate</param> |
55 | /// <param name="b">minimum Y coordinate</param> | 55 | /// <param name="b">minimum Y coordinate</param> |
56 | /// <param name="c">maximum X coordinate</param> | 56 | /// <param name="c">maximum X coordinate</param> |
57 | /// <param name="d">maximum Y coordinate</param> | 57 | /// <param name="d">maximum Y coordinate</param> |
58 | /// <returns>An array of region profiles</returns> | 58 | /// <returns>An array of region profiles</returns> |
59 | public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) | 59 | public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) |
60 | { | 60 | { |
61 | return null; | 61 | return null; |
62 | } | 62 | } |
63 | 63 | ||
64 | /// <summary> | 64 | /// <summary> |
65 | /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned) | 65 | /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned) |
66 | /// </summary> | 66 | /// </summary> |
67 | /// <param name="handle">The handle to search for</param> | 67 | /// <param name="handle">The handle to search for</param> |
68 | /// <returns>A region profile</returns> | 68 | /// <returns>A region profile</returns> |
69 | public SimProfileData GetProfileByHandle(ulong handle) { | 69 | public SimProfileData GetProfileByHandle(ulong handle) { |
70 | lock (manager.simProfiles) | 70 | lock (manager.simProfiles) |
71 | { | 71 | { |
72 | foreach (LLUUID UUID in manager.simProfiles.Keys) | 72 | foreach (LLUUID UUID in manager.simProfiles.Keys) |
73 | { | 73 | { |
74 | if (manager.simProfiles[UUID].regionHandle == handle) | 74 | if (manager.simProfiles[UUID].regionHandle == handle) |
75 | { | 75 | { |
76 | return manager.simProfiles[UUID]; | 76 | return manager.simProfiles[UUID]; |
77 | } | 77 | } |
78 | } | 78 | } |
79 | } | 79 | } |
80 | throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")"); | 80 | throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")"); |
81 | } | 81 | } |
82 | 82 | ||
83 | /// <summary> | 83 | /// <summary> |
84 | /// Returns a specific region | 84 | /// Returns a specific region |
85 | /// </summary> | 85 | /// </summary> |
86 | /// <param name="uuid">The region ID code</param> | 86 | /// <param name="uuid">The region ID code</param> |
87 | /// <returns>A region profile</returns> | 87 | /// <returns>A region profile</returns> |
88 | public SimProfileData GetProfileByLLUUID(LLUUID uuid) | 88 | public SimProfileData GetProfileByLLUUID(LLUUID uuid) |
89 | { | 89 | { |
90 | lock (manager.simProfiles) | 90 | lock (manager.simProfiles) |
91 | { | 91 | { |
92 | if (manager.simProfiles.ContainsKey(uuid)) | 92 | if (manager.simProfiles.ContainsKey(uuid)) |
93 | return manager.simProfiles[uuid]; | 93 | return manager.simProfiles[uuid]; |
94 | } | 94 | } |
95 | throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count); | 95 | throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + "). Total Registered Regions: " + manager.simProfiles.Count); |
96 | } | 96 | } |
97 | 97 | ||
98 | /// <summary> | 98 | /// <summary> |
99 | /// Adds a new specified region to the database | 99 | /// Adds a new specified region to the database |
100 | /// </summary> | 100 | /// </summary> |
101 | /// <param name="profile">The profile to add</param> | 101 | /// <param name="profile">The profile to add</param> |
102 | /// <returns>A dataresponse enum indicating success</returns> | 102 | /// <returns>A dataresponse enum indicating success</returns> |
103 | public DataResponse AddProfile(SimProfileData profile) | 103 | public DataResponse AddProfile(SimProfileData profile) |
104 | { | 104 | { |
105 | lock (manager.simProfiles) | 105 | lock (manager.simProfiles) |
106 | { | 106 | { |
107 | if (manager.AddRow(profile)) | 107 | if (manager.AddRow(profile)) |
108 | { | 108 | { |
109 | return DataResponse.RESPONSE_OK; | 109 | return DataResponse.RESPONSE_OK; |
110 | } | 110 | } |
111 | else | 111 | else |
112 | { | 112 | { |
113 | return DataResponse.RESPONSE_ERROR; | 113 | return DataResponse.RESPONSE_ERROR; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | /// <summary> | 118 | /// <summary> |
119 | /// Authenticates a new region using the shared secrets. NOT SECURE. | 119 | /// Authenticates a new region using the shared secrets. NOT SECURE. |
120 | /// </summary> | 120 | /// </summary> |
121 | /// <param name="uuid">The UUID the region is authenticating with</param> | 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> | 122 | /// <param name="handle">The location the region is logging into (unused in Db4o)</param> |
123 | /// <param name="key">The shared secret</param> | 123 | /// <param name="key">The shared secret</param> |
124 | /// <returns>Authenticated?</returns> | 124 | /// <returns>Authenticated?</returns> |
125 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { | 125 | public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { |
126 | if (manager.simProfiles[uuid].regionRecvKey == key) | 126 | if (manager.simProfiles[uuid].regionRecvKey == key) |
127 | return true; | 127 | return true; |
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | 130 | ||
131 | /// <summary> | 131 | /// <summary> |
132 | /// Shuts down the database | 132 | /// Shuts down the database |
133 | /// </summary> | 133 | /// </summary> |
134 | public void Close() | 134 | public void Close() |
135 | { | 135 | { |
136 | manager = null; | 136 | manager = null; |
137 | } | 137 | } |
138 | 138 | ||
139 | /// <summary> | 139 | /// <summary> |
140 | /// Returns the providers name | 140 | /// Returns the providers name |
141 | /// </summary> | 141 | /// </summary> |
142 | /// <returns>The name of the storage system</returns> | 142 | /// <returns>The name of the storage system</returns> |
143 | public string getName() | 143 | public string getName() |
144 | { | 144 | { |
145 | return "DB4o Grid Provider"; | 145 | return "DB4o Grid Provider"; |
146 | } | 146 | } |
147 | 147 | ||
148 | /// <summary> | 148 | /// <summary> |
149 | /// Returns the providers version | 149 | /// Returns the providers version |
150 | /// </summary> | 150 | /// </summary> |
151 | /// <returns>The version of the storage system</returns> | 151 | /// <returns>The version of the storage system</returns> |
152 | public string getVersion() | 152 | public string getVersion() |
153 | { | 153 | { |
154 | return "0.1"; | 154 | return "0.1"; |
155 | } | 155 | } |
156 | 156 | ||
157 | public ReservationData GetReservationAtPoint(uint x, uint y) | 157 | public ReservationData GetReservationAtPoint(uint x, uint y) |
158 | { | 158 | { |
159 | return null; | 159 | return null; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
diff --git a/OpenSim/Framework/Data.DB4o/DB4oManager.cs b/OpenSim/Framework/Data.DB4o/DB4oManager.cs index 0df6350..43f9095 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oManager.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oManager.cs | |||
@@ -1,163 +1,163 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using Db4objects.Db4o; | 30 | using Db4objects.Db4o; |
31 | using libsecondlife; | 31 | using libsecondlife; |
32 | 32 | ||
33 | namespace OpenSim.Framework.Data.DB4o | 33 | namespace OpenSim.Framework.Data.DB4o |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// A Database manager for Db4o | 36 | /// A Database manager for Db4o |
37 | /// </summary> | 37 | /// </summary> |
38 | class DB4oGridManager | 38 | class DB4oGridManager |
39 | { | 39 | { |
40 | /// <summary> | 40 | /// <summary> |
41 | /// A list of the current regions connected (in-memory cache) | 41 | /// A list of the current regions connected (in-memory cache) |
42 | /// </summary> | 42 | /// </summary> |
43 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); | 43 | public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); |
44 | /// <summary> | 44 | /// <summary> |
45 | /// Database File Name | 45 | /// Database File Name |
46 | /// </summary> | 46 | /// </summary> |
47 | string dbfl; | 47 | string dbfl; |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Creates a new grid storage manager | 50 | /// Creates a new grid storage manager |
51 | /// </summary> | 51 | /// </summary> |
52 | /// <param name="db4odb">Filename to the database file</param> | 52 | /// <param name="db4odb">Filename to the database file</param> |
53 | public DB4oGridManager(string db4odb) | 53 | public DB4oGridManager(string db4odb) |
54 | { | 54 | { |
55 | dbfl = db4odb; | 55 | dbfl = db4odb; |
56 | IObjectContainer database; | 56 | IObjectContainer database; |
57 | database = Db4oFactory.OpenFile(dbfl); | 57 | database = Db4oFactory.OpenFile(dbfl); |
58 | IObjectSet result = database.Get(typeof(SimProfileData)); | 58 | IObjectSet result = database.Get(typeof(SimProfileData)); |
59 | // Loads the file into the in-memory cache | 59 | // Loads the file into the in-memory cache |
60 | foreach(SimProfileData row in result) { | 60 | foreach(SimProfileData row in result) { |
61 | simProfiles.Add(row.UUID, row); | 61 | simProfiles.Add(row.UUID, row); |
62 | } | 62 | } |
63 | database.Close(); | 63 | database.Close(); |
64 | } | 64 | } |
65 | 65 | ||
66 | /// <summary> | 66 | /// <summary> |
67 | /// Adds a new profile to the database (Warning: Probably slow.) | 67 | /// Adds a new profile to the database (Warning: Probably slow.) |
68 | /// </summary> | 68 | /// </summary> |
69 | /// <param name="row">The profile to add</param> | 69 | /// <param name="row">The profile to add</param> |
70 | /// <returns>Successful?</returns> | 70 | /// <returns>Successful?</returns> |
71 | public bool AddRow(SimProfileData row) | 71 | public bool AddRow(SimProfileData row) |
72 | { | 72 | { |
73 | if (simProfiles.ContainsKey(row.UUID)) | 73 | if (simProfiles.ContainsKey(row.UUID)) |
74 | { | 74 | { |
75 | simProfiles[row.UUID] = row; | 75 | simProfiles[row.UUID] = row; |
76 | } | 76 | } |
77 | else | 77 | else |
78 | { | 78 | { |
79 | simProfiles.Add(row.UUID, row); | 79 | simProfiles.Add(row.UUID, row); |
80 | } | 80 | } |
81 | 81 | ||
82 | try | 82 | try |
83 | { | 83 | { |
84 | IObjectContainer database; | 84 | IObjectContainer database; |
85 | database = Db4oFactory.OpenFile(dbfl); | 85 | database = Db4oFactory.OpenFile(dbfl); |
86 | database.Set(row); | 86 | database.Set(row); |
87 | database.Close(); | 87 | database.Close(); |
88 | return true; | 88 | return true; |
89 | } | 89 | } |
90 | catch (Exception) | 90 | catch (Exception) |
91 | { | 91 | { |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | } | 97 | } |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// A manager for the DB4o database (user profiles) | 100 | /// A manager for the DB4o database (user profiles) |
101 | /// </summary> | 101 | /// </summary> |
102 | class DB4oUserManager | 102 | class DB4oUserManager |
103 | { | 103 | { |
104 | /// <summary> | 104 | /// <summary> |
105 | /// A list of the user profiles (in memory cache) | 105 | /// A list of the user profiles (in memory cache) |
106 | /// </summary> | 106 | /// </summary> |
107 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); | 107 | public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); |
108 | /// <summary> | 108 | /// <summary> |
109 | /// Database filename | 109 | /// Database filename |
110 | /// </summary> | 110 | /// </summary> |
111 | string dbfl; | 111 | string dbfl; |
112 | 112 | ||
113 | /// <summary> | 113 | /// <summary> |
114 | /// Initialises a new DB manager | 114 | /// Initialises a new DB manager |
115 | /// </summary> | 115 | /// </summary> |
116 | /// <param name="db4odb">The filename to the database</param> | 116 | /// <param name="db4odb">The filename to the database</param> |
117 | public DB4oUserManager(string db4odb) | 117 | public DB4oUserManager(string db4odb) |
118 | { | 118 | { |
119 | dbfl = db4odb; | 119 | dbfl = db4odb; |
120 | IObjectContainer database; | 120 | IObjectContainer database; |
121 | database = Db4oFactory.OpenFile(dbfl); | 121 | database = Db4oFactory.OpenFile(dbfl); |
122 | // Load to cache | 122 | // Load to cache |
123 | IObjectSet result = database.Get(typeof(UserProfileData)); | 123 | IObjectSet result = database.Get(typeof(UserProfileData)); |
124 | foreach (UserProfileData row in result) | 124 | foreach (UserProfileData row in result) |
125 | { | 125 | { |
126 | userProfiles.Add(row.UUID, row); | 126 | userProfiles.Add(row.UUID, row); |
127 | } | 127 | } |
128 | database.Close(); | 128 | database.Close(); |
129 | } | 129 | } |
130 | 130 | ||
131 | /// <summary> | 131 | /// <summary> |
132 | /// Adds a new profile to the database (Warning: Probably slow.) | 132 | /// Adds a new profile to the database (Warning: Probably slow.) |
133 | /// </summary> | 133 | /// </summary> |
134 | /// <param name="row">The profile to add</param> | 134 | /// <param name="row">The profile to add</param> |
135 | /// <returns>Successful?</returns> | 135 | /// <returns>Successful?</returns> |
136 | public bool AddRow(UserProfileData row) | 136 | public bool AddRow(UserProfileData row) |
137 | { | 137 | { |
138 | if (userProfiles.ContainsKey(row.UUID)) | 138 | if (userProfiles.ContainsKey(row.UUID)) |
139 | { | 139 | { |
140 | userProfiles[row.UUID] = row; | 140 | userProfiles[row.UUID] = row; |
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
144 | userProfiles.Add(row.UUID, row); | 144 | userProfiles.Add(row.UUID, row); |
145 | } | 145 | } |
146 | 146 | ||
147 | try | 147 | try |
148 | { | 148 | { |
149 | IObjectContainer database; | 149 | IObjectContainer database; |
150 | database = Db4oFactory.OpenFile(dbfl); | 150 | database = Db4oFactory.OpenFile(dbfl); |
151 | database.Set(row); | 151 | database.Set(row); |
152 | database.Close(); | 152 | database.Close(); |
153 | return true; | 153 | return true; |
154 | } | 154 | } |
155 | catch (Exception) | 155 | catch (Exception) |
156 | { | 156 | { |
157 | return false; | 157 | return false; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | 161 | ||
162 | } | 162 | } |
163 | } | 163 | } |
diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs index 2e33ab0..845b764 100644 --- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs +++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs | |||
@@ -1,202 +1,202 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | 28 | using System; |
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | 30 | ||
31 | namespace OpenSim.Framework.Data.DB4o | 31 | namespace OpenSim.Framework.Data.DB4o |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// A User storage interface for the DB4o database system | 34 | /// A User storage interface for the DB4o database system |
35 | /// </summary> | 35 | /// </summary> |
36 | public class DB4oUserData : IUserData | 36 | public class DB4oUserData : IUserData |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// The database manager | 39 | /// The database manager |
40 | /// </summary> | 40 | /// </summary> |
41 | DB4oUserManager manager; | 41 | DB4oUserManager manager; |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Artificial constructor called upon plugin load | 44 | /// Artificial constructor called upon plugin load |
45 | /// </summary> | 45 | /// </summary> |
46 | public void Initialise() | 46 | public void Initialise() |
47 | { | 47 | { |
48 | manager = new DB4oUserManager("userprofiles.yap"); | 48 | manager = new DB4oUserManager("userprofiles.yap"); |
49 | } | 49 | } |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Loads a specified user profile from a UUID | 52 | /// Loads a specified user profile from a UUID |
53 | /// </summary> | 53 | /// </summary> |
54 | /// <param name="uuid">The users UUID</param> | 54 | /// <param name="uuid">The users UUID</param> |
55 | /// <returns>A user profile</returns> | 55 | /// <returns>A user profile</returns> |
56 | public UserProfileData getUserByUUID(LLUUID uuid) | 56 | public UserProfileData getUserByUUID(LLUUID uuid) |
57 | { | 57 | { |
58 | if(manager.userProfiles.ContainsKey(uuid)) | 58 | if(manager.userProfiles.ContainsKey(uuid)) |
59 | return manager.userProfiles[uuid]; | 59 | return manager.userProfiles[uuid]; |
60 | return null; | 60 | return null; |
61 | } | 61 | } |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Returns a user by searching for its name | 64 | /// Returns a user by searching for its name |
65 | /// </summary> | 65 | /// </summary> |
66 | /// <param name="name">The users account name</param> | 66 | /// <param name="name">The users account name</param> |
67 | /// <returns>A matching users profile</returns> | 67 | /// <returns>A matching users profile</returns> |
68 | public UserProfileData getUserByName(string name) | 68 | public UserProfileData getUserByName(string name) |
69 | { | 69 | { |
70 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | 70 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); |
71 | } | 71 | } |
72 | 72 | ||
73 | /// <summary> | 73 | /// <summary> |
74 | /// Returns a user by searching for its name | 74 | /// Returns a user by searching for its name |
75 | /// </summary> | 75 | /// </summary> |
76 | /// <param name="fname">The first part of the users account name</param> | 76 | /// <param name="fname">The first part of the users account name</param> |
77 | /// <param name="lname">The second part of the users account name</param> | 77 | /// <param name="lname">The second part of the users account name</param> |
78 | /// <returns>A matching users profile</returns> | 78 | /// <returns>A matching users profile</returns> |
79 | public UserProfileData getUserByName(string fname, string lname) | 79 | public UserProfileData getUserByName(string fname, string lname) |
80 | { | 80 | { |
81 | foreach (UserProfileData profile in manager.userProfiles.Values) | 81 | foreach (UserProfileData profile in manager.userProfiles.Values) |
82 | { | 82 | { |
83 | if (profile.username == fname && profile.surname == lname) | 83 | if (profile.username == fname && profile.surname == lname) |
84 | return profile; | 84 | return profile; |
85 | } | 85 | } |
86 | return null; | 86 | return null; |
87 | } | 87 | } |
88 | 88 | ||
89 | /// <summary> | 89 | /// <summary> |
90 | /// Returns a user by UUID direct | 90 | /// Returns a user by UUID direct |
91 | /// </summary> | 91 | /// </summary> |
92 | /// <param name="uuid">The users account ID</param> | 92 | /// <param name="uuid">The users account ID</param> |
93 | /// <returns>A matching users profile</returns> | 93 | /// <returns>A matching users profile</returns> |
94 | public UserAgentData getAgentByUUID(LLUUID uuid) | 94 | public UserAgentData getAgentByUUID(LLUUID uuid) |
95 | { | 95 | { |
96 | try | 96 | try |
97 | { | 97 | { |
98 | return getUserByUUID(uuid).currentAgent; | 98 | return getUserByUUID(uuid).currentAgent; |
99 | } | 99 | } |
100 | catch (Exception) | 100 | catch (Exception) |
101 | { | 101 | { |
102 | return null; | 102 | return null; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | /// <summary> | 106 | /// <summary> |
107 | /// Returns a session by account name | 107 | /// Returns a session by account name |
108 | /// </summary> | 108 | /// </summary> |
109 | /// <param name="name">The account name</param> | 109 | /// <param name="name">The account name</param> |
110 | /// <returns>The users session agent</returns> | 110 | /// <returns>The users session agent</returns> |
111 | public UserAgentData getAgentByName(string name) | 111 | public UserAgentData getAgentByName(string name) |
112 | { | 112 | { |
113 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | 113 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); |
114 | } | 114 | } |
115 | 115 | ||
116 | /// <summary> | 116 | /// <summary> |
117 | /// Returns a session by account name | 117 | /// Returns a session by account name |
118 | /// </summary> | 118 | /// </summary> |
119 | /// <param name="fname">The first part of the users account name</param> | 119 | /// <param name="fname">The first part of the users account name</param> |
120 | /// <param name="lname">The second part of the users account name</param> | 120 | /// <param name="lname">The second part of the users account name</param> |
121 | /// <returns>A user agent</returns> | 121 | /// <returns>A user agent</returns> |
122 | public UserAgentData getAgentByName(string fname, string lname) | 122 | public UserAgentData getAgentByName(string fname, string lname) |
123 | { | 123 | { |
124 | try | 124 | try |
125 | { | 125 | { |
126 | return getUserByName(fname,lname).currentAgent; | 126 | return getUserByName(fname,lname).currentAgent; |
127 | } | 127 | } |
128 | catch (Exception) | 128 | catch (Exception) |
129 | { | 129 | { |
130 | return null; | 130 | return null; |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | /// <summary> | 134 | /// <summary> |
135 | /// Creates a new user profile | 135 | /// Creates a new user profile |
136 | /// </summary> | 136 | /// </summary> |
137 | /// <param name="user">The profile to add to the database</param> | 137 | /// <param name="user">The profile to add to the database</param> |
138 | public void addNewUserProfile(UserProfileData user) | 138 | public void addNewUserProfile(UserProfileData user) |
139 | { | 139 | { |
140 | try | 140 | try |
141 | { | 141 | { |
142 | manager.AddRow(user); | 142 | manager.AddRow(user); |
143 | } | 143 | } |
144 | catch (Exception e) | 144 | catch (Exception e) |
145 | { | 145 | { |
146 | Console.WriteLine(e.ToString()); | 146 | Console.WriteLine(e.ToString()); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | /// <summary> | 150 | /// <summary> |
151 | /// Creates a new user agent | 151 | /// Creates a new user agent |
152 | /// </summary> | 152 | /// </summary> |
153 | /// <param name="agent">The agent to add to the database</param> | 153 | /// <param name="agent">The agent to add to the database</param> |
154 | public void addNewUserAgent(UserAgentData agent) | 154 | public void addNewUserAgent(UserAgentData agent) |
155 | { | 155 | { |
156 | // Do nothing. yet. | 156 | // Do nothing. yet. |
157 | } | 157 | } |
158 | 158 | ||
159 | /// <summary> | 159 | /// <summary> |
160 | /// Transfers money between two user accounts | 160 | /// Transfers money between two user accounts |
161 | /// </summary> | 161 | /// </summary> |
162 | /// <param name="from">Starting account</param> | 162 | /// <param name="from">Starting account</param> |
163 | /// <param name="to">End account</param> | 163 | /// <param name="to">End account</param> |
164 | /// <param name="amount">The amount to move</param> | 164 | /// <param name="amount">The amount to move</param> |
165 | /// <returns>Success?</returns> | 165 | /// <returns>Success?</returns> |
166 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | 166 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) |
167 | { | 167 | { |
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | 170 | ||
171 | /// <summary> | 171 | /// <summary> |
172 | /// Transfers inventory between two accounts | 172 | /// Transfers inventory between two accounts |
173 | /// </summary> | 173 | /// </summary> |
174 | /// <remarks>Move to inventory server</remarks> | 174 | /// <remarks>Move to inventory server</remarks> |
175 | /// <param name="from">Senders account</param> | 175 | /// <param name="from">Senders account</param> |
176 | /// <param name="to">Recievers account</param> | 176 | /// <param name="to">Recievers account</param> |
177 | /// <param name="item">Inventory item</param> | 177 | /// <param name="item">Inventory item</param> |
178 | /// <returns>Success?</returns> | 178 | /// <returns>Success?</returns> |
179 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | 179 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) |
180 | { | 180 | { |
181 | return true; | 181 | return true; |
182 | } | 182 | } |
183 | 183 | ||
184 | /// <summary> | 184 | /// <summary> |
185 | /// Returns the name of the storage provider | 185 | /// Returns the name of the storage provider |
186 | /// </summary> | 186 | /// </summary> |
187 | /// <returns>Storage provider name</returns> | 187 | /// <returns>Storage provider name</returns> |
188 | public string getName() | 188 | public string getName() |
189 | { | 189 | { |
190 | return "DB4o Userdata"; | 190 | return "DB4o Userdata"; |
191 | } | 191 | } |
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
194 | /// Returns the version of the storage provider | 194 | /// Returns the version of the storage provider |
195 | /// </summary> | 195 | /// </summary> |
196 | /// <returns>Storage provider version</returns> | 196 | /// <returns>Storage provider version</returns> |
197 | public string getVersion() | 197 | public string getVersion() |
198 | { | 198 | { |
199 | return "0.1"; | 199 | return "0.1"; |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
diff --git a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs index 905cd9b..52d09fa 100644 --- a/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs +++ b/OpenSim/Framework/Data.DB4o/Properties/AssemblyInfo.cs | |||
@@ -1,33 +1,33 @@ | |||
1 | using System.Reflection; | 1 | using System.Reflection; |
2 | using System.Runtime.InteropServices; | 2 | using System.Runtime.InteropServices; |
3 | // General Information about an assembly is controlled through the following | 3 | // General Information about an assembly is controlled through the following |
4 | // set of attributes. Change these attribute values to modify the information | 4 | // set of attributes. Change these attribute values to modify the information |
5 | // associated with an assembly. | 5 | // associated with an assembly. |
6 | [assembly: AssemblyTitle("OpenSim.Framework.Data.DB4o")] | 6 | [assembly: AssemblyTitle("OpenSim.Framework.Data.DB4o")] |
7 | [assembly: AssemblyDescription("")] | 7 | [assembly: AssemblyDescription("")] |
8 | [assembly: AssemblyConfiguration("")] | 8 | [assembly: AssemblyConfiguration("")] |
9 | [assembly: AssemblyCompany("")] | 9 | [assembly: AssemblyCompany("")] |
10 | [assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")] | 10 | [assembly: AssemblyProduct("OpenSim.Framework.Data.DB4o")] |
11 | [assembly: AssemblyCopyright("Copyright © 2007")] | 11 | [assembly: AssemblyCopyright("Copyright © 2007")] |
12 | [assembly: AssemblyTrademark("")] | 12 | [assembly: AssemblyTrademark("")] |
13 | [assembly: AssemblyCulture("")] | 13 | [assembly: AssemblyCulture("")] |
14 | 14 | ||
15 | // Setting ComVisible to false makes the types in this assembly not visible | 15 | // Setting ComVisible to false makes the types in this assembly not visible |
16 | // to COM components. If you need to access a type in this assembly from | 16 | // to COM components. If you need to access a type in this assembly from |
17 | // COM, set the ComVisible attribute to true on that type. | 17 | // COM, set the ComVisible attribute to true on that type. |
18 | [assembly: ComVisible(false)] | 18 | [assembly: ComVisible(false)] |
19 | 19 | ||
20 | // The following GUID is for the ID of the typelib if this project is exposed to COM | 20 | // The following GUID is for the ID of the typelib if this project is exposed to COM |
21 | [assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")] | 21 | [assembly: Guid("57991e15-79da-41b7-aa06-2e6b49165a63")] |
22 | 22 | ||
23 | // Version information for an assembly consists of the following four values: | 23 | // Version information for an assembly consists of the following four values: |
24 | // | 24 | // |
25 | // Major Version | 25 | // Major Version |
26 | // Minor Version | 26 | // Minor Version |
27 | // Build Number | 27 | // Build Number |
28 | // Revision | 28 | // Revision |
29 | // | 29 | // |
30 | // You can specify all the values or you can default the Revision and Build Numbers | 30 | // You can specify all the values or you can default the Revision and Build Numbers |
31 | // by using the '*' as shown below: | 31 | // by using the '*' as shown below: |
32 | [assembly: AssemblyVersion("1.0.0.0")] | 32 | [assembly: AssemblyVersion("1.0.0.0")] |
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | 33 | [assembly: AssemblyFileVersion("1.0.0.0")] |