aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/DB4o/DB4oUserData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/DB4o/DB4oUserData.cs')
-rw-r--r--OpenSim/Data/DB4o/DB4oUserData.cs271
1 files changed, 0 insertions, 271 deletions
diff --git a/OpenSim/Data/DB4o/DB4oUserData.cs b/OpenSim/Data/DB4o/DB4oUserData.cs
deleted file mode 100644
index 4a2fc9c..0000000
--- a/OpenSim/Data/DB4o/DB4oUserData.cs
+++ /dev/null
@@ -1,271 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using libsecondlife;
32using OpenSim.Framework;
33
34namespace OpenSim.Data.DB4o
35{
36 /// <summary>
37 /// A User storage interface for the DB4o database system
38 /// </summary>
39 public class DB4oUserData : IUserData
40 {
41 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42
43 /// <summary>
44 /// The database manager
45 /// </summary>
46 private DB4oUserManager manager;
47
48 /// <summary>
49 /// Artificial constructor called upon plugin load
50 /// </summary>
51 public void Initialise()
52 {
53 manager = new DB4oUserManager(Path.Combine(Util.dataDir(), "userprofiles.yap"));
54 }
55
56 /// <summary>
57 /// Loads a specified user profile from a UUID
58 /// </summary>
59 /// <param name="uuid">The users UUID</param>
60 /// <returns>A user profile</returns>
61 public UserProfileData GetUserByUUID(LLUUID uuid)
62 {
63 if (manager.userProfiles.ContainsKey(uuid))
64 return manager.userProfiles[uuid];
65 return null;
66 }
67
68 /// <summary>
69 /// Returns a user by searching for its name
70 /// </summary>
71 /// <param name="name">The users account name</param>
72 /// <returns>A matching users profile</returns>
73 public UserProfileData GetUserByName(string name)
74 {
75 return GetUserByName(name.Split(' ')[0], name.Split(' ')[1]);
76 }
77
78 /// <summary>
79 /// Returns a user by searching for its name
80 /// </summary>
81 /// <param name="fname">The first part of the users account name</param>
82 /// <param name="lname">The second part of the users account name</param>
83 /// <returns>A matching users profile</returns>
84 public UserProfileData GetUserByName(string fname, string lname)
85 {
86 foreach (UserProfileData profile in manager.userProfiles.Values)
87 {
88 if (profile.FirstName == fname && profile.SurName == lname)
89 return profile;
90 }
91 return null;
92 }
93
94 /// <summary>
95 /// Returns a user by UUID direct
96 /// </summary>
97 /// <param name="uuid">The users account ID</param>
98 /// <returns>A matching users profile</returns>
99 public UserAgentData GetAgentByUUID(LLUUID uuid)
100 {
101 try
102 {
103 return GetUserByUUID(uuid).CurrentAgent;
104 }
105 catch (Exception)
106 {
107 return null;
108 }
109 }
110
111 /// <summary>
112 /// Returns a session by account name
113 /// </summary>
114 /// <param name="name">The account name</param>
115 /// <returns>The users session agent</returns>
116 public UserAgentData GetAgentByName(string name)
117 {
118 return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
119 }
120
121 /// <summary>
122 /// Returns a session by account name
123 /// </summary>
124 /// <param name="fname">The first part of the users account name</param>
125 /// <param name="lname">The second part of the users account name</param>
126 /// <returns>A user agent</returns>
127 public UserAgentData GetAgentByName(string fname, string lname)
128 {
129 try
130 {
131 return GetUserByName(fname, lname).CurrentAgent;
132 }
133 catch (Exception)
134 {
135 return null;
136 }
137 }
138 public void StoreWebLoginKey(LLUUID AgentID, LLUUID WebLoginKey)
139 {
140 UserProfileData user = GetUserByUUID(AgentID);
141 user.WebLoginKey = WebLoginKey;
142 UpdateUserProfile(user);
143
144 }
145 #region User Friends List Data
146
147 public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms)
148 {
149 //m_log.Info("[FRIEND]: Stub AddNewUserFriend called");
150 }
151
152 public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend)
153 {
154 //m_log.Info("[FRIEND]: Stub RemoveUserFriend called");
155 }
156 public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms)
157 {
158 //m_log.Info("[FRIEND]: Stub UpdateUserFriendPerms called");
159 }
160
161
162 public List<FriendListItem> GetUserFriendList(LLUUID friendlistowner)
163 {
164 //m_log.Info("[FRIEND]: Stub GetUserFriendList called");
165 return new List<FriendListItem>();
166 }
167
168 #endregion
169
170 public void UpdateUserCurrentRegion(LLUUID avatarid, LLUUID regionuuid)
171 {
172 //m_log.Info("[USER]: Stub UpdateUserCUrrentRegion called");
173 }
174
175
176
177 public List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query)
178 {
179 //Do nothing yet
180 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
181 return returnlist;
182 }
183
184 /// <summary>
185 /// Creates a new user profile
186 /// </summary>
187 /// <param name="user">The profile to add to the database</param>
188 public void AddNewUserProfile(UserProfileData user)
189 {
190 try
191 {
192 manager.UpdateRecord(user);
193 }
194 catch (Exception e)
195 {
196 Console.WriteLine(e.ToString());
197 }
198 }
199
200 /// <summary>
201 /// Creates a new user profile
202 /// </summary>
203 /// <param name="user">The profile to add to the database</param>
204 /// <returns>True on success, false on error</returns>
205 public bool UpdateUserProfile(UserProfileData user)
206 {
207 try
208 {
209 return manager.UpdateRecord(user);
210 }
211 catch (Exception e)
212 {
213 Console.WriteLine(e.ToString());
214 return false;
215 }
216 }
217
218
219 /// <summary>
220 /// Creates a new user agent
221 /// </summary>
222 /// <param name="agent">The agent to add to the database</param>
223 public void AddNewUserAgent(UserAgentData agent)
224 {
225 // Do nothing. yet.
226 }
227
228 /// <summary>
229 /// Transfers money between two user accounts
230 /// </summary>
231 /// <param name="from">Starting account</param>
232 /// <param name="to">End account</param>
233 /// <param name="amount">The amount to move</param>
234 /// <returns>Success?</returns>
235 public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
236 {
237 return true;
238 }
239
240 /// <summary>
241 /// Transfers inventory between two accounts
242 /// </summary>
243 /// <remarks>Move to inventory server</remarks>
244 /// <param name="from">Senders account</param>
245 /// <param name="to">Receivers account</param>
246 /// <param name="item">Inventory item</param>
247 /// <returns>Success?</returns>
248 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
249 {
250 return true;
251 }
252
253 /// <summary>
254 /// Returns the name of the storage provider
255 /// </summary>
256 /// <returns>Storage provider name</returns>
257 public string getName()
258 {
259 return "DB4o Userdata";
260 }
261
262 /// <summary>
263 /// Returns the version of the storage provider
264 /// </summary>
265 /// <returns>Storage provider version</returns>
266 public string GetVersion()
267 {
268 return "0.1";
269 }
270 }
271}