powered by Jive Software

Need code for this case

<presence from='juliet@capulet.com/balcony'>
  <x xmlns='vcard-temp:x:update'>
    <photo>sha1-hash-of-image</photo>
  </x>
</presence>

How do i send this code in smack format..

I no where found to set these tags in presence.

Thanks in advance.
Nikhil dhiman

Hi,

broadcasting the SHA-1 of a new avatar is not implemented in Smack but you can create a packet like that with the following code:

// create presence of type available (Presence has no empty constructor)
Presence avatarPresenceBroadcast = new Presence(Presence.Type.available); // build packet extension for vcard-temp:x:update
DefaultPacketExtension vcardExtension = new DefaultPacketExtension("x", "vcard-temp:x:update"); // set content of packet extension
vcardExtension.setValue("photo", "sha1-hash-of-image"); // add packet extension to presence
avatarPresenceBroadcast.addExtension(vcardExtension); // set from (optional)
avatarPresenceBroadcast.setFrom("juliet@capulet.com/balcony"); // show presences XML
System.out.println(avatarPresenceBroadcast.toXML());

Best regards,

Henning