From ddaa90d270c9bd10c74cf89b29b45963719f9b60 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 15 Sep 2008 19:02:34 +0000
Subject: * refactor: collapse UpdateUserProfileProperties() into existing
 UpdateUserProfile * the methods were identical except that the Properties one
 did a check for the user profile beforehand.  However, every caller was doing
 this already anyway.

---
 .../Communications/CommunicationsManager.cs        |  2 +-
 OpenSim/Framework/Communications/IUserService.cs   |  7 ---
 .../Framework/Communications/UserManagerBase.cs    | 23 ----------
 OpenSim/Grid/UserServer/UserManager.cs             |  2 +-
 .../Region/Communications/OGS1/OGS1UserServices.cs | 51 ++++++++++------------
 .../Avatar/Profiles/AvatarProfilesModule.cs        |  3 +-
 OpenSim/Region/Environment/Scenes/Scene.cs         |  4 +-
 7 files changed, 29 insertions(+), 63 deletions(-)

diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index 27cdd35..5bed282 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -350,7 +350,7 @@ namespace OpenSim.Framework.Communications
 
         public void UpdateAvatarPropertiesRequest(IClientAPI remote_client, UserProfileData UserProfile)
         {
-            m_userService.UpdateUserProfileProperties(UserProfile);
+            m_userService.UpdateUserProfile(UserProfile);
             return;
         }
 
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 64c6c68..50c9917 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -88,13 +88,6 @@ namespace OpenSim.Framework.Communications
         void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms);
 
         /// <summary>
-        /// Updates a user profile
-        /// </summary>
-        /// <param name="UserProfile">Profile to update</param>
-        /// <returns></returns>
-        bool UpdateUserProfileProperties(UserProfileData UserProfile);
-
-        /// <summary>
         /// Logs off a user on the user server
         /// </summary>
         /// <param name="UserID">UUID of the user</param>
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index f06a438..46a9b67 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -600,29 +600,6 @@ namespace OpenSim.Framework.Communications
             return true;
         }        
 
-        public bool UpdateUserProfileProperties(UserProfileData UserProfile)
-        {
-            if (null == GetUserProfile(UserProfile.ID))
-            {
-                m_log.Info("[USERSTORAGE]: Failed to find User by UUID " + UserProfile.ID.ToString());
-                return false;
-            }
-            foreach (IUserDataPlugin plugin in _plugins)
-            {
-                try
-                {
-                    plugin.UpdateUserProfile(UserProfile);
-                }
-                catch (Exception e)
-                {
-                    m_log.Info("[USERSTORAGE]: Unable to update user " + UserProfile.ID.ToString()
-                               + " via " + plugin.Name + "(" + e.ToString() + ")");
-                    return false;
-                }
-            }
-            return true;
-        }
-
         public abstract UserProfileData SetupMasterUser(string firstName, string lastName);
         public abstract UserProfileData SetupMasterUser(string firstName, string lastName, string password);
         public abstract UserProfileData SetupMasterUser(UUID uuid);
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index 4b5f5a0..ecb806f 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -695,7 +695,7 @@ namespace OpenSim.Grid.UserServer
             }
 
             // call plugin!
-            bool ret = UpdateUserProfileProperties(userProfile);
+            bool ret = UpdateUserProfile(userProfile);
             responseData["returnString"] = ret.ToString();
             response.Value = responseData;
             return response;
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 0ca85d2..28177d0 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -475,38 +475,32 @@ namespace OpenSim.Region.Communications.OGS1
             throw new Exception("The method or operation is not implemented.");
         }        
 
-        // TODO
-        public bool UpdateUserProfile(UserProfileData data)
-        {
-            return false;
-        }
-
-        public bool UpdateUserProfileProperties(UserProfileData UserProfile)
+        public bool UpdateUserProfile(UserProfileData userProfile)
         {
             m_log.Debug("[OGS1 USER SERVICES]: Asking UserServer to update profile.");
             Hashtable param = new Hashtable();
-            param["avatar_uuid"] = UserProfile.ID.ToString();
-            //param["AllowPublish"] = UserProfile.ToString();
-            param["FLImageID"] = UserProfile.FirstLifeImage.ToString();
-            param["ImageID"] = UserProfile.Image.ToString();
+            param["avatar_uuid"] = userProfile.ID.ToString();
+            //param["AllowPublish"] = userProfile.ToString();
+            param["FLImageID"] = userProfile.FirstLifeImage.ToString();
+            param["ImageID"] = userProfile.Image.ToString();
             //param["MaturePublish"] = MaturePublish.ToString();
-            param["AboutText"] = UserProfile.AboutText;
-            param["FLAboutText"] = UserProfile.FirstLifeAboutText;
-            //param["ProfileURL"] = UserProfile.ProfileURL.ToString();
-
-            param["home_region"] = UserProfile.HomeRegion.ToString();
-            param["home_region_id"] = UserProfile.HomeRegionID.ToString();
-
-            param["home_pos_x"] = UserProfile.HomeLocationX.ToString();
-            param["home_pos_y"] = UserProfile.HomeLocationY.ToString();
-            param["home_pos_z"] = UserProfile.HomeLocationZ.ToString();
-            param["home_look_x"] = UserProfile.HomeLookAtX.ToString();
-            param["home_look_y"] = UserProfile.HomeLookAtY.ToString();
-            param["home_look_z"] = UserProfile.HomeLookAtZ.ToString();
-            param["user_flags"] = UserProfile.UserFlags.ToString();
-            param["god_level"] = UserProfile.GodLevel.ToString();
-            param["custom_type"] = UserProfile.CustomType.ToString();
-            param["partner"] = UserProfile.Partner.ToString();
+            param["AboutText"] = userProfile.AboutText;
+            param["FLAboutText"] = userProfile.FirstLifeAboutText;
+            //param["ProfileURL"] = userProfile.ProfileURL.ToString();
+
+            param["home_region"] = userProfile.HomeRegion.ToString();
+            param["home_region_id"] = userProfile.HomeRegionID.ToString();
+
+            param["home_pos_x"] = userProfile.HomeLocationX.ToString();
+            param["home_pos_y"] = userProfile.HomeLocationY.ToString();
+            param["home_pos_z"] = userProfile.HomeLocationZ.ToString();
+            param["home_look_x"] = userProfile.HomeLookAtX.ToString();
+            param["home_look_y"] = userProfile.HomeLookAtY.ToString();
+            param["home_look_z"] = userProfile.HomeLookAtZ.ToString();
+            param["user_flags"] = userProfile.UserFlags.ToString();
+            param["god_level"] = userProfile.GodLevel.ToString();
+            param["custom_type"] = userProfile.CustomType.ToString();
+            param["partner"] = userProfile.Partner.ToString();
 
             IList parameters = new ArrayList();
             parameters.Add(param);
@@ -535,6 +529,7 @@ namespace OpenSim.Region.Communications.OGS1
                 m_log.Warn("[GRID]: Unable to update user profile, UserServer didn't understand me!");
                 return false;
             }
+            
             return true;
         }
 
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
index f9c0dcf..b1cf802 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
@@ -134,7 +134,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
             {
                 return;
             }
-            if (m_scene.CommsManager.UserService.UpdateUserProfileProperties(Profile))
+            
+            if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile))
             {
                 RequestAvatarProperty(remoteClient, newProfile.ID);
             }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 7116904..2a736fb 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -2254,7 +2254,7 @@ namespace OpenSim.Region.Environment.Scenes
                         return;
                     }
                     UserProfile.HomeRegionID = info.RegionID;
-                    CommsManager.UserService.UpdateUserProfileProperties(UserProfile);
+                    CommsManager.UserService.UpdateUserProfile(UserProfile);
                 }
                 else
                 {
@@ -2355,7 +2355,7 @@ namespace OpenSim.Region.Environment.Scenes
                 UserProfile.HomeRegion = RegionInfo.RegionHandle;
                 UserProfile.HomeLocation = position;
                 UserProfile.HomeLookAt = lookAt;
-                CommsManager.UserService.UpdateUserProfileProperties(UserProfile);
+                CommsManager.UserService.UpdateUserProfile(UserProfile);
 
                 remoteClient.SendAgentAlertMessage("Set home to here if supported by login service",false);
             }
-- 
cgit v1.1