Ejemplo n.º 1
0
  void Adhoc::handleDiscoInfo( const JID& from, const Disco::Info& info, int context )
  {
    if( context != CheckAdhocSupport )
      return;

    util::MutexGuard m( m_adhocTrackMapMutex );

    AdhocTrackMap::iterator it = m_adhocTrackMap.begin();
    for( ; it != m_adhocTrackMap.end() && (*it).second.context != context
                                       && (*it).second.remote  != from; ++it )
      ;
    if( it == m_adhocTrackMap.end() )
      return;

    (*it).second.ah->handleAdhocSupport( from, info.hasFeature( XMLNS_ADHOC_COMMANDS ), (*it).second.handlerContext );
    m_adhocTrackMap.erase( it );
  }
Ejemplo n.º 2
0
void TalkDiscoHandler::handleDiscoInfo(const JID& from, const Disco::Info& info, int context)
{
        ServerDiscoWindow* discowindow = Bodies::Get_Bodies().get_main_window().get_disco_window();

        if (NULL == discowindow)
                return ;


        const Disco::IdentityList& list = info.identities();

        Disco::IdentityList::const_iterator iter = list.begin();

        for (; iter != list.end(); ++iter) {
                if ((*iter)->category() == "server") {

                        discowindow->setLabel(from.full(), (*iter)->name());
                }
        }
}
Ejemplo n.º 3
0
 virtual void handleDiscoInfo( const JID& /*from*/, const Disco::Info& info, int /*context*/ )
 {
   if( m_test == 8 && info.hasFeature( XMLNS_DISCO_INFO ) && info.hasFeature( "foofeature" )
       && info.hasFeature( "foofeature2" ) )
     m_result = true;
 }
Ejemplo n.º 4
0
int main( int /*argc*/, char** /*argv*/ )
{
  int fail = 0;
  std::string name;
  Tag *t;

  // -------
  {
    name = "empty disco#info request";
    Disco::Info di;
    t = di.tag();
    if( t->xml() != "<query xmlns='" + XMLNS_DISCO_INFO + "'/>"
        || !di.node().empty() )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed\n", name.c_str() );
    }
    delete t;
    t = 0;
  }

  // -------
  {
    name = "empty (default) disco#info reply";
    Disco::Info di( EmptyString, true );
    t = di.tag();
    if( t->xml() != "<query xmlns='" + XMLNS_DISCO_INFO + "'>"
                    "<feature var='" + XMLNS_DISCO_INFO + "'/>"
                    "<feature var='" + XMLNS_DISCO_ITEMS + "'/>"
        "</query>"
        || !di.node().empty() )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed\n", name.c_str() );
    }
    delete t;
    t = 0;
  }

  // -------
  {
    name = "empty disco#info request + node + default features";
    Disco::Info di( "somenode", true );
    t = di.tag();
    if( t->xml() != "<query xmlns='" + XMLNS_DISCO_INFO + "' node='somenode'>"
                    "<feature var='" + XMLNS_DISCO_INFO + "'/>"
                    "<feature var='" + XMLNS_DISCO_ITEMS + "'/>"
                    "</query>"
        || di.node() != "somenode" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed\n", name.c_str() );
    }
    delete t;
    t = 0;
  }

  // -------
  {
    name = "empty disco#info request + node - default features";
    Disco::Info di( "somenode" );
    t = di.tag();
    if( t->xml() != "<query xmlns='" + XMLNS_DISCO_INFO + "' node='somenode'/>"
        || di.node() != "somenode" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed\n", name.c_str() );
    }
    delete t;
    t = 0;
  }

  // -------
  {
    name = "setnode()";
    Disco::Info di( "somenode" );
    di.setNode( "othernode" );
    if( di.node() != "othernode" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed\n", name.c_str() );
    }
  }

  // -------
  {
    name = "Tag ctor";
    t = new Tag( "query" );
    t->setXmlns( XMLNS_DISCO_INFO );
    t->addAttribute( "node", "somenode" );
    Tag* i = new Tag( t, "identity", "category", "category1" );
    i->addAttribute( "type", "type1" );
    i->addAttribute( "name", "name1" );
    i = new Tag( t, "identity", "category", "category2" );
    i->addAttribute( "type", "type1" );
    i->addAttribute( "name", "name1" );
    i = new Tag( t, "identity", "category", "category3" );
    i->addAttribute( "type", "type1" );
    i->addAttribute( "name", "name1" );
    new Tag( t, "feature", "var", "foo1" );
    new Tag( t, "feature", "var", "foo2" );
    new Tag( t, "feature", "var", "foo3" );
    Disco::Info di( t );
    if( di.node() != "somenode" || di.identities().size() != 3 || di.features().size() != 3
        || !di.hasFeature( "foo1" ) || !di.hasFeature( "foo2" ) || !di.hasFeature( "foo3" ) )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed\n", name.c_str() );
    }
    delete t;
    t = 0;
  }

  // -------
  name = "Disco::Info/SEFactory test";
  StanzaExtensionFactory sef;
  sef.registerExtension( new Disco::Info() );
  Tag* f = new Tag( "iq" );
  new Tag( f, "query", "xmlns", XMLNS_DISCO_INFO );
  IQ iq( IQ::Set, JID(), "" );
  sef.addExtensions( iq, f );
  const Disco::Info* se = iq.findExtension<Disco::Info>( ExtDiscoInfo );
  if( se == 0 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete f;


  if( fail == 0 )
  {
    printf( "Disco::Info: OK\n" );
    return 0;
  }
  else
  {
    fprintf( stderr, "Disco::Info: %d test(s) failed\n", fail );
    return 1;
  }

}