private void GotVCard(object sender, jabber.protocol.client.IQ iq, object data) { jabber.protocol.iq.VCard vcard = (jabber.protocol.iq.VCard)iq.Query; if (iq.Type != jabber.protocol.client.IQType.result) { return; } PopulateName(vcard); PopulateAddresses(vcard); PopulateTelephones(vcard); EmailLink.Text = vcard.Email; CommentTextBox.Text = vcard.Description; if (vcard.Url != null) { WebLink.Text = vcard.Url.ToString(); } PhotoPictureBox.Image = XmppImages.DefaultAvatar; if (vcard.Photo != null) { if (vcard.Photo["BINVAL"] != null) { PhotoPictureBox.Image = ImageManipulation.Base64ToImage(vcard.Photo["BINVAL"].InnerText); } } Spinner.Visible = false; }
internal void GotVCardResponse(object sender, jabber.protocol.client.IQ response, object data) { try { XmppGlobal.InternalQueryCache.VCard[response.From.Bare] = response; jabber.protocol.iq.VCard vcard = (jabber.protocol.iq.VCard)response.Query; if (vcard.Photo != null) { if (vcard.Photo["BINVAL"] != null) { BaseAvatar = ImageManipulation.Base64ToImage(vcard.Photo["BINVAL"].InnerText); } } OnVCardReceived(new VCardEventArgs(response)); CallbackState state = (CallbackState)data; if (state.Callback != null) { state.Callback.Invoke(sender, response, state.State); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void PopulateTelephones(jabber.protocol.iq.VCard vcard) { if (vcard.GetTelephone(jabber.protocol.iq.TelephoneType.voice, jabber.protocol.iq.TelephoneLocation.work) != null) { FillInPhoneTextBox("Work:", vcard.GetTelephone(jabber.protocol.iq.TelephoneType.voice, jabber.protocol.iq.TelephoneLocation.work).Number); } foreach (jabber.protocol.iq.VCard.VTelephone t in vcard.GetTelephoneList()) { if (t["CELL"] != null) { FillInPhoneTextBox("Cell:", t.Number); } } if (vcard.GetTelephone(jabber.protocol.iq.TelephoneType.voice, jabber.protocol.iq.TelephoneLocation.home) != null) { FillInPhoneTextBox("Work:", vcard.GetTelephone(jabber.protocol.iq.TelephoneType.voice, jabber.protocol.iq.TelephoneLocation.home).Number); } if (vcard.GetTelephone(jabber.protocol.iq.TelephoneType.voice, jabber.protocol.iq.TelephoneLocation.unknown) != null) { FillInPhoneTextBox("Work:", vcard.GetTelephone(jabber.protocol.iq.TelephoneType.voice, jabber.protocol.iq.TelephoneLocation.unknown).Number); } foreach (jabber.protocol.iq.VCard.VTelephone t in vcard.GetTelephoneList()) { if (t["PAGER"] != null) { FillInPhoneTextBox("Pager:", t.Number); } } foreach (jabber.protocol.iq.VCard.VTelephone t in vcard.GetTelephoneList()) { if (t["FAX"] != null) { FillInPhoneTextBox("Fax:", t.Number); } } }
private void PopulateAddresses(jabber.protocol.iq.VCard vcard) { if (vcard.GetAddress(jabber.protocol.iq.AddressLocation.work) != null) { Address1TypeLabel.Text = "Work:"; Address1TextBox.Lines = FormatAddress(vcard.GetAddress(jabber.protocol.iq.AddressLocation.work)); } if (vcard.GetAddress(jabber.protocol.iq.AddressLocation.home) != null) { if (Address1TextBox.Text.Trim().Length == 0) { Address1TypeLabel.Text = "Home:"; Address1TextBox.Lines = FormatAddress(vcard.GetAddress(jabber.protocol.iq.AddressLocation.home)); } else { Address2TypeLabel.Text = "Home:"; Address2TextBox.Lines = FormatAddress(vcard.GetAddress(jabber.protocol.iq.AddressLocation.home)); return; } } if (vcard.GetAddress(jabber.protocol.iq.AddressLocation.unknown) != null) { if (Address1TextBox.Text.Trim().Length == 0) { Address1TypeLabel.Text = "Address:"; Address1TextBox.Lines = FormatAddress(vcard.GetAddress(jabber.protocol.iq.AddressLocation.unknown)); } else { Address2TypeLabel.Text = "Address:"; Address2TextBox.Lines = FormatAddress(vcard.GetAddress(jabber.protocol.iq.AddressLocation.unknown)); return; } } }
private void PopulateName(jabber.protocol.iq.VCard vcard) { List <string> names = new List <string> (); if (!string.IsNullOrEmpty(vcard.FullName)) { if (!string.IsNullOrEmpty(vcard.Nickname)) { names.Add(string.Format("{0} ({1})", vcard.FullName.Trim(), vcard.Nickname.Trim())); } else { names.Add(vcard.FullName.Trim()); } } else { if (!string.IsNullOrEmpty(vcard.Nickname)) { names.Add(vcard.Nickname.Trim()); } } if (!string.IsNullOrEmpty(vcard.Title)) { names.Add(vcard.Title.Trim()); } if (vcard.Organization != null) { if (!string.IsNullOrEmpty(vcard.Organization.Unit)) { names.Add(vcard.Organization.Unit.Trim()); } if (!string.IsNullOrEmpty(vcard.Organization.OrgName)) { names.Add(vcard.Organization.OrgName.Trim()); } } NameTextBox.Lines = names.ToArray(); switch (NameTextBox.Lines.Length) { case 1: NameTextBox.Height = 14; NameTextBox.Top = 69; break; case 2: NameTextBox.Height = 28; NameTextBox.Top = 62; break; case 3: NameTextBox.Height = 42; NameTextBox.Top = 55; break; case 4: NameTextBox.Height = 56; NameTextBox.Top = 48; break; } }