Exemplo n.º 1
0
void TestInitiator::send( IQ& iq, IqHandler*, int ctx )
{
  m_result = false;
  iq.setFrom( JID( "self" ) );
  Tag* t = iq.tag();
  std::string expected;

//   printf( "TestInitiator: test %d: %s\n", m_test, t->xml().c_str() );

  switch( m_test )
  {
    case 1:
    {
      expected = "<iq to='foo@bar' from='self' id='id' type='set'><jingle xmlns='" + XMLNS_JINGLE + "' action='session-initiate' initiator='notself' sid='somesid'/></iq>";
      if( t->xml() == expected )
        m_result = true;
      else
        fprintf( stderr, "Jingle::Session test %d\nHave:     %s\nExpected: %s\n", m_test, t->xml().c_str(), expected.c_str() );
      res->sm()->handleIq( iq );
      break;
    }
  }

  delete t;
}
Exemplo n.º 2
0
void SOCKS5BytestreamManager::acknowledgeStreamHost( bool success, const JID& jid,
        const std::string& sid )
{
    AsyncTrackMap::const_iterator it = m_asyncTrackMap.find( sid );
    if( it == m_asyncTrackMap.end() || !m_parent )
        return;

    const AsyncS5BItem& item = (*it).second;

    IQ* iq = 0;

    if( item.incoming )
    {
        iq = new IQ( IQ::Result, item.from.full(), item.id );
        if( item.to )
            iq->setFrom( item.to );

        if( success )
            iq->addExtension( new Query( jid, sid, false ) );
        else
            iq->addExtension( new Error( StanzaErrorTypeCancel, StanzaErrorItemNotFound ) );

        m_parent->send( *iq );
    }
    else
    {
        if( success )
        {
            const std::string& id = m_parent->getID();
            iq = new IQ( IQ::Set, jid.full(), id );
            iq->addExtension( new Query( item.from, sid, true ) );

            m_trackMap[id] = sid;
            m_parent->send( *iq, this, S5BActivateStream );
        }
    }

    delete iq;
}
Exemplo n.º 3
0
void TestResponder::send( IQ& iq, IqHandler*, int ctx )
{
  m_result = false;
  iq.setFrom( remote_jid );
  Tag* t = iq.tag();
  std::string expected;

//   printf( "TestResponder: test %d: %s\n", m_test, t->xml().c_str() );
  switch( m_test )
  {
    case 1:
      break;
    case 2:
      expected = "<iq to='self' from='foo@bar' id='id' type='set'><jingle xmlns='" + XMLNS_JINGLE + "' action='session-accept' responder='self' sid='somesid'/></iq>";
      if( t->xml() == expected )
        m_result = true;
      else
        fprintf( stderr, "Jingle::Session test %d\nHave:     %s\nExpected: %s\n", m_test, t->xml().c_str(), expected.c_str() );
      ini->js()->handleIq( iq );
      break;
    case 3:
      expected = "<iq to='self' from='foo@bar' id='id' type='set'><jingle xmlns='" + XMLNS_JINGLE + "' action='session-terminate' sid='somesid'><reason><success/></reason></jingle></iq>";
      if( t->xml() == expected )
        m_result = true;
      else
        fprintf( stderr, "Jingle::Session test %d\nHave:     %s\nExpected: %s\n", m_test, t->xml().c_str(), expected.c_str() );
      ini->js()->handleIq( iq );
      break;
    case 4:
    case 5:
    {
      break;
    }
  }

  delete t;
}