Creates a new vcard extension. It can take a cache argument, which should be a tied hash which should be able to save the retrieved vcards. If no cache is set a internal hash will be used and the vcards will be retrieved everytime the program is restarted. The keys will be the stringprepped bare JIDs of the people we got a vcard from and the value will be a non-cyclic hash/array datastructure representing the vcard.

About this datastructure see below at VCARD STRUCTURE.

If you want to support avatars correctly make sure you hook up the connection via the hook_on method.

$con must be an object of the class AnyEvent::XMPP::Connection (or derived). Once the vCard extension has been hooked up on a connection it will add the avatar information to all outgoing presence stanzas.

IMPORTANT: You need to hook on the connection BEFORE it was connected. The initial presence stanza needs to contain the information that we support avatars. The vcard will automatically retrieved if the session wasn't already started. Otherwise you will have to retrieve the vcard manually if you hook it up after the session_ready event was received. You can prevent the automatic retrieval by giving a true value in $dont_retrieve_vcard. However, just make sure to hook up on any connection before it is connected if you want to offer avatar support on it.

This method will store your $vcard on the connected server. $cb is called when either an error occured or the storage was successful. If an error occured the first argument is not undefined and contains an AnyEvent::XMPP::Error::IQ object.

This method will retrieve the vCard for $jid via the connection $con. If $jid is undefined the vCard of yourself is retrieved. The callback $cb is called when an error occured or the vcard was retrieved. The first argument of the callback will be the JID to which the vCard belongs, the second argument is the vCard itself (as described in VCARD STRUCTURE below) and the thrid argument is the error, if an error occured (undef otherwise).

The keys represent the toplevel element of a vCard, the values are always array references containig one or more values for the key. If the value is a hash reference again it's value will not be an array reference but either undef or plain values.

The values of the toplevel keys are all array references because fields like ADR may occur multiple times.

Consult XEP-0054 for an explanation what these fields mean or contain.

There are special fields in this structure for handling avatars: _avatar contains the binary data for the avatar image. _avatar_hash contains the sha1 hexencoded hash of the binary image data. _avatar_type contains the mime type of the avatar.

If you want to store the vcard you only have to set _avatar and _avatar_type if you want to store an avatar.