Exemplo n.º 1
0
        private void PresenceChanged(object sender, PresenceItemEventArgs e)
        {
            RosterItem ri = (RosterItem)sender;

            jabber.protocol.client.Presence pres = ri.GetPresence();

            if (pres == null)
            {
                pres = e.Item;
            }

            ContactItem ci = null;

            if (pres != null)
            {
                ci = ContactListPanel.GetContactItem(ri.Jid.Bare);

                if (pres.Status != null)
                {
                    ci.TextLineTwo = pres.Status;
                }
                else if (pres.Show != null)
                {
                    ci.TextLineTwo = pres.Show;
                }
                else
                {
                    ci.TextLineTwo = "Online";
                }
            }

            switch (pres.Type)
            {
            case jabber.protocol.client.PresenceType.available:
                if (!(ci == null))
                {
                    ci.Enabled = true;
                    ci.Visible = true;
                    ci.Image   = ri.Avatar;
                }
                break;

            case jabber.protocol.client.PresenceType.unavailable:
                if (ci != null)
                {
                    ci.Enabled = false;
                    ci.Visible = false;
                }
                break;
            }
        }
Exemplo n.º 2
0
        private void PresenceChanged(object sender, PresenceItemEventArgs e)
        {
            RosterItem ri = (RosterItem)sender;

            jabber.protocol.client.Presence pres = ri.GetPresence();

            if (pres == null)
            {
                StatusBarPanel1.Text    = string.Format("{0} is offline.", ri.GetDisplayName());
                StatusBarPanel1.Visible = true;
            }
            else
            {
                switch (pres.Type)
                {
                case jabber.protocol.client.PresenceType.available:
                    switch (pres.Show)
                    {
                    case "away":
                    case "xa":
                    case "dnd":
                        if (pres.Status == null)
                        {
                            StatusBarPanel1.Text = string.Format("{0} is away.", ri.GetDisplayName());
                        }
                        else
                        {
                            StatusBarPanel1.Text = string.Format("{0} is away. {1}", ri.GetDisplayName(), pres.Status.Trim().Length > 0 ? string.Format(" ({0})", pres.Status.Trim()) : string.Empty);
                        }

                        StatusBarPanel1.Visible = true;
                        break;

                    default:
                        StatusBarPanel1.Visible = false;
                        break;
                    }
                    break;

                case jabber.protocol.client.PresenceType.unavailable:
                    StatusBarPanel1.Text    = string.Format("{0} is offline.", ri.GetDisplayName());
                    StatusBarPanel1.Visible = true;
                    break;
                }
            }

            UserAvatar.Image = ri.Avatar;
        }
Exemplo n.º 3
0
        // Called when someone asks for a subscription to us
        private void Presence_GotSubscriptionRequest(object sender, PresenceItemEventArgs e)
        {
            SubscriptionRequestDialog dialog = new SubscriptionRequestDialog(e.Item);

            dialog.Show();
        }