diff options
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs | 205 |
1 files changed, 0 insertions, 205 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs deleted file mode 100644 index 315f48d..0000000 --- a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs +++ /dev/null | |||
@@ -1,205 +0,0 @@ | |||
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 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using OpenGrid.Framework.Data; | ||
32 | using libsecondlife; | ||
33 | |||
34 | namespace OpenGrid.Framework.Data.DB4o | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// A User storage interface for the DB4o database system | ||
38 | /// </summary> | ||
39 | public class DB4oUserData : IUserData | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// The database manager | ||
43 | /// </summary> | ||
44 | DB4oUserManager manager; | ||
45 | |||
46 | /// <summary> | ||
47 | /// Artificial constructor called upon plugin load | ||
48 | /// </summary> | ||
49 | public void Initialise() | ||
50 | { | ||
51 | manager = new DB4oUserManager("userprofiles.yap"); | ||
52 | } | ||
53 | |||
54 | /// <summary> | ||
55 | /// Loads a specified user profile from a UUID | ||
56 | /// </summary> | ||
57 | /// <param name="uuid">The users UUID</param> | ||
58 | /// <returns>A user profile</returns> | ||
59 | public UserProfileData getUserByUUID(LLUUID uuid) | ||
60 | { | ||
61 | if(manager.userProfiles.ContainsKey(uuid)) | ||
62 | return manager.userProfiles[uuid]; | ||
63 | return null; | ||
64 | } | ||
65 | |||
66 | /// <summary> | ||
67 | /// Returns a user by searching for its name | ||
68 | /// </summary> | ||
69 | /// <param name="name">The users account name</param> | ||
70 | /// <returns>A matching users profile</returns> | ||
71 | public UserProfileData getUserByName(string name) | ||
72 | { | ||
73 | return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
74 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Returns a user by searching for its name | ||
78 | /// </summary> | ||
79 | /// <param name="fname">The first part of the users account name</param> | ||
80 | /// <param name="lname">The second part of the users account name</param> | ||
81 | /// <returns>A matching users profile</returns> | ||
82 | public UserProfileData getUserByName(string fname, string lname) | ||
83 | { | ||
84 | foreach (UserProfileData profile in manager.userProfiles.Values) | ||
85 | { | ||
86 | if (profile.username == fname && profile.surname == lname) | ||
87 | return profile; | ||
88 | } | ||
89 | return null; | ||
90 | } | ||
91 | |||
92 | /// <summary> | ||
93 | /// Returns a user by UUID direct | ||
94 | /// </summary> | ||
95 | /// <param name="uuid">The users account ID</param> | ||
96 | /// <returns>A matching users profile</returns> | ||
97 | public UserAgentData getAgentByUUID(LLUUID uuid) | ||
98 | { | ||
99 | try | ||
100 | { | ||
101 | return getUserByUUID(uuid).currentAgent; | ||
102 | } | ||
103 | catch (Exception e) | ||
104 | { | ||
105 | return null; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | /// <summary> | ||
110 | /// Returns a session by account name | ||
111 | /// </summary> | ||
112 | /// <param name="name">The account name</param> | ||
113 | /// <returns>The users session agent</returns> | ||
114 | public UserAgentData getAgentByName(string name) | ||
115 | { | ||
116 | return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); | ||
117 | } | ||
118 | |||
119 | /// <summary> | ||
120 | /// Returns a session by account name | ||
121 | /// </summary> | ||
122 | /// <param name="fname">The first part of the users account name</param> | ||
123 | /// <param name="lname">The second part of the users account name</param> | ||
124 | /// <returns>A user agent</returns> | ||
125 | public UserAgentData getAgentByName(string fname, string lname) | ||
126 | { | ||
127 | try | ||
128 | { | ||
129 | return getUserByName(fname,lname).currentAgent; | ||
130 | } | ||
131 | catch (Exception e) | ||
132 | { | ||
133 | return null; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | /// <summary> | ||
138 | /// Creates a new user profile | ||
139 | /// </summary> | ||
140 | /// <param name="user">The profile to add to the database</param> | ||
141 | public void addNewUserProfile(UserProfileData user) | ||
142 | { | ||
143 | try | ||
144 | { | ||
145 | manager.AddRow(user); | ||
146 | } | ||
147 | catch (Exception e) | ||
148 | { | ||
149 | Console.WriteLine(e.ToString()); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /// <summary> | ||
154 | /// Creates a new user agent | ||
155 | /// </summary> | ||
156 | /// <param name="agent">The agent to add to the database</param> | ||
157 | public void addNewUserAgent(UserAgentData agent) | ||
158 | { | ||
159 | // Do nothing. yet. | ||
160 | } | ||
161 | |||
162 | /// <summary> | ||
163 | /// Transfers money between two user accounts | ||
164 | /// </summary> | ||
165 | /// <param name="from">Starting account</param> | ||
166 | /// <param name="to">End account</param> | ||
167 | /// <param name="amount">The amount to move</param> | ||
168 | /// <returns>Success?</returns> | ||
169 | public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) | ||
170 | { | ||
171 | return true; | ||
172 | } | ||
173 | |||
174 | /// <summary> | ||
175 | /// Transfers inventory between two accounts | ||
176 | /// </summary> | ||
177 | /// <remarks>Move to inventory server</remarks> | ||
178 | /// <param name="from">Senders account</param> | ||
179 | /// <param name="to">Recievers account</param> | ||
180 | /// <param name="item">Inventory item</param> | ||
181 | /// <returns>Success?</returns> | ||
182 | public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) | ||
183 | { | ||
184 | return true; | ||
185 | } | ||
186 | |||
187 | /// <summary> | ||
188 | /// Returns the name of the storage provider | ||
189 | /// </summary> | ||
190 | /// <returns>Storage provider name</returns> | ||
191 | public string getName() | ||
192 | { | ||
193 | return "DB4o Userdata"; | ||
194 | } | ||
195 | |||
196 | /// <summary> | ||
197 | /// Returns the version of the storage provider | ||
198 | /// </summary> | ||
199 | /// <returns>Storage provider version</returns> | ||
200 | public string getVersion() | ||
201 | { | ||
202 | return "0.1"; | ||
203 | } | ||
204 | } | ||
205 | } | ||