1

I did exactly what the answer suggested ( Asmack not loading VCard ) but it still doesn't work. The DEBUG output shows that Smack receives the packet with the VCard information but then throws a ClassCastException in https://github.com/rtreffer/smack/blob/master/source/org/jivesoftware/smackx/packet/VCard.java#L548 and all I get is 'No VCard for xxx@xxx'.

My code:

public VCard getUserVCard() throws XMPPException {
    VCard userVCard = new VCard();
    userVCard.load(connection);
    return userVCard;
}

And some previous initialization:

ConnectionConfiguration config = new ConnectionConfiguration(OF_HOST, OF_PORT, OF_SERVICE_NAME);
config.setDebuggerEnabled(true);
    config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
ProviderManager.getInstance().addIQProvider("vCard ", "vcard-temp", new org.jivesoftware.smackx.provider.VCardProvider());
connection = new XMPPConnection(config);
this.context = context;
try {
    connection.connect();
} catch (XMPPException e) {
    // TODO Auto-generated catch block
        e.printStackTrace();
}

The VCard information in the database is OK - only the final casting fails. Any suggestions?

Community
  • 1
  • 1
PawelPredki
  • 754
  • 1
  • 12
  • 26
  • One comment - if I use the VCardProvider directly, I am able to create a VCard from a String: `String vCardString = prefs .getString(UserPreferences.USER_VCARD, null); userVCard = VCardProvider.createVCardFromXML(vCardString); ` – PawelPredki Feb 01 '12 at 13:51
  • Have you tried using the other method `userVCard.load(connection, user);`, user being the id of the user you want to retrieve the vCard (i.e. your id in this case)? I don't know if it will work better but that's the one I'm using with success. – Guillaume Feb 01 '12 at 18:25
  • I tried that as well and the result was similar. The VCard data is fetched from the server but it is not parsed as a VCard object by asmack. – PawelPredki Feb 05 '12 at 17:24
  • I still haven't found a solution for this. I am not able to parse any users' VCard although they are fetched from the server. – PawelPredki Feb 16 '12 at 11:00

1 Answers1

0

I finally decided not only to add the VCardProvider but the whole nine yards in the configuration following this post getSearchForm returns null when using UserSearch in XMPP with aSmack and it worked.

Community
  • 1
  • 1
PawelPredki
  • 754
  • 1
  • 12
  • 26