VCardManager Class Reference

`#include <vcardmanager.h>`

Inheritance diagram for VCardManager:
[legend]

## Public Member Functions

| VCardManager (ClientBase *parent)
virtual | ~VCardManager ()
void | fetchVCard (const JID &jid, VCardHandler *vch)
void | storeVCard (VCard *vcard, VCardHandler *vch)
void | cancelVCardOperations (VCardHandler *vch)
virtual bool | handleIq (const IQ &iq)
virtual void | handleIqID (const IQ &iq, int context)
Public Member Functions inherited from IqHandler
virtual | ~IqHandler ()

## Detailed Description

A VCardManager can be used to fetch an entities VCard as well as for setting one's own VCard.

You need only one VCardManager per Client/ClientBase.

# Fetching a VCard

Create a VCardManager and have a VCardHandler ready. Then simply call fetchVCard() and wait for the result.

class MyClass : public VCardHandler
{
public:
MyClass()
{
m_myClass = new MyClass();
m_vcardManager = new VCardManager( m_client );
};
...
void fetchVCard( const JID& jid )
{
m_vcardManager->fetchVCard( jid, this );
};
virtual void handleVCard( const JID& jid, const VCard* vcard );
{
printf( "received vcard\n" );
};
virtual void handleVCardResult( VCardContext context, const JID& jid,
StanzaError se )
{
printf( "vcard operation result received\n" );
};
...
private:
VCardManager* m_vcardManager;
};
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::VCardHandler
A virtual interface that helps requesting Jabber VCards.
Definition vcardhandler.h:37
gloox::VCardHandler::handleVCardResult
virtual void handleVCardResult(VCardContext context, const JID &jid, StanzaError se=StanzaErrorUndefined)=0
gloox::VCardHandler::handleVCard
virtual void handleVCard(const JID &jid, const VCard *vcard)=0
gloox::VCardHandler::VCardContext
VCardContext
Definition vcardhandler.h:43
gloox::VCardManager::VCardManager
VCardManager(ClientBase *parent)
Definition vcardmanager.cpp:24
gloox::StanzaError
StanzaError
Definition gloox.h:872

# Storing one's own VCard

Note
  Some, if not many, servers do not implement support for all the fields specified in XEP-0054. Therefore it is possible that you cannot retrieve fields you stored previously.

Similar to the above, you need a VCardManager and a VCardHandler. Then construct your VCard and call storeVCard().

void storeMyVCard()
{
VCard* v = new VCard();
v->setFormattedname( "Me" );
v->setNickname( "Myself" );
...
m_vcardManager->storeVCard( v, this );
};
gloox::VCard
A VCard abstraction.
Definition vcard.h:35
gloox::VCard::setFormattedname
void setFormattedname(const std::string &name)
Definition vcard.h:231
gloox::VCard::setNickname
void setNickname(const std::string &nickname)
Definition vcard.h:262

This implementation supports more than one address, address label, email address and telephone number.

Note
  Currently, this implementation lacks support for the following fields: AGENT, CATEGORIES, SOUND, KEY

When cleaning up, delete your VCardManager instance before deleting the Client/ClientBase instance.

Author
  Jakob Schröter js@ca.nosp@m.maya.nosp@m..net

Since
  0.8

Definition at line 100 of file vcardmanager.h.

## Constructor & Destructor Documentation

## VCardManager()

VCardManager | ( | ClientBase * | parent | ) |

Constructor.

Parameters

  parent | The ClientBase object to use for communication.

Definition at line 24 of file vcardmanager.cpp.

## ~VCardManager()

~VCardManager | ( |  | ) |

virtual

Virtual destructor.

Definition at line 35 of file vcardmanager.cpp.

## Member Function Documentation

## cancelVCardOperations()

void cancelVCardOperations | ( | VCardHandler * | vch | ) |

Use this function, e.g. from your VCardHandler-derived class's dtor, to cancel any outstanding operations (fetchVCard(), storeVCard()). Calling this function even if no operations are pending is just fine.

Parameters

  vch | The VCardHandler to remove from any queues.

Since
  0.9

Definition at line 62 of file vcardmanager.cpp.

## fetchVCard()

void fetchVCard | ( | const JID & | jid,
|  | VCardHandler * | vch )

Use this function to fetch the VCard of a remote entity or yourself. The result will be announced by calling handleVCard() the VCardHandler.

Parameters

  jid | The entity's JID. Should be a bare JID unless you want to fetch the VCard of, e.g., a MUC item.
  vch | The VCardHandler that will receive the result of the VCard fetch.

Definition at line 45 of file vcardmanager.cpp.

## handleIq()

virtual bool handleIq | ( | const IQ & | iq | ) |

inline virtual

Reimplement this function if you want to be notified about incoming IQs.

Parameters

  iq | The complete IQ stanza.

Returns
  Indicates whether a request of type 'get' or 'set' has been handled. This includes the obligatory 'result' answer. If you return false, an 'error' will be sent back.

Since
  1.0

Implements IqHandler.

Definition at line 142 of file vcardmanager.h.

## handleIqID()

void handleIqID | ( | const IQ & | iq,
|  | int | context )

virtual

Reimplement this function if you want to be notified about incoming IQs with a specific value of the `id` attribute. You have to enable tracking of those IDs using Client::trackID(). This is usually useful for IDs that generate a empty positive reply, i.e. <iq type='result' id='reg'/> where a namespace filter wouldn't work.

Parameters

  iq | The complete IQ stanza.
  context | A value to restore context, stored with ClientBase::trackID().

Note
  Only IQ stanzas of type 'result' or 'error' can arrive here.

Since
  1.0

Implements IqHandler.

Definition at line 88 of file vcardmanager.cpp.

## storeVCard()

void storeVCard | ( | VCard * | vcard,
|  | VCardHandler * | vch )

Use this function to store or update your own VCard on the server. Remember to always send a full VCard, not a delta of changes. If you, for any reason, pass a foreign VCard to this function, your own will be overwritten.

Parameters

  vcard | Your VCard to store.
  vch | The VCardHandler that will receive the result of the VCard store.

Definition at line 75 of file vcardmanager.cpp.

The documentation for this class was generated from the following files:

- vcardmanager.h
- vcardmanager.cpp