Exemple #1
0
        private async Task MucClient_PrivateMessageReceived(object Sender, RoomOccupantMessageEventArgs e)
        {
            RoomNode RoomNode = await this.GetRoomNode(e.RoomId, e.Domain);

            OccupantNode Occupant = RoomNode.GetOccupantNode(e.NickName, null, null, null);

            MainWindow.ParseChatMessage(e, out string Message, out bool IsMarkdown, out DateTime Timestamp);

            MainWindow.currentInstance.MucPrivateChatMessage(e.From, XmppClient.GetBareJID(e.To), Message, e.ThreadID,
                                                             IsMarkdown, Timestamp, Occupant, e.From);
        }
Exemple #2
0
        internal OccupantNode CreateOccupantNode(string RoomId, string Domain, string NickName, Affiliation Affiliation, Role Role, string Jid)
        {
            lock (this.occupantByNick)
            {
                if (!this.occupantByNick.TryGetValue(NickName, out OccupantNode Node))
                {
                    Node = new OccupantNode(this, RoomId, Domain, NickName, Affiliation, Role, Jid);

                    lock (this.occupantByNick)
                        this.occupantByNick[NickName] = Node;
                }

                return(Node);
            }
        }
Exemple #3
0
        internal async Task MucClient_OccupantPresence(object Sender, UserPresenceEventArgs e)
        {
            RoomNode RoomNode = await this.GetRoomNode(e.RoomId, e.Domain);

            OccupantNode OccupantNode = RoomNode.GetOccupantNode(e.NickName, e.Affiliation, e.Role, e.FullJid);
            ChatView     View         = null;

            if (!OccupantNode.Availability.HasValue || e.Availability != OccupantNode.Availability.Value)
            {
                OccupantNode.Availability = e.Availability;
                OccupantNode.OnUpdated();

                View = MainWindow.currentInstance.FindRoomView(e.From, XmppClient.GetBareJID(e.To));

                if (!(View is null))
                {
                    switch (OccupantNode.Availability)
                    {
                    case Availability.Online:
                        View.Event("Online.", e.NickName, string.Empty);
                        break;

                    case Availability.Offline:
                        View.Event("Offline.", e.NickName, string.Empty);
                        break;

                    case Availability.Away:
                        View.Event("Away.", e.NickName, string.Empty);
                        break;

                    case Availability.Chat:
                        View.Event("Ready to chat.", e.NickName, string.Empty);
                        break;

                    case Availability.DoNotDisturb:
                        View.Event("Busy.", e.NickName, string.Empty);
                        break;

                    case Availability.ExtendedAway:
                        View.Event("Away (extended).", e.NickName, string.Empty);
                        break;
                    }
                }
            }

            await this.MucClient_RoomPresence(Sender, e, View);
        }
Exemple #4
0
        private OccupantNode AddOccupantNode(string RoomId, string Domain, string NickName, Affiliation?Affiliation, Role?Role, string Jid)
        {
            OccupantNode Node = new OccupantNode(this, RoomId, Domain, NickName, Affiliation, Role, Jid);

            lock (this.occupantByNick)
            {
                this.occupantByNick[NickName] = Node;
            }

            if (this.IsLoaded)
            {
                if (this.children is null)
                {
                    this.children = new SortedDictionary <string, TreeNode>()
                    {
                        { Node.Key, Node }
                    }
                }
                ;
                else
                {
                    lock (this.children)
                    {
                        this.children[Node.Key] = Node;
                    }
                }

                MainWindow.UpdateGui(() =>
                {
                    this.Service?.Account?.View?.NodeAdded(this, Node);

                    if (!(Node.Children is null))
                    {
                        foreach (TreeNode Node2 in Node.Children)
                        {
                            this.Service?.Account?.View?.NodeAdded(Node, Node2);
                        }
                    }

                    this.OnUpdated();
                });
            }

            return(Node);
        }