diff options
Diffstat (limited to 'OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | 108 |
1 files changed, 106 insertions, 2 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs index b95219c..db4deb8 100644 --- a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs +++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | |||
@@ -1,3 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (c) OpenSim project, http://sim.opensecondlife.org/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
10 | * documentation and/or other materials provided with the distribution. | ||
11 | * * Neither the name of the <organization> nor the | ||
12 | * names of its contributors may be used to endorse or promote products | ||
13 | * derived from this software without specific prior written permission. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
18 | * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY | ||
19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
25 | * | ||
26 | */ | ||
1 | using System; | 27 | using System; |
2 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
3 | using System.Text; | 29 | using System.Text; |
@@ -6,15 +32,29 @@ using libsecondlife; | |||
6 | 32 | ||
7 | namespace OpenGrid.Framework.Data.DB4o | 33 | namespace OpenGrid.Framework.Data.DB4o |
8 | { | 34 | { |
35 | /// <summary> | ||
36 | /// A User storage interface for the DB4o database system | ||
37 | /// </summary> | ||
9 | public class DB4oUserData : IUserData | 38 | public class DB4oUserData : IUserData |
10 | { | 39 | { |
40 | /// <summary> | ||
41 | /// The database manager | ||
42 | /// </summary> | ||
11 | DB4oUserManager manager; | 43 | DB4oUserManager manager; |
12 | 44 | ||
45 | /// <summary> | ||
46 | /// Artificial constructor called upon plugin load | ||
47 | /// </summary> | ||
13 | public void Initialise() | 48 | public void Initialise() |
14 | { | 49 | { |
15 | manager = new DB4oUserManager("userprofiles.yap"); | 50 | manager = new DB4oUserManager("userprofiles.yap"); |
16 | } | 51 | } |
17 | 52 | ||
53 | /// <summary> | ||
54 | /// Loads a specified user profile from a UUID | ||
55 | /// </summary> | ||
56 | /// <param name="uuid">The users UUID</param> | ||
57 | /// <returns>A user profile</returns> | ||
18 | public UserProfileData getUserByUUID(LLUUID uuid) | 58 | public UserProfileData getUserByUUID(LLUUID uuid) |
19 | { | 59 | { |
20 | if(manager.userProfiles.ContainsKey(uuid)) | 60 | if(manager.userProfiles.ContainsKey(uuid)) |
@@ -22,11 +62,22 @@ namespace OpenGrid.Framework.Data.DB4o | |||
22 | return null; | 62 | return null; |
23 | } | 63 | } |
24 | 64 | ||
65 | /// <summary> | ||
66 | /// Returns a user by searching for its name | ||
67 | /// </summary> | ||
68 | /// <param name="name">The users account name</param> | ||
69 | /// <returns>A matching users profile</returns> | ||
25 | public UserProfileData getUserByName(string name) | 70 | public UserProfileData getUserByName(string name) |
26 | { | 71 | { |
27 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | 72 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); |
28 | } | 73 | } |
29 | 74 | ||
75 | /// <summary> | ||
76 | /// Returns a user by searching for its name | ||
77 | /// </summary> | ||
78 | /// <param name="fname">The first part of the users account name</param> | ||
79 | /// <param name="lname">The second part of the users account name</param> | ||
80 | /// <returns>A matching users profile</returns> | ||
30 | public UserProfileData getUserByName(string fname, string lname) | 81 | public UserProfileData getUserByName(string fname, string lname) |
31 | { | 82 | { |
32 | foreach (UserProfileData profile in manager.userProfiles.Values) | 83 | foreach (UserProfileData profile in manager.userProfiles.Values) |
@@ -37,6 +88,11 @@ namespace OpenGrid.Framework.Data.DB4o | |||
37 | return null; | 88 | return null; |
38 | } | 89 | } |
39 | 90 | ||
91 | /// <summary> | ||
92 | /// Returns a user by UUID direct | ||
93 | /// </summary> | ||
94 | /// <param name="uuid">The users account ID</param> | ||
95 | /// <returns>A matching users profile</returns> | ||
40 | public UserAgentData getAgentByUUID(LLUUID uuid) | 96 | public UserAgentData getAgentByUUID(LLUUID uuid) |
41 | { | 97 | { |
42 | try | 98 | try |
@@ -49,11 +105,22 @@ namespace OpenGrid.Framework.Data.DB4o | |||
49 | } | 105 | } |
50 | } | 106 | } |
51 | 107 | ||
108 | /// <summary> | ||
109 | /// Returns a session by account name | ||
110 | /// </summary> | ||
111 | /// <param name="name">The account name</param> | ||
112 | /// <returns>The users session agent</returns> | ||
52 | public UserAgentData getAgentByName(string name) | 113 | public UserAgentData getAgentByName(string name) |
53 | { | 114 | { |
54 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | 115 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); |
55 | } | 116 | } |
56 | 117 | ||
118 | /// <summary> | ||
119 | /// Returns a session by account name | ||
120 | /// </summary> | ||
121 | /// <param name="fname">The first part of the users account name</param> | ||
122 | /// <param name="lname">The second part of the users account name</param> | ||
123 | /// <returns>A user agent</returns> | ||
57 | public UserAgentData getAgentByName(string fname, string lname) | 124 | public UserAgentData getAgentByName(string fname, string lname) |
58 | { | 125 | { |
59 | try | 126 | try |
@@ -66,32 +133,69 @@ namespace OpenGrid.Framework.Data.DB4o | |||
66 | } | 133 | } |
67 | } | 134 | } |
68 | 135 | ||
136 | /// <summary> | ||
137 | /// Creates a new user profile | ||
138 | /// </summary> | ||
139 | /// <param name="user">The profile to add to the database</param> | ||
69 | public void addNewUserProfile(UserProfileData user) | 140 | public void addNewUserProfile(UserProfileData user) |
70 | { | 141 | { |
71 | manager.AddRow(user); | 142 | try |
143 | { | ||
144 | manager.AddRow(user); | ||
145 | } | ||
146 | catch (Exception e) | ||
147 | { | ||
148 | Console.WriteLine(e.ToString()); | ||
149 | } | ||
72 | } | 150 | } |
73 | 151 | ||
152 | /// <summary> | ||
153 | /// Creates a new user agent | ||
154 | /// </summary> | ||
155 | /// <param name="agent">The agent to add to the database</param> | ||
74 | public void addNewUserAgent(UserAgentData agent) | 156 | public void addNewUserAgent(UserAgentData agent) |
75 | { | 157 | { |
76 | // Do nothing. yet. | 158 | // Do nothing. yet. |
77 | } | 159 | } |
78 | 160 | ||
161 | /// <summary> | ||
162 | /// Transfers money between two user accounts | ||
163 | /// </summary> | ||
164 | /// <param name="from">Starting account</param> | ||
165 | /// <param name="to">End account</param> | ||
166 | /// <param name="amount">The amount to move</param> | ||
167 | /// <returns>Success?</returns> | ||
79 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | 168 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) |
80 | { | 169 | { |
81 | return true; | 170 | return true; |
82 | } | 171 | } |
83 | 172 | ||
173 | /// <summary> | ||
174 | /// Transfers inventory between two accounts | ||
175 | /// </summary> | ||
176 | /// <remarks>Move to inventory server</remarks> | ||
177 | /// <param name="from">Senders account</param> | ||
178 | /// <param name="to">Recievers account</param> | ||
179 | /// <param name="item">Inventory item</param> | ||
180 | /// <returns>Success?</returns> | ||
84 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | 181 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) |
85 | { | 182 | { |
86 | return true; | 183 | return true; |
87 | } | 184 | } |
88 | 185 | ||
89 | 186 | /// <summary> | |
187 | /// Returns the name of the storage provider | ||
188 | /// </summary> | ||
189 | /// <returns>Storage provider name</returns> | ||
90 | public string getName() | 190 | public string getName() |
91 | { | 191 | { |
92 | return "DB4o Userdata"; | 192 | return "DB4o Userdata"; |
93 | } | 193 | } |
94 | 194 | ||
195 | /// <summary> | ||
196 | /// Returns the version of the storage provider | ||
197 | /// </summary> | ||
198 | /// <returns>Storage provider version</returns> | ||
95 | public string getVersion() | 199 | public string getVersion() |
96 | { | 200 | { |
97 | return "0.1"; | 201 | return "0.1"; |