aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLUserData.cs
diff options
context:
space:
mode:
authorJohn Hurliman2010-02-22 14:10:19 -0800
committerJohn Hurliman2010-02-22 14:10:19 -0800
commit71c6559a91a58d93588dcdd8c74b5fce0c1a3780 (patch)
treecca5b1ea88ad4b29156767afdd77e37ec072c8a7 /OpenSim/Data/MySQL/MySQLUserData.cs
parent* Adds CreatorID to asset metadata. This is just the plumbing to support Crea... (diff)
parentMerge branch 'presence-refactor' of ssh://diva@opensimulator.org/var/git/open... (diff)
downloadopensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.zip
opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.gz
opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.bz2
opensim-SC-71c6559a91a58d93588dcdd8c74b5fce0c1a3780.tar.xz
Merge branch 'presence-refactor' of ssh://opensimulator.org/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLUserData.cs')
-rw-r--r--OpenSim/Data/MySQL/MySQLUserData.cs766
1 files changed, 0 insertions, 766 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserData.cs b/OpenSim/Data/MySQL/MySQLUserData.cs
deleted file mode 100644
index 0a9d2e3..0000000
--- a/OpenSim/Data/MySQL/MySQLUserData.cs
+++ /dev/null
@@ -1,766 +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;
30using System.Collections.Generic;
31using System.Data;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using System.Threading;
35using log4net;
36using MySql.Data.MySqlClient;
37using OpenMetaverse;
38using OpenSim.Framework;
39
40namespace OpenSim.Data.MySQL
41{
42 /// <summary>
43 /// A database interface class to a user profile storage system
44 /// </summary>
45 public class MySQLUserData : UserDataBase
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private MySQLManager m_database;
50 private string m_connectionString;
51 private object m_dbLock = new object();
52
53 public int m_maxConnections = 10;
54 public int m_lastConnect;
55
56 private string m_agentsTableName = "agents";
57 private string m_usersTableName = "users";
58 private string m_userFriendsTableName = "userfriends";
59 private string m_appearanceTableName = "avatarappearance";
60 private string m_attachmentsTableName = "avatarattachments";
61
62 public override void Initialise()
63 {
64 m_log.Info("[MySQLUserData]: " + Name + " cannot be default-initialized!");
65 throw new PluginNotInitialisedException(Name);
66 }
67
68 /// <summary>
69 /// Initialise User Interface
70 /// Loads and initialises the MySQL storage plugin
71 /// Warns and uses the obsolete mysql_connection.ini if connect string is empty.
72 /// Checks for migration
73 /// </summary>
74 /// <param name="connect">connect string.</param>
75 public override void Initialise(string connect)
76 {
77 m_connectionString = connect;
78 m_database = new MySQLManager(connect);
79
80 // This actually does the roll forward assembly stuff
81 Assembly assem = GetType().Assembly;
82
83 using (MySql.Data.MySqlClient.MySqlConnection dbcon = new MySql.Data.MySqlClient.MySqlConnection(m_connectionString))
84 {
85 dbcon.Open();
86 Migration m = new Migration(dbcon, assem, "UserStore");
87 m.Update();
88 }
89 }
90
91 public override void Dispose()
92 {
93 }
94
95 // see IUserDataPlugin
96 public override UserProfileData GetUserByName(string user, string last)
97 {
98 try
99 {
100 Dictionary<string, object> param = new Dictionary<string, object>();
101 param["?first"] = user;
102 param["?second"] = last;
103
104 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
105 {
106 dbcon.Open();
107
108 using (IDbCommand result = m_database.Query(dbcon,
109 "SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param))
110 {
111 using (IDataReader reader = result.ExecuteReader())
112 {
113 UserProfileData row = m_database.readUserRow(reader);
114 return row;
115 }
116 }
117 }
118 }
119 catch (Exception e)
120 {
121 m_log.Error(e.Message, e);
122 return null;
123 }
124 }
125
126 #region User Friends List Data
127
128 public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
129 {
130 int dtvalue = Util.UnixTimeSinceEpoch();
131
132 Dictionary<string, object> param = new Dictionary<string, object>();
133 param["?ownerID"] = friendlistowner.ToString();
134 param["?friendID"] = friend.ToString();
135 param["?friendPerms"] = perms.ToString();
136 param["?datetimestamp"] = dtvalue.ToString();
137
138 try
139 {
140 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
141 {
142 dbcon.Open();
143
144 using (IDbCommand adder = m_database.Query(dbcon,
145 "INSERT INTO `" + m_userFriendsTableName + "` " +
146 "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
147 "VALUES " +
148 "(?ownerID,?friendID,?friendPerms,?datetimestamp)",
149 param))
150 {
151 adder.ExecuteNonQuery();
152 }
153
154 using (IDbCommand adder = m_database.Query(dbcon,
155 "INSERT INTO `" + m_userFriendsTableName + "` " +
156 "(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
157 "VALUES " +
158 "(?friendID,?ownerID,?friendPerms,?datetimestamp)",
159 param))
160 {
161 adder.ExecuteNonQuery();
162 }
163 }
164 }
165 catch (Exception e)
166 {
167 m_log.Error(e.Message, e);
168 return;
169 }
170 }
171
172 public override void RemoveUserFriend(UUID friendlistowner, UUID friend)
173 {
174 Dictionary<string, object> param = new Dictionary<string, object>();
175 param["?ownerID"] = friendlistowner.ToString();
176 param["?friendID"] = friend.ToString();
177
178 try
179 {
180 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
181 {
182 dbcon.Open();
183
184 using (IDbCommand updater = m_database.Query(dbcon,
185 "delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
186 param))
187 {
188 updater.ExecuteNonQuery();
189 }
190
191 using (IDbCommand updater = m_database.Query(dbcon,
192 "delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
193 param))
194 {
195 updater.ExecuteNonQuery();
196 }
197 }
198 }
199 catch (Exception e)
200 {
201 m_log.Error(e.Message, e);
202 return;
203 }
204 }
205
206 public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
207 {
208 Dictionary<string, object> param = new Dictionary<string, object>();
209 param["?ownerID"] = friendlistowner.ToString();
210 param["?friendID"] = friend.ToString();
211 param["?friendPerms"] = perms.ToString();
212
213 try
214 {
215 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
216 {
217 dbcon.Open();
218
219 using (IDbCommand updater = m_database.Query(dbcon,
220 "update " + m_userFriendsTableName +
221 " SET friendPerms = ?friendPerms " +
222 "where ownerID = ?ownerID and friendID = ?friendID",
223 param))
224 {
225 updater.ExecuteNonQuery();
226 }
227 }
228 }
229 catch (Exception e)
230 {
231 m_log.Error(e.Message, e);
232 return;
233 }
234 }
235
236 public override List<FriendListItem> GetUserFriendList(UUID friendlistowner)
237 {
238 List<FriendListItem> Lfli = new List<FriendListItem>();
239
240 Dictionary<string, object> param = new Dictionary<string, object>();
241 param["?ownerID"] = friendlistowner.ToString();
242
243 try
244 {
245 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
246 {
247 dbcon.Open();
248
249 //Left Join userfriends to itself
250 using (IDbCommand result = m_database.Query(dbcon,
251 "select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " +
252 m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
253 " where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
254 param))
255 {
256 using (IDataReader reader = result.ExecuteReader())
257 {
258 while (reader.Read())
259 {
260 FriendListItem fli = new FriendListItem();
261 fli.FriendListOwner = new UUID((string)reader["ownerID"]);
262 fli.Friend = new UUID((string)reader["friendID"]);
263 fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]);
264
265 // This is not a real column in the database table, it's a joined column from the opposite record
266 fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]);
267
268 Lfli.Add(fli);
269 }
270 }
271 }
272 }
273 }
274 catch (Exception e)
275 {
276 m_log.Error(e.Message, e);
277 return Lfli;
278 }
279
280 return Lfli;
281 }
282
283 override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
284 {
285 Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
286
287 try
288 {
289 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
290 {
291 dbcon.Open();
292
293 foreach (UUID uuid in uuids)
294 {
295 Dictionary<string, object> param = new Dictionary<string, object>();
296 param["?uuid"] = uuid.ToString();
297
298 using (IDbCommand result = m_database.Query(dbcon, "select agentOnline,currentHandle from " + m_agentsTableName +
299 " where UUID = ?uuid", param))
300 {
301 using (IDataReader reader = result.ExecuteReader())
302 {
303 while (reader.Read())
304 {
305 FriendRegionInfo fri = new FriendRegionInfo();
306 fri.isOnline = (sbyte)reader["agentOnline"] != 0;
307 fri.regionHandle = (ulong)reader["currentHandle"];
308
309 infos[uuid] = fri;
310 }
311 }
312 }
313 }
314 }
315 }
316 catch (Exception e)
317 {
318 m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
319 m_log.Error(e.Message, e);
320 }
321
322 return infos;
323 }
324
325 #endregion
326
327 public override List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query)
328 {
329 List<AvatarPickerAvatar> returnlist = new List<AvatarPickerAvatar>();
330
331 Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
332
333 string[] querysplit;
334 querysplit = query.Split(' ');
335 if (querysplit.Length > 1 && querysplit[1].Trim() != String.Empty)
336 {
337 Dictionary<string, object> param = new Dictionary<string, object>();
338 param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
339 param["?second"] = objAlphaNumericPattern.Replace(querysplit[1], String.Empty) + "%";
340
341 try
342 {
343 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
344 {
345 dbcon.Open();
346
347 using (IDbCommand result = m_database.Query(dbcon,
348 "SELECT UUID,username,lastname FROM " + m_usersTableName +
349 " WHERE username like ?first AND lastname like ?second LIMIT 100",
350 param))
351 {
352 using (IDataReader reader = result.ExecuteReader())
353 {
354 while (reader.Read())
355 {
356 AvatarPickerAvatar user = new AvatarPickerAvatar();
357 user.AvatarID = new UUID((string)reader["UUID"]);
358 user.firstName = (string)reader["username"];
359 user.lastName = (string)reader["lastname"];
360 returnlist.Add(user);
361 }
362 }
363 }
364 }
365 }
366 catch (Exception e)
367 {
368 m_log.Error(e.Message, e);
369 return returnlist;
370 }
371 }
372 else
373 {
374 try
375 {
376 Dictionary<string, object> param = new Dictionary<string, object>();
377 param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
378
379 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
380 {
381 dbcon.Open();
382
383 using (IDbCommand result = m_database.Query(dbcon,
384 "SELECT UUID,username,lastname FROM " + m_usersTableName +
385 " WHERE username like ?first OR lastname like ?first LIMIT 100",
386 param))
387 {
388 using (IDataReader reader = result.ExecuteReader())
389 {
390 while (reader.Read())
391 {
392 AvatarPickerAvatar user = new AvatarPickerAvatar();
393 user.AvatarID = new UUID((string)reader["UUID"]);
394 user.firstName = (string)reader["username"];
395 user.lastName = (string)reader["lastname"];
396 returnlist.Add(user);
397 }
398 }
399 }
400 }
401 }
402 catch (Exception e)
403 {
404 m_log.Error(e.Message, e);
405 return returnlist;
406 }
407 }
408 return returnlist;
409 }
410
411 /// <summary>
412 /// See IUserDataPlugin
413 /// </summary>
414 /// <param name="uuid">User UUID</param>
415 /// <returns>User profile data</returns>
416 public override UserProfileData GetUserByUUID(UUID uuid)
417 {
418 try
419 {
420 Dictionary<string, object> param = new Dictionary<string, object>();
421 param["?uuid"] = uuid.ToString();
422
423 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
424 {
425 dbcon.Open();
426
427 using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param))
428 {
429 using (IDataReader reader = result.ExecuteReader())
430 {
431 UserProfileData row = m_database.readUserRow(reader);
432 return row;
433 }
434 }
435 }
436 }
437 catch (Exception e)
438 {
439 m_log.Error(e.Message, e);
440 return null;
441 }
442 }
443
444 /// <summary>
445 /// Returns a user session searching by name
446 /// </summary>
447 /// <param name="name">The account name : "Username Lastname"</param>
448 /// <returns>The users session</returns>
449 public override UserAgentData GetAgentByName(string name)
450 {
451 return GetAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
452 }
453
454 /// <summary>
455 /// Returns a user session by account name
456 /// </summary>
457 /// <param name="user">First part of the users account name</param>
458 /// <param name="last">Second part of the users account name</param>
459 /// <returns>The users session</returns>
460 public override UserAgentData GetAgentByName(string user, string last)
461 {
462 UserProfileData profile = GetUserByName(user, last);
463 return GetAgentByUUID(profile.ID);
464 }
465
466 /// <summary>
467 /// </summary>
468 /// <param name="AgentID"></param>
469 /// <param name="WebLoginKey"></param>
470 /// <remarks>is it still used ?</remarks>
471 public override void StoreWebLoginKey(UUID AgentID, UUID WebLoginKey)
472 {
473 Dictionary<string, string> param = new Dictionary<string, string>();
474 param["?UUID"] = AgentID.ToString();
475 param["?webLoginKey"] = WebLoginKey.ToString();
476
477 try
478 {
479 m_database.ExecuteParameterizedSql(
480 "update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
481 "where UUID = ?UUID",
482 param);
483 }
484 catch (Exception e)
485 {
486 m_log.Error(e.Message, e);
487 return;
488 }
489 }
490
491 /// <summary>
492 /// Returns an agent session by account UUID
493 /// </summary>
494 /// <param name="uuid">The accounts UUID</param>
495 /// <returns>The users session</returns>
496 public override UserAgentData GetAgentByUUID(UUID uuid)
497 {
498 try
499 {
500 Dictionary<string, object> param = new Dictionary<string, object>();
501 param["?uuid"] = uuid.ToString();
502
503 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
504 {
505 dbcon.Open();
506
507 using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param))
508 {
509 using (IDataReader reader = result.ExecuteReader())
510 {
511 UserAgentData row = m_database.readAgentRow(reader);
512 return row;
513 }
514 }
515 }
516 }
517 catch (Exception e)
518 {
519 m_log.Error(e.Message, e);
520 return null;
521 }
522 }
523
524 /// <summary>
525 /// Creates a new users profile
526 /// </summary>
527 /// <param name="user">The user profile to create</param>
528 public override void AddNewUserProfile(UserProfileData user)
529 {
530 UUID zero = UUID.Zero;
531 if (user.ID == zero)
532 {
533 return;
534 }
535
536 try
537 {
538 m_database.insertUserRow(
539 user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
540 user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
541 user.HomeLocation.Z,
542 user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
543 user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
544 user.CanDoMask, user.WantDoMask,
545 user.AboutText, user.FirstLifeAboutText, user.Image,
546 user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
547 }
548 catch (Exception e)
549 {
550 m_log.Error(e.Message, e);
551 }
552 }
553
554 /// <summary>
555 /// Creates a new agent
556 /// </summary>
557 /// <param name="agent">The agent to create</param>
558 public override void AddNewUserAgent(UserAgentData agent)
559 {
560 UUID zero = UUID.Zero;
561 if (agent.ProfileID == zero || agent.SessionID == zero)
562 return;
563
564 try
565 {
566 m_database.insertAgentRow(agent);
567 }
568 catch (Exception e)
569 {
570 m_log.Error(e.Message, e);
571 }
572 }
573
574 /// <summary>
575 /// Updates a user profile stored in the DB
576 /// </summary>
577 /// <param name="user">The profile data to use to update the DB</param>
578 public override bool UpdateUserProfile(UserProfileData user)
579 {
580 try
581 {
582 m_database.updateUserRow(
583 user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
584 user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
585 user.HomeLocation.Z, user.HomeLookAt.X,
586 user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
587 user.UserInventoryURI,
588 user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
589 user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
590 user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
591
592 return true;
593 }
594 catch
595 {
596 return false;
597 }
598 }
599
600 /// <summary>
601 /// Performs a money transfer request between two accounts
602 /// </summary>
603 /// <param name="from">The senders account ID</param>
604 /// <param name="to">The receivers account ID</param>
605 /// <param name="amount">The amount to transfer</param>
606 /// <returns>Success?</returns>
607 public override bool MoneyTransferRequest(UUID from, UUID to, uint amount)
608 {
609 return false;
610 }
611
612 /// <summary>
613 /// Performs an inventory transfer request between two accounts
614 /// </summary>
615 /// <remarks>TODO: Move to inventory server</remarks>
616 /// <param name="from">The senders account ID</param>
617 /// <param name="to">The receivers account ID</param>
618 /// <param name="item">The item to transfer</param>
619 /// <returns>Success?</returns>
620 public override bool InventoryTransferRequest(UUID from, UUID to, UUID item)
621 {
622 return false;
623 }
624
625 public override AvatarAppearance GetUserAppearance(UUID user)
626 {
627 try
628 {
629 Dictionary<string, object> param = new Dictionary<string, object>();
630 param["?owner"] = user.ToString();
631
632 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
633 {
634 dbcon.Open();
635
636 using (IDbCommand result = m_database.Query(dbcon, "SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param))
637 {
638 using (IDataReader reader = result.ExecuteReader())
639 {
640 AvatarAppearance appearance = m_database.readAppearanceRow(reader);
641
642 if (appearance == null)
643 {
644 m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString());
645 return null;
646 }
647 else
648 {
649 appearance.SetAttachments(GetUserAttachments(user));
650 return appearance;
651 }
652 }
653 }
654 }
655 }
656 catch (Exception e)
657 {
658 m_log.Error(e.Message, e);
659 return null;
660 }
661 }
662
663 /// <summary>
664 /// Updates an avatar appearence
665 /// </summary>
666 /// <param name="user">The user UUID</param>
667 /// <param name="appearance">The avatar appearance</param>
668 // override
669 public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
670 {
671 try
672 {
673 appearance.Owner = user;
674 m_database.insertAppearanceRow(appearance);
675
676 UpdateUserAttachments(user, appearance.GetAttachments());
677 }
678 catch (Exception e)
679 {
680 m_log.Error(e.Message, e);
681 }
682 }
683
684 /// <summary>
685 /// Database provider name
686 /// </summary>
687 /// <returns>Provider name</returns>
688 public override string Name
689 {
690 get { return "MySQL Userdata Interface"; }
691 }
692
693 /// <summary>
694 /// Database provider version
695 /// </summary>
696 /// <returns>provider version</returns>
697 public override string Version
698 {
699 get { return "0.1"; }
700 }
701
702 public Hashtable GetUserAttachments(UUID agentID)
703 {
704 Dictionary<string, object> param = new Dictionary<string, object>();
705 param["?uuid"] = agentID.ToString();
706
707 try
708 {
709 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
710 {
711 dbcon.Open();
712
713 using (IDbCommand result = m_database.Query(dbcon,
714 "SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param))
715 {
716 using (IDataReader reader = result.ExecuteReader())
717 {
718 Hashtable ret = m_database.readAttachments(reader);
719 return ret;
720 }
721 }
722 }
723 }
724 catch (Exception e)
725 {
726 m_log.Error(e.Message, e);
727 return null;
728 }
729 }
730
731 public void UpdateUserAttachments(UUID agentID, Hashtable data)
732 {
733 m_database.writeAttachments(agentID, data);
734 }
735
736 public override void ResetAttachments(UUID userID)
737 {
738 Dictionary<string, string> param = new Dictionary<string, string>();
739 param["?uuid"] = userID.ToString();
740
741 m_database.ExecuteParameterizedSql(
742 "UPDATE " + m_attachmentsTableName +
743 " SET asset = '00000000-0000-0000-0000-000000000000' WHERE UUID = ?uuid",
744 param);
745 }
746
747 public override void LogoutUsers(UUID regionID)
748 {
749 Dictionary<string, string> param = new Dictionary<string, string>();
750 param["?regionID"] = regionID.ToString();
751
752 try
753 {
754 m_database.ExecuteParameterizedSql(
755 "update " + m_agentsTableName + " SET agentOnline = 0 " +
756 "where currentRegion = ?regionID",
757 param);
758 }
759 catch (Exception e)
760 {
761 m_log.Error(e.Message, e);
762 return;
763 }
764 }
765 }
766}