Smuxi.Engine.XmppProtocolManager.OnPrivateChatPresence C# (CSharp) Method

OnPrivateChatPresence() private method

private OnPrivateChatPresence ( Presence pres ) : void
pres agsXMPP.protocol.client.Presence
return void
        void OnPrivateChatPresence(Presence pres)
        {
            Jid jid = pres.From;
            if (jid.Bare == JabberClient.MyJID.Bare) {
                // don't process any of my own resources
                return;
            }
            var person = GetOrCreateContact(jid.Bare, jid);
            PrintPrivateChatPresence(person, pres);
            switch (pres.Type) {
                case PresenceType.available:
                    if (pres.Priority < 0) break;
                    if (ContactChat == null) break;
                    if (ContactChat.UnsafePersons.ContainsKey(jid.Bare)) break;
                    Session.AddPersonToGroupChat(ContactChat, person.ToPersonModel());
                    break;
                case PresenceType.unavailable:
                    person.RemoveResource(jid);
                    if (pres.Priority < 0) break;
                    if (ContactChat == null) break;
                    if (!ContactChat.UnsafePersons.ContainsKey(jid.Bare)) break;
                    var pers = ContactChat.GetPerson(jid.Bare);
                    Session.RemovePersonFromGroupChat(ContactChat, pers);
                    break;
                case PresenceType.subscribe:
                    if (person.Ask == AskType.subscribe) {
                        // we are currently asking the contact OR are subscribed to him
                        // so we allow the contact to subscribe
                        // TODO: make the following dependent on some user setable boolean
                        JabberClient.PresenceManager.ApproveSubscriptionRequest(jid);
                    }
                    break;
                case PresenceType.subscribed:
                    // we are now able to see that contact's presences
                    break;
                case PresenceType.unsubscribed:
                    // the contact does not wish us to see his presences anymore
                    if (person.Subscription == SubscriptionType.from) {
                        // but the contact can still see us
                        // TODO: make the following dependent on some user setable boolean
                        JabberClient.PresenceManager.RefuseSubscriptionRequest(jid);
                    } else {
                        // TODO: this contact was just created in OnPresence… prevent it from doing that?
                        // TODO: this can happen when a subscription=none contact sends a deny…
                        Contacts.Remove(jid.Bare);
                    }
                    break;
                case PresenceType.unsubscribe:
                    // the contact does not wish to see our presence anymore?
                    // we could care less
                    break;
            }
        }