/* * Copyright (c) 2007, Second Life Reverse Engineering Team * All rights reserved. * * - 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. * - Neither the name of the Second Life Reverse Engineering Team 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR 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 libsecondlife; using libsecondlife.Packets; using System; using System.Collections.Generic; using System.Text; namespace libsecondlife { /// /// /// public class FriendManager { private SecondLife Client; /// /// /// [Flags] public enum UserRights { /// None = 0x00, /// ViewOnlineStatus = 0x01, /// ViewMapLocation = 0x02, /// ModifyObjects = 0x04, /// AllUserRights = 0x07 } /// Constructor for FriendManager public FriendManager(SecondLife client) { Client = client; } /// /// Grants the specified user rights such as map or modify /// /// The user to grant rights to /// User can see your online status /// User can see your map location /// User can modify your objects public void GrantUserRights(LLUUID targetID, bool viewOnlineStatus, bool viewMapLocation, bool modifyObjects) { UserRights rights = UserRights.None; if (viewOnlineStatus) rights |= UserRights.ViewOnlineStatus; if (viewMapLocation) rights |= UserRights.ViewMapLocation; if (modifyObjects) rights |= UserRights.ModifyObjects; GrantUserRightsPacket p = new GrantUserRightsPacket(); p.AgentData.AgentID = Client.Network.AgentID; p.AgentData.SessionID = Client.Network.SessionID; p.Rights = new GrantUserRightsPacket.RightsBlock[1]; p.Rights[1].AgentRelated = targetID; p.Rights[1].RelatedRights = (int)rights; } /// /// Offers friendship to the specified user /// public void RequestFriendship(LLUUID targetID) { Client.Self.InstantMessage(String.Empty, targetID, String.Empty, LLUUID.Zero, MainAvatar.InstantMessageDialog.FriendshipOffered, MainAvatar.InstantMessageOnline.Online, Client.Self.Position, Client.Network.CurrentSim.ID, new byte[0]); } /// /// Revokes friendship from the specified user /// public void RemoveFriend(LLUUID targetID) { TerminateFriendshipPacket p = new TerminateFriendshipPacket(); p.AgentData.AgentID = Client.Network.AgentID; p.AgentData.SessionID = Client.Network.SessionID; p.ExBlock.OtherID = targetID; Client.Network.SendPacket(p); } } }