vcard_example test error
From: lerosua <lerosua@xxxxxxxxx>
Date: Tue, 3 Jun 2008 04:19:38 +0200 (CEST)
hi, js.

i test vcard_example.cpp in gloox 1.0beta2
Action and result:

leros@leros-desktop:~/work/gloox-1.0-beta2/src/examples$ ./vcard_example
status: 35
issuer:
peer:
protocol: TLS 1.0
mac: SHA
cipher: AES 256 CBC
compression: DEFLATE
connected
received vcard for lerosua@xxxxxxxxxx: <vCard xmlns='vcard-temp' version='
3.0'/>, 1
setting vcard: <vCard xmlns='vcard-temp' version='3.0'><FN>icalk
test</FN><NICKNAME>cyclone</NICKNAME><N><FAMILY>Simpson</FAMILY><GIVEN>Bart</GIVEN><PREFIX>Mr.</PREFIX><SUFFIX>jr.</SUFFIX></N><ADR><HOME/><POBOX>pobox</POBOX><EXTADD>app.
2</EXTADD><STREET>street</STREET><LOCALITY>Springfield</LOCALITY><REGION>region</REGION><PCODE>123</PCODE><CTRY>USA</CTRY></ADR></vCard>
vcard result: context: 1, jid: lerosua@xxxxxxxxxx, error: 0

leros@leros-desktop:~/work/gloox-1.0-beta2/src/examples$


+++++++++++++++++++++++++++++++++++++++++++++++++++++++
why i get the result context is 1, i find the error  means
*StanzaErrorBadRequest*  The sender has sent XML that is malformed or that
cannot be processed (e.g., an
IQ<http://camaya.net/api/gloox-trunk/classgloox_1_1IQ.html>stanza that
includes an unrecognized value of the 'type' attribute); the
associated error type SHOULD be "modify".
i not change your test code more , just make my account in it .
what wrong with it ?

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++


the source code:

#include "../client.h"
#include "../connectionlistener.h"
#include "../disco.h"
#include "../stanza.h"
#include "../gloox.h"
#include "../loghandler.h"
#include "../vcardhandler.h"
#include "../vcardmanager.h"
#include "../vcard.h"
using namespace gloox;

#include <stdio.h>
#include <locale.h>
#include <string>

class VCardTest : public ConnectionListener, LogHandler, VCardHandler
{
  public:
    VCardTest() : m_count( 0 ) {}
    virtual ~VCardTest() {}

    void start()
    {

      JID jid( "lerosua@xxxxxxxxxx/gloox" );
      j = new Client( jid, "xxxxxxxxx" );
      j->disableRoster();
      j->registerConnectionListener( this );
      j->disco()->setVersion( "discoTest", GLOOX_VERSION, "linux" );
      j->disco()->setIdentity( "client", "bot" );
      StringList ca;
      ca.push_back( "/path/to/cacert.crt" );
      j->setCACerts( ca );
//       j->logInstance().registerLogHandler( LogLevelDebug, LogAreaAll,
this );
      m_vManager = new VCardManager( j );

      j->connect();

      delete( j );
      delete( m_vManager );
    }

    virtual void onConnect()
    {
      printf( "connected\n" );
      JID jid( "lerosua@xxxxxxxxxx" );
      m_vManager->fetchVCard( jid, this );
    }

    virtual void onDisconnect( ConnectionError e ) { printf( "disco_test:
disconnected: %d\n", e ); }

    virtual bool onTLSConnect( const CertInfo& info )
    {
      printf( "status: %d\nissuer: %s\npeer: %s\nprotocol: %s\nmac:
%s\ncipher: %s\ncompression: %s\n",
              info.status, info.issuer.c_str(), info.server.c_str(),
              info.protocol.c_str(), info.mac.c_str(), info.cipher.c_str(),
              info.compression.c_str() );
      return true;
    }

    virtual void handleLog( LogLevel level, LogArea area, const std::string&
message )
    {
      printf("log: level: %d, area: %d, %s\n", level, area, message.c_str()
);
    }

    virtual void handleVCard( const JID& jid, VCard *vcard )
    {
      ++m_count;
      if( !vcard )
      {
        printf( "empty vcard!\n" );
        return;
      }
      printf( "received vcard for %s: %s, %d\n", jid.full().c_str(),
vcard->tag()->xml().c_str(), m_count );
      VCard::AddressList::const_iterator it = vcard->addresses().begin();
      for( ; it != vcard->addresses().end(); ++it )
      {
        printf( "address: %s\n", (*it).street.c_str() );
      }

      if( m_count > 2 )
        j->disconnect();
      else if( m_count == 1 )
      {
        VCard *v = new VCard();
        v->setFormattedname( "icalk test" );
        v->setNickname( "cyclone" );
        v->setName( "Simpson", "Bart", "", "Mr.", "jr." );
        v->addAddress( "pobox", "app. 2", "street", "Springfield", "region",
"123", "USA", VCard::AddrTypeHome );
        m_vManager->storeVCard( v, this );
        printf( "setting vcard: %s\n", v->tag()->xml().c_str() );
      }
      else
      {
        JID jid( "lerosua@xxxxxxxxxx" );
        m_vManager->fetchVCard( jid, this );
      }
    }

    virtual void handleVCardResult( VCardContext context, const JID& jid,
                                    StanzaError se = StanzaErrorUndefined  )
    {
      printf( "vcard result: context: %d, jid: %s, error: %d\n", context,
jid.full().c_str(), se );
      //m_vManager->fetchVCard( jid, this );
    }

  private:
    Client *j;
    VCardManager *m_vManager;
    int m_count;
};

int main( int /*argc*/, char** /*argv*/ )
{
  VCardTest *v = new VCardTest();
  v->start();
  delete( v );
  return 0;
}