Esempio n. 1
0
  void RosterManager::subscribe( const JID& jid, const std::string& name,
                                 const StringList& groups, const std::string& msg )
  {
    if( !jid )
      return;

    add( jid, name, groups );

    Subscription s( Subscription::Subscribe, jid.bareJID(), msg );
    m_parent->send( s );
  }
Esempio n. 2
0
int main( int /*argc*/, char** /*argv*/ )
{
  int fail = 0;
  std::string name;
  JID j;

  // -------
  name = "bare JID ctor";
  j = JID( "*****@*****.**" );
  if( j.bare() != "*****@*****.**" || j.username() != "abc" || j.server() != "server.dom" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "full JID ctor";
  j = JID( "[email protected]/res" );
  if( j.full() != "[email protected]/res" || j.username() != "abc" || j.server() != "server.dom"
      || j.resource() != "res" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "server + resource ctor";
  j = JID( "server.dom/res" );
  if( j.full() != "server.dom/res" || j.server() != "server.dom" || j.resource() != "res" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "server ctor";
  j = JID( "server.dom" );
  if( j.full() != "server.dom" || j.server() != "server.dom" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "prepped node";
  j = JID( "*****@*****.**" );
  if( j.bare() != "*****@*****.**" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "prepped dom";
  j = JID( "*****@*****.**" );
  if( j.bare() != "*****@*****.**" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "resource getter";
  j = JID( "[email protected]/rEsOurCe" );
  if( j.resource() != "rEsOurCe" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "node getter";
  j = JID( "[email protected]/rEsOurCe" );
  if( j.username() != "abc" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "server getter";
  j = JID( "[email protected]/rEsOurCe" );
  if( j.server() != "server.dom" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "bare JID getter";
  j = JID( "[email protected]/rEsOurCe" );
  JID t1( "[email protected]/rEsOurCe");
  if( j.bareJID() != t1.bareJID() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "clear jid";
  j = JID( "[email protected]/rEsOurCe" );
  j.setJID( "" );
  if( j || !j.username().empty()
        || !j.server().empty()
        || !j.serverRaw().empty()
        || !j.resource().empty()
        || !j.bare().empty()
        || !j.full().empty() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "operator bool() 1";
  JID jid1( "[email protected]/rEsOurCe" );
  if( !jid1 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "operator bool() 2";
  JID jid2( "" );
  if( jid2 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "JID\20Escaping";
  const std::string e = JID::escapeNode( "1 2\"3&4'5/6:7<8>9@10\\" );
  if( e != "1\\202\\223\\264\\275\\2f6\\3a7\\3c8\\3e9\\4010\\5c" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "JID\20Unescaping";
  const std::string f = JID::unescapeNode( "1\\202\\223\\264\\275\\2f6\\3a7\\3c8\\3e9\\4010\\5c" );
  if( f != "1 2\"3&4'5/6:7<8>9@10\\" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }










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

}
Esempio n. 3
0
 void RosterManager::ackSubscriptionRequest( const JID& to, bool ack )
 {
   Subscription p( ack ? Subscription::Subscribed
                                           : Subscription::Unsubscribed, to.bareJID() );
   m_parent->send( p );
 }
Esempio n. 4
0
 void RosterManager::cancel( const JID& jid, const std::string& msg )
 {
   Subscription p( Subscription::Unsubscribed, jid.bareJID(), msg );
   m_parent->send( p );
 }