public static void ProcessRosterIQSet(string username, IQ iq) { if (iq.Query.HasChildElements) { BLL.Users api = new BLL.Users(); foreach (Node r in iq.Query.ChildNodes) { Element el = r as Element; if (el != null) { RosterItem ri = el as RosterItem; if (el.HasAttribute("subscription")) { if (ri.Subscription == SubscriptionType.remove) { api.DeleteFriend(username, ri.Jid.User); } } if (el.HasChildElements) { NodeList li = el.ChildNodes; ElementList eli = ri.GetGroups(); string groupName = null; if (eli.Count > 0) { groupName = eli.Item(0).Value; } if (li.Count > 0) { api.ChangeFriendStatus(username, ri.Jid.User, groupName, null, true); } } } } iq.Type = IqType.get; ProcessRosterIQGet(username, iq); } }