Пример #1
0
        public void handleInvitation(Message msg, Invite inv)
        {
            InvitationForm frm = new InvitationForm();

            frm.setChatroomInvite(inv.From, msg.From);
            frm.Show();
            frm.Activate();
        }
Пример #2
0
        void conn_OnPresence(object sender, agsXMPP.protocol.client.Presence pres)
        {
            if (pres.HasTag(typeof(agsXMPP.protocol.x.muc.User), true) ||
                (pres.Type == agsXMPP.protocol.client.PresenceType.error && pres.HasTag(typeof(agsXMPP.protocol.x.muc.Muc), true)))
            {
                return;
            }
            if (pres.Type == agsXMPP.protocol.client.PresenceType.available || pres.Type == agsXMPP.protocol.client.PresenceType.unavailable)
            {
                if (!contacts.ContainsKey(pres.From.Bare))
                {
                    contacts.Add(pres.From.Bare, new JabberContact(pres.From));
                }
                JabberContact contact = contacts[pres.From.Bare];
                if (!contact.resources.Contains(pres.From.Resource))
                {
                    contact.resources.Add(pres.From.Resource);
                }
                if (pres.Type == agsXMPP.protocol.client.PresenceType.unavailable)
                {
                    contact.available = false;
                }
                else
                {
                    contact.available = true;
                }
                if (OnContactPresence != null)
                {
                    OnContactPresence(this, new JabberEventArgs(pres.From.Bare));
                }
            }
            else if (pres.Type == PresenceType.subscribe || pres.Type == PresenceType.subscribed ||
                     pres.Type == PresenceType.unsubscribe || pres.Type == PresenceType.unsubscribed)
            {
                Program.MainWnd.Invoke(new Action <object>((x) => {
                    var f = new InvitationForm();
                    switch (pres.Type)
                    {
                    case PresenceType.subscribe:
                        f.setContactRequest(pres.From);
                        break;

                    case PresenceType.subscribed:
                        f.setContactSubscriptionApproved(pres.From);
                        break;

                    case PresenceType.unsubscribe:
                        f.setContactUnsubscribe(pres.From);
                        break;

                    case PresenceType.unsubscribed:
                        f.setContactSubscriptionCancelled(pres.From);
                        break;
                    }
                    f.Show();
                }), this);
            }
        }