Tag* SIManager::SI::tag() const { if( !m_valid ) return 0; Tag* t = new Tag( "si" ); t->setXmlns( XMLNS_SI ); if( !m_id.empty() ) t->addAttribute( "id", m_id ); if( !m_mimetype.empty() ) t->addAttribute( "mime-type", m_mimetype.empty() ? "binary/octet-stream" : m_mimetype ); if( !m_profile.empty() ) t->addAttribute( "profile", m_profile ); if( m_tag1 ) t->addChildCopy( m_tag1 ); if( m_tag2 ) t->addChildCopy( m_tag2 ); return t; }
Tag* Event::tag() const { if( !m_valid ) return 0; Tag* event = new Tag( "event", XMLNS, XMLNS_PUBSUB_EVENT ); Tag* child = new Tag( event, util::lookup( m_type, eventTypeValues ) ); Tag* item = 0; switch( m_type ) { case PubSub::EventCollection: { item = new Tag( child, "node", "id", m_node ); item->addChildCopy( m_config ); break; } case PubSub::EventPurge: case PubSub::EventDelete: case PubSub::EventConfigure: child->addAttribute( "node", m_node ); if( m_type == PubSub::EventConfigure ) child->addChildCopy( m_config ); break; case PubSub::EventItems: case PubSub::EventItemsRetract: { child->addAttribute( "node", m_node ); if( m_itemOperations ) { // Tag* item; ItemOperation* op; ItemOperationList::const_iterator itt = m_itemOperations->begin(); for( ; itt != m_itemOperations->end(); ++itt ) { op = (*itt); // item = new Tag( child, op->retract ? "retract" : "item", "id", op->item ); if( op->payload ) child->addChildCopy( op->payload ); } } break; } case EventSubscription: { child->addAttribute( "node", m_node ); child->addAttribute( "jid", m_jid.full() ); child->addAttribute( "subscription", m_subscription ? "subscribed" : "none" ); break; } default: delete event; return 0; } if( m_subscriptionIDs || !m_collection.empty() ) { Tag* headers = new Tag( event, "headers", XMLNS, "http://jabber.org/protocol/shim" ); StringList::const_iterator it = m_subscriptionIDs->begin(); for( ; it != m_subscriptionIDs->end(); ++it ) { (new Tag( headers, "header", "name", "pubsub#subid" ))->setCData( (*it) ); } if( !m_collection.empty() ) (new Tag( headers, "header", "name", "pubsub#collection" ) ) ->setCData( m_collection ); } return event; }