private bool onRequestBanListMessage(MessageResponseHelper <IQMessage> helper, IQMessage iq)
        {
            if (iq is IQErrorMessage)
            {
                IQErrorMessage errorMessage = iq as IQErrorMessage;
                Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    showErrorMessage("Type: " + errorMessage.ERROR_OBJ.ERROR_NAME + "\nMessage: " + errorMessage.ERROR_OBJ.ERROR_MESSAGE);
                    reload_btn.IsEnabled   = true;
                    reload_prgr.Visibility = Visibility.Collapsed;
                }).AsTask();
                return(true);
            }
            else if (iq is BanListMessage)
            {
                BanListMessage banListMessage = iq as BanListMessage;
                Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    BANNED_USERS.Clear();
                    foreach (BanedUser user in banListMessage.BANED_USERS)
                    {
                        BANNED_USERS.Add(new MUCBanedUserTemplate {
                            banedUser = user
                        });
                    }
                    reload_btn.IsEnabled   = true;
                    reload_prgr.Visibility = Visibility.Collapsed;
                }).AsTask();
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Sends a BanListMessage for requesting the ban list of the given room.
        /// Only the room owner and admins can request this list.
        /// </summary>
        /// <param name="roomJid">The bare JID if the room you would like to request the ban list for. e.g. '*****@*****.**'</param>
        /// <param name="onMessage">The method that should get executed once the helper receives a new valid message.</param>
        /// <param name="onTimeout">The method that should get executed once the helper timeout gets triggered.</param>
        /// <returns>Returns a MessageResponseHelper listening for BanListMessage answers.</returns>
        public MessageResponseHelper <IQMessage> requestBanList(string roomJid, MessageResponseHelper <IQMessage> .OnMessageHandler onMessage, MessageResponseHelper <IQMessage> .OnTimeoutHandler onTimeout)
        {
            MessageResponseHelper <IQMessage> helper = new MessageResponseHelper <IQMessage>(CONNECTION, onMessage, onTimeout);
            BanListMessage msg = new BanListMessage(CONNECTION.account.getFullJid(), roomJid);

            helper.start(msg);
            return(helper);
        }
        /// <summary>
        /// Sends a BanListMessage for requesting the ban list of the given room.
        /// Only the room owner and admins can request this list.
        /// </summary>
        /// <param name="roomJid">The bare JID if the room you would like to request the ban list for. e.g. '*****@*****.**'</param>
        /// <param name="onMessage">The method that should get executed once the helper receives a new valid message.</param>
        /// <param name="onTimeout">The method that should get executed once the helper timeout gets triggered.</param>
        /// <returns>Returns a MessageResponseHelper listening for BanListMessage answers.</returns>
        public MessageResponseHelper <IQMessage> requestBanList(string roomJid, Func <IQMessage, bool> onMessage, Action onTimeout)
        {
            MessageResponseHelper <IQMessage> helper = new MessageResponseHelper <IQMessage>(CLIENT, onMessage, onTimeout);
            BanListMessage msg = new BanListMessage(CLIENT.getXMPPAccount().getIdDomainAndResource(), roomJid);

            helper.start(msg);
            return(helper);
        }
Beispiel #4
0
        /// <summary>
        /// Finds a message type to handle the message.
        /// </summary>
        public ReceivableMessage Process()
        {
            // Named messages.
            if (NickMessage.CanProcess(this))
            {
                return(new NickMessage(this));
            }
            if (QuitMessage.CanProcess(this))
            {
                return(new QuitMessage(this));
            }
            if (JoinMessage.CanProcess(this))
            {
                return(new JoinMessage(this));
            }
            if (PartMessage.CanProcess(this))
            {
                return(new PartMessage(this));
            }
            if (PrivateMessage.CanProcess(this))
            {
                return(new PrivateMessage(this));
            }
            if (PingMessage.CanProcess(this))
            {
                return(new PingMessage(this));
            }
            if (NoticeMessage.CanProcess(this))
            {
                return(new NoticeMessage(this));
            }
            if (UserModeMessage.CanProcess(this))
            {
                return(new UserModeMessage(this));
            }
            if (ChannelModeMessage.CanProcess(this))
            {
                return(new ChannelModeMessage(this));
            }
            if (KickMessage.CanProcess(this))
            {
                return(new KickMessage(this));
            }
            if (InviteMessage.CanProcess(this))
            {
                return(new InviteMessage(this));
            }
            if (OperwallMessage.CanProcess(this))
            {
                return(new OperwallMessage(this));
            }
            if (Receive.TopicMessage.CanProcess(this))
            {
                return(new Receive.TopicMessage(this));
            }

            // IRCv3 messages.
            if (Receive.v3.CapabilityMessage.CanProcess(this))
            {
                return(new Receive.v3.CapabilityMessage(this));
            }
            if (Receive.v3.AwayMessage.CanProcess(this))
            {
                return(new Receive.v3.AwayMessage(this));
            }

            // Numerics.
            if (NumericMessage.CanProcess(this))
            {
                // Pass all numeric messages to NumericMessage so an event can be fired, then pass it to more specific instances.
                // ReSharper disable once ObjectCreationAsStatement
                new NumericMessage(this);

                if (WelcomeMessage.CanProcess(this))
                {
                    return(new WelcomeMessage(this));
                }
                if (YourHostMessage.CanProcess(this))
                {
                    return(new YourHostMessage(this));
                }
                if (CreatedMessage.CanProcess(this))
                {
                    return(new CreatedMessage(this));
                }
                if (MyInfoMessage.CanProcess(this))
                {
                    return(new MyInfoMessage(this));
                }
                if (SupportMessage.CanProcess(this))
                {
                    return(new SupportMessage(this));
                }
                if (BounceMessage.CanProcess(this))
                {
                    return(new BounceMessage(this));
                }
                if (MOTDEndMessage.CanProcess(this))
                {
                    return(new MOTDEndMessage(this));
                }
                if (MOTDStartMessage.CanProcess(this))
                {
                    return(new MOTDStartMessage(this));
                }
                if (MOTDMessage.CanProcess(this))
                {
                    return(new MOTDMessage(this));
                }
                if (LUserMessage.CanProcess(this))
                {
                    return(new LUserMessage(this));
                }
                if (NamesMessage.CanProcess(this))
                {
                    return(new NamesMessage(this));
                }
                if (EndOfNamesMessage.CanProcess(this))
                {
                    return(new EndOfNamesMessage(this));
                }
                if (TopicMessage.CanProcess(this))
                {
                    return(new TopicMessage(this));
                }
                if (TopicWhoTimeMessage.CanProcess(this))
                {
                    return(new TopicWhoTimeMessage(this));
                }
                if (ListMessage.CanProcess(this))
                {
                    return(new ListMessage(this));
                }
                if (ListEndMessage.CanProcess(this))
                {
                    return(new ListEndMessage(this));
                }
                if (YoureOperMessage.CanProcess(this))
                {
                    return(new YoureOperMessage(this));
                }
                if (AwayMessage.CanProcess(this))
                {
                    return(new AwayMessage(this));
                }
                if (UnAwayMessage.CanProcess(this))
                {
                    return(new UnAwayMessage(this));
                }
                if (NowAwayMessage.CanProcess(this))
                {
                    return(new NowAwayMessage(this));
                }
                if (ChannelModeIsMessage.CanProcess(this))
                {
                    return(new ChannelModeIsMessage(this));
                }
                if (UModeIsMessage.CanProcess(this))
                {
                    return(new UModeIsMessage(this));
                }
                if (VersionMessage.CanProcess(this))
                {
                    return(new VersionMessage(this));
                }
                if (TimeMessage.CanProcess(this))
                {
                    return(new TimeMessage(this));
                }
                if (WhoMessage.CanProcess(this))
                {
                    return(new WhoMessage(this));
                }
                if (WhoisMessage.CanProcess(this))
                {
                    return(new WhoisMessage(this));
                }
                if (EndOfWhoMessage.CanProcess(this))
                {
                    return(new EndOfWhoMessage(this));
                }
                if (EndOfWhoisMessage.CanProcess(this))
                {
                    return(new EndOfWhoisMessage(this));
                }
                if (BanListMessage.CanProcess(this))
                {
                    return(new BanListMessage(this));
                }
                if (EndOfBanListMessage.CanProcess(this))
                {
                    return(new EndOfBanListMessage(this));
                }
                if (InviteListMessage.CanProcess(this))
                {
                    return(new InviteListMessage(this));
                }
                if (EndOfInviteListMessage.CanProcess(this))
                {
                    return(new EndOfInviteListMessage(this));
                }
                if (ExceptListMessage.CanProcess(this))
                {
                    return(new ExceptListMessage(this));
                }
                if (EndOfExceptListMessage.CanProcess(this))
                {
                    return(new EndOfExceptListMessage(this));
                }
                if (IsOnMessage.CanProcess(this))
                {
                    return(new IsOnMessage(this));
                }

                // Catch all for unhandled error messages.
                if (ErrorMessage.CanProcess(this))
                {
                    return(new ErrorMessage(this));
                }
            }

            Console.WriteLine("Message handler for \"" + Text + "\" not found.");
            return(null);
        }
Beispiel #5
0
 internal void OnReplyBanList(BanListMessage message) => ReplyBanList?.Invoke(message);