aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares2008-03-03 08:30:36 +0000
committerTeravus Ovares2008-03-03 08:30:36 +0000
commitfe49c96ee0db0974a91b9b175ac1b00aef035797 (patch)
tree27fb1de9eea228d2e89e1c5b1c83cca8577b3bd9
parent* Doh, forgot one license header (diff)
downloadopensim-SC-fe49c96ee0db0974a91b9b175ac1b00aef035797.zip
opensim-SC-fe49c96ee0db0974a91b9b175ac1b00aef035797.tar.gz
opensim-SC-fe49c96ee0db0974a91b9b175ac1b00aef035797.tar.bz2
opensim-SC-fe49c96ee0db0974a91b9b175ac1b00aef035797.tar.xz
* Applying Ahzz's profile patch. Thanks Ahzz!
* Fixed a few bugs in the patch that are sim crashers. * There's still a bug in mySQL mode/ grid mode where the main userprofile text doesn't save.
-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
-rw-r--r--OpenSim/Grid/UserServer/Main.cs1
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs55
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs27
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs42
-rw-r--r--OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs45
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs2
15 files changed, 349 insertions, 35 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)
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index fcf9de6..c3d65c4 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -127,6 +127,7 @@ namespace OpenSim.Grid.UserServer
127 httpServer.AddStreamHandler( 127 httpServer.AddStreamHandler(
128 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); 128 new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod));
129 129
130 httpServer.AddXmlRPCHandler("update_user_profile", m_userManager.XmlRpcResponseXmlRPCUpdateUserProfile);
130 httpServer.Start(); 131 httpServer.Start();
131 m_log.Info("[SERVER]: Userserver 0.5 - Startup complete"); 132 m_log.Info("[SERVER]: Userserver 0.5 - Startup complete");
132 } 133 }
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 367b5d7..153ac75 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -313,6 +313,61 @@ namespace OpenSim.Grid.UserServer
313 return ProfileToXmlRPCResponse(userProfile); 313 return ProfileToXmlRPCResponse(userProfile);
314 } 314 }
315 315
316
317 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request)
318 {
319 m_log.Debug("[UserManager]: Got request to update user profile");
320 XmlRpcResponse response = new XmlRpcResponse();
321 Hashtable requestData = (Hashtable)request.Params[0];
322 Hashtable responseData = new Hashtable();
323
324 UserProfileData userProfile;
325 if (!requestData.Contains("avatar_uuid"))
326 {
327 return CreateUnknownUserErrorResponse();
328 }
329
330 LLUUID UserUUID = new LLUUID((string)requestData["avatar_uuid"]);
331 userProfile = GetUserProfile(UserUUID);
332 if (null == userProfile)
333 {
334 return CreateUnknownUserErrorResponse();
335 }
336 // don't know how yet.
337 if (requestData.Contains("AllowPublish"))
338 {
339 }
340 if (requestData.Contains("FLImageID"))
341 {
342 userProfile.profileFirstImage = new LLUUID((string)requestData["FLImageID"]);
343 }
344 if (requestData.Contains("ImageID"))
345 {
346 userProfile.profileImage = new LLUUID((string)requestData["ImageID"]);
347 }
348 // dont' know how yet
349 if (requestData.Contains("MaturePublish"))
350 {
351 }
352 if (requestData.Contains("AboutText"))
353 {
354 userProfile.profileAboutText = (string)requestData["AboutText"];
355 }
356 if (requestData.Contains("FLAboutText"))
357 {
358 userProfile.profileFirstText = (string)requestData["FLAboutText"];
359 }
360 // not in DB yet.
361 if (requestData.Contains("ProfileURL"))
362 {
363 }
364 // call plugin!
365 bool ret = UpdateUserProfileProperties(userProfile);
366 responseData["returnString"] = ret.ToString();
367 response.Value = responseData;
368 return response;
369 }
370
316 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) 371 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
317 { 372 {
318 XmlRpcResponse response = new XmlRpcResponse(); 373 XmlRpcResponse response = new XmlRpcResponse();
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index d032a2e..fe12cb7 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -123,6 +123,7 @@ namespace OpenSim.Region.ClientStack
123 //- used so we don't create new objects for each incoming packet and then toss it out later */ 123 //- used so we don't create new objects for each incoming packet and then toss it out later */
124 124
125 private RequestAvatarProperties handlerRequestAvatarProperties = null; //OnRequestAvatarProperties; 125 private RequestAvatarProperties handlerRequestAvatarProperties = null; //OnRequestAvatarProperties;
126 private UpdateAvatarProperties handlerUpdateAvatarProperties = null; // OnUpdateAvatarProperties;
126 private ChatFromViewer handlerChatFromViewer = null; //OnChatFromViewer; 127 private ChatFromViewer handlerChatFromViewer = null; //OnChatFromViewer;
127 private ChatFromViewer handlerChatFromViewer2 = null; //OnChatFromViewer; 128 private ChatFromViewer handlerChatFromViewer2 = null; //OnChatFromViewer;
128 private ImprovedInstantMessage handlerInstantMessage = null; //OnInstantMessage; 129 private ImprovedInstantMessage handlerInstantMessage = null; //OnInstantMessage;
@@ -217,7 +218,6 @@ namespace OpenSim.Region.ClientStack
217 private PacketStats handlerPacketStats = null; // OnPacketStats;# 218 private PacketStats handlerPacketStats = null; // OnPacketStats;#
218 private RequestAsset handlerRequestAsset = null; // OnRequestAsset; 219 private RequestAsset handlerRequestAsset = null; // OnRequestAsset;
219 220
220
221 /* Properties */ 221 /* Properties */
222 222
223 public LLUUID SecureSessionId 223 public LLUUID SecureSessionId
@@ -670,6 +670,7 @@ namespace OpenSim.Region.ClientStack
670 public event FetchInventory OnAgentDataUpdateRequest; 670 public event FetchInventory OnAgentDataUpdateRequest;
671 public event FetchInventory OnUserInfoRequest; 671 public event FetchInventory OnUserInfoRequest;
672 public event TeleportLocationRequest OnSetStartLocationRequest; 672 public event TeleportLocationRequest OnSetStartLocationRequest;
673 public event UpdateAvatarProperties OnUpdateAvatarProperties;
673 674
674 675
675 public event CreateNewInventoryItem OnCreateNewInventoryItem; 676 public event CreateNewInventoryItem OnCreateNewInventoryItem;
@@ -1591,7 +1592,10 @@ namespace OpenSim.Region.ClientStack
1591 avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText); 1592 avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText);
1592 avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn); 1593 avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn);
1593 avatarReply.PropertiesData.CharterMember = Helpers.StringToField(charterMember); 1594 avatarReply.PropertiesData.CharterMember = Helpers.StringToField(charterMember);
1594 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout); 1595 if (flAbout != null)
1596 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout);
1597 else
1598 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField("");
1595 avatarReply.PropertiesData.Flags = 0; 1599 avatarReply.PropertiesData.Flags = 0;
1596 avatarReply.PropertiesData.FLImageID = flImageID; 1600 avatarReply.PropertiesData.FLImageID = flImageID;
1597 avatarReply.PropertiesData.ImageID = imageID; 1601 avatarReply.PropertiesData.ImageID = imageID;
@@ -2901,10 +2905,25 @@ namespace OpenSim.Region.ClientStack
2901 if (handlerChatFromViewer != null) 2905 if (handlerChatFromViewer != null)
2902 handlerChatFromViewer(this, args); 2906 handlerChatFromViewer(this, args);
2903 } 2907 }
2908 break;
2909 case PacketType.AvatarPropertiesUpdate:
2910 AvatarPropertiesUpdatePacket Packet = (AvatarPropertiesUpdatePacket)Pack;
2904 2911
2905 2912 handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
2906 2913 if (handlerUpdateAvatarProperties != null)
2914 {
2915 AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = Packet.PropertiesData;
2916 UserProfileData UserProfile = new UserProfileData();
2917 UserProfile.UUID = AgentId;
2918 UserProfile.profileAboutText = Util.FieldToString(Properties.AboutText);
2919 UserProfile.profileFirstText = Util.FieldToString(Properties.FLAboutText);
2920 UserProfile.profileFirstImage = Properties.FLImageID;
2921 UserProfile.profileImage = Properties.ImageID;
2922
2923 handlerUpdateAvatarProperties(this, UserProfile);
2924 }
2907 break; 2925 break;
2926
2908 case PacketType.ScriptDialogReply: 2927 case PacketType.ScriptDialogReply:
2909 ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; 2928 ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
2910 int ch = rdialog.Data.ChatChannel; 2929 int ch = rdialog.Data.ChatChannel;
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 8ad4468..7dcbb46 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -270,6 +270,48 @@ namespace OpenSim.Region.Communications.OGS1
270 throw new Exception("The method or operation is not implemented."); 270 throw new Exception("The method or operation is not implemented.");
271 } 271 }
272 272
273 public bool UpdateUserProfileProperties(UserProfileData UserProfile)
274 {
275 m_log.Debug("[OGS1UserService]: Asking UserServer to update profile.");
276 Hashtable param = new Hashtable();
277 param["avatar_uuid"] = UserProfile.UUID.ToString();
278 //param["AllowPublish"] = UserProfile.ToString();
279 param["FLImageID"] = UserProfile.profileFirstImage.ToString();
280 param["ImageID"] = UserProfile.profileImage.ToString();
281 //param["MaturePublish"] = MaturePublish.ToString();
282 param["AboutText"] = UserProfile.profileAboutText;
283 param["FLAboutText"] = UserProfile.profileFirstText;
284 //param["ProfileURL"] = UserProfile.ProfileURL.ToString();
285 IList parameters = new ArrayList();
286 parameters.Add(param);
287
288 XmlRpcRequest req = new XmlRpcRequest("update_user_profile", parameters);
289 XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
290 Hashtable respData = (Hashtable)resp.Value;
291 if (respData != null)
292 {
293 if (respData.Contains("returnString"))
294 {
295 if (((string)respData["returnString"]).ToUpper() != "TRUE")
296 {
297 m_log.Warn("[GRID]: Unable to update user profile, User Server Reported an issue");
298 return false;
299 }
300 }
301 else
302 {
303 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
304 return false;
305 }
306 }
307 else
308 {
309 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
310 return false;
311 }
312 return true;
313 }
314
273 #region IUserServices Friend Methods 315 #region IUserServices Friend Methods
274 /// <summary> 316 /// <summary>
275 /// Adds a new friend to the database for XUser 317 /// Adds a new friend to the database for XUser
diff --git a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
index 8f4a0a1..711236d 100644
--- a/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
+++ b/OpenSim/Region/Environment/Modules/AvatarProfilesModule.cs
@@ -36,6 +36,7 @@ namespace OpenSim.Region.Environment.Modules
36{ 36{
37 public class AvatarProfilesModule : IRegionModule 37 public class AvatarProfilesModule : IRegionModule
38 { 38 {
39 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
39 private Scene m_scene; 40 private Scene m_scene;
40 41
41 public AvatarProfilesModule() 42 public AvatarProfilesModule()
@@ -69,11 +70,13 @@ namespace OpenSim.Region.Environment.Modules
69 public void NewClient(IClientAPI client) 70 public void NewClient(IClientAPI client)
70 { 71 {
71 client.OnRequestAvatarProperties += RequestAvatarProperty; 72 client.OnRequestAvatarProperties += RequestAvatarProperty;
73 client.OnUpdateAvatarProperties += UpdateAvatarProperties;
72 } 74 }
73 75
74 public void RemoveClient(IClientAPI client) 76 public void RemoveClient(IClientAPI client)
75 { 77 {
76 client.OnRequestAvatarProperties -= RequestAvatarProperty; 78 client.OnRequestAvatarProperties -= RequestAvatarProperty;
79 client.OnUpdateAvatarProperties -= UpdateAvatarProperties;
77 } 80 }
78 81
79 /// <summary> 82 /// <summary>
@@ -83,12 +86,42 @@ namespace OpenSim.Region.Environment.Modules
83 /// <param name="avatarID"></param> 86 /// <param name="avatarID"></param>
84 public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID) 87 public void RequestAvatarProperty(IClientAPI remoteClient, LLUUID avatarID)
85 { 88 {
86 string about = "OpenSim crash test dummy"; 89 // FIXME: finish adding fields such as url, masking, etc.
87 string bornOn = "Before now";
88 string flAbout = "First life? What is one of those? OpenSim is my life!";
89 LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000"); 90 LLUUID partner = new LLUUID("11111111-1111-0000-0000-000100bba000");
90 remoteClient.SendAvatarProperties(avatarID, about, bornOn, System.String.Empty, flAbout, 0, LLUUID.Zero, LLUUID.Zero, System.String.Empty, 91 UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID);
91 partner); 92 if (null != profile)
93 {
94 remoteClient.SendAvatarProperties(profile.UUID, profile.profileAboutText,
95 Util.ToDateTime(profile.created).ToString(),
96 System.String.Empty, profile.profileFirstText, profile.profileCanDoMask,
97 profile.profileFirstImage, profile.profileImage, System.String.Empty, partner);
98 }
99 else
100 {
101 m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString());
102 }
103 }
104
105 public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile)
106 {
107 UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.UUID);
108
109 // if it's the profile of the user requesting the update, then we change only a few things.
110 if (remoteClient.AgentId.CompareTo(Profile.UUID) == 0)
111 {
112 Profile.profileImage = newProfile.profileImage;
113 Profile.profileFirstImage = newProfile.profileFirstImage;
114 Profile.profileAboutText = newProfile.profileAboutText;
115 Profile.profileFirstText = newProfile.profileFirstText;
116 }
117 else
118 {
119 return;
120 }
121 if (m_scene.CommsManager.UserService.UpdateUserProfileProperties(Profile))
122 {
123 RequestAvatarProperty(remoteClient, newProfile.UUID);
124 }
92 } 125 }
93 } 126 }
94} \ No newline at end of file 127}
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 30a41b7..cb2c908 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -154,6 +154,8 @@ namespace SimpleApp
154 public event FriendshipTermination OnTerminateFriendship; 154 public event FriendshipTermination OnTerminateFriendship;
155 public event PacketStats OnPacketStats; 155 public event PacketStats OnPacketStats;
156 public event MoneyBalanceRequest OnMoneyBalanceRequest; 156 public event MoneyBalanceRequest OnMoneyBalanceRequest;
157 public event UpdateAvatarProperties OnUpdateAvatarProperties;
158
157 159
158#pragma warning restore 67 160#pragma warning restore 67
159 161