Role manager for a group
Ejemplo n.º 1
0
        /// <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>
        protected void GroupRoleDataReplyHandler(object sender, PacketReceivedEventArgs e)
        {
            Packet packet = e.Packet;
            GroupRoleDataReplyPacket roles = (GroupRoleDataReplyPacket)packet;
            Dictionary<UUID, GroupRole> groupRoleCache = null;

            lock (GroupRolesRequests)
            {
                // If nothing is registered to receive this RequestID drop the data
                if (GroupRolesRequests.Contains(roles.GroupData.RequestID))
                {
                    GroupRolesRequests.Remove(roles.GroupData.RequestID);

                    lock (TempGroupRoles.Dictionary)
                    {
                        if (!TempGroupRoles.TryGetValue(roles.GroupData.RequestID, out groupRoleCache))
                        {
                            groupRoleCache = new Dictionary<UUID, GroupRole>();
                            TempGroupRoles[roles.GroupData.RequestID] = groupRoleCache;
                        }

                        foreach (GroupRoleDataReplyPacket.RoleDataBlock block in roles.RoleData)
                        {
                            GroupRole groupRole = new GroupRole();

                            groupRole.GroupID = roles.GroupData.GroupID;
                            groupRole.ID = block.RoleID;
                            groupRole.Description = Utils.BytesToString(block.Description);
                            groupRole.Name = Utils.BytesToString(block.Name);
                            groupRole.Powers = (GroupPowers)block.Powers;
                            groupRole.Title = Utils.BytesToString(block.Title);

                            groupRoleCache[block.RoleID] = groupRole;
                        }

                        if (groupRoleCache.Count >= roles.GroupData.RoleCount)
                        {
                            GroupRolesRequests.Remove(roles.GroupData.RequestID);
                            TempGroupRoles.Remove(roles.GroupData.RequestID);
                        }
                    }
                }
            }

            if (m_GroupRoles != null && groupRoleCache != null && groupRoleCache.Count >= roles.GroupData.RoleCount)
            {
                OnGroupRoleDataReply(new GroupRolesDataReplyEventArgs(roles.GroupData.RequestID, roles.GroupData.GroupID, groupRoleCache));
            }
        }
Ejemplo n.º 2
0
 /// <summary>Update role information</summary>
 /// <param name="role">Modified role to be updated</param>
 public void UpdateRole(GroupRole role)
 {
     OpenMetaverse.Packets.GroupRoleUpdatePacket gru = new GroupRoleUpdatePacket();
     gru.AgentData.AgentID = Client.Self.AgentID;
     gru.AgentData.SessionID = Client.Self.SessionID;
     gru.AgentData.GroupID = role.GroupID;
     gru.RoleData = new GroupRoleUpdatePacket.RoleDataBlock[1];
     gru.RoleData[0] = new GroupRoleUpdatePacket.RoleDataBlock();
     gru.RoleData[0].Name = Utils.StringToBytes(role.Name);
     gru.RoleData[0].Description = Utils.StringToBytes(role.Description);
     gru.RoleData[0].Powers = (ulong)role.Powers;
     gru.RoleData[0].RoleID = role.ID;
     gru.RoleData[0].Title = Utils.StringToBytes(role.Title);
     gru.RoleData[0].UpdateType = (byte)GroupRoleUpdate.UpdateAll;
     Client.Network.SendPacket(gru);
 }
Ejemplo n.º 3
0
        private void GroupRoleDataHandler(Packet packet, Simulator simulator)
        {
            GroupRoleDataReplyPacket roles = (GroupRoleDataReplyPacket)packet;
            Dictionary<UUID, GroupRole> groupRoleCache = null;

            lock (GroupRolesRequests)
            {
                // If nothing is registered to receive this RequestID drop the data
                if (GroupRolesRequests.Contains(roles.GroupData.RequestID))
                {
                    GroupRolesRequests.Remove(roles.GroupData.RequestID);

                    lock (TempGroupRoles.Dictionary)
                    {
                        if (!TempGroupRoles.TryGetValue(roles.GroupData.RequestID, out groupRoleCache))
                        {
                            groupRoleCache = new Dictionary<UUID, GroupRole>();
                            TempGroupRoles[roles.GroupData.RequestID] = groupRoleCache;
                        }

                        foreach (GroupRoleDataReplyPacket.RoleDataBlock block in roles.RoleData)
                        {
                            GroupRole groupRole = new GroupRole();

                            groupRole.GroupID = roles.GroupData.GroupID;
                            groupRole.ID = block.RoleID;
                            groupRole.Description = Utils.BytesToString(block.Description);
                            groupRole.Name = Utils.BytesToString(block.Name);
                            groupRole.Powers = (GroupPowers)block.Powers;
                            groupRole.Title = Utils.BytesToString(block.Title);

                            groupRoleCache[block.RoleID] = groupRole;
                        }

                        if (groupRoleCache.Count >= roles.GroupData.RoleCount)
                        {
                            GroupRolesRequests.Remove(roles.GroupData.RequestID);
                            TempGroupRoles.Remove(roles.GroupData.RequestID);
                        }
                    }
                }
            }

            if (OnGroupRoles != null && groupRoleCache != null && groupRoleCache.Count >= roles.GroupData.RoleCount)
            {
                try { OnGroupRoles(roles.GroupData.RequestID, roles.GroupData.GroupID, groupRoleCache); }
                catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
            }
        }
Ejemplo n.º 4
0
 /// <summary>Create a new group role</summary>
 /// <param name="group">Group ID to update</param>
 /// <param name="role">Role to create</param>
 public void CreateRole(UUID group, GroupRole role)
 {
     OpenMetaverse.Packets.GroupRoleUpdatePacket gru = new GroupRoleUpdatePacket();
     gru.AgentData.AgentID = Network.AgentID;
     gru.AgentData.SessionID = Network.SessionID;
     gru.AgentData.GroupID = group;
     gru.RoleData = new GroupRoleUpdatePacket.RoleDataBlock[1];
     gru.RoleData[0].Name = Utils.StringToBytes(role.Name);
     gru.RoleData[0].Description = Utils.StringToBytes(role.Description);
     gru.RoleData[0].Powers = (ulong)role.Powers;
     gru.RoleData[0].Title = Utils.StringToBytes(role.Title);
     gru.RoleData[0].UpdateType = (byte)GroupRoleUpdate.Create;
     Network.SendPacket(gru);
 }
Ejemplo n.º 5
0
        private void btnSaveRole_Click(object sender, EventArgs e)
        {
            if (btnSaveRole.Tag == null) // new role
            {
                GroupRole role = new GroupRole();
                role.Name = txtRoleName.Text;
                role.Title = txtRoleTitle.Text;
                role.Description = txtRoleDescription.Text;
                client.Groups.CreateRole(group.ID, role);
                System.Threading.Thread.Sleep(100);
                RefreshRoles();
            }
            else if (btnSaveRole.Tag is GroupRole) // update role
            {
                GroupRole role = (GroupRole)btnSaveRole.Tag;

                if (HasPower(GroupPowers.ChangeActions))
                {
                    role.Powers = GroupPowers.None;

                    foreach (ListViewItem item in lvwRoleAbilitis.Items)
                    {
                        if (item.Checked)
                            role.Powers |= (GroupPowers)item.Tag;
                    }
                }

                if (HasPower(GroupPowers.RoleProperties))
                {
                    role.Name = txtRoleName.Text;
                    role.Title = txtRoleTitle.Text;
                    role.Description = txtRoleDescription.Text;
                }

                client.Groups.UpdateRole(role);
                System.Threading.Thread.Sleep(100);
                RefreshRoles();
            }
        }
Ejemplo n.º 6
0
        private void GroupRoleDataHandler(Packet packet, Simulator simulator)
        {
            GroupRoleDataReplyPacket roles = (GroupRoleDataReplyPacket)packet;
            Dictionary<UUID, GroupRole> groupRoleCache = null;

            lock (GroupRolesCaches)
            {
                // If nothing is registered to receive this RequestID drop the data
                if (GroupRolesCaches.ContainsKey(roles.GroupData.RequestID))
                {
                    groupRoleCache = GroupRolesCaches[roles.GroupData.RequestID];

                    foreach (GroupRoleDataReplyPacket.RoleDataBlock block in roles.RoleData)
                    {
                        GroupRole groupRole = new GroupRole();

                        groupRole.ID = block.RoleID;
                        groupRole.Description = Utils.BytesToString(block.Description);
                        groupRole.Name = Utils.BytesToString(block.Name);
                        groupRole.Powers = (GroupPowers)block.Powers;
                        groupRole.Title = Utils.BytesToString(block.Title);

                        groupRoleCache[block.RoleID] = groupRole;
                    }
                }
            }

            // Check if we've received all the group members that are showing up
            if (OnGroupRoles != null && groupRoleCache != null && groupRoleCache.Count >= roles.GroupData.RoleCount)
            {
                try { OnGroupRoles(groupRoleCache); }
                catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
            }
        }