Ejemplo n.º 1
0
        void ReleaseDesignerOutlets()
        {
            if (JoinContainerView != null)
            {
                JoinContainerView.Dispose();
                JoinContainerView = null;
            }

            if (ChatView != null)
            {
                ChatView.Dispose();
                ChatView = null;
            }

            if (OverlayView != null)
            {
                OverlayView.Dispose();
                OverlayView = null;
            }

            if (JoinButton != null)
            {
                JoinButton.Dispose();
                JoinButton = null;
            }

            if (RoomTextField != null)
            {
                RoomTextField.Dispose();
                RoomTextField = null;
            }

            if (AudioButton != null)
            {
                AudioButton.Dispose();
                AudioButton = null;
            }

            if (ButtonContainerView != null)
            {
                ButtonContainerView.Dispose();
                ButtonContainerView = null;
            }

            if (ButtonContainerViewLeftConstraint != null)
            {
                ButtonContainerViewLeftConstraint.Dispose();
                ButtonContainerViewLeftConstraint = null;
            }

            if (FooterView != null)
            {
                FooterView.Dispose();
                FooterView = null;
            }

            if (FooterViewBottomConstraint != null)
            {
                FooterViewBottomConstraint.Dispose();
                FooterViewBottomConstraint = null;
            }

            if (HangupButton != null)
            {
                HangupButton.Dispose();
                HangupButton = null;
            }

            if (LocalView != null)
            {
                LocalView.Dispose();
                LocalView = null;
            }

            if (LocalViewBottomConstraint != null)
            {
                LocalViewBottomConstraint.Dispose();
                LocalViewBottomConstraint = null;
            }

            if (LocalViewHeightConstraint != null)
            {
                LocalViewHeightConstraint.Dispose();
                LocalViewHeightConstraint = null;
            }

            if (LocalViewRightConstraint != null)
            {
                LocalViewRightConstraint.Dispose();
                LocalViewRightConstraint = null;
            }

            if (LocalViewWidthConstraint != null)
            {
                LocalViewWidthConstraint.Dispose();
                LocalViewWidthConstraint = null;
            }

            if (RemoteView != null)
            {
                RemoteView.Dispose();
                RemoteView = null;
            }

            if (RemoteViewBottomConstraint != null)
            {
                RemoteViewBottomConstraint.Dispose();
                RemoteViewBottomConstraint = null;
            }

            if (RemoteViewLeftConstraint != null)
            {
                RemoteViewLeftConstraint.Dispose();
                RemoteViewLeftConstraint = null;
            }

            if (RemoteViewRightConstraint != null)
            {
                RemoteViewRightConstraint.Dispose();
                RemoteViewRightConstraint = null;
            }

            if (RemoteViewTopConstraint != null)
            {
                RemoteViewTopConstraint.Dispose();
                RemoteViewTopConstraint = null;
            }

            if (UrlLabel != null)
            {
                UrlLabel.Dispose();
                UrlLabel = null;
            }

            if (VideoButton != null)
            {
                VideoButton.Dispose();
                VideoButton = null;
            }
        }
Ejemplo n.º 2
0
        private async Task MucClient_RoomPresence(object _, UserPresenceEventArgs e, ChatView View)
        {
            if ((e.MucStatus?.Length ?? 0) > 0 || e.RoomDestroyed)
            {
                RoomNode RoomNode = await this.GetRoomNode(e.RoomId, e.Domain);

                if (View is null)
                {
                    View = MainWindow.currentInstance.FindRoomView(e.From, XmppClient.GetBareJID(e.To));
                }

                if (!(View is null))
                {
                    foreach (MucStatus Status in e.MucStatus ?? new MucStatus[0])
                    {
                        switch (Status)
                        {
                        case MucStatus.AffiliationChanged:
                            if (e.Affiliation.HasValue)
                            {
                                View.Event("New affiliation: " + e.Affiliation.ToString(), e.NickName, string.Empty);
                            }
                            break;

                        case MucStatus.LoggingEnabled:
                            View.Event("This room logs messages.", e.NickName, string.Empty);
                            break;

                        case MucStatus.LoggingDisabled:
                            View.Event("This room does not log messages.", e.NickName, string.Empty);
                            break;

                        case MucStatus.NickModified:
                            View.Event("Nick-name changed.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RoomNonAnonymous:
                            View.Event("This room does not anonymous.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RoomSemiAnonymous:
                            View.Event("This room is semi-anonymous.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RoomAnonymous:
                            View.Event("This room does anonymous.", e.NickName, string.Empty);
                            break;

                        case MucStatus.FullJidVisisble:
                            View.Event("All participants in this room have access to the full JID of each other.", e.NickName, string.Empty);
                            break;

                        case MucStatus.ShowsUnavailableMembers:
                            View.Event("This room displays unavailable members.", e.NickName, string.Empty);
                            break;

                        case MucStatus.DoesNotShowUnavailableMembers:
                            View.Event("This room hieds unavailable members.", e.NickName, string.Empty);
                            break;

                        case MucStatus.NonPrivacyRelatedConfigurationChange:
                            View.Event("A configuration that does not affect privacy changed.", e.NickName, string.Empty);
                            break;

                        case MucStatus.OwnPresence:
                            break;

                        case MucStatus.Created:
                            View.Event("Room created.", e.NickName, string.Empty);
                            break;

                        case MucStatus.Banned:
                            View.Event("Banned from the room.", e.NickName, string.Empty);
                            break;

                        case MucStatus.NewRoomNickName:
                            View.Event("New room nick-name.", e.NickName, string.Empty);
                            break;

                        case MucStatus.Kicked:
                            View.Event("Temporarily kicked from the room.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RemovedDueToAffiliationChange:
                            View.Event("Removed from the room due to an affiliation change.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RemovedDueToNonMembership:
                            View.Event("Removed from the room, since no longer member.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RemovedDueToSystemShutdown:
                            View.Event("Removed from the room due to system shutdown.", e.NickName, string.Empty);
                            break;

                        case MucStatus.RemovedDueToFailure:
                            View.Event("Removed from the room due to technical problems.", e.NickName, string.Empty);
                            break;
                        }
                    }
                }

                if (e.RoomDestroyed)
                {
                    View?.Event("Room has been destroyed on the host.", e.NickName, string.Empty);

                    RoomNode.Parent.RemoveChild(RoomNode);
                    RoomNode.Parent.OnUpdated();
                }
            }
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            if (currentInstance == null)
            {
                currentInstance = this;
            }

            Types.Initialize(typeof(MainWindow).Assembly,
                             typeof(Content.InternetContent).Assembly,
                             typeof(Content.Images.ImageCodec).Assembly,
                             typeof(Content.Markdown.MarkdownDocument).Assembly,
                             typeof(XML).Assembly,
                             typeof(Content.Xsl.XSL).Assembly,
                             typeof(SensorData).Assembly,
                             typeof(Networking.XMPP.BOSH.HttpBinding).Assembly,
                             typeof(Networking.XMPP.P2P.EndpointSecurity).Assembly,
                             typeof(Networking.XMPP.Provisioning.ProvisioningClient).Assembly,
                             typeof(Networking.XMPP.WebSocket.WebSocketBinding).Assembly,
                             typeof(Database).Assembly,
                             typeof(FilesProvider).Assembly,
                             typeof(Script.Expression).Assembly,
                             typeof(Script.Content.Functions.Encoding.Decode).Assembly,
                             typeof(Script.Graphs.Graph).Assembly,
                             typeof(Script.Fractals.FractalGraph).Assembly,
                             typeof(Script.Persistence.Functions.FindObjects).Assembly,
                             typeof(Script.Statistics.Functions.Beta).Assembly,
                             typeof(Security.IUser).Assembly,
                             typeof(Security.EllipticCurves.CurvePrimeField).Assembly);

            appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            if (!appDataFolder.EndsWith(new string(Path.DirectorySeparatorChar, 1)))
            {
                appDataFolder += Path.DirectorySeparatorChar;
            }

            appDataFolder += "IoT Client" + Path.DirectorySeparatorChar;

            if (!Directory.Exists(appDataFolder))
            {
                Directory.CreateDirectory(appDataFolder);
            }

            Task.Run(() =>
            {
                try
                {
                    databaseProvider = new FilesProvider(appDataFolder + "Data", "Default", 8192, 10000, 8192, Encoding.UTF8, 3600000);
                    Database.Register(databaseProvider);

                    Database.Find <Question>(new FilterAnd(new FilterFieldEqualTo("OwnerJID", string.Empty),
                                                           new FilterFieldEqualTo("ProvisioningJID", string.Empty))); // To prepare indices, etc.

                    ChatView.InitEmojis();
                }
                catch (Exception ex)
                {
                    ex = Log.UnnestException(ex);
                    ErrorBox(ex.Message);
                }
            });

            InitializeComponent();

            this.MainView.Load(this);
        }
Ejemplo n.º 4
0
        private void ChatMessageReceived(object P)
        {
            MessageEventArgs e = (MessageEventArgs)P;
            ChatView         ChatView;

            string Message    = e.Body;
            bool   IsMarkdown = false;

            foreach (XmlNode N in e.Message.ChildNodes)
            {
                if (N.LocalName == "content" && N.NamespaceURI == "urn:xmpp:content")
                {
                    string Type = XML.Attribute((XmlElement)N, "type");
                    if (Type == "text/markdown")
                    {
                        IsMarkdown = true;

                        Type = N.InnerText;
                        if (!string.IsNullOrEmpty(Type))
                        {
                            Message = Type;
                        }

                        break;
                    }
                }
            }

            foreach (TabItem TabItem in this.Tabs.Items)
            {
                ChatView = TabItem.Content as ChatView;
                if (ChatView == null)
                {
                    continue;
                }

                XmppContact XmppContact = ChatView.Node as XmppContact;
                if (XmppContact == null)
                {
                    continue;
                }

                if (XmppContact.BareJID != e.FromBareJID)
                {
                    continue;
                }

                XmppAccountNode XmppAccountNode = XmppContact.XmppAccountNode;
                if (XmppAccountNode == null)
                {
                    continue;
                }

                if (XmppAccountNode.BareJID != XmppClient.GetBareJID(e.To))
                {
                    continue;
                }

                ChatView.ChatMessageReceived(Message, IsMarkdown, this);
                return;
            }

            foreach (TreeNode Node in this.MainView.ConnectionTree.Items)
            {
                XmppAccountNode XmppAccountNode = Node as XmppAccountNode;
                if (XmppAccountNode == null)
                {
                    continue;
                }

                if (XmppAccountNode.BareJID != XmppClient.GetBareJID(e.To))
                {
                    continue;
                }

                if (XmppAccountNode.TryGetChild(e.FromBareJID, out TreeNode ContactNode))
                {
                    TabItem TabItem2 = MainWindow.NewTab(e.FromBareJID);
                    this.Tabs.Items.Add(TabItem2);

                    ChatView         = new ChatView(ContactNode);
                    TabItem2.Content = ChatView;

                    ChatView.ChatMessageReceived(Message, IsMarkdown, this);
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        private void FocusChatInput2(object P)
        {
            ChatView View = (ChatView)P;

            View.Input.Focus();
        }
Ejemplo n.º 6
-1
        public MainWindow()
        {
            #if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
            #endif
            Thread.CurrentThread.Name = "UI Thread";

            Bot = new BotClient();
            Bot.StateChanged += Bot_StateChanged;
            Bot.ClientChanged += Bot_ClientChanged;
            Bot.AutoReconnector.StateChanged += Bot_AutoReconnectorStateChanged;
            Bot.StaffAvoider.StateChanged += Bot_StaffAvoiderStateChanged;
            Bot.PokemonEvolver.StateChanged += Bot_PokemonEvolverStateChanged;
            Bot.ConnectionOpened += Bot_ConnectionOpened;
            Bot.ConnectionClosed += Bot_ConnectionClosed;
            Bot.MessageLogged += Bot_LogMessage;

            InitializeComponent();
            AutoReconnectSwitch.IsChecked = Bot.AutoReconnector.IsEnabled;
            AvoidStaffSwitch.IsChecked = Bot.StaffAvoider.IsEnabled;
            AutoEvolveSwitch.IsChecked = Bot.PokemonEvolver.IsEnabled;

            App.InitializeVersion();

            Team = new TeamView(Bot);
            Inventory = new InventoryView();
            Chat = new ChatView(Bot);
            Players = new PlayersView(Bot);

            _refreshPlayers = DateTime.UtcNow;
            _refreshPlayersDelay = 5000;

            TeamContent.Content = Team;
            InventoryContent.Content = Inventory;
            ChatContent.Content = Chat;
            PlayersContent.Content = Players;

            TeamContent.Visibility = Visibility.Visible;
            InventoryContent.Visibility = Visibility.Collapsed;
            ChatContent.Visibility = Visibility.Collapsed;
            PlayersContent.Visibility = Visibility.Collapsed;
            TeamButton.IsChecked = true;

            SetTitle(null);

            LogMessage("Running " + App.Name + " by " + App.Author + ", version " + App.Version);

            Task.Run(() => UpdateClients());
        }