private void XmppCon_OnPresence(object sender, Presence pres) { if (base.InvokeRequired) { base.BeginInvoke(new OnPresenceDelegate(this.XmppCon_OnPresence), new object[] { sender, pres }); } else if (pres.get_Type() == 0) { new frmSubscribe(this.XmppCon, pres.get_From()).Show(); } else if (((pres.get_Type() != 1) && (pres.get_Type() != 2)) && (pres.get_Type() != 3)) { try { this.rosterControl.SetPresence(pres); } catch (Exception exception) { Console.WriteLine(exception.Message); } } }
private void PresenceCallback(object sender, Presence pres, object data) { if (base.InvokeRequired) { base.BeginInvoke(new PresenceCB(this, (IntPtr) this.PresenceCallback), new object[] { sender, pres, data }); } else { int rosterImageIndex; User user; ListViewItem item = this.FindListViewItem(pres.get_From()); if (item != null) { if (pres.get_Type() == 4) { item.Remove(); } else { rosterImageIndex = Util.GetRosterImageIndex(pres); item.ImageIndex = rosterImageIndex; item.SubItems[1].Text = (pres.get_Status() == null) ? "" : pres.get_Status(); user = pres.SelectSingleElement(typeof(User)) as User; if (user != null) { item.SubItems[2].Text = user.get_Item().get_Affiliation().ToString(); item.SubItems[3].Text = user.get_Item().get_Role().ToString(); } } } else { rosterImageIndex = Util.GetRosterImageIndex(pres); ListViewItem item2 = new ListViewItem(pres.get_From().get_Resource()); item2.Tag = pres.get_From().ToString(); item2.SubItems.Add((pres.get_Status() == null) ? "" : pres.get_Status()); user = pres.SelectSingleElement(typeof(User)) as User; if (user != null) { item2.SubItems.Add(user.get_Item().get_Affiliation().ToString()); item2.SubItems.Add(user.get_Item().get_Role().ToString()); } item2.ImageIndex = rosterImageIndex; this.lvwRoster.Items.Add(item2); } } }