From b4c9b6bd19c0725ae5bf60172db75ebc63ba72c6 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 1 Jan 2008 06:12:04 +0000 Subject: * You can add and remove a friend in standalone now within the same simulator. It saves. * You can add and remove a friend in grid mode now within the same simulator. It doesn't save yet. * I got rid of Mr. OpenSim as a friend.. he bothers me /:b... --- .../Communications/CommunicationsManager.cs | 43 +++++++++++++++ OpenSim/Framework/Data.MySQL/MySQLUserData.cs | 7 +++ OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 44 ++++++++++++--- OpenSim/Framework/GridInstantMessage.cs | 64 ++++++++++++++++++++++ OpenSim/Framework/IClientAPI.cs | 13 +++++ OpenSim/Framework/IUserService.cs | 30 ++++++++++ OpenSim/Framework/sLLVector3.cs | 6 +- 7 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 OpenSim/Framework/GridInstantMessage.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 02c54e1..0c6d53f 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -152,6 +152,49 @@ namespace OpenSim.Framework.Communications } } + #region Friend Methods + /// + /// Adds a new friend to the database for XUser + /// + /// The agent that who's friends list is being added to + /// The agent that being added to the friends list of the friends list owner + /// 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) + { + m_userService.AddNewUserFriend(friendlistowner, friend, perms); + } + + /// + /// Delete friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The Ex-friend agent + public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) + { + m_userService.RemoveUserFriend(friendlistowner, friend); + } + + /// + /// Update permissions for friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The agent that is getting or loosing permissions + /// 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) + { + m_userService.UpdateUserFriendPerms(friendlistowner, friend, perms); + } + /// + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner + /// + /// The agent that we're retreiving the friends Data. + public List GetUserFriendList(LLUUID friendlistowner) + { + return m_userService.GetUserFriendList(friendlistowner); + } + + #endregion + #region Packet Handlers public void HandleUUIDNameRequest(LLUUID uuid, IClientAPI remote_client) diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs index 779d050..a5e6da4 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs @@ -226,6 +226,13 @@ namespace OpenSim.Framework.Data.MySQL param); updater.ExecuteNonQuery(); + updater = + database.Query( + "delete from userfriends " + + "where ownerID = ?friendID and friendID = ?ownerID", + param); + updater.ExecuteNonQuery(); + } } catch (Exception e) diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index c97dc52..e9a8eca 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs @@ -47,16 +47,20 @@ namespace OpenSim.Framework.Data.SQLite /// private const string userSelect = "select * from users"; private const string userFriendsSelect = "select a.ownerID as ownerID,a.friendID as friendID,a.friendPerms as friendPerms,b.friendPerms as ownerperms, b.ownerID as fownerID, b.friendID as ffriendID from userfriends as a, userfriends as b"; - + private DataSet ds; private SqliteDataAdapter da; private SqliteDataAdapter daf; + SqliteConnection g_conn; public void Initialise() { SqliteConnection conn = new SqliteConnection("URI=file:userprofiles.db,version=3"); TestTables(conn); + // This sucks, but It doesn't seem to work with the dataset Syncing :P + g_conn = conn; + ds = new DataSet(); da = new SqliteDataAdapter(new SqliteCommand(userSelect, conn)); daf = new SqliteDataAdapter(new SqliteCommand(userFriendsSelect, conn)); @@ -147,11 +151,11 @@ namespace OpenSim.Framework.Data.SQLite DataRow row = friends.NewRow(); - fillFriendRow(row, friendlistowner,friend,perms); + fillFriendRow(row, friendlistowner.UUID.ToString(),friend.UUID.ToString(),perms); friends.Rows.Add(row); row = friends.NewRow(); - fillFriendRow(row, friend, friendlistowner, perms); + fillFriendRow(row, friend.UUID.ToString(), friendlistowner.UUID.ToString(), perms); friends.Rows.Add(row); MainLog.Instance.Verbose("SQLITE", @@ -164,7 +168,7 @@ namespace OpenSim.Framework.Data.SQLite public void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend) { DataTable ua = ds.Tables["userfriends"]; - string select = "a.ownernID '" + friendlistowner.UUID.ToString() + "' and b.friendID ='" + friend.UUID.ToString() + "';"; + string select = "`ownerID` ='" + friendlistowner.UUID.ToString() + "' and `friendID` ='" + friend.UUID.ToString() + "'"; lock (ds) { DataRow[] rows = ds.Tables["userfriends"].Select(select); @@ -175,20 +179,44 @@ namespace OpenSim.Framework.Data.SQLite { for (int i = 0; i < rows.Length; i++) { - FriendListItem user = new FriendListItem(); DataRow row = rows[i]; row.Delete(); } - daf.Update(ds, "userfriends"); + + } + } + } + select = "`ownerID` ='" + friend.UUID.ToString() + "' and `friendID` ='" + friendlistowner.UUID.ToString() + "'"; + lock (ds) + { + DataRow[] rows = ds.Tables["userfriends"].Select(select); + + if (rows != null) + { + if (rows.Length > 0) + { + for (int i = 0; i < rows.Length; i++) + { + DataRow row = rows[i]; + row.Delete(); + } + } } } + SqliteCommand deletecommand = new SqliteCommand("delete from userfriends where `ownerID`='" + friendlistowner.UUID.ToString() + "' and `friendID` ='" + friend.UUID.ToString() + "'", g_conn); + g_conn.Open(); + deletecommand.ExecuteNonQuery(); + deletecommand = new SqliteCommand("delete from userfriends where `ownerID`='" + friend.UUID.ToString() + "' and `friendID` ='" + friendlistowner.UUID.ToString() + "'", g_conn); + deletecommand.ExecuteNonQuery(); + g_conn.Close(); + MainLog.Instance.Verbose("FRIEND", "Stub RemoveUserFriend called"); } public void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms) { DataTable ua = ds.Tables["userfriends"]; - string select = "a.ownernID '" + friendlistowner.UUID.ToString() + "' and b.friendID ='" + friend.UUID.ToString() + "';"; + string select = "a.ownerID ='" + friendlistowner.UUID.ToString() + "' and b.friendID ='" + friend.UUID.ToString() + "'"; lock (ds) { DataRow[] rows = ds.Tables["userfriends"].Select(select); @@ -737,7 +765,7 @@ namespace OpenSim.Framework.Data.SQLite daf.UpdateCommand = createUpdateCommand("userfriends", "ownerID=:ownerID and friendID=:friendID", ds.Tables["userfriends"]); daf.UpdateCommand.Connection = conn; - SqliteCommand delete = new SqliteCommand("delete from users where ownerID=:ownerID and friendID=:friendID"); + SqliteCommand delete = new SqliteCommand("delete from userfriends where ownerID=:ownerID and friendID=:friendID"); delete.Parameters.Add(createSqliteParameter("ownerID", typeof(String))); delete.Parameters.Add(createSqliteParameter("friendID", typeof(String))); delete.Connection = conn; diff --git a/OpenSim/Framework/GridInstantMessage.cs b/OpenSim/Framework/GridInstantMessage.cs new file mode 100644 index 0000000..6ae3424 --- /dev/null +++ b/OpenSim/Framework/GridInstantMessage.cs @@ -0,0 +1,64 @@ +/* +* Copyright (c) Contributors, http://opensimulator.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +using System; +using OpenSim.Framework; + + +namespace OpenSim.Framework +{ + + [Serializable] + public class GridInstantMessage + { + public Guid fromAgentID; + public Guid fromAgentSession; + public Guid toAgentID; + public Guid imSessionID; + public uint timestamp; + public string fromAgentName; + + public string message; + public byte dialog; + public bool fromGroup; + public byte offline; + + public uint ParentEstateID; + + public sLLVector3 Position; + + public Guid RegionID; + + public byte[] binaryBucket; + + public GridInstantMessage() + { + + } + } +} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 61a713a..c5e4809 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -395,6 +395,14 @@ namespace OpenSim.Framework public delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID); + public delegate void FriendActionDelegate(IClientAPI remoteClient,LLUUID agentID,LLUUID transactionID,List callingCardFolders); + + public delegate void FriendshipTermination(IClientAPI remoteClient,LLUUID agentID, LLUUID ExID); + + + + + public delegate void ObjectPermissions( IClientAPI remoteClinet, LLUUID AgentID, LLUUID SessionID, List permChanges); @@ -490,6 +498,11 @@ namespace OpenSim.Framework event RegionInfoRequest OnRegionInfoRequest; event EstateCovenantRequest OnEstateCovenantRequest; + event FriendActionDelegate OnApproveFriendRequest; + event FriendActionDelegate OnDenyFriendRequest; + event FriendshipTermination OnTerminateFriendship; + + LLVector3 StartPos { get; set; } LLUUID AgentId { get; } diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index 2b08582..2b59c25 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs @@ -47,5 +47,35 @@ namespace OpenSim.Framework /// /// LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); + + + /// + /// Adds a new friend to the database for XUser + /// + /// The agent that who's friends list is being added to + /// The agent that being added to the friends list of the friends list owner + /// 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 + void AddNewUserFriend(LLUUID friendlistowner, LLUUID friend, uint perms); + + /// + /// Delete friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The Ex-friend agent + void RemoveUserFriend(LLUUID friendlistowner, LLUUID friend); + + /// + /// Update permissions for friend on friendlistowner's friendlist. + /// + /// The agent that who's friends list is being updated + /// The agent that is getting or loosing permissions + /// 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 + void UpdateUserFriendPerms(LLUUID friendlistowner, LLUUID friend, uint perms); + + /// + /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner + /// + /// The agent that we're retreiving the friends Data. + List GetUserFriendList(LLUUID friendlistowner); } } \ No newline at end of file diff --git a/OpenSim/Framework/sLLVector3.cs b/OpenSim/Framework/sLLVector3.cs index 2e2c005..8187597 100644 --- a/OpenSim/Framework/sLLVector3.cs +++ b/OpenSim/Framework/sLLVector3.cs @@ -45,8 +45,8 @@ namespace OpenSim.Framework z = v.Z; } - public float x; - public float y; - public float z; + public float x=0; + public float y=0; + public float z=0; } } \ No newline at end of file -- cgit v1.1