aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteUserData.cs
diff options
context:
space:
mode:
authorDiva Canto2010-02-21 15:38:52 -0800
committerDiva Canto2010-02-21 15:38:52 -0800
commitbb171717ceaef37b022a135209c2e0bf031d21f9 (patch)
tree2239ad031280027839b22c4f3c9df1a598a63228 /OpenSim/Data/SQLite/SQLiteUserData.cs
parentBug fixes on field names in order to make data import work from old users tab... (diff)
downloadopensim-SC_OLD-bb171717ceaef37b022a135209c2e0bf031d21f9.zip
opensim-SC_OLD-bb171717ceaef37b022a135209c2e0bf031d21f9.tar.gz
opensim-SC_OLD-bb171717ceaef37b022a135209c2e0bf031d21f9.tar.bz2
opensim-SC_OLD-bb171717ceaef37b022a135209c2e0bf031d21f9.tar.xz
Deleted obsolete files in the Data layer. Compiles.
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteUserData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteUserData.cs1262
1 files changed, 0 insertions, 1262 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteUserData.cs b/OpenSim/Data/SQLite/SQLiteUserData.cs
deleted file mode 100644
index caddcf8..0000000
--- a/OpenSim/Data/SQLite/SQLiteUserData.cs
+++ /dev/null
@@ -1,1262 +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 OpenSimulator 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.Data;
31using System.Reflection;
32using log4net;
33using Mono.Data.SqliteClient;
34using OpenMetaverse;
35using OpenSim.Framework;
36
37namespace OpenSim.Data.SQLite
38{
39 /// <summary>
40 /// A User storage interface for the SQLite database system
41 /// </summary>
42 public class SQLiteUserData : UserDataBase
43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45
46 /// <summary>
47 /// The database manager
48 /// </summary>
49 /// <summary>
50 /// Artificial constructor called upon plugin load
51 /// </summary>
52 private const string SelectUserByUUID = "select * from users where UUID=:UUID";
53 private const string SelectUserByName = "select * from users where username=:username and surname=:surname";
54 private const string SelectFriendsByUUID = "select a.friendID, a.friendPerms, b.friendPerms from userfriends as a, userfriends as b where a.ownerID=:ownerID and b.ownerID=a.friendID and b.friendID=a.ownerID";
55
56 private const string userSelect = "select * from users";
57 private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b";
58 private const string userAgentSelect = "select * from useragents";
59 private const string AvatarAppearanceSelect = "select * from avatarappearance";
60
61 private const string AvatarPickerAndSQL = "select * from users where username like :username and surname like :surname";
62 private const string AvatarPickerOrSQL = "select * from users where username like :username or surname like :surname";
63
64 private DataSet ds;
65 private SqliteDataAdapter da;
66 private SqliteDataAdapter daf;
67 private SqliteDataAdapter dua;
68 private SqliteDataAdapter daa;
69 SqliteConnection g_conn;
70
71 public override void Initialise()
72 {
73 m_log.Info("[SQLiteUserData]: " + Name + " cannot be default-initialized!");
74 throw new PluginNotInitialisedException (Name);
75 }
76
77 /// <summary>
78 /// <list type="bullet">
79 /// <item>Initialises User Interface</item>
80 /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
81 /// <item>use default URI if connect string string is empty.</item>
82 /// </list>
83 /// </summary>
84 /// <param name="connect">connect string</param>
85 override public void Initialise(string connect)
86 {
87 // default to something sensible
88 if (connect == "")
89 connect = "URI=file:userprofiles.db,version=3";
90
91 SqliteConnection conn = new SqliteConnection(connect);
92
93 // This sucks, but It doesn't seem to work with the dataset Syncing :P
94 g_conn = conn;
95 g_conn.Open();
96
97 Assembly assem = GetType().Assembly;
98 Migration m = new Migration(g_conn, assem, "UserStore");
99 m.Update();
100
101
102 ds = new DataSet();
103 da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn));
104 dua = new SqliteDataAdapter(new SqliteCommand(userAgentSelect, conn));
105 daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn));
106 daa = new SqliteDataAdapter(new SqliteCommand(AvatarAppearanceSelect, conn));
107 //if (daa == null) m_log.Info("[SQLiteUserData]: daa = null");
108
109 lock (ds)
110 {
111 ds.Tables.Add(createUsersTable());
112 ds.Tables.Add(createUserAgentsTable());
113 ds.Tables.Add(createUserFriendsTable());
114 ds.Tables.Add(createAvatarAppearanceTable());
115
116 setupUserCommands(da, conn);
117 da.Fill(ds.Tables["users"]);
118
119 setupAgentCommands(dua, conn);
120 dua.Fill(ds.Tables["useragents"]);
121
122 setupUserFriendsCommands(daf, conn);
123 daf.Fill(ds.Tables["userfriends"]);
124
125 setupAvatarAppearanceCommands(daa, conn);
126 daa.Fill(ds.Tables["avatarappearance"]);
127 }
128
129 return;
130 }
131
132 public override void Dispose ()
133 {
134 if (g_conn != null)
135 {
136 g_conn.Close();
137 g_conn = null;
138 }
139 if (ds != null)
140 {
141 ds.Dispose();
142 ds = null;
143 }
144 if (da != null)
145 {
146 da.Dispose();
147 da = null;
148 }
149 if (daf != null)
150 {
151 daf.Dispose();
152 daf = null;
153 }
154 if (dua != null)
155 {
156 dua.Dispose();
157 dua = null;
158 }
159 if (daa != null)
160 {
161 daa.Dispose();
162 daa = null;
163 }
164 }
165
166 /// <summary>
167 /// see IUserDataPlugin,
168 /// Get user data profile by UUID
169 /// </summary>
170 /// <param name="uuid">User UUID</param>
171 /// <returns>user profile data</returns>
172 override public UserProfileData GetUserByUUID(UUID uuid)
173 {
174 lock (ds)
175 {
176 DataRow row = ds.Tables["users"].Rows.Find(uuid.ToString());
177 if (row != null)
178 {
179 UserProfileData user = buildUserProfile(row);
180 return user;
181 }
182 else
183 {
184 return null;
185 }
186 }
187 }
188
189 /// <summary>
190 /// see IUserDataPlugin,
191 /// Get user data profile by name
192 /// </summary>
193 /// <param name="fname">first name</param>
194 /// <param name="lname">last name</param>
195 /// <returns>user profile data</returns>
196 override public UserProfileData GetUserByName(string fname, string lname)
197 {
198 string select = "surname = '" + lname + "' and username = '" + fname + "'";
199 lock (ds)
200 {
201 DataRow[] rows = ds.Tables["users"].Select(select);
202 if (rows.Length > 0)
203 {
204 UserProfileData user = buildUserProfile(rows[0]);
205 return user;
206 }
207 else
208 {
209 return null;
210 }
211 }
212 }
213
214 #region User Friends List Data
215
216 private bool ExistsFriend(UUID owner, UUID friend)
217 {
218 string FindFriends = "select * from userfriends where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)";
219 using (SqliteCommand cmd = new SqliteCommand(FindFriends, g_conn))
220 {
221 cmd.Parameters.Add(new SqliteParameter(":ownerID", owner.ToString()));
222 cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString()));
223 try
224 {
225 using (IDataReader reader = cmd.ExecuteReader())
226 {
227 if (reader.Read())
228 {
229 reader.Close();
230 return true;
231 }
232 else
233 {
234 reader.Close();
235 return false;
236 }
237 }
238 }
239 catch (Exception ex)
240 {
241 m_log.Error("[USER DB]: Exception getting friends list for user: " + ex.ToString());
242 return false;
243 }
244 }
245 }
246 /// <summary>
247 /// Add a new friend in the friendlist
248 /// </summary>
249 /// <param name="friendlistowner">UUID of the friendlist owner</param>
250 /// <param name="friend">UUID of the friend to add</param>
251 /// <param name="perms">permission flag</param>
252 override public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
253 {
254 if (ExistsFriend(friendlistowner, friend))
255 return;
256
257 string InsertFriends = "insert into userfriends(ownerID, friendID, friendPerms) values(:ownerID, :friendID, :perms)";
258 using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn))
259 {
260 cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));
261 cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString()));
262 cmd.Parameters.Add(new SqliteParameter(":perms", perms));
263 cmd.ExecuteNonQuery();
264 }
265 using (SqliteCommand cmd = new SqliteCommand(InsertFriends, g_conn))
266 {
267 cmd.Parameters.Add(new SqliteParameter(":ownerID", friend.ToString()));
268 cmd.Parameters.Add(new SqliteParameter(":friendID", friendlistowner.ToString()));
269 cmd.Parameters.Add(new SqliteParameter(":perms", perms));
270 cmd.ExecuteNonQuery();
271 }
272 }
273
274 /// <summary>
275 /// Remove a user from the friendlist
276 /// </summary>
277 /// <param name="friendlistowner">UUID of the friendlist owner</param>
278 /// <param name="friend">UUID of the friend to remove</param>
279 override public void RemoveUserFriend(UUID friendlistowner, UUID friend)
280 {
281 string DeletePerms = "delete from userfriends where (ownerID=:ownerID and friendID=:friendID) or (ownerID=:friendID and friendID=:ownerID)";
282 using (SqliteCommand cmd = new SqliteCommand(DeletePerms, g_conn))
283 {
284 cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));
285 cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString()));
286 cmd.ExecuteNonQuery();
287 }
288 }
289
290 /// <summary>
291 /// Update the friendlist permission
292 /// </summary>
293 /// <param name="friendlistowner">UUID of the friendlist owner</param>
294 /// <param name="friend">UUID of the friend to modify</param>
295 /// <param name="perms">updated permission flag</param>
296 override public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
297 {
298 string UpdatePerms = "update userfriends set friendPerms=:perms where ownerID=:ownerID and friendID=:friendID";
299 using (SqliteCommand cmd = new SqliteCommand(UpdatePerms, g_conn))
300 {
301 cmd.Parameters.Add(new SqliteParameter(":perms", perms));
302 cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));
303 cmd.Parameters.Add(new SqliteParameter(":friendID", friend.ToString()));
304 cmd.ExecuteNonQuery();
305 }
306 }
307
308 /// <summary>
309 /// Get (fetch?) the friendlist for a user
310 /// </summary>
311 /// <param name="friendlistowner">UUID of the friendlist owner</param>
312 /// <returns>The friendlist list</returns>
313 override public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
314 {
315 List<FriendListItem> returnlist = new List<FriendListItem>();
316
317 using (SqliteCommand cmd = new SqliteCommand(SelectFriendsByUUID, g_conn))
318 {
319 cmd.Parameters.Add(new SqliteParameter(":ownerID", friendlistowner.ToString()));
320
321 try
322 {
323 using (IDataReader reader = cmd.ExecuteReader())
324 {
325 while (reader.Read())
326 {
327 FriendListItem user = new FriendListItem();
328 user.FriendListOwner = friendlistowner;
329 user.Friend = new UUID((string)reader[0]);
330 user.FriendPerms = Convert.ToUInt32(reader[1]);
331 user.FriendListOwnerPerms = Convert.ToUInt32(reader[2]);
332 returnlist.Add(user);
333 }
334 reader.Close();
335 }
336 }
337 catch (Exception ex)
338 {
339 m_log.Error("[USER DB]: Exception getting friends list for user: " + ex.ToString());
340 }
341 }
342
343 return returnlist;
344 }
345
346 override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
347 {
348 Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
349
350 DataTable agents = ds.Tables["useragents"];
351 foreach (UUID uuid in uuids)
352 {
353 lock (ds)
354 {
355 DataRow row = agents.Rows.Find(uuid.ToString());
356 if (row == null) infos[uuid] = null;
357 else
358 {
359 FriendRegionInfo fri = new FriendRegionInfo();
360 fri.isOnline = (bool)row["agentOnline"];
361 fri.regionHandle = Convert.ToUInt64(row["currentHandle"]);
362 infos[uuid] = fri;
363 }
364 }
365 }
366 return infos;
367 }
368
369 #endregion
370
371 /// <summary>
372 ///
373 /// </summary>
374 /// <param name="queryID"></param>
375 /// <param name="query"></param>
376 /// <returns></returns>
377 override public List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
378 {
379 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
380 string[] querysplit;
381 querysplit = query.Split(' ');
382 if (querysplit.Length == 2)
383 {
384 using (SqliteCommand cmd = new SqliteCommand(AvatarPickerAndSQL, g_conn))
385 {
386 cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
387 cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[1] + "%"));
388
389 using (IDataReader reader = cmd.ExecuteReader())
390 {
391 while (reader.Read())
392 {
393 AvatarPickerAvatar user = new AvatarPickerAvatar();
394 user.AvatarID = new UUID((string) reader["UUID"]);
395 user.firstName = (string) reader["username"];
396 user.lastName = (string) reader["surname"];
397 returnlist.Add(user);
398 }
399 reader.Close();
400 }
401 }
402 }
403 else if (querysplit.Length == 1)
404 {
405 using (SqliteCommand cmd = new SqliteCommand(AvatarPickerOrSQL, g_conn))
406 {
407 cmd.Parameters.Add(new SqliteParameter(":username", querysplit[0] + "%"));
408 cmd.Parameters.Add(new SqliteParameter(":surname", querysplit[0] + "%"));
409
410 using (IDataReader reader = cmd.ExecuteReader())
411 {
412 while (reader.Read())
413 {
414 AvatarPickerAvatar user = new AvatarPickerAvatar();
415 user.AvatarID = new UUID((string) reader["UUID"]);
416 user.firstName = (string) reader["username"];
417 user.lastName = (string) reader["surname"];
418 returnlist.Add(user);
419 }
420 reader.Close();
421 }
422 }
423 }
424 return returnlist;
425 }
426
427 /// <summary>
428 /// Returns a user by UUID direct
429 /// </summary>
430 /// <param name="uuid">The user's account ID</param>
431 /// <returns>A matching user profile</returns>
432 override public UserAgentData GetAgentByUUID(UUID uuid)
433 {
434 lock (ds)
435 {
436 DataRow row = ds.Tables["useragents"].Rows.Find(uuid.ToString());
437 if (row != null)
438 {
439 return buildUserAgent(row);
440 }
441 else
442 {
443 return null;
444 }
445 }
446 }
447
448 /// <summary>
449 /// Returns a session by account name
450 /// </summary>
451 /// <param name="name">The account name</param>
452 /// <returns>The user's session agent</returns>
453 override public UserAgentData GetAgentByName(string name)
454 {
455 return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
456 }
457
458 /// <summary>
459 /// Returns a session by account name
460 /// </summary>
461 /// <param name="fname">The first part of the user's account name</param>
462 /// <param name="lname">The second part of the user's account name</param>
463 /// <returns>A user agent</returns>
464 override public UserAgentData GetAgentByName(string fname, string lname)
465 {
466 UserAgentData agent = null;
467
468 UserProfileData profile = GetUserByName(fname, lname);
469 if (profile != null)
470 {
471 agent = GetAgentByUUID(profile.ID);
472 }
473 return agent;
474 }
475
476 /// <summary>
477 /// DEPRECATED? Store the weblogin key
478 /// </summary>
479 /// <param name="AgentID">UUID of the user</param>
480 /// <param name="WebLoginKey">UUID of the weblogin</param>
481 override public void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey)
482 {
483 DataTable users = ds.Tables["users"];
484 lock (ds)
485 {
486 DataRow row = users.Rows.Find(AgentID.ToString());
487 if (row == null)
488 {
489 m_log.Warn("[USER DB]: Unable to store new web login key for non-existant user");
490 }
491 else
492 {
493 UserProfileData user = GetUserByUUID(AgentID);
494 user.WebLoginKey = WebLoginKey;
495 fillUserRow(row, user);
496 da.Update(ds, "users");
497 }
498 }
499 }
500
501 private bool ExistsFirstLastName(String fname, String lname)
502 {
503 string FindUser = "select * from users where (username=:username and surname=:surname)";
504 using (SqliteCommand cmd = new SqliteCommand(FindUser, g_conn))
505 {
506 cmd.Parameters.Add(new SqliteParameter(":username", fname));
507 cmd.Parameters.Add(new SqliteParameter(":surname", lname));
508 try
509 {
510 using (IDataReader reader = cmd.ExecuteReader())
511 {
512 if (reader.Read())
513 {
514 reader.Close();
515 return true;
516 }
517 else
518 {
519 reader.Close();
520 return false;
521 }
522 }
523 }
524 catch (Exception ex)
525 {
526 m_log.Error("[USER DB]: Exception searching for user's first and last name: " + ex.ToString());
527 return false;
528 }
529 }
530 }
531
532 /// <summary>
533 /// Creates a new user profile
534 /// </summary>
535 /// <param name="user">The profile to add to the database</param>
536 override public void AddNewUserProfile(UserProfileData user)
537 {
538 DataTable users = ds.Tables["users"];
539 UUID zero = UUID.Zero;
540 if (ExistsFirstLastName(user.FirstName, user.SurName) || user.ID == zero)
541 return;
542
543 lock (ds)
544 {
545 DataRow row = users.Rows.Find(user.ID.ToString());
546 if (row == null)
547 {
548 row = users.NewRow();
549 fillUserRow(row, user);
550 users.Rows.Add(row);
551
552 m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");
553
554 // save changes off to disk
555 da.Update(ds, "users");
556 }
557 else
558 {
559 m_log.WarnFormat("[USER DB]: Ignoring add since user with id {0} already exists", user.ID);
560 }
561 }
562 }
563
564 /// <summary>
565 /// Creates a new user profile
566 /// </summary>
567 /// <param name="user">The profile to add to the database</param>
568 /// <returns>True on success, false on error</returns>
569 override public bool UpdateUserProfile(UserProfileData user)
570 {
571 DataTable users = ds.Tables["users"];
572 lock (ds)
573 {
574 DataRow row = users.Rows.Find(user.ID.ToString());
575 if (row == null)
576 {
577 return false;
578 }
579 else
580 {
581 fillUserRow(row, user);
582 da.Update(ds, "users");
583 }
584 }
585
586 //AddNewUserProfile(user);
587 return true;
588 }
589
590 /// <summary>
591 /// Creates a new user agent
592 /// </summary>
593 /// <param name="agent">The agent to add to the database</param>
594 override public void AddNewUserAgent(UserAgentData agent)
595 {
596 UUID zero = UUID.Zero;
597 if (agent.SessionID == zero || agent.ProfileID == zero)
598 return;
599
600 DataTable agents = ds.Tables["useragents"];
601 lock (ds)
602 {
603 DataRow row = agents.Rows.Find(agent.ProfileID.ToString());
604 if (row == null)
605 {
606 row = agents.NewRow();
607 fillUserAgentRow(row, agent);
608 agents.Rows.Add(row);
609 }
610 else
611 {
612 fillUserAgentRow(row, agent);
613
614 }
615 m_log.Info("[USER DB]: Syncing useragent database: " + ds.Tables["useragents"].Rows.Count + " agents stored");
616 // save changes off to disk
617 dua.Update(ds, "useragents");
618 }
619 }
620
621 /// <summary>
622 /// Transfers money between two user accounts
623 /// </summary>
624 /// <param name="from">Starting account</param>
625 /// <param name="to">End account</param>
626 /// <param name="amount">The amount to move</param>
627 /// <returns>Success?</returns>
628 override public bool MoneyTransferRequest(UUID from, UUID to, uint amount)
629 {
630 return false; // for consistency with the MySQL impl
631 }
632
633 /// <summary>
634 /// Transfers inventory between two accounts
635 /// </summary>
636 /// <remarks>Move to inventory server</remarks>
637 /// <param name="from">Senders account</param>
638 /// <param name="to">Receivers account</param>
639 /// <param name="item">Inventory item</param>
640 /// <returns>Success?</returns>
641 override public bool InventoryTransferRequest(UUID from, UUID to, UUID item)
642 {
643 return false; //for consistency with the MySQL impl
644 }
645
646
647 /// <summary>
648 /// Appearance.
649 /// TODO: stubs for now to do in memory appearance.
650 /// </summary>
651 /// <param name="user">The user UUID</param>
652 /// <returns>Avatar Appearence</returns>
653 override public AvatarAppearance GetUserAppearance(UUID user)
654 {
655 m_log.Info("[APPEARANCE] GetUserAppearance " + user.ToString());
656
657 AvatarAppearance aa = new AvatarAppearance(user);
658 //try {
659 aa.Owner = user;
660
661 DataTable aap = ds.Tables["avatarappearance"];
662 lock (ds)
663 {
664 DataRow row = aap.Rows.Find(Util.ToRawUuidString(user));
665 if (row == null)
666 {
667 m_log.Info("[APPEARANCE] Could not find appearance for " + user.ToString());
668
669 //m_log.Debug("[USER DB]: Creating avatarappearance For: " + user.ToString());
670
671 //row = aap.NewRow();
672 //fillAvatarAppearanceRow(row, user, appearance);
673 //aap.Rows.Add(row);
674 // m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");
675 // save changes off to disk
676 //daa.Update(ds, "avatarappearance");
677 }
678 else
679 {
680 m_log.InfoFormat("[APPEARANCE] appearance found for {0}", user.ToString());
681
682 aa.BodyAsset = new UUID((String)row["BodyAsset"]);
683 aa.BodyItem = new UUID((String)row["BodyItem"]);
684 aa.SkinItem = new UUID((String)row["SkinItem"]);
685 aa.SkinAsset = new UUID((String)row["SkinAsset"]);
686 aa.HairItem = new UUID((String)row["HairItem"]);
687 aa.HairAsset = new UUID((String)row["HairAsset"]);
688 aa.EyesItem = new UUID((String)row["EyesItem"]);
689 aa.EyesAsset = new UUID((String)row["EyesAsset"]);
690 aa.ShirtItem = new UUID((String)row["ShirtItem"]);
691 aa.ShirtAsset = new UUID((String)row["ShirtAsset"]);
692 aa.PantsItem = new UUID((String)row["PantsItem"]);
693 aa.PantsAsset = new UUID((String)row["PantsAsset"]);
694 aa.ShoesItem = new UUID((String)row["ShoesItem"]);
695 aa.ShoesAsset = new UUID((String)row["ShoesAsset"]);
696 aa.SocksItem = new UUID((String)row["SocksItem"]);
697 aa.SocksAsset = new UUID((String)row["SocksAsset"]);
698 aa.JacketItem = new UUID((String)row["JacketItem"]);
699 aa.JacketAsset = new UUID((String)row["JacketAsset"]);
700 aa.GlovesItem = new UUID((String)row["GlovesItem"]);
701 aa.GlovesAsset = new UUID((String)row["GlovesAsset"]);
702 aa.UnderShirtItem = new UUID((String)row["UnderShirtItem"]);
703 aa.UnderShirtAsset = new UUID((String)row["UnderShirtAsset"]);
704 aa.UnderPantsItem = new UUID((String)row["UnderPantsItem"]);
705 aa.UnderPantsAsset = new UUID((String)row["UnderPantsAsset"]);
706 aa.SkirtItem = new UUID((String)row["SkirtItem"]);
707 aa.SkirtAsset = new UUID((String)row["SkirtAsset"]);
708
709 // Ewe Loon
710 // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date)
711
712 String str = (String)row["Texture"];
713 byte[] texture = Convert.FromBase64String(str);
714 aa.Texture = new Primitive.TextureEntry(texture, 0, texture.Length);
715
716 str = (String)row["VisualParams"];
717 byte[] VisualParams = Convert.FromBase64String(str);
718 aa.VisualParams = VisualParams;
719
720 aa.Serial = Convert.ToInt32(row["Serial"]);
721 aa.AvatarHeight = Convert.ToSingle(row["AvatarHeight"]);
722 m_log.InfoFormat("[APPEARANCE] appearance set for {0}", user.ToString());
723 }
724 }
725
726 // m_log.Info("[APPEARANCE] Found appearance for " + user.ToString() + aa.ToString());
727 // } catch (KeyNotFoundException) {
728 // m_log.InfoFormat("[APPEARANCE] No appearance found for {0}", user.ToString());
729 // }
730 return aa;
731 }
732
733 /// <summary>
734 /// Update a user appearence
735 /// </summary>
736 /// <param name="user">the user UUID</param>
737 /// <param name="appearance">appearence</param>
738 override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
739 {
740 appearance.Owner = user;
741 DataTable aap = ds.Tables["avatarappearance"];
742 lock (ds)
743 {
744 DataRow row = aap.Rows.Find(Util.ToRawUuidString(user));
745 if (row == null)
746 {
747 m_log.Debug("[USER DB]: Creating UserAppearance For: " + user.ToString());
748
749 row = aap.NewRow();
750 fillAvatarAppearanceRow(row, user, appearance);
751 aap.Rows.Add(row);
752 // m_log.Debug("[USER DB]: Syncing user database: " + ds.Tables["users"].Rows.Count + " users stored");
753 // save changes off to disk
754 daa.Update(ds, "avatarappearance");
755 }
756 else
757 {
758 m_log.Debug("[USER DB]: Updating UserAppearance For: " + user.ToString());
759 fillAvatarAppearanceRow(row, user, appearance);
760 daa.Update(ds, "avatarappearance");
761 }
762 }
763 }
764
765 /// <summary>
766 /// Returns the name of the storage provider
767 /// </summary>
768 /// <returns>Storage provider name</returns>
769 override public string Name
770 {
771 get {return "Sqlite Userdata";}
772 }
773
774 /// <summary>
775 /// Returns the version of the storage provider
776 /// </summary>
777 /// <returns>Storage provider version</returns>
778 override public string Version
779 {
780 get {return "0.1";}
781 }
782
783 /***********************************************************************
784 *
785 * DataTable creation
786 *
787 **********************************************************************/
788 /***********************************************************************
789 *
790 * Database Definition Functions
791 *
792 * This should be db agnostic as we define them in ADO.NET terms
793 *
794 **********************************************************************/
795
796 /// <summary>
797 /// Create the "users" table
798 /// </summary>
799 /// <returns>DataTable</returns>
800 private static DataTable createUsersTable()
801 {
802 DataTable users = new DataTable("users");
803
804 SQLiteUtil.createCol(users, "UUID", typeof (String));
805 SQLiteUtil.createCol(users, "username", typeof (String));
806 SQLiteUtil.createCol(users, "surname", typeof (String));
807 SQLiteUtil.createCol(users, "email", typeof (String));
808 SQLiteUtil.createCol(users, "passwordHash", typeof (String));
809 SQLiteUtil.createCol(users, "passwordSalt", typeof (String));
810
811 SQLiteUtil.createCol(users, "homeRegionX", typeof (Int32));
812 SQLiteUtil.createCol(users, "homeRegionY", typeof (Int32));
813 SQLiteUtil.createCol(users, "homeRegionID", typeof (String));
814 SQLiteUtil.createCol(users, "homeLocationX", typeof (Double));
815 SQLiteUtil.createCol(users, "homeLocationY", typeof (Double));
816 SQLiteUtil.createCol(users, "homeLocationZ", typeof (Double));
817 SQLiteUtil.createCol(users, "homeLookAtX", typeof (Double));
818 SQLiteUtil.createCol(users, "homeLookAtY", typeof (Double));
819 SQLiteUtil.createCol(users, "homeLookAtZ", typeof (Double));
820 SQLiteUtil.createCol(users, "created", typeof (Int32));
821 SQLiteUtil.createCol(users, "lastLogin", typeof (Int32));
822
823 //TODO: Please delete this column. It's now a brick
824 SQLiteUtil.createCol(users, "rootInventoryFolderID", typeof (String));
825
826 SQLiteUtil.createCol(users, "userInventoryURI", typeof (String));
827 SQLiteUtil.createCol(users, "userAssetURI", typeof (String));
828 SQLiteUtil.createCol(users, "profileCanDoMask", typeof (Int32));
829 SQLiteUtil.createCol(users, "profileWantDoMask", typeof (Int32));
830 SQLiteUtil.createCol(users, "profileAboutText", typeof (String));
831 SQLiteUtil.createCol(users, "profileFirstText", typeof (String));
832 SQLiteUtil.createCol(users, "profileImage", typeof (String));
833 SQLiteUtil.createCol(users, "profileFirstImage", typeof (String));
834 SQLiteUtil.createCol(users, "webLoginKey", typeof(String));
835 SQLiteUtil.createCol(users, "userFlags", typeof (Int32));
836 SQLiteUtil.createCol(users, "godLevel", typeof (Int32));
837 SQLiteUtil.createCol(users, "customType", typeof (String));
838 SQLiteUtil.createCol(users, "partner", typeof (String));
839 // Add in contraints
840 users.PrimaryKey = new DataColumn[] {users.Columns["UUID"]};
841 return users;
842 }
843
844 /// <summary>
845 /// Create the "useragents" table
846 /// </summary>
847 /// <returns>Data Table</returns>
848 private static DataTable createUserAgentsTable()
849 {
850 DataTable ua = new DataTable("useragents");
851 // this is the UUID of the user
852 SQLiteUtil.createCol(ua, "UUID", typeof (String));
853 SQLiteUtil.createCol(ua, "agentIP", typeof (String));
854 SQLiteUtil.createCol(ua, "agentPort", typeof (Int32));
855 SQLiteUtil.createCol(ua, "agentOnline", typeof (Boolean));
856 SQLiteUtil.createCol(ua, "sessionID", typeof (String));
857 SQLiteUtil.createCol(ua, "secureSessionID", typeof (String));
858 SQLiteUtil.createCol(ua, "regionID", typeof (String));
859 SQLiteUtil.createCol(ua, "loginTime", typeof (Int32));
860 SQLiteUtil.createCol(ua, "logoutTime", typeof (Int32));
861 SQLiteUtil.createCol(ua, "currentRegion", typeof (String));
862 SQLiteUtil.createCol(ua, "currentHandle", typeof (String));
863 // vectors
864 SQLiteUtil.createCol(ua, "currentPosX", typeof (Double));
865 SQLiteUtil.createCol(ua, "currentPosY", typeof (Double));
866 SQLiteUtil.createCol(ua, "currentPosZ", typeof (Double));
867 // constraints
868 ua.PrimaryKey = new DataColumn[] {ua.Columns["UUID"]};
869
870 return ua;
871 }
872
873 /// <summary>
874 /// Create the "userfriends" table
875 /// </summary>
876 /// <returns>Data Table</returns>
877 private static DataTable createUserFriendsTable()
878 {
879 DataTable ua = new DataTable("userfriends");
880 // table contains user <----> user relationship with perms
881 SQLiteUtil.createCol(ua, "ownerID", typeof(String));
882 SQLiteUtil.createCol(ua, "friendID", typeof(String));
883 SQLiteUtil.createCol(ua, "friendPerms", typeof(Int32));
884 SQLiteUtil.createCol(ua, "ownerPerms", typeof(Int32));
885 SQLiteUtil.createCol(ua, "datetimestamp", typeof(Int32));
886
887 return ua;
888 }
889
890 /// <summary>
891 /// Create the "avatarappearance" table
892 /// </summary>
893 /// <returns>Data Table</returns>
894 private static DataTable createAvatarAppearanceTable()
895 {
896 DataTable aa = new DataTable("avatarappearance");
897 // table contains user appearance items
898
899 SQLiteUtil.createCol(aa, "Owner", typeof(String));
900 SQLiteUtil.createCol(aa, "BodyItem", typeof(String));
901 SQLiteUtil.createCol(aa, "BodyAsset", typeof(String));
902 SQLiteUtil.createCol(aa, "SkinItem", typeof(String));
903 SQLiteUtil.createCol(aa, "SkinAsset", typeof(String));
904 SQLiteUtil.createCol(aa, "HairItem", typeof(String));
905 SQLiteUtil.createCol(aa, "HairAsset", typeof(String));
906 SQLiteUtil.createCol(aa, "EyesItem", typeof(String));
907 SQLiteUtil.createCol(aa, "EyesAsset", typeof(String));
908 SQLiteUtil.createCol(aa, "ShirtItem", typeof(String));
909 SQLiteUtil.createCol(aa, "ShirtAsset", typeof(String));
910 SQLiteUtil.createCol(aa, "PantsItem", typeof(String));
911 SQLiteUtil.createCol(aa, "PantsAsset", typeof(String));
912 SQLiteUtil.createCol(aa, "ShoesItem", typeof(String));
913 SQLiteUtil.createCol(aa, "ShoesAsset", typeof(String));
914 SQLiteUtil.createCol(aa, "SocksItem", typeof(String));
915 SQLiteUtil.createCol(aa, "SocksAsset", typeof(String));
916 SQLiteUtil.createCol(aa, "JacketItem", typeof(String));
917 SQLiteUtil.createCol(aa, "JacketAsset", typeof(String));
918 SQLiteUtil.createCol(aa, "GlovesItem", typeof(String));
919 SQLiteUtil.createCol(aa, "GlovesAsset", typeof(String));
920 SQLiteUtil.createCol(aa, "UnderShirtItem", typeof(String));
921 SQLiteUtil.createCol(aa, "UnderShirtAsset", typeof(String));
922 SQLiteUtil.createCol(aa, "UnderPantsItem", typeof(String));
923 SQLiteUtil.createCol(aa, "UnderPantsAsset", typeof(String));
924 SQLiteUtil.createCol(aa, "SkirtItem", typeof(String));
925 SQLiteUtil.createCol(aa, "SkirtAsset", typeof(String));
926
927 // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date)
928 SQLiteUtil.createCol(aa, "Texture", typeof (String));
929 SQLiteUtil.createCol(aa, "VisualParams", typeof (String));
930
931 SQLiteUtil.createCol(aa, "Serial", typeof(Int32));
932 SQLiteUtil.createCol(aa, "AvatarHeight", typeof(Double));
933
934 aa.PrimaryKey = new DataColumn[] { aa.Columns["Owner"] };
935
936 return aa;
937 }
938
939 /***********************************************************************
940 *
941 * Convert between ADO.NET <=> OpenSim Objects
942 *
943 * These should be database independant
944 *
945 **********************************************************************/
946
947 /// <summary>
948 /// TODO: this doesn't work yet because something more
949 /// interesting has to be done to actually get these values
950 /// back out. Not enough time to figure it out yet.
951 /// </summary>
952 /// <param name="row"></param>
953 /// <returns></returns>
954 private static UserProfileData buildUserProfile(DataRow row)
955 {
956 UserProfileData user = new UserProfileData();
957 UUID tmp;
958 UUID.TryParse((String)row["UUID"], out tmp);
959 user.ID = tmp;
960 user.FirstName = (String) row["username"];
961 user.SurName = (String) row["surname"];
962 user.Email = (row.IsNull("email")) ? "" : (String) row["email"];
963
964 user.PasswordHash = (String) row["passwordHash"];
965 user.PasswordSalt = (String) row["passwordSalt"];
966
967 user.HomeRegionX = Convert.ToUInt32(row["homeRegionX"]);
968 user.HomeRegionY = Convert.ToUInt32(row["homeRegionY"]);
969 user.HomeLocation = new Vector3(
970 Convert.ToSingle(row["homeLocationX"]),
971 Convert.ToSingle(row["homeLocationY"]),
972 Convert.ToSingle(row["homeLocationZ"])
973 );
974 user.HomeLookAt = new Vector3(
975 Convert.ToSingle(row["homeLookAtX"]),
976 Convert.ToSingle(row["homeLookAtY"]),
977 Convert.ToSingle(row["homeLookAtZ"])
978 );
979
980 UUID regionID = UUID.Zero;
981 UUID.TryParse(row["homeRegionID"].ToString(), out regionID); // it's ok if it doesn't work; just use UUID.Zero
982 user.HomeRegionID = regionID;
983
984 user.Created = Convert.ToInt32(row["created"]);
985 user.LastLogin = Convert.ToInt32(row["lastLogin"]);
986 user.UserInventoryURI = (String) row["userInventoryURI"];
987 user.UserAssetURI = (String) row["userAssetURI"];
988 user.CanDoMask = Convert.ToUInt32(row["profileCanDoMask"]);
989 user.WantDoMask = Convert.ToUInt32(row["profileWantDoMask"]);
990 user.AboutText = (String) row["profileAboutText"];
991 user.FirstLifeAboutText = (String) row["profileFirstText"];
992 UUID.TryParse((String)row["profileImage"], out tmp);
993 user.Image = tmp;
994 UUID.TryParse((String)row["profileFirstImage"], out tmp);
995 user.FirstLifeImage = tmp;
996 user.WebLoginKey = new UUID((String) row["webLoginKey"]);
997 user.UserFlags = Convert.ToInt32(row["userFlags"]);
998 user.GodLevel = Convert.ToInt32(row["godLevel"]);
999 user.CustomType = row["customType"].ToString();
1000 user.Partner = new UUID((String) row["partner"]);
1001
1002 return user;
1003 }
1004
1005 /// <summary>
1006 /// Persist user profile data
1007 /// </summary>
1008 /// <param name="row"></param>
1009 /// <param name="user"></param>
1010 private void fillUserRow(DataRow row, UserProfileData user)
1011 {
1012 row["UUID"] = user.ID.ToString();
1013 row["username"] = user.FirstName;
1014 row["surname"] = user.SurName;
1015 row["email"] = user.Email;
1016 row["passwordHash"] = user.PasswordHash;
1017 row["passwordSalt"] = user.PasswordSalt;
1018
1019 row["homeRegionX"] = user.HomeRegionX;
1020 row["homeRegionY"] = user.HomeRegionY;
1021 row["homeRegionID"] = user.HomeRegionID.ToString();
1022 row["homeLocationX"] = user.HomeLocation.X;
1023 row["homeLocationY"] = user.HomeLocation.Y;
1024 row["homeLocationZ"] = user.HomeLocation.Z;
1025 row["homeLookAtX"] = user.HomeLookAt.X;
1026 row["homeLookAtY"] = user.HomeLookAt.Y;
1027 row["homeLookAtZ"] = user.HomeLookAt.Z;
1028
1029 row["created"] = user.Created;
1030 row["lastLogin"] = user.LastLogin;
1031 //TODO: Get rid of rootInventoryFolderID in a safe way.
1032 row["rootInventoryFolderID"] = UUID.Zero.ToString();
1033 row["userInventoryURI"] = user.UserInventoryURI;
1034 row["userAssetURI"] = user.UserAssetURI;
1035 row["profileCanDoMask"] = user.CanDoMask;
1036 row["profileWantDoMask"] = user.WantDoMask;
1037 row["profileAboutText"] = user.AboutText;
1038 row["profileFirstText"] = user.FirstLifeAboutText;
1039 row["profileImage"] = user.Image.ToString();
1040 row["profileFirstImage"] = user.FirstLifeImage.ToString();
1041 row["webLoginKey"] = user.WebLoginKey.ToString();
1042 row["userFlags"] = user.UserFlags;
1043 row["godLevel"] = user.GodLevel;
1044 row["customType"] = user.CustomType == null ? "" : user.CustomType;
1045 row["partner"] = user.Partner.ToString();
1046
1047 // ADO.NET doesn't handle NULL very well
1048 foreach (DataColumn col in ds.Tables["users"].Columns)
1049 {
1050 if (row[col] == null)
1051 {
1052 row[col] = String.Empty;
1053 }
1054 }
1055 }
1056
1057 /// <summary>
1058 ///
1059 /// </summary>
1060 /// <param name="row"></param>
1061 /// <param name="user"></param>
1062 private void fillAvatarAppearanceRow(DataRow row, UUID user, AvatarAppearance appearance)
1063 {
1064 row["Owner"] = Util.ToRawUuidString(user);
1065 row["BodyItem"] = appearance.BodyItem.ToString();
1066 row["BodyAsset"] = appearance.BodyAsset.ToString();
1067 row["SkinItem"] = appearance.SkinItem.ToString();
1068 row["SkinAsset"] = appearance.SkinAsset.ToString();
1069 row["HairItem"] = appearance.HairItem.ToString();
1070 row["HairAsset"] = appearance.HairAsset.ToString();
1071 row["EyesItem"] = appearance.EyesItem.ToString();
1072 row["EyesAsset"] = appearance.EyesAsset.ToString();
1073 row["ShirtItem"] = appearance.ShirtItem.ToString();
1074 row["ShirtAsset"] = appearance.ShirtAsset.ToString();
1075 row["PantsItem"] = appearance.PantsItem.ToString();
1076 row["PantsAsset"] = appearance.PantsAsset.ToString();
1077 row["ShoesItem"] = appearance.ShoesItem.ToString();
1078 row["ShoesAsset"] = appearance.ShoesAsset.ToString();
1079 row["SocksItem"] = appearance.SocksItem.ToString();
1080 row["SocksAsset"] = appearance.SocksAsset.ToString();
1081 row["JacketItem"] = appearance.JacketItem.ToString();
1082 row["JacketAsset"] = appearance.JacketAsset.ToString();
1083 row["GlovesItem"] = appearance.GlovesItem.ToString();
1084 row["GlovesAsset"] = appearance.GlovesAsset.ToString();
1085 row["UnderShirtItem"] = appearance.UnderShirtItem.ToString();
1086 row["UnderShirtAsset"] = appearance.UnderShirtAsset.ToString();
1087 row["UnderPantsItem"] = appearance.UnderPantsItem.ToString();
1088 row["UnderPantsAsset"] = appearance.UnderPantsAsset.ToString();
1089 row["SkirtItem"] = appearance.SkirtItem.ToString();
1090 row["SkirtAsset"] = appearance.SkirtAsset.ToString();
1091
1092 // Used Base64String because for some reason it wont accept using Byte[] (which works in Region date)
1093 row["Texture"] = Convert.ToBase64String(appearance.Texture.GetBytes());
1094 row["VisualParams"] = Convert.ToBase64String(appearance.VisualParams);
1095
1096 row["Serial"] = appearance.Serial;
1097 row["AvatarHeight"] = appearance.AvatarHeight;
1098
1099 // ADO.NET doesn't handle NULL very well
1100 foreach (DataColumn col in ds.Tables["avatarappearance"].Columns)
1101 {
1102 if (row[col] == null)
1103 {
1104 row[col] = String.Empty;
1105 }
1106 }
1107 }
1108
1109 /// <summary>
1110 ///
1111 /// </summary>
1112 /// <param name="row"></param>
1113 /// <returns></returns>
1114 private static UserAgentData buildUserAgent(DataRow row)
1115 {
1116 UserAgentData ua = new UserAgentData();
1117
1118 UUID tmp;
1119 UUID.TryParse((String)row["UUID"], out tmp);
1120 ua.ProfileID = tmp;
1121 ua.AgentIP = (String)row["agentIP"];
1122 ua.AgentPort = Convert.ToUInt32(row["agentPort"]);
1123 ua.AgentOnline = Convert.ToBoolean(row["agentOnline"]);
1124 ua.SessionID = new UUID((String) row["sessionID"]);
1125 ua.SecureSessionID = new UUID((String) row["secureSessionID"]);
1126 ua.InitialRegion = new UUID((String) row["regionID"]);
1127 ua.LoginTime = Convert.ToInt32(row["loginTime"]);
1128 ua.LogoutTime = Convert.ToInt32(row["logoutTime"]);
1129 ua.Region = new UUID((String) row["currentRegion"]);
1130 ua.Handle = Convert.ToUInt64(row["currentHandle"]);
1131 ua.Position = new Vector3(
1132 Convert.ToSingle(row["currentPosX"]),
1133 Convert.ToSingle(row["currentPosY"]),
1134 Convert.ToSingle(row["currentPosZ"])
1135 );
1136 ua.LookAt = new Vector3(
1137 Convert.ToSingle(row["currentLookAtX"]),
1138 Convert.ToSingle(row["currentLookAtY"]),
1139 Convert.ToSingle(row["currentLookAtZ"])
1140 );
1141 return ua;
1142 }
1143
1144 /// <summary>
1145 ///
1146 /// </summary>
1147 /// <param name="row"></param>
1148 /// <param name="ua"></param>
1149 private static void fillUserAgentRow(DataRow row, UserAgentData ua)
1150 {
1151 row["UUID"] = ua.ProfileID.ToString();
1152 row["agentIP"] = ua.AgentIP;
1153 row["agentPort"] = ua.AgentPort;
1154 row["agentOnline"] = ua.AgentOnline;
1155 row["sessionID"] = ua.SessionID.ToString();
1156 row["secureSessionID"] = ua.SecureSessionID.ToString();
1157 row["regionID"] = ua.InitialRegion.ToString();
1158 row["loginTime"] = ua.LoginTime;
1159 row["logoutTime"] = ua.LogoutTime;
1160 row["currentRegion"] = ua.Region.ToString();
1161 row["currentHandle"] = ua.Handle.ToString();
1162 // vectors
1163 row["currentPosX"] = ua.Position.X;
1164 row["currentPosY"] = ua.Position.Y;
1165 row["currentPosZ"] = ua.Position.Z;
1166 row["currentLookAtX"] = ua.LookAt.X;
1167 row["currentLookAtY"] = ua.LookAt.Y;
1168 row["currentLookAtZ"] = ua.LookAt.Z;
1169 }
1170
1171 /***********************************************************************
1172 *
1173 * Database Binding functions
1174 *
1175 * These will be db specific due to typing, and minor differences
1176 * in databases.
1177 *
1178 **********************************************************************/
1179
1180 /// <summary>
1181 ///
1182 /// </summary>
1183 /// <param name="da"></param>
1184 /// <param name="conn"></param>
1185 private void setupUserCommands(SqliteDataAdapter da, SqliteConnection conn)
1186 {
1187 da.InsertCommand = SQLiteUtil.createInsertCommand("users", ds.Tables["users"]);
1188 da.InsertCommand.Connection = conn;
1189
1190 da.UpdateCommand = SQLiteUtil.createUpdateCommand("users", "UUID=:UUID", ds.Tables["users"]);
1191 da.UpdateCommand.Connection = conn;
1192
1193 SqliteCommand delete = new SqliteCommand("delete from users where UUID = :UUID");
1194 delete.Parameters.Add(SQLiteUtil.createSqliteParameter("UUID", typeof(String)));
1195 delete.Connection = conn;
1196 da.DeleteCommand = delete;
1197 }
1198
1199 private void setupAgentCommands(SqliteDataAdapter da, SqliteConnection conn)
1200 {
1201 da.InsertCommand = SQLiteUtil.createInsertCommand("useragents", ds.Tables["useragents"]);
1202 da.InsertCommand.Connection = conn;
1203
1204 da.UpdateCommand = SQLiteUtil.createUpdateCommand("useragents", "UUID=:UUID", ds.Tables["useragents"]);
1205 da.UpdateCommand.Connection = conn;
1206
1207 SqliteCommand delete = new SqliteCommand("delete from useragents where UUID = :ProfileID");
1208 delete.Parameters.Add(SQLiteUtil.createSqliteParameter("ProfileID", typeof(String)));
1209 delete.Connection = conn;
1210 da.DeleteCommand = delete;
1211 }
1212
1213 /// <summary>
1214 ///
1215 /// </summary>
1216 /// <param name="daf"></param>
1217 /// <param name="conn"></param>
1218 private void setupUserFriendsCommands(SqliteDataAdapter daf, SqliteConnection conn)
1219 {
1220 daf.InsertCommand = SQLiteUtil.createInsertCommand("userfriends", ds.Tables["userfriends"]);
1221 daf.InsertCommand.Connection = conn;
1222
1223 daf.UpdateCommand = SQLiteUtil.createUpdateCommand("userfriends", "ownerID=:ownerID and friendID=:friendID", ds.Tables["userfriends"]);
1224 daf.UpdateCommand.Connection = conn;
1225
1226 SqliteCommand delete = new SqliteCommand("delete from userfriends where ownerID=:ownerID and friendID=:friendID");
1227 delete.Parameters.Add(SQLiteUtil.createSqliteParameter("ownerID", typeof(String)));
1228 delete.Parameters.Add(SQLiteUtil.createSqliteParameter("friendID", typeof(String)));
1229 delete.Connection = conn;
1230 daf.DeleteCommand = delete;
1231
1232 }
1233
1234 /// <summary>
1235 ///
1236 /// </summary>
1237 /// <param name="daf"></param>
1238 /// <param name="conn"></param>
1239 private void setupAvatarAppearanceCommands(SqliteDataAdapter daa, SqliteConnection conn)
1240 {
1241 daa.InsertCommand = SQLiteUtil.createInsertCommand("avatarappearance", ds.Tables["avatarappearance"]);
1242 daa.InsertCommand.Connection = conn;
1243
1244 daa.UpdateCommand = SQLiteUtil.createUpdateCommand("avatarappearance", "Owner=:Owner", ds.Tables["avatarappearance"]);
1245 daa.UpdateCommand.Connection = conn;
1246
1247 SqliteCommand delete = new SqliteCommand("delete from avatarappearance where Owner=:Owner");
1248 delete.Parameters.Add(SQLiteUtil.createSqliteParameter("Owner", typeof(String)));
1249 delete.Connection = conn;
1250 daa.DeleteCommand = delete;
1251 }
1252
1253
1254 override public void ResetAttachments(UUID userID)
1255 {
1256 }
1257
1258 override public void LogoutUsers(UUID regionID)
1259 {
1260 }
1261 }
1262}