Esempio n. 1
0
        public MucAffiliationDialog(Room room, RoomParticipant participant, QWidget parentWindow)
            : base(parentWindow)
        {
            SetupUi();

            m_Room = room;
            m_Participant = participant;

            roomLabel.Text = room.JID.Bare;
            userLabel.Text = participant.RealJID.Bare;

            switch (participant.Affiliation) {
            case RoomAffiliation.owner:
                ownerRadioButton.Checked = true;
                break;
            case RoomAffiliation.admin:
                adminRadioButton.Checked = true;
                break;
            case RoomAffiliation.member:
                memberRadioButton.Checked = true;
                break;
            case RoomAffiliation.outcast:
                outcastRadioButton.Checked = true;
                break;
            default:
                noneRadioButton.Checked = true;
                break;
            }

            buttonBox.StandardButtons = (uint)QDialogButtonBox.StandardButton.Ok | (uint)QDialogButtonBox.StandardButton.Cancel;

            Gui.CenterWidgetOnScreen(this);
        }
Esempio n. 2
0
        internal ConferenceMember(RoomParticipant participant, Room room)
        {
            this.participant = participant;
            this.room = room;

            room.OnParticipantPresenceChange += room_OnParticipantPresenceChange;
        }
 private void newRoom_OnParticipantJoin(Room room, RoomParticipant participant)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
     {
         TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
         tr.Text = participant.Nick + " joined the room." + Environment.NewLine;
         tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
     }));
 }
Esempio n. 4
0
 /// <summary>
 /// Add a participant to the list, indexed by full nick JID.
 /// </summary>
 /// <param name="pres">The latest presence</param>
 /// <param name="mod">Was this a JOIN, a LEAVE, or no change?</param>
 /// <returns>The associated participant.</returns>
 internal RoomParticipant Modify(Presence pres, out Modification mod)
 {
     JID from = pres.From;
     mod = Modification.NONE;
     RoomParticipant party = (RoomParticipant)m_hash[from];
     if (party != null)
     {
         party.Presence = pres;
         if (pres.Type == PresenceType.unavailable)
         {
             m_hash.Remove(from);
             mod = Modification.LEAVE;
         }
     }
     else
     {
         party = new RoomParticipant(pres);
         // XCP will send unavails from registered users that
         // are not currently online.
         if (pres.Type != PresenceType.unavailable)
         {
             m_hash[from] = party;
             mod = Modification.JOIN;
         }
     }
     return party;
 }
Esempio n. 5
0
        public void OnParticipantLeave(Room room, RoomParticipant roomParticipant)
        {
            string jid = room.JID.Bare;
            var chat = (GroupChatModel) Session.GetChat(jid, ChatType.Group, this);
            string nickname = roomParticipant.Nick;

            lock (chat) {
                var person = chat.GetPerson(nickname);
                if (person == null) {
                    return;
                }

                Session.RemovePersonFromGroupChat(chat, person);
            }
        }
Esempio n. 6
0
 void OnParticipantJoin(Room room, RoomParticipant roomParticipant)
 {
     AddPersonToGroup(room, roomParticipant.Nick);
 }
Esempio n. 7
0
        void HandleOnPresenceChange(Room room, RoomParticipant participant, Presence oldPresence)
        {
            var x1 = (UserX)oldPresence["x", URI.MUC_USER];
            var x2 = (UserX)participant.Presence["x", URI.MUC_USER];

            var oldAffiliation = x1.RoomItem.Affiliation;
            var newAffiliation = x2.RoomItem.Affiliation;

            var oldRole = x1.RoomItem.Role;
            var newRole = x2.RoomItem.Role;

            var nick = (room.Nickname == participant.Nick) ? "You are" :  participant.Nick + " is";

            if (newAffiliation != oldAffiliation) {
                switch (newAffiliation) {
                case RoomAffiliation.admin:
                    base.AppendStatus(String.Format("{0} now a room admin.", nick));
                    break;
                case RoomAffiliation.member:
                    // "is now a room member" sounds weird...so we show something more useful if possible.
                    switch (oldAffiliation) {
                    case RoomAffiliation.admin:
                        base.AppendStatus(String.Format("{0} longer a room admin.", nick));
                        break;
                    case RoomAffiliation.owner:
                        base.AppendStatus(String.Format("{0} no longer a room owner.", nick));
                        break;
                    default:
                        base.AppendStatus(String.Format("{0} now a room member.", nick));
                        break;
                    }
                    break;
                case RoomAffiliation.outcast:
                    base.AppendStatus(String.Format("{0} now banned from the room.", nick));
                    break;
                case RoomAffiliation.owner:
                    base.AppendStatus(String.Format("{0}  now a room owner.", nick));
                    break;
                case RoomAffiliation.none:
                    switch (oldAffiliation) {
                    case RoomAffiliation.admin:
                        base.AppendStatus(String.Format("{0} no longer a room admin.", nick));
                        break;
                    case RoomAffiliation.owner:
                        base.AppendStatus(String.Format("{0} no longer a room owner.", nick));
                        break;
                    case RoomAffiliation.member:
                        base.AppendStatus(String.Format("{0} no longer a room member.", nick));
                        break;
                    case RoomAffiliation.outcast:
                        base.AppendStatus(String.Format("{0} no longer banned from the room.", nick));
                        break;
                    }
                    break;
                }
            } else if (newRole != oldRole) {
                switch (newRole) {
                case RoomRole.moderator:
                    base.AppendStatus(String.Format("{0} now a moderator.", nick));
                    break;
                case RoomRole.participant:
                    base.AppendStatus(String.Format("{0} now a participant.", nick));
                    break;
                case RoomRole.visitor:
                    base.AppendStatus(String.Format("{0} now a visitor.", nick));
                    break;
                }
            } else if (participant.Presence.Show != oldPresence.Show || participant.Presence.Status != oldPresence.Status) {
                if (participant.Presence.Type == PresenceType.available) {
                    if (!String.IsNullOrEmpty(participant.Presence.Status))
                        base.AppendStatus(String.Format("{0} now {1}: {2}.", nick, Helper.GetPresenceDisplay(participant.Presence), participant.Presence.Status));
                    else
                        base.AppendStatus(String.Format("{0} now {1}.", nick, Helper.GetPresenceDisplay(participant.Presence)));
                }
            }
        }
Esempio n. 8
0
        void HandleOnParticipantLeave(Room room, RoomParticipant participant)
        {
            string reason = null;
            RoomStatus status = RoomStatus.UNKNOWN;
            GetReasonAndStatus(participant.Presence, out reason, out status);

            var builder = new StringBuilder();
            builder.Append(participant.Nick);

            if (status == RoomStatus.KICKED)
                builder.Append(" was kicked from the room");
            else if (status == RoomStatus.BANNED)
                builder.Append(" has been banned from the room");
            else
                builder.Append(" left the room");

            if (!String.IsNullOrEmpty(reason)) {
                builder.Append(": ");
                builder.Append(reason);
            }

            builder.Append(".");

            base.AppendStatus(builder.ToString());
        }
Esempio n. 9
0
 void HandleOnParticipantJoin(Room room, RoomParticipant participant)
 {
     base.AppendStatus(String.Format("{0} has joined the room.", participant.Nick));
 }
Esempio n. 10
0
 private void room_OnParticipantJoin(Room room, RoomParticipant participant)
 {
     Members.Add(participant, room);
 }
Esempio n. 11
0
 private void room_OnParticipantLeave(Room room, RoomParticipant participant)
 {
     Members.Remove(participant.NickJID);
 }
Esempio n. 12
0
        void on_participantsGrid_customContextMenuRequested(QPoint point)
        {
            if (participantsGrid.HoverItem != null) {

                var mucHandler = (MucHandler)m_Handler;

                m_SelectedParticipant = participantsGrid.HoverItem;

                var me = mucHandler.Room.Participants[mucHandler.Room.RoomAndNick];

                bool isModerator = me.Role == RoomRole.moderator;
                bool isAdminOrOwner = me.Affiliation == RoomAffiliation.admin || me.Affiliation == RoomAffiliation.owner;

                m_ModeratorActionsMenu.Enabled = isModerator || isAdminOrOwner;
                m_ChangeAffiliationAction.Enabled = isAdminOrOwner;

                m_ModeratorAction.Checked   = (m_SelectedParticipant.Role == RoomRole.moderator);
                m_VisitorAction.Checked     = (m_SelectedParticipant.Role == RoomRole.visitor);
                m_ParticipantAction.Checked = (m_SelectedParticipant.Role == RoomRole.participant);

                m_AddAsFriendAction.Enabled = !String.IsNullOrEmpty(participantsGrid.HoverItem.RealJID);

                m_ParticipantItemMenu.Popup(participantsGrid.MapToGlobal(point));
            } else {
                m_ParticipantsMenu.Popup(participantsGrid.MapToGlobal(point));
            }
        }
Esempio n. 13
0
 void HandleItemActivated(AvatarGrid<RoomParticipant> grid, RoomParticipant participant)
 {
     if (!String.IsNullOrEmpty(participant.RealJID))
         Gui.TabbedChatsWindow.StartChat(m_Handler.Account, participant.RealJID, false);
     else
         Gui.TabbedChatsWindow.StartChat(m_Handler.Account, participant.NickJID, true);
 }
Esempio n. 14
0
 private void room_OnParticipantPresenceChange(Room room, RoomParticipant participant)
 {
     if (this.participant == participant)
         foreach (var property in GetType().GetProperties())
             OnPropertyChanged(property.Name); //Request for UI to update all member fields
 }