private void PresenceCallback(object sender, PresenceEventArgs e) { var mucX = e.Presence.MucUser; // check for status code 201, this means the room is not ready to use yet // we request an instant room and accept the and accept the default configuration by the server if (mucX.HasStatus(201)) // 201 = room is awaiting configuration. { mm.RequestInstantRoom(_roomJid); } var lvi = FindListViewItem(e.Presence.From); if (lvi != null) { if (e.Presence.Type == PresenceType.Unavailable) { lvi.Remove(); } else { int imageIdx = Util.GetRosterImageIndex(e.Presence); lvi.ImageIndex = imageIdx; lvi.SubItems[1].Text = (e.Presence.Status ?? ""); var u = e.Presence.MucUser; if (u != null) { lvi.SubItems[2].Text = u.Item.Affiliation.ToString(); lvi.SubItems[3].Text = u.Item.Role.ToString(); } } } else { int imageIdx = Util.GetRosterImageIndex(e.Presence); var lv = new ListViewItem(e.Presence.From.Resource) { Tag = e.Presence.From.ToString() }; lv.SubItems.Add(e.Presence.Status ?? ""); var u = e.Presence.MucUser; if (u != null) { lv.SubItems.Add(u.Item.Affiliation.ToString()); lv.SubItems.Add(u.Item.Role.ToString()); } lv.ImageIndex = imageIdx; lvwRoster.Items.Add(lv); } }
private void PresenceCallback(object sender, PresenceEventArgs e) { var mucX = e.Presence.MucUser; if (mucX == null) { if (e.Presence.Error.Type == Matrix.Xmpp.Base.ErrorType.Auth) { if (e.Presence.Error.FirstAttribute.Value == "407") { MessageBox.Show("Unauthorized!"); this.Close(); return; } } } // check for status code 201, this means the room is not ready to use yet // we request an instant room and accept the and accept the default configuration by the server if (mucX.HasStatus(201)) // 201 = room is awaiting configuration.d { mm.RequestInstantRoom(_roomJid); } var lvi = FindListViewItem(e.Presence.From); if (lvi != null) { if (e.Presence.Type == PresenceType.Unavailable) { lvi.Remove(); } else { int imageIdx = Util.GetRosterImageIndex(e.Presence); lvi.ImageIndex = imageIdx; //lvi.SubItems[1].Text = (e.Presence.Status ?? ""); var u = e.Presence.MucUser; if (u != null) { lvi.SubItems[1].Text = u.Item.Affiliation.ToString(); lvi.SubItems[2].Text = u.Item.Role.ToString(); //string bare = e.Presence.From.Resource + "@" + FrmLogin.Instance.HostName; //listAddress[lvi.SubItems[3].Text] = bare; //lvi.SubItems[3].Text = bare; } } } else { int imageIdx = Util.GetRosterImageIndex(e.Presence); var lv = new ListViewItem(e.Presence.From.Resource) { Tag = e.Presence.From.ToString() }; //lv.SubItems.Add(e.Presence.Status ?? ""); var u = e.Presence.MucUser; if (u != null) { lv.SubItems.Add(u.Item.Affiliation.ToString()); lv.SubItems.Add(u.Item.Role.ToString()); //string bare = e.Presence.From.Resource + "@" + FrmLogin.Instance.HostName; //lv.SubItems.Add(bare); //if (!listAddress.ContainsKey(bare)) //{ // listAddress.Add(bare, bare); //} } lv.ImageIndex = imageIdx; lvwRoster.Items.Add(lv); } }