From 3738bc88999d4cf8060fa2535cb264e0cddcb8c7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Wed, 2 Jan 2008 00:54:50 +0000 Subject: * Updates UserServer * Updates OSG1UserServices * Friends list is now persistent in grid mode. * You can add, new friends and remove them --- OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 4 - OpenSim/Framework/Servers/BaseHttpServer.cs | 2 +- OpenSim/Grid/UserServer/Main.cs | 6 +- OpenSim/Grid/UserServer/UserManager.cs | 98 +++++++++++- .../Region/Communications/OGS1/OGS1UserServices.cs | 175 ++++++++++++++++++++- 5 files changed, 277 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index a5e6da4..7e2d4f0 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -205,7 +205,6 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Error(e.ToString()); return; } - MainLog.Instance.Verbose("FRIEND", "Stub AddNewUserFriend called"); } public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) @@ -241,7 +240,6 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Error(e.ToString()); return; } - MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called"); } public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { @@ -271,7 +269,6 @@ namespace OpenSim.Framework.Data.MySQL MainLog.Instance.Error(e.ToString()); return; } - MainLog.Instance.Verbose("FRIEND", "Stub UpdateUserFriendPerms called"); } @@ -318,7 +315,6 @@ namespace OpenSim.Framework.Data.MySQL return Lfli; } - MainLog.Instance.Verbose("FRIEND", "Stub GetUserFriendList called"); return Lfli; } diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 7af1716..af2b27c 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -385,7 +385,7 @@ namespace OpenSim.Framework.Servers response.StatusCode = 301; response.RedirectLocation = "secondlife:///app/login?first_name=" + keysvals["username"] + "&last_name=" + keysvals["lastname"] + - "&location=home&grid=Other&web_login_key=796f2b2a-0131-41e4-af12-00f60c24c458"; + "&location=home&grid=other&web_login_key=796f2b2a-0131-41e4-af12-00f60c24c458"; response.OutputStream.Close(); } // show_login_form == "FALSE" diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index d50558f..0f1d845 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -101,7 +101,11 @@ namespace OpenSim.Grid.UserServer httpServer.AddXmlRPCHandler("get_user_by_name", m_userManager.XmlRPCGetUserMethodName); httpServer.AddXmlRPCHandler("get_user_by_uuid", m_userManager.XmlRPCGetUserMethodUUID); httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", m_userManager.XmlRPCGetAvatarPickerAvatar); - + httpServer.AddXmlRPCHandler("add_new_user_friend", m_userManager.XmlRpcResponseXmlRPCAddUserFriend); + httpServer.AddXmlRPCHandler("remove_user_friend", m_userManager.XmlRpcResponseXmlRPCRemoveUserFriend); + httpServer.AddXmlRPCHandler("update_user_friend_perms", m_userManager.XmlRpcResponseXmlRPCUpdateUserFriendPerms); + httpServer.AddXmlRPCHandler("get_user_friend_list", m_userManager.XmlRpcResponseXmlRPCGetUserFriendList); + httpServer.AddStreamHandler( new RestStreamHandler("DELETE", "/usersessions/", m_userManager.RestDeleteUserSessionMethod)); diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index a50419e..c905ffe 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -87,10 +87,29 @@ namespace OpenSim.Grid.UserServer responseData["lastname" + i.ToString()] = returnUsers[i].lastName; } response.Value = responseData; - + return response; } + public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List returnUsers) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + // Query Result Information + + responseData["avcount"] = (string)returnUsers.Count.ToString(); + + for (int i = 0; i < returnUsers.Count; i++) + { + responseData["ownerID" + i.ToString()] = returnUsers[i].FriendListOwner.UUID.ToString(); + responseData["friendID" + i.ToString()] = returnUsers[i].Friend.UUID.ToString(); + responseData["ownerPerms" + i.ToString()] = returnUsers[i].FriendListOwnerPerms.ToString(); + responseData["friendPerms" + i.ToString()] = returnUsers[i].FriendPerms.ToString(); + } + response.Value = responseData; + + return response; + } /// /// Converts a user profile to an XML element which can be returned /// @@ -151,6 +170,83 @@ namespace OpenSim.Grid.UserServer return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); } + public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData = new Hashtable(); + string returnString = "FALSE"; + // Query Result Information + + if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) + { + // UserManagerBase.AddNewuserFriend + AddNewUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); + returnString = "TRUE"; + } + responseData["returnString"] = returnString; + response.Value = responseData; + return response; + } + + public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData = new Hashtable(); + string returnString = "FALSE"; + // Query Result Information + + if (requestData.Contains("ownerID") && requestData.Contains("friendID")) + { + // UserManagerBase.AddNewuserFriend + RemoveUserFriend(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"])); + returnString = "TRUE"; + } + responseData["returnString"] = returnString; + response.Value = responseData; + return response; + + } + + public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData = new Hashtable(); + string returnString = "FALSE"; + + + + if (requestData.Contains("ownerID") && requestData.Contains("friendID") && requestData.Contains("friendPerms")) + { + UpdateUserFriendPerms(new LLUUID((string)requestData["ownerID"]), new LLUUID((string)requestData["friendID"]), (uint)Convert.ToInt32((string)requestData["friendPerms"])); + // UserManagerBase. + returnString = "TRUE"; + } + responseData["returnString"] = returnString; + response.Value = responseData; + return response; + } + + public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) + { + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable responseData = new Hashtable(); + + List returndata = new List(); + + + + if (requestData.Contains("ownerID")) + { + returndata = this.GetUserFriendList(new LLUUID((string)requestData["ownerID"])); + } + + return FriendListItemListtoXmlRPCResponse(returndata); + } + public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) { XmlRpcResponse response = new XmlRpcResponse(); diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index c205d08..e645074 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -109,6 +109,28 @@ namespace OpenSim.Region.Communications.OGS1 return pickerlist; } + public List ConvertXMLRPCDataToFriendListItemList(Hashtable data) + { + List buddylist = new List(); + int buddycount = Convert.ToInt32((string)data["avcount"]); + + + for (int i = 0; i < buddycount; i++) + { + FriendListItem buddylistitem = new FriendListItem(); + + buddylistitem.FriendListOwner = new LLUUID((string)data["ownerID" + i.ToString()]); + buddylistitem.Friend = new LLUUID((string)data["friendID" + i.ToString()]); + buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]); + buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]); + + buddylist.Add(buddylistitem); + } + + + return buddylist; + } + public UserProfileData GetUserProfile(string firstName, string lastName) { return GetUserProfile(firstName + " " + lastName); @@ -223,7 +245,49 @@ namespace OpenSim.Region.Communications.OGS1 /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects public void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms) { + try + { + Hashtable param = new Hashtable(); + param["ownerID"] = friendlistowner.UUID.ToString(); + param["friendID"] = friend.UUID.ToString(); + param["friendPerms"] = perms.ToString(); + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("add_new_user_friend", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); + Hashtable respData = (Hashtable)resp.Value; + if (respData != null) + { + if (respData.Contains("returnString")) + { + if ((string)respData["returnString"] == "TRUE") + { + + } + else + { + MainLog.Instance.Warn("GRID", "Unable to add new friend, User Server Reported an issue"); + } + } + else + { + MainLog.Instance.Warn("GRID", "Unable to add new friend, UserServer didn't understand me!"); + } + } + else + { + MainLog.Instance.Warn("GRID", "Unable to add new friend, UserServer didn't understand me!"); + + } + } + catch (WebException e) + { + MainLog.Instance.Warn("GRID","Error when trying to AddNewUserFriend: " + + e.Message); + + } + } /// @@ -233,7 +297,49 @@ namespace OpenSim.Region.Communications.OGS1 /// The Ex-friend agent public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { + try + { + Hashtable param = new Hashtable(); + param["ownerID"] = friendlistowner.UUID.ToString(); + param["friendID"] = friend.UUID.ToString(); + + + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("remove_user_friend", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); + Hashtable respData = (Hashtable)resp.Value; + if (respData != null) + { + if (respData.Contains("returnString")) + { + if ((string)respData["returnString"] == "TRUE") + { + + } + else + { + MainLog.Instance.Warn("GRID", "Unable to remove friend, User Server Reported an issue"); + } + } + else + { + MainLog.Instance.Warn("GRID", "Unable to remove friend, UserServer didn't understand me!"); + } + } + else + { + MainLog.Instance.Warn("GRID", "Unable to remove friend, UserServer didn't understand me!"); + + } + } + catch (WebException e) + { + MainLog.Instance.Warn("GRID", "Error when trying to RemoveUserFriend: " + + e.Message); + + } } /// @@ -244,7 +350,48 @@ namespace OpenSim.Region.Communications.OGS1 /// A uint bit vector for set perms that the friend being added has; 0 = none, 1=This friend can see when they sign on, 2 = map, 4 edit objects public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { + try + { + Hashtable param = new Hashtable(); + param["ownerID"] = friendlistowner.UUID.ToString(); + param["friendID"] = friend.UUID.ToString(); + param["friendPerms"] = perms.ToString(); + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("update_user_friend_perms", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); + Hashtable respData = (Hashtable)resp.Value; + if (respData != null) + { + if (respData.Contains("returnString")) + { + if ((string)respData["returnString"] == "TRUE") + { + + } + else + { + MainLog.Instance.Warn("GRID", "Unable to update_user_friend_perms, User Server Reported an issue"); + } + } + else + { + MainLog.Instance.Warn("GRID", "Unable to update_user_friend_perms, UserServer didn't understand me!"); + } + } + else + { + MainLog.Instance.Warn("GRID", "Unable to update_user_friend_perms, UserServer didn't understand me!"); + + } + } + catch (WebException e) + { + MainLog.Instance.Warn("GRID", "Error when trying to update_user_friend_perms: " + + e.Message); + + } } /// /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner @@ -252,7 +399,33 @@ namespace OpenSim.Region.Communications.OGS1 /// The agent that we're retreiving the friends Data. public List GetUserFriendList(LLUUID friendlistowner) { - return new List(); + List buddylist = new List(); + + try + { + Hashtable param = new Hashtable(); + param["ownerID"] = friendlistowner.UUID.ToString(); + + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); + Hashtable respData = (Hashtable) resp.Value; + + if (respData.Contains("avcount")) + { + buddylist = ConvertXMLRPCDataToFriendListItemList(respData); + } + + } + catch (WebException e) + { + MainLog.Instance.Warn("Error when trying to fetch Avatar's friends list: " + + e.Message); + // Return Empty list (no friends) + } + return buddylist; + } #endregion -- cgit v1.1