private void XmppOnOnIq(object sender, IQ iq) { if (iq.Error != null && iq.Error.Code == ErrorCode.NotAllowed) { if (OnLoginComplete != null) { OnLoginComplete.Invoke(this, LoginResults.Failure); } } if (iq.Type == IqType.result) { if (iq.Vcard != null) { var f = Friends.AsParallel().SingleOrDefault(x => x.User.Bare == iq.From.Bare); if (f != null) { var email = DatabaseHandler.GetUser(f.User.Bare); if (String.IsNullOrWhiteSpace(email)) { var s = iq.Vcard.GetEmailAddresses().SingleOrDefault(x => !String.IsNullOrWhiteSpace(x.UserId)); if (s != null) { f.Email = s.UserId; DatabaseHandler.AddUser(f.User.Bare, f.Email); } } else { f.Email = email; } } if (OnDataRecieved != null) { OnDataRecieved.Invoke(this, DataRecType.FriendList, Friends); } } } }