48 m_subscriptionIDs( 0 ), m_config( 0 ), m_itemOperations( 0 ), m_subscription( false )
50 if( !event || event->
name() !=
"event" )
54 TagList::const_iterator it = events.begin();
56 for( ; it != events.end(); ++it )
59 PubSub::EventType type = static_cast<PubSub::EventType>( util::lookup( tag->name(), eventTypeValues ) );
63 case PubSub::EventCollection:
64 tag = tag->findChild(
"node" );
67 m_node = tag->findAttribute(
"id" );
68 if( ( m_config = tag->findChild(
"x" ) ) )
69 m_config = m_config->clone();
73 case PubSub::EventConfigure:
74 case PubSub::EventDelete:
75 case PubSub::EventPurge:
76 m_node = tag->findAttribute(
"node" );
77 if( type == PubSub::EventConfigure
78 && ( m_config = tag->findChild(
"x" ) ) )
79 m_config = m_config->clone();
82 case PubSub::EventItems:
83 case PubSub::EventItemsRetract:
85 if( !m_itemOperations )
86 m_itemOperations = new ItemOperationList();
88 m_node = tag->findAttribute(
"node" );
89 const TagList& items = tag->children();
90 TagList::const_iterator itt = items.begin();
91 for( ; itt != items.end(); ++itt )
95 if( tag->name() ==
"retract" )
98 type = PubSub::EventItemsRetract;
100 ItemOperation* op = new ItemOperation( retract,
101 tag->findAttribute(
"id" ),
103 m_itemOperations->push_back( op );
108 case EventSubscription:
110 m_node = tag->findAttribute(
"node" );
111 m_jid.setJID( tag->findAttribute(
"jid" ) );
112 m_subscription = tag->hasAttribute(
"subscription",
"subscribed" );
116 case PubSub::EventUnknown:
117 if( type == PubSub::EventUnknown )
119 if( tag->name() !=
"headers" || m_subscriptionIDs != 0 )
125 m_subscriptionIDs = new StringList();
127 const TagList& headers = tag->children();
128 TagList::const_iterator ith = headers.begin();
129 for( ; ith != headers.end(); ++ith )
131 const std::string& name = (*ith)->findAttribute(
"name" );
132 if( name ==
"pubsub#subid" )
133 m_subscriptionIDs->push_back( (*ith)->cdata() );
134 else if( name ==
"pubsub#collection" )
135 m_collection = (*ith)->cdata();
193 Tag* child =
new Tag( event, util::lookup( m_type, eventTypeValues ) );
201 item =
new Tag( child,
"node",
"id", m_node );
218 if( m_itemOperations )
222 ItemOperationList::const_iterator itt = m_itemOperations->begin();
223 for( ; itt != m_itemOperations->end(); ++itt )
238 child->
addAttribute(
"subscription", m_subscription ?
"subscribed" :
"none" );
247 if( m_subscriptionIDs || !m_collection.empty() )
249 Tag* headers =
new Tag( event,
"headers",
XMLNS,
"http://jabber.org/protocol/shim" );
251 if( m_subscriptionIDs )
253 StringList::const_iterator it = m_subscriptionIDs->begin();
254 for( ; it != m_subscriptionIDs->end(); ++it )
255 (
new Tag( headers,
"header",
"name",
"pubsub#subid" ))->setCData( (*it) );
258 if( !m_collection.empty() )
259 (
new Tag( headers,
"header",
"name",
"pubsub#collection" ))->setCData( m_collection );
268 e->m_subscriptionIDs = m_subscriptionIDs ?
new StringList( *m_subscriptionIDs ) : 0;
269 e->m_config = m_config ? m_config->
clone() : 0;
270 if( m_itemOperations )
273 ItemOperationList::const_iterator it = m_itemOperations->begin();
274 for( ; it != m_itemOperations->end(); ++it )
275 e->m_itemOperations->push_back(
new ItemOperation( *(*it) ) );
278 e->m_itemOperations = 0;
280 e->m_collection = m_collection;