powered by Jive Software

vCard: JM API/Smack API

Hi all,

Is there a way to create and populate a vCard using JM API and grab it with Smack API?

PS: reading the Javadoc, I don’'t understand how to create a vCard using the method:

public void setVCard(String username, org.dom4j.Element vCardElement[/b])

I wonder how to set the argument “org.dom4j.Element vCardElement”…

If someone can help me…it would be great!

Thanks.

Alex

Hey Alex,

The easiest way would be to use Smack API to create and retrieve vCards. If you need to create vCards from the server side for some reason (e.g. import from legacy system) then you will need to pass the following parameters to VCardManager#setVCard(String username, Element vCardElement):

Parameters:

username = the node of the user JID. That would be the first part before the @.

vCardElement = a DOM Element that contains the vCard element. An example of the vCard element XML would be:

/code

Regards,

– Gato

Hi Gato…

Thanks for your help, and explanations…

As Ryang told me today (http://www.jivesoftware.org/forums/thread.jspa?threadID=15387&tstart=0), it seems possible to grab directly, using vCard api on Smack side, custom properties set from “org.jivesoftware.messenger.user.User” class on server side:

  • Do you think I’'d better use vCard api on client side (Smack) AND[/b] on server side? And if yes, is there a best practice (code snippet) to use Dom4j to create the java representation of your sample XML code?

  • Is there a more efficient way to set and grab custom properties using JM api and Smack api together (=> my core problem)?

Thanks a lot…

Alex

Hey Alex,

I don’'t know your requirements but my first approach would be to use the simplest solution that would be using only Smack API for doing any vCard related work. And only have a mix solution (ie. server side and client side) if there is a real reason for having a more complex solution.

Regards,

– Gato

Hi Gato…

I’'m running JM on Tomcat and using a Smack client embedded in an applet…

I just want to keep control on custom user properties created on server side, and only allow Smack client to read those properties (for example to spread them in client gui…).

Alex

Hi all,

Do you know where I can find some code example showing how to use dom4j (in java) with vCard?

Thanks a lot

Alex