void OnRosterItem(object sender, RosterItem rosterItem)
{
// setting to none also removes the person from chat, as we'd never get an offline message anymore
if (rosterItem.Subscription == SubscriptionType.none
|| rosterItem.Subscription == SubscriptionType.remove) {
if (rosterItem.Subscription == SubscriptionType.remove) {
Contacts.Remove(rosterItem.Jid);
}
if (ContactChat == null) {
return;
}
PersonModel oldp = ContactChat.GetPerson(rosterItem.Jid);
if (oldp == null) {
// doesn't exist, don't need to do anything
return;
}
Session.RemovePersonFromGroupChat(ContactChat, oldp);
return;
}
// create or update a roster item
var contact = GetOrCreateContact(rosterItem.Jid.Bare, rosterItem.Name ?? rosterItem.Jid);
contact.Temporary = false;
contact.Subscription = rosterItem.Subscription;
contact.Ask = rosterItem.Ask;
string oldIdentityName = contact.IdentityName;
var oldIdentityNameColored = contact.IdentityNameColored;
contact.IdentityName = rosterItem.Name ?? rosterItem.Jid;
if (oldIdentityName == contact.IdentityName) {
// identity name didn't change
// the rest of this function only handles changed identity names
return;
}
contact.IdentityNameColored = null; // uncache
ProcessIdentityNameChanged(contact, oldIdentityNameColored, oldIdentityName);
}