aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Data.MySQL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs113
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs8
2 files changed, 115 insertions, 6 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
index 1a90eea..ea11aa0 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs
@@ -452,11 +452,25 @@ namespace OpenSim.Framework.Data.MySQL
452 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); 452 retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString());
453 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); 453 retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString());
454 454
455 retval.profileAboutText = (string) reader["profileAboutText"]; 455 if (reader.IsDBNull(reader.GetOrdinal("profileAboutText")))
456 retval.profileFirstText = (string) reader["profileFirstText"]; 456 retval.profileAboutText = "";
457 else
458 retval.profileAboutText = (string) reader["profileAboutText"];
457 459
458 LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); 460 if (reader.IsDBNull( reader.GetOrdinal( "profileFirstText" ) ) )
459 LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); 461 retval.profileFirstText = "";
462 else
463 retval.profileFirstText = (string)reader["profileFirstText"];
464
465 if (reader.IsDBNull( reader.GetOrdinal( "profileImage" ) ) )
466 retval.profileImage = LLUUID.Zero;
467 else
468 LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage);
469
470 if (reader.IsDBNull( reader.GetOrdinal( "profileFirstImage" ) ) )
471 retval.profileFirstImage = LLUUID.Zero;
472 else
473 LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage);
460 474
461 if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) ) 475 if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) )
462 { 476 {
@@ -553,6 +567,7 @@ namespace OpenSim.Framework.Data.MySQL
553 string aboutText, string firstText, 567 string aboutText, string firstText,
554 LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) 568 LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey)
555 { 569 {
570 m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString());
556 string sql = 571 string sql =
557 "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; 572 "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, ";
558 sql += 573 sql +=
@@ -610,9 +625,99 @@ namespace OpenSim.Framework.Data.MySQL
610 return false; 625 return false;
611 } 626 }
612 627
628 m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString());
613 return returnval; 629 return returnval;
614 } 630 }
615 631
632 /// <summary>
633 /// Creates a new user and inserts it into the database
634 /// </summary>
635 /// <param name="uuid">User ID</param>
636 /// <param name="username">First part of the login</param>
637 /// <param name="lastname">Second part of the login</param>
638 /// <param name="passwordHash">A salted hash of the users password</param>
639 /// <param name="passwordSalt">The salt used for the password hash</param>
640 /// <param name="homeRegion">A regionHandle of the users home region</param>
641 /// <param name="homeLocX">Home region position vector</param>
642 /// <param name="homeLocY">Home region position vector</param>
643 /// <param name="homeLocZ">Home region position vector</param>
644 /// <param name="homeLookAtX">Home region 'look at' vector</param>
645 /// <param name="homeLookAtY">Home region 'look at' vector</param>
646 /// <param name="homeLookAtZ">Home region 'look at' vector</param>
647 /// <param name="created">Account created (unix timestamp)</param>
648 /// <param name="lastlogin">Last login (unix timestamp)</param>
649 /// <param name="inventoryURI">Users inventory URI</param>
650 /// <param name="assetURI">Users asset URI</param>
651 /// <param name="canDoMask">I can do mask</param>
652 /// <param name="wantDoMask">I want to do mask</param>
653 /// <param name="aboutText">Profile text</param>
654 /// <param name="firstText">Firstlife text</param>
655 /// <param name="profileImage">UUID for profile image</param>
656 /// <param name="firstImage">UUID for firstlife image</param>
657 /// <returns>Success?</returns>
658 public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash,
659 string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ,
660 float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin,
661 string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask,
662 string aboutText, string firstText,
663 LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey)
664 {
665 string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname ";
666 sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , ";
667 sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , ";
668 sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , ";
669 sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , ";
670 sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , ";
671 sql += "`userInventoryURI` = ?userInventoryURI , `userAssetURI` = ?userAssetURI , ";
672 sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , ";
673 sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, ";
674 sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , ";
675 sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID";
676
677 Dictionary<string, string> parameters = new Dictionary<string, string>();
678 parameters["?UUID"] = uuid.ToString();
679 parameters["?username"] = username.ToString();
680 parameters["?lastname"] = lastname.ToString();
681 parameters["?passwordHash"] = passwordHash.ToString();
682 parameters["?passwordSalt"] = passwordSalt.ToString();
683 parameters["?homeRegion"] = homeRegion.ToString();
684 parameters["?homeLocationX"] = homeLocX.ToString();
685 parameters["?homeLocationY"] = homeLocY.ToString();
686 parameters["?homeLocationZ"] = homeLocZ.ToString();
687 parameters["?homeLookAtX"] = homeLookAtX.ToString();
688 parameters["?homeLookAtY"] = homeLookAtY.ToString();
689 parameters["?homeLookAtZ"] = homeLookAtZ.ToString();
690 parameters["?created"] = created.ToString();
691 parameters["?lastLogin"] = lastlogin.ToString();
692 parameters["?userInventoryURI"] = inventoryURI;
693 parameters["?userAssetURI"] = assetURI;
694 parameters["?profileCanDoMask"] = "0";
695 parameters["?profileWantDoMask"] = "0";
696 parameters["?profileAboutText"] = aboutText;
697 parameters["?profileFirstText"] = firstText;
698 parameters["?profileImage"] = profileImage.ToString();
699 parameters["?profileFirstImage"] = firstImage.ToString();
700 parameters["?webLoginKey"] = webLoginKey.ToString();
701
702 bool returnval = false;
703 try
704 {
705 IDbCommand result = Query(sql, parameters);
706
707 if (result.ExecuteNonQuery() == 1)
708 returnval = true;
709
710 result.Dispose();
711 }
712 catch (Exception e)
713 {
714 m_log.Error(e.ToString());
715 return false;
716 }
717
718 m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString());
719 return returnval;
720 }
616 721
617 /// <summary> 722 /// <summary>
618 /// Inserts a new region into the database 723 /// Inserts a new region into the database
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
index bc18376..2bba6ce 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -594,7 +594,11 @@ namespace OpenSim.Framework.Data.MySQL
594 /// <param name="user">The profile data to use to update the DB</param> 594 /// <param name="user">The profile data to use to update the DB</param>
595 public bool UpdateUserProfile(UserProfileData user) 595 public bool UpdateUserProfile(UserProfileData user)
596 { 596 {
597 // TODO: implement 597 database.updateUserRow(user.UUID, user.username, user.surname, user.passwordHash, user.passwordSalt
598 , user.homeRegion, user.homeLocation.X, user.homeLocation.Y, user.homeLocation.Z, user.homeLookAt.X
599 , user.homeLookAt.Y, user.homeLookAt.Z, user.created, user.lastLogin, user.userInventoryURI
600 , user.userAssetURI, user.profileCanDoMask, user.profileWantDoMask, user.profileAboutText
601 , user.profileFirstText, user.profileImage, user.profileFirstImage, user.webLoginKey);
598 return true; 602 return true;
599 } 603 }
600 604
@@ -641,4 +645,4 @@ namespace OpenSim.Framework.Data.MySQL
641 return "0.1"; 645 return "0.1";
642 } 646 }
643 } 647 }
644} \ No newline at end of file 648}