Beispiel #1
0
  // ---- SIManager::SI ----
  SIManager::SI::SI( const Tag* tag )
    : StanzaExtension( ExtSI ), m_tag1( 0 ), m_tag2( 0 )
  {
    if( !tag || tag->name() != "si" || tag->xmlns() != XMLNS_SI )
      return;

    m_valid = true;

    m_id = tag->findAttribute( "id" );
    m_mimetype = tag->findAttribute( "mime-type" );
    m_profile = tag->findAttribute( "profile" );

    Tag* c = tag->findChild( "file", "xmlns", XMLNS_SI_FT );
    if ( c )
      m_tag1 = c->clone();
    c = tag->findChild( "feature", "xmlns", XMLNS_FEATURE_NEG );
    if( c )
      m_tag2 = c->clone();
  }
Beispiel #2
0
  Forward::Forward( const Tag* tag )
    : StanzaExtension( ExtForward ),
      m_stanza( 0 ), m_tag( 0 ), m_delay( 0 )
  {
    if( !tag || !( tag->name() == "forwarded" && tag->hasAttribute( XMLNS, XMLNS_STANZA_FORWARDING ) ) )
      return;

    m_delay = new DelayedDelivery( tag->findChild( "delay", XMLNS, XMLNS_DELAY ) );

    Tag* m = tag->findChild( "message" );
    if( !m )
      return;

    m_tag = m->clone();
    m_stanza = new Message( m );
  }
Beispiel #3
0
AdhocTag::AdhocTag(const IQ &stanza) : Tag("command") {
    m_from = stanza.from().full();
    m_id = stanza.id();
    xdata = NULL;
    Tag *iq = stanza.tag();
    Tag *command = iq->findChild("command");
    if (command) {
        const Tag::AttributeList & attributes = command->attributes();
        for (Tag::AttributeList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
            addAttribute(std::string((*it)->name()), std::string((*it)->value()));
        }
        Tag *x = command->findChildWithAttrib("xmlns","jabber:x:data");
        if (x) {
            xdata = x->clone();
            addChild(xdata);
        }
    }
    delete iq;
}
Beispiel #4
0
int main( int /*argc*/, char** /*argv*/ )
{
  int fail = 0;
  std::string name;
  Tag *t = new Tag( "toe" ); t->addAttribute( "foo", "bar" );
  Tag *u = new Tag( t, "uni" ); u->addAttribute( "u3", "3u" );
  Tag *v = new Tag( t, "vie" ); v->addAttribute( "v3", "3v" );
  Tag *v2 = new Tag( t, "vie" ); v->addAttribute( "v32", "3v2" );
  Tag *w = new Tag( u, "who" ); w->addAttribute( "w3", "3w" );
  Tag *x = new Tag( v, "xep" ); x->addAttribute( "x3", "3x" );
  Tag *y = new Tag( u, "yps" ); y->addAttribute( "y3", "3y" );
  Tag *z = new Tag( w, "zoo" ); z->addAttribute( "z3", "3z" );
  Tag *c = 0;
  Tag *d = 0;

  // -------
  name = "simple ctor";
  if( t->name() != "toe" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  // -------
  name = "cdata ctor";
  c = new Tag( "cod", "foobar" );
  if( c->name() != "cod" || c->cdata() != "foobar" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "clone test 1";
  c = z->clone();
  if( *z != *c )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "clone test 2";
  c = t->clone();
  if( *t != *c )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "operator== test 1";
  c = new Tag( "name" );
  if( *t == *c )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "operator== test 2";
  c = new Tag( "test" );
  c->addAttribute( "me", "help" );
  c->addChild( new Tag( "yes" ) );
  if( *t == *c )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "operator== test 3";
  c = new Tag( "hello" );
  c->addAttribute( "test", "bacd" );
  c->addChild( new Tag( "hello" ) );
  d = new Tag( "hello" );
  d->addAttribute( "test", "bacd" );
  d->addChild( new Tag( "helloo" ) );
  if( *d == *c )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  delete d;
  c = 0;
  d = 0;

  //-------
  name = "operator!= test 1";
  c = new Tag( "hello" );
  c->addAttribute( "test", "bacd" );
  c->addChild( new Tag( "hello" ) );
  d = new Tag( "hello" );
  d->addAttribute( "test", "bacd" );
  d->addChild( new Tag( "hello" ) );
  if( *d != *c )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  delete d;
  c = 0;
  d = 0;

  //-------
  name = "findChildren test";
  TagList l = t->findChildren( "vie" );
  TagList::const_iterator it = l.begin();
  if( l.size() != 2 || (*it) != v || *(++it) != v2 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "util::escape";
  if ( util::escape( "&<>'\"" ) != "&amp;&lt;&gt;&apos;&quot;" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }

  //-------
  name = "xml() 1";
  if( t->xml() != "<toe foo='bar'><uni u3='3u'><who w3='3w'><zoo z3='3z'/></who><yps y3='3y'/>"
                    "</uni><vie v3='3v' v32='3v2'><xep x3='3x'/></vie><vie/></toe>" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "xml() 2";
  t->addAttribute( "test", "bacd" );
  if( t->xml() != "<toe foo='bar' test='bacd'><uni u3='3u'><who w3='3w'><zoo z3='3z'/></who><yps y3='3y'/>"
                    "</uni><vie v3='3v' v32='3v2'><xep x3='3x'/></vie><vie/></toe>" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "hasChild 1";
  if( !t->hasChild( "uni" ) || !t->hasChild( "vie" ) || !u->hasChild( "who" ) || !w->hasChild( "zoo" )
      || !u->hasChild( "yps" ) )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "hasAttribute 1";
  if( !t->hasAttribute( "test" ) || !t->hasAttribute( "test", "bacd" )
      || !t->hasAttribute( "foo" ) || !t->hasAttribute( "foo", "bar" ) )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "findAttribute 1";
  if( t->findAttribute( "test" ) != "bacd" || t->findAttribute( "foo" ) != "bar" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "findChild 1";
  c = t->findChild( "uni" );
  if( c != u )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "findChild 2";
  c = t->findChild( "uni", "u3" );
  if( c != u )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "findChild 3";
  c = t->findChild( "uni", "u3", "3u" );
  if( c != u )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "findChildWithAttrib 1";
  c = t->findChildWithAttrib( "u3" );
  if( c != u )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "findChildWithAttrib 2";
  c = t->findChildWithAttrib( "u3", "3u" );
  if( c != u )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
  }

  //-------
  name = "attribute order";
  c = new Tag( "abc" );
  c->addAttribute( "abc", "def" );
  c->addAttribute( "xyz", "123" );
  d = c->clone();
  if( *c != *d )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), d->xml().c_str() );
  }
  delete c;
  c = 0;
  delete d;
  d = 0;

  //-------
  name = "mixed content 1";
  c = new Tag( "abc" );
  c->addCData( "cdata1" );
  new Tag( c, "fgh" );
  c->addCData( "cdata2" );
  new Tag( c, "xyz" );
  c->addCData( "cdata3" );
  if( c->xml() != "<abc>cdata1<fgh/>cdata2<xyz/>cdata3</abc>" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), c->xml().c_str() );
  }
  delete c;
  c = 0;

  //-------
  name = "operator bool()";
  Tag tag1( "" );
  if( tag1 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), tag1.xml().c_str() );
  }

  //-------
  name = "bool operator!()";
  Tag tag2( "abc" );
  if( !tag2 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), d->xml().c_str() );
  }

  //-------
  {
    name = "simple xmlns";
    Tag t( "abc" );
    t.setXmlns( "foo" );
    if( t.xml() != "<abc xmlns='foo'/>" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "deep xmlns";
    Tag t( "abc" );
    Tag* f = new Tag( &t, "def" );
    f = new Tag( f, "ghi" );
    t.setXmlns( "foo" );
    if( t.xml() != "<abc xmlns='foo'><def><ghi/></def></abc>" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "simple nested xmlns 2";
    Tag t( "abc" );
    t.setXmlns( "foo" );
    Tag* d = new Tag( &t, "def" );
    d->setXmlns( "foobar", "xyz" );
    d->setPrefix( "xyz" );
    if( t.xml() != "<abc xmlns='foo'><xyz:def xmlns:xyz='foobar'/></abc>" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "attribute with xmlns";
    Tag t( "abc" );
    t.setXmlns( "foo", "xyz" );
    Tag::Attribute* a = new Tag::Attribute( "foo", "bar", "foo" );
    a->setPrefix( "xyz" );
    t.addAttribute( a );
    if( t.xml() != "<abc xmlns:xyz='foo' xyz:foo='bar'/>" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "escape attribute value";
    Tag t( "foo", "abc", "&amp;" );
    if( t.xml() != "<foo abc='&amp;amp;'/>" )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "remove child 1";
    Tag t( "foo" );
    t.addChild( new Tag( "test", "xmlns", "foo" ) );
    t.addChild( new Tag( "abc", "xmlns", "foobar" ) );
    t.addAttribute( "attr1", "value1" );
    t.addAttribute( "attr2", "value2" );
    t.removeChild( "test" );
    if( t.hasChild( "test" ) )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }

    name = "remove child 2";
    t.removeChild( "abc", "foobar" );
    if( t.hasChild( "abc", "xmlns", "foobar" ) )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }

    name = "remove attrib 1";
    t.removeAttribute( "attr1" );
    if( t.hasAttribute( "attr1", "value1") )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }

    name = "remove attrib 2";
    t.removeAttribute( "attr2", "value2" );
    if( t.hasAttribute( "attr2", "value2") )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "invalid chars 1";
    Tag t( "foo" );
    bool check = t.addAttribute( "nul", std::string( 1, 0x00 ) );
    if( check || t.hasAttribute( "nul" ) )
    {
      ++fail;
      fprintf( stderr, "test '%s' failed:%s\n", name.c_str(), t.xml().c_str() );
    }
  }

  //-------
  {
    name = "invalid chars 2";
    for( int i = 0; i <= 0xff; ++i )
    {
      Tag::Attribute a( "test", std::string( 1, i ) );

      if( ( i < 0x09 || i == 0x0b || i == 0x0c
          || ( i > 0x0d && i < 0x20 ) || i == 0xc0
          || i == 0xc1 || i >= 0xf5 ) && a )
      {
        ++fail;
        fprintf( stderr, "test '%s' (branch 1) failed (i == %02X)\n", name.c_str(), i );
      }
      else if( ( i == 0x09 || i == 0x0a || i == 0x0d
                 || ( i >= 0x20 && i < 0xc0 )
                 || ( i > 0xc1 && i < 0xf5 ) ) && !a )
      {
        ++fail;
        fprintf( stderr, "test '%s' (branch 2) failed (i == %02X)\n", name.c_str(), i );
      }
//       printf( "i: 0x%02X, a: %d, value: %s\n", i, (bool)a, std::string( 1, i ).c_str() );
    }
  }




  delete t;
  t = 0;




















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

}
void SpectrumMUCConversation::addUsers(AbstractUser *user, GList *cbuddies) {
	Log(m_jid, "ADDING USERS3");
	GList *l = cbuddies;
	while (l != NULL) {
		PurpleConvChatBuddy *cb = (PurpleConvChatBuddy *)l->data;
// 		std::string alias(cb->alias ? cb->alias: "");
		std::string name(cb->name);
		int flags = GPOINTER_TO_INT(cb->flags);
// 		PURPLE_CBFLAGS_OP
// 		<presence
// 		from='[email protected]/firstwitch'
// 		to='[email protected]/pda'>
// 		<x xmlns='http://jabber.org/protocol/muc#user'>
// 		<item affiliation='member' role='participant'/>
// 		</x>
// 		</presence>
		Tag *tag = new Tag("presence");
		tag->addAttribute("from", m_jid + "/" + name);
		tag->addAttribute("to", user->jid() + m_res);

		Tag *x = new Tag("x");
		x->addAttribute("xmlns", "http://jabber.org/protocol/muc#user");

		Tag *item = new Tag("item");


		if (flags & PURPLE_CBFLAGS_OP || flags & PURPLE_CBFLAGS_HALFOP) {
			item->addAttribute("affiliation", "admin");
			item->addAttribute("role", "moderator");
		}
		else if (flags & PURPLE_CBFLAGS_FOUNDER) {
			item->addAttribute("affiliation", "owner");
			item->addAttribute("role", "moderator");
		}
		else {
			item->addAttribute("affiliation", "member");
			item->addAttribute("role", "participant");
		}

		if (name == m_nickname) {
			Tag *status = new Tag("status");
			status->addAttribute("code", "110");
			item->addChild(status);
		}

		x->addChild(item);
		tag->addChild(x);

		if (name == m_nickname) {
			if (m_lastPresence)
				delete m_lastPresence;
			m_lastPresence = tag->clone();
		}
		Transport::instance()->send(tag);

		l = l->next;
	}
	if (!m_connected && !m_topic.empty()) {
		sendTopic(user);
	}
	m_connected = true;
}
Beispiel #6
0
  IOData::IOData( const Tag* tag )
    : AdhocPlugin( ExtIOData ),
      m_in( 0 ), m_out( 0 ), m_error( 0 ),
      m_type( TypeInvalid )
  {
    if( !tag || !( tag->name() == "iodata" && tag->hasAttribute( XMLNS, XMLNS_IODATA ) ) )
      return;

    m_status.elapsed = -1;
    m_status.remaining = -1;
    m_status.percentage = -1;

    m_type = ioType( tag->findAttribute( "type" ) );
    Tag* m = 0;
    switch( m_type )
    {
      case TypeInput:
        m = tag->findChild( "in" );
        if( m )
          m_in = m->clone();
        break;
      case TypeIoSchemataResult:
        m = tag->findChild( "desc" );
        if( m )
          m_desc = m->cdata();

        m = tag->findChild( "out" );
        if( m )
          m_out = m->clone();

        m = tag->findChild( "in" );
        if( m )
          m_in = m->clone();
        break;
      case TypeOutput:
        m = tag->findChild( "out" );
        if( m )
          m_out = m->clone();
        break;
      case TypeError:
        m = tag->findChild( "error" );
        if( m )
          m_error = m->clone();
        break;
      case TypeStatus:
        m = tag->findChild( "status" );
        if( m )
        {
          Tag* t = m->findChild( "elapsed" );
          if( t )
            m_status.elapsed = atoi( t->cdata().c_str() );

          t = m->findChild( "remaining" );
          if( t )
            m_status.remaining = atoi( t->cdata().c_str() );

          t = m->findChild( "percentage" );
          if( t )
            m_status.percentage = atoi( t->cdata().c_str() );

          t = m->findChild( "information" );
          if( t )
            m_status.info = t->cdata();
        }
        break;
      case TypeIoSchemataGet:
      case TypeGetStatus:
      case TypeGetOutput:
      default:
        break;
    }

  }
int main( int /*argc*/, char** /*argv*/ )
{
  int fail = 0;
  std::string name;
  IOData *i = 0;
  Tag* t = 0;
  Tag* f = 0;
  Tag* s = new Tag( "iodata" );
  s->setXmlns( XMLNS_IODATA );


  // -------
  name = "parsing 0 tag";
  i = new IOData( 0 );
  if( i->tag() != 0 )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'io-schemata-get' type";
  s->addAttribute( "type", "io-schemata-get" );
  i = new IOData( s );
  if( i->tag()->xml() != s->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'input' type";
  t = s->clone();
  t->addAttribute( "type", "input" );
  f = new Tag( t, "in" );
  new Tag( f, "foo" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "parsing 'getStatus' type";
  s->addAttribute( "type", "getStatus" );
  i = new IOData( s );
  if( i->tag()->xml() != s->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'getOutput' type";
  s->addAttribute( "type", "getOutput" );
  i = new IOData( s );
  if( i->tag()->xml() != s->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;

  // -------
  name = "parsing 'io-schemata-result' type";
  t = s->clone();
  t->addAttribute( "type", "io-schemata-result" );
  f = new Tag( t, "in" );
  new Tag( f, "foo" );
  f = new Tag( t, "out" );
  new Tag( f, "foobar" );
  f = new Tag( t, "desc", "some description" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "parsing 'output' type";
  t = s->clone();
  t->addAttribute( "type", "output" );
  f = new Tag( t, "out" );
  new Tag( f, "foo" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "parsing 'error' type";
  t = s->clone();
  t->addAttribute( "type", "error" );
  f = new Tag( t, "error", "some error description" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "parsing 'status' type";
  t = s->clone();
  t->addAttribute( "type", "status" );
  f = new Tag( t, "status" );
  new Tag( f, "elapsed", "12" );
  new Tag( f, "remaining", "34" );
  new Tag( f, "percentage", "56" );
  new Tag( f, "information", "some information" );
  i = new IOData( t );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'io-schemata-get' type";
  t = s->clone();
  t->addAttribute( "type", "io-schemata-get" );
  i = new IOData( IOData::TypeIoSchemataGet );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'input' type";
  t = s->clone();
  t->addAttribute( "type", "input" );
  f = new Tag( t, "in" );
  f = new Tag( f, "foo" );
  i = new IOData( IOData::TypeInput );
  i->setIn( f->clone() );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'getStatus' type";
  t = s->clone();
  t->addAttribute( "type", "getStatus" );
  i = new IOData( IOData::TypeGetStatus );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'getOutput' type";
  t = s->clone();
  t->addAttribute( "type", "getOutput" );
  i = new IOData( IOData::TypeGetOutput );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'io-schemata-result' type";
  t = s->clone();
  t->addAttribute( "type", "io-schemata-result" );
  i = new IOData( IOData::TypeIoSchemataResult );
  f = new Tag( t, "in" );
  f = new Tag( f, "foo" );
  i->setIn( f->clone() );
  f = new Tag( t, "out" );
  f = new Tag( f, "foobar" );
  i->setOut( f->clone() );
  f = new Tag( t, "desc", "some description" );
  i->setDesc( "some description" );
  if( i->tag()->xml() != t->xml() || i->desc() != "some description" )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'output' type";
  t = s->clone();
  t->addAttribute( "type", "output" );
  i = new IOData( IOData::TypeOutput );
  f = new Tag( t, "out" );
  f = new Tag( f, "foobar" );
  i->setOut( f->clone() );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'error' type";
  t = s->clone();
  t->addAttribute( "type", "error" );
  i = new IOData( IOData::TypeError );
  f = new Tag( t, "error" );
  f = new Tag( f, "foo" );
  i->setError( f->clone() );
  if( i->tag()->xml() != t->xml() )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;

  // -------
  name = "creating 'status' type";
  t = s->clone();
  t->addAttribute( "type", "status" );
  i = new IOData( IOData::TypeStatus );
  f = new Tag( t, "status" );
  new Tag( f, "elapsed", "12" );
  new Tag( f, "remaining", "34" );
  new Tag( f, "percentage", "56" );
  new Tag( f, "information", "some info" );
  IOData::Status st = { 12, 34, 56, "some info" };
  i->setStatus( st );
  if( i->tag()->xml() != t->xml() || i->status().elapsed != st.elapsed
      || i->status().remaining != st.remaining || i->status().percentage != st.percentage
      || i->status().info != st.info )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\ni: %s\ns: %s\n", name.c_str(), i->tag()->xml().c_str(), t->xml().c_str() );
  }
  delete i;
  i = 0;
  delete t;
  t = 0;


  // -------
  name = "cloning";
  i = new IOData( IOData::TypeStatus );
  i->setStatus( st );
  i->setOut( new Tag( "foo" ) );
  IOData* j = i->clone();
  if( !j || !j->out() || i->out()->name() != "out" || !j->out()->hasChild( "foo" ) || j->status().elapsed != st.elapsed )
  {
    ++fail;
    fprintf( stderr, "test '%s' failed\n", name.c_str() );
  }
  delete i;
  i = 0;
  delete j;
  j = 0;







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

}