14 #include "inbandbytestreammanager.h"
15 #include "inbandbytestreamhandler.h"
16 #include "inbandbytestream.h"
17 #include "clientbase.h"
24 : m_parent( parent ), m_inbandBytestreamHandler( 0 ), m_syncInbandBytestreams( true ),
43 IBBMap::iterator it = m_ibbMap.begin();
44 for( ; it != m_ibbMap.end(); ++it )
51 const std::string& sid )
53 if( !m_parent || !ibbh )
56 const std::string& msid = sid.empty() ? m_parent->
getID() : sid;
57 const std::string&
id = m_parent->
getID();
62 Tag *o =
new Tag( iq,
"open" );
70 m_trackMap[id] = item;
71 m_parent->
trackID(
this,
id, IBBOpenStream );
87 if( !m_inbandBytestreamHandler )
90 if( !m_syncInbandBytestreams )
94 item.from = stanza->
from();
95 item.id = stanza->
id();
96 m_asyncTrackMap[sid] = item;
100 if( m_syncInbandBytestreams && t )
104 else if( m_syncInbandBytestreams && !t )
113 IBBMap::iterator it = m_ibbMap.find( o->
findAttribute(
"sid" ) );
114 if( it != m_ibbMap.end() )
116 (*it).second->closed();
118 Tag *iq =
new Tag(
"iq" );
123 m_parent->
send( iq );
136 if( m_syncInbandBytestreams )
139 AsyncTrackMap::iterator it = m_asyncTrackMap.find( ibb->
sid() );
140 if( it != m_asyncTrackMap.end() )
143 m_asyncTrackMap.erase( it );
149 if( m_syncInbandBytestreams )
152 AsyncTrackMap::iterator it = m_asyncTrackMap.find( ibb->
sid() );
153 if( it != m_asyncTrackMap.end() )
156 m_asyncTrackMap.erase( it );
161 const JID& from,
const std::string&
id )
163 m_ibbMap[ibb->
sid()] = ibb;
164 Tag *iq =
new Tag(
"iq" );
168 m_parent->
send( iq );
172 const JID& from,
const std::string&
id )
175 Tag *iq =
new Tag(
"iq" );
176 iq->addAttribute(
"type",
"error" );
177 iq->addAttribute(
"to", from.full() );
178 iq->addAttribute(
"id",
id );
179 Tag *e =
new Tag( iq,
"error" );
180 e->addAttribute(
"code",
"501" );
181 e->addAttribute(
"type",
"cancel" );
182 Tag *f =
new Tag( e,
"feature-not-implemented" );
184 m_parent->
send( iq );
193 TrackMap::iterator it = m_trackMap.find( stanza->
id() );
194 if( it != m_trackMap.end() )
201 ibb->setSid( (*it).second.sid );
202 ibb->setBlockSize( m_blockSize );
203 m_ibbMap[(*it).second.sid] = ibb;
209 (*it).second.ibbh->handleInBandBytestreamError( stanza->
from(), stanza->
error() );
214 m_trackMap.erase( it );
227 IBBMap::iterator it = m_ibbMap.find( ibb->
sid() );
228 if( it != m_ibbMap.end() )
231 m_ibbMap.erase( it );
241 m_inbandBytestreamHandler = ibbh;
242 m_syncInbandBytestreams = sync;
247 m_inbandBytestreamHandler = 0;