Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
acdelemos #1
Member since Feb 2006 · 21 posts · Location: Brazil
Group memberships: Members
Show profile · Link to this post
Subject: Problems to read information of vcard
Hi.

I noticed that these definitive fields (below) are not correctly showing the data of vcard that it was generated by the Pandion/Exodus.
-------- Start Code ----------
if (iq.Type == IqType.result)
{
    Vcard vcard = iq.Vcard;
    if (vcard != null)
    {
        txtMailPes.Text =  vcard.GetPreferedEmailAddress().UserId.ToString();
        txtCelPes.Text =   vcard.GetTelephoneNumber(TelephoneType.CELL, TelephoneLocation.HOME).Number.ToString();
        txtFaxPes.Text =   vcard.GetTelephoneNumber(TelephoneType.FAX, TelephoneLocation.HOME).Number.ToString();
        txtPaisPes.Text =  vcard.GetAddress(AddressLocation.HOME).Country.ToString();
        txtMailEmp.Text =  vcard.GetEmailAddress(EmailType.WORK).ToString();
        txtCelEmp.Text =   vcard.GetTelephoneNumber(TelephoneType.CELL, TelephoneLocation.WORK).Number.ToString();
        txtFaxEmp.Text =   vcard.GetTelephoneNumber(TelephoneType.FAX, TelephoneLocation.WORK).Number.ToString();
        txtPaisEmp.Text =  vcard.GetAddress(AddressLocation.WORK).Country.ToString();
    }
}
---------- End Code -------------
This post was edited on 2006-05-29, 18:47 by acdelemos.
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hi,

if the information is not showing up correct then Exodus and Pandion are using other fields than you. There are lots of fields in the vCrad specs and the most existing clients are using only a small subset of them.
Below is a code snipped which we use in one of our clients and works pretty well.

Alex


  1. private void VcardResult(object sender, IQ iq, object data)
  2.         {
  3.             if (InvokeRequired)
  4.             {
  5.                 // Windows Forms are not Thread Safe, we need to invoke this :(
  6.                 // We're not in the UI thread, so we need to call BeginInvoke            
  7.                 BeginInvoke(new IqCB(VcardResult), new object[] { sender, iq, data });
  8.                 return;
  9.             }
  10.             if (iq.Type == IqType.result)
  11.             {
  12.                 Vcard vcard = iq.Vcard;
  13.                 if (vcard != null)
  14.                 {
  15.                     txtFullname.Text = vcard.Fullname;
  16.                     txtNickname.Text = vcard.Nickname;
  17.                     Email mail = vcard.GetEmailAddress(EmailType.INTERNET);
  18.                     if (mail != null)
  19.                         txtEmail.Text = mail.UserId;
  20.  
  21.                     txtHomepage.Text = vcard.Url;
  22.  
  23.                     if (isOwnVcard)
  24.                     {
  25.                         dtBirthday.Visible = true;
  26.                         txtBirthday.Visible = false;
  27.                         if (vcard.Birthday != DateTime.MinValue || vcard.Birthday > dtBirthday.MinDate)
  28.                         {
  29.                             dtBirthday.Value    = vcard.Birthday;
  30.                             dtBirthday.Checked  = true;
  31.                         }
  32.                        
  33.                     }
  34.                     else
  35.                     {
  36.                         dtBirthday.Visible = false;
  37.                         txtBirthday.Visible = true;
  38.                         if (vcard.Birthday != DateTime.MinValue)
  39.                             txtBirthday.Text = vcard.Birthday.ToShortDateString();
  40.                     }
  41.                                        
  42.                     Photo photo = vcard.Photo;
  43.                     if (photo != null)
  44.                     {
  45.                         picPhoto.Image = vcard.Photo.Image;
  46.                         imageFormat = photo.ImageFormat;
  47.                         hasPhoto = true;
  48.                     }
  49.                    
  50.                     // Personal
  51.                     //<STREET>1899 Wynkoop Street</STREET>
  52.                     //<EXTADD>Suite 600</EXTADD>
  53.                     //<LOCALITY>Denver</LOCALITY>
  54.                     //<REGION>Colorado</REGION>
  55.                     //<PCODE>80202</PCODE>
  56.                     //<COUNTRY>USA</COUNTRY>
  57.                     Address personalAddress = vcard.GetAddress(AddressLocation.HOME);
  58.                     // Some clients don't include the HOME tag in the home address,
  59.                     // so also check for thr "default" address
  60.                     if (personalAddress == null)
  61.                         personalAddress = vcard.GetAddress(AddressLocation.NONE);
  62.                     if (personalAddress != null)
  63.                     {
  64.                         txtPersonalStreet.Text = personalAddress.Street;
  65.                         txtPersonalExtAdd.Text = personalAddress.ExtraAddress;
  66.                         txtPersonalCity.Text = personalAddress.Locality;
  67.                         txtPersonalRegion.Text = personalAddress.Region;
  68.                         txtPersonalPostalCode.Text = personalAddress.PostalCode;
  69.                         txtPersonalCountry.Text = personalAddress.Country;
  70.                     }
  71.  
  72.                     // Work
  73.                     Address workAddress = vcard.GetAddress(AddressLocation.WORK);
  74.                     if (workAddress != null)
  75.                     {
  76.                         txtWorkStreet.Text = workAddress.Street;
  77.                         txtWorkExtAdd.Text = workAddress.ExtraAddress;
  78.                         txtWorkCity.Text = workAddress.Locality;
  79.                         txtWorkRegion.Text = workAddress.Region;
  80.                         txtWorkPostalCode.Text = workAddress.PostalCode;
  81.                         txtWorkCountry.Text = workAddress.Country;
  82.                     }
  83.                     // Tab Description
  84.                     txtDescription.Text = vcard.Description;
  85.  
  86.                 }
  87.             }
  88.         }
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS