aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs6
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs31
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs14
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLManager.cs113
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs8
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs8
-rw-r--r--OpenSim/Framework/IClientAPI.cs3
-rw-r--r--OpenSim/Framework/IUserService.cs7
-rw-r--r--OpenSim/Framework/Util.cs22
9 files changed, 187 insertions, 25 deletions
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 4ad808a..655abd7 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -229,6 +229,12 @@ namespace OpenSim.Framework.Communications
229 229
230 #region Packet Handlers 230 #region Packet Handlers
231 231
232 public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile)
233 {
234 m_userService.UpdateUserProfileProperties(UserProfile);
235 return;
236 }
237
232 public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) 238 public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client)
233 { 239 {
234 if (uuid == m_userProfileCacheService.libraryRoot.agentID) 240 if (uuid == m_userProfileCacheService.libraryRoot.agentID)
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index 733d62b..3380e90 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -139,11 +139,10 @@ namespace OpenSim.Framework.UserManagement
139 } 139 }
140 140
141 /// <summary> 141 /// <summary>
142 /// Set's user profile from object 142 /// Set's user profile from data object
143 /// </summary> 143 /// </summary>
144 /// <param name="fname">First name</param> 144 /// <param name="data"></param>
145 /// <param name="lname">Last name</param> 145 /// <returns></returns>
146 /// <returns>A user profile</returns>
147 public bool setUserProfile(UserProfileData data) 146 public bool setUserProfile(UserProfileData data)
148 { 147 {
149 foreach (KeyValuePair<string, IUserData> plugin in _plugins) 148 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
@@ -158,7 +157,6 @@ namespace OpenSim.Framework.UserManagement
158 m_log.Info("[USERSTORAGE]: Unable to set user via " + plugin.Key + "(" + e.ToString() + ")"); 157 m_log.Info("[USERSTORAGE]: Unable to set user via " + plugin.Key + "(" + e.ToString() + ")");
159 } 158 }
160 } 159 }
161
162 return false; 160 return false;
163 } 161 }
164 162
@@ -534,6 +532,29 @@ namespace OpenSim.Framework.UserManagement
534 return user.UUID; 532 return user.UUID;
535 } 533 }
536 534
535 public bool UpdateUserProfileProperties(UserProfileData UserProfile)
536 {
537 if (null == GetUserProfile(UserProfile.UUID))
538 {
539 m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.UUID.ToString());
540 return false;
541 }
542 foreach (KeyValuePair<string, IUserData> plugin in _plugins)
543 {
544 try
545 {
546 plugin.Value.UpdateUserProfile(UserProfile);
547 }
548 catch (Exception e)
549 {
550 m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.UUID.ToString()
551 + " via " + plugin.Key + "(" + e.ToString() + ")");
552 return false;
553 }
554 }
555 return true;
556 }
557
537 public abstract UserProfileData SetupMasterUser(string firstName, string lastName); 558 public abstract UserProfileData SetupMasterUser(string firstName, string lastName);
538 public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password); 559 public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
539 public abstract UserProfileData SetupMasterUser(LLUUID uuid); 560 public abstract UserProfileData SetupMasterUser(LLUUID uuid);
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
index 402a88f..2244f4b 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
@@ -588,10 +588,10 @@ namespace OpenSim.Framework.Data.MSSQL
588 parameters["userAssetURI"] = String.Empty; 588 parameters["userAssetURI"] = String.Empty;
589 parameters["profileCanDoMask"] = "0"; 589 parameters["profileCanDoMask"] = "0";
590 parameters["profileWantDoMask"] = "0"; 590 parameters["profileWantDoMask"] = "0";
591 parameters["profileAboutText"] = String.Empty; 591 parameters["profileAboutText"] = aboutText;
592 parameters["profileFirstText"] = String.Empty; 592 parameters["profileFirstText"] = firstText;
593 parameters["profileImage"] = LLUUID.Zero.ToString(); 593 parameters["profileImage"] = profileImage.ToString();
594 parameters["profileFirstImage"] = LLUUID.Zero.ToString(); 594 parameters["profileFirstImage"] = firstImage.ToString();
595 parameters["webLoginKey"] = LLUUID.Random().ToString(); 595 parameters["webLoginKey"] = LLUUID.Random().ToString();
596 596
597 bool returnval = false; 597 bool returnval = false;
@@ -670,8 +670,8 @@ namespace OpenSim.Framework.Data.MSSQL
670 SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.profileWantDoMask)); 670 SqlParameter param18 = new SqlParameter("@profileWantDoMask", Convert.ToInt32(user.profileWantDoMask));
671 SqlParameter param19 = new SqlParameter("@profileAboutText", user.profileAboutText); 671 SqlParameter param19 = new SqlParameter("@profileAboutText", user.profileAboutText);
672 SqlParameter param20 = new SqlParameter("@profileFirstText", user.profileFirstText); 672 SqlParameter param20 = new SqlParameter("@profileFirstText", user.profileFirstText);
673 SqlParameter param21 = new SqlParameter("@profileImage", LLUUID.Zero.ToString()); 673 SqlParameter param21 = new SqlParameter("@profileImage", user.profileImage.ToString());
674 SqlParameter param22 = new SqlParameter("@profileFirstImage", LLUUID.Zero.ToString()); 674 SqlParameter param22 = new SqlParameter("@profileFirstImage", user.profileFirstImage.ToString());
675 SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString()); 675 SqlParameter param23 = new SqlParameter("@keyUUUID", user.UUID.ToString());
676 SqlParameter param24 = new SqlParameter("@webLoginKey", user.webLoginKey.UUID.ToString()); 676 SqlParameter param24 = new SqlParameter("@webLoginKey", user.webLoginKey.UUID.ToString());
677 command.Parameters.Add(param1); 677 command.Parameters.Add(param1);
@@ -768,4 +768,4 @@ namespace OpenSim.Framework.Data.MSSQL
768 { 768 {
769 } 769 }
770 } 770 }
771} \ No newline at end of file 771}
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}
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index 2316de8..22f0053 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -590,7 +590,7 @@ namespace OpenSim.Framework.Data.SQLite
590 // interesting has to be done to actually get these values 590 // interesting has to be done to actually get these values
591 // back out. Not enough time to figure it out yet. 591 // back out. Not enough time to figure it out yet.
592 UserProfileData user = new UserProfileData(); 592 UserProfileData user = new UserProfileData();
593 user.UUID = new LLUUID((String) row["UUID"]); 593 LLUUID.TryParse((String)row["UUID"], out user.UUID);
594 user.username = (String) row["username"]; 594 user.username = (String) row["username"];
595 user.surname = (String) row["surname"]; 595 user.surname = (String) row["surname"];
596 user.passwordHash = (String) row["passwordHash"]; 596 user.passwordHash = (String) row["passwordHash"];
@@ -617,8 +617,8 @@ namespace OpenSim.Framework.Data.SQLite
617 user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]); 617 user.profileWantDoMask = Convert.ToUInt32(row["profileWantDoMask"]);
618 user.profileAboutText = (String) row["profileAboutText"]; 618 user.profileAboutText = (String) row["profileAboutText"];
619 user.profileFirstText = (String) row["profileFirstText"]; 619 user.profileFirstText = (String) row["profileFirstText"];
620 user.profileImage = new LLUUID((String) row["profileImage"]); 620 LLUUID.TryParse((String)row["profileImage"], out user.profileImage);
621 user.profileFirstImage = new LLUUID((String) row["profileFirstImage"]); 621 LLUUID.TryParse((String)row["profileFirstImage"], out user.profileFirstImage);
622 user.webLoginKey = new LLUUID((String) row["webLoginKey"]); 622 user.webLoginKey = new LLUUID((String) row["webLoginKey"]);
623 623
624 return user; 624 return user;
@@ -832,4 +832,4 @@ namespace OpenSim.Framework.Data.SQLite
832 return true; 832 return true;
833 } 833 }
834 } 834 }
835} \ No newline at end of file 835}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 511bbad..5001f00 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -264,6 +264,8 @@ namespace OpenSim.Framework
264 264
265 public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID); 265 public delegate void RequestAvatarProperties(IClientAPI remoteClient, LLUUID avatarID);
266 266
267 public delegate void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData ProfileData);
268
267 public delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun); 269 public delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun);
268 270
269 public delegate void GenericCall2(); 271 public delegate void GenericCall2();
@@ -530,6 +532,7 @@ namespace OpenSim.Framework
530 event MoneyTransferRequest OnMoneyTransferRequest; 532 event MoneyTransferRequest OnMoneyTransferRequest;
531 533
532 event MoneyBalanceRequest OnMoneyBalanceRequest; 534 event MoneyBalanceRequest OnMoneyBalanceRequest;
535 event UpdateAvatarProperties OnUpdateAvatarProperties;
533 536
534 537
535 LLVector3 StartPos { get; set; } 538 LLVector3 StartPos { get; set; }
diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs
index 3b84486..0faf12e 100644
--- a/OpenSim/Framework/IUserService.cs
+++ b/OpenSim/Framework/IUserService.cs
@@ -87,6 +87,13 @@ namespace OpenSim.Framework
87 void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms); 87 void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms);
88 88
89 /// <summary> 89 /// <summary>
90 /// Updates a user profile
91 /// </summary>
92 /// <param name="UserProfile">Profile to update</param>
93 /// <returns></returns>
94 bool UpdateUserProfileProperties(UserProfileData UserProfile);
95
96 /// <summary>
90 /// Logs off a user on the user server 97 /// Logs off a user on the user server
91 /// </summary> 98 /// </summary>
92 /// <param name="UserID">UUID of the user</param> 99 /// <param name="UserID">UUID of the user</param>
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 856cac3..35e795b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -181,9 +181,25 @@ namespace OpenSim.Framework
181 181
182 public static int UnixTimeSinceEpoch() 182 public static int UnixTimeSinceEpoch()
183 { 183 {
184 TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); 184 return ToUnixTime(DateTime.UtcNow);
185 int timestamp = (int) t.TotalSeconds; 185 }
186 return timestamp; 186
187 public static int ToUnixTime(DateTime stamp)
188 {
189 TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM"));
190 return (int)t.TotalSeconds;
191 }
192
193 public static DateTime ToDateTime(ulong seconds)
194 {
195 DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
196 return epoch.AddSeconds(seconds);
197 }
198
199 public static DateTime ToDateTime(int seconds)
200 {
201 DateTime epoch = Convert.ToDateTime("1/1/1970 8:00:00 AM");
202 return epoch.AddSeconds(seconds);
187 } 203 }
188 204
189 public static string Md5Hash(string pass) 205 public static string Md5Hash(string pass)