/// <summary> /// Handle notifications sent when a friend rights change. This notification is also received /// when my own rights change. /// </summary> /// <param name="packet"></param> /// <param name="simulator"></param> private void ChangeUserRightsHandler(Packet packet, Simulator simulator) { if (packet.Type == PacketType.ChangeUserRights) { FriendInfo friend; ChangeUserRightsPacket rights = (ChangeUserRightsPacket)packet; foreach (ChangeUserRightsPacket.RightsBlock block in rights.Rights) { FriendRights newRights = (FriendRights)block.RelatedRights; if (FriendList.TryGetValue(block.AgentRelated, out friend)) { friend.TheirFriendRights = newRights; if (OnFriendRights != null) { try { OnFriendRights(friend); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } } else if (block.AgentRelated == Client.Self.AgentID) { if (FriendList.TryGetValue(rights.AgentData.AgentID, out friend)) { friend.MyFriendRights = newRights; if (OnFriendRights != null) { try { OnFriendRights(friend); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } } } } } }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> private void ChangeUserRightsHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; if (packet.Type == PacketType.ChangeUserRights) { FriendInfo friend; ChangeUserRightsPacket rights = (ChangeUserRightsPacket)packet; foreach (ChangeUserRightsPacket.RightsBlock block in rights.Rights) { FriendRights newRights = (FriendRights)block.RelatedRights; if (FriendList.TryGetValue(block.AgentRelated, out friend)) { friend.TheirFriendRights = newRights; if (m_FriendRights != null) { OnFriendRights(new FriendInfoEventArgs(friend)); } } else if (block.AgentRelated == Client.Self.AgentID) { if (FriendList.TryGetValue(rights.AgentData.AgentID, out friend)) { friend.MyFriendRights = newRights; if (m_FriendRights != null) { OnFriendRights(new FriendInfoEventArgs(friend)); } } } } } }
/// <summary> /// Used internally when building the initial list of friends at login time /// </summary> /// <param name="id">System ID of the avatar being prepesented</param> /// <param name="theirRights">Rights the friend has to see you online and to modify your objects</param> /// <param name="myRights">Rights you have to see your friend online and to modify their objects</param> internal FriendInfo(UUID id, FriendRights theirRights, FriendRights myRights) { m_id = id; m_canSeeMeOnline = (theirRights & FriendRights.CanSeeOnline) != 0; m_canSeeMeOnMap = (theirRights & FriendRights.CanSeeOnMap) != 0; m_canModifyMyObjects = (theirRights & FriendRights.CanModifyObjects) != 0; m_canSeeThemOnline = (myRights & FriendRights.CanSeeOnline) != 0; m_canSeeThemOnMap = (myRights & FriendRights.CanSeeOnMap) != 0; m_canModifyTheirObjects = (myRights & FriendRights.CanModifyObjects) != 0; }
/// <summary> /// Used by the libsecondlife framework when building the initial list of friends /// at login time. This constructor should not be called by consummer of this class. /// </summary> /// <param name="id">System ID of the avatar being prepesented</param> /// <param name="theirRights">Rights the friend has to see you online and to modify your objects</param> /// <param name="myRights">Rights you have to see your friend online and to modify their objects</param> public FriendInfo(LLUUID id, FriendRights theirRights, FriendRights myRights) { m_id = id; m_canSeeMeOnline = (theirRights & FriendRights.CanSeeOnline) != 0; m_canSeeMeOnMap = (theirRights & FriendRights.CanSeeOnMap) != 0; m_canModifyMyObjects = (theirRights & FriendRights.CanModifyObjects) != 0; m_canSeeThemOnline = (myRights & FriendRights.CanSeeOnline) != 0; m_canSeeThemOnMap = (myRights & FriendRights.CanSeeOnMap) != 0; m_canModifyTheirObjects = (myRights & FriendRights.CanModifyObjects) != 0; }
/// <summary> /// Change the rights of a friend avatar. /// </summary> /// <param name="friendID">the <seealso cref="UUID"/> of the friend</param> /// <param name="rights">the new rights to give the friend</param> /// <remarks>This method will implicitly set the rights to those passed in the rights parameter.</remarks> public void GrantRights(UUID friendID, FriendRights rights) { GrantUserRightsPacket request = new GrantUserRightsPacket(); request.AgentData.AgentID = Client.Self.AgentID; request.AgentData.SessionID = Client.Self.SessionID; request.Rights = new GrantUserRightsPacket.RightsBlock[1]; request.Rights[0] = new GrantUserRightsPacket.RightsBlock(); request.Rights[0].AgentRelated = friendID; request.Rights[0].RelatedRights = (int)rights; Client.Network.SendPacket(request); }
private void SetRights() { FriendRights rgts = FriendRights.None; if (chkSeeMeOnline.Checked) { rgts |= FriendRights.CanSeeOnline; } if (chkSeeMeOnMap.Checked) { rgts |= FriendRights.CanSeeOnMap; } if (chkModifyMyObjects.Checked) { rgts |= FriendRights.CanModifyObjects; } client.Friends.GrantRights(selectedFriend.UUID, rgts); }
FriendRights getrights(FriendInfo finfo) { FriendRights rights=new FriendRights(); rights=0; if(finfo.CanModifyMyObjects) rights|=FriendRights.CanModifyObjects; if(finfo.CanSeeMeOnMap) rights|=FriendRights.CanSeeOnMap; if(finfo.CanSeeMeOnline) rights|=FriendRights.CanSeeOnline; return rights; }