14 #include "siprofileft.h"
16 #include "clientbase.h"
17 #include "siprofilefthandler.h"
18 #include "simanager.h"
20 #include "inbandbytestream.h"
22 #include "socks5bytestream.h"
23 #include "socks5bytestreammanager.h"
33 : m_parent( parent ), m_manager( manager ), m_handler( sipfth ),
34 m_socks5Manager( s5Manager ), m_delManager( false ),
35 m_delS5Manager( false )
45 if( !m_socks5Manager )
48 m_delS5Manager =
true;
59 if( m_socks5Manager && m_delS5Manager )
60 delete m_socks5Manager;
64 const std::string& hash,
const std::string& desc,
65 const std::string& date,
const std::string& mimetype,
66 int streamTypes,
const JID& from,
67 const std::string& sid )
69 if( name.empty() || size <= 0 || !m_manager )
80 new Tag( file,
"desc", desc );
89 sm.insert( std::make_pair(
"ibb",
XMLNS_IBB ) );
103 if( m_id2sid.find( sid ) == m_id2sid.end() )
106 const std::string&
id = m_id2sid[sid];
121 from ? from : m_parent->
jid(), sid );
133 m_manager->
acceptSI( to,
id, 0, feature, from );
137 const std::string& text )
139 if( m_id2sid.find( sid ) == m_id2sid.end() || !m_manager )
142 m_manager->
declineSI( to, m_id2sid[sid], reason, text );
150 m_socks5Manager->
dispose( static_cast<SOCKS5Bytestream*>( bs ) );
161 if( m_id2sid.find( bs->
sid() ) == m_id2sid.end() || !m_manager )
172 if( m_socks5Manager )
178 if( m_socks5Manager )
183 const SIManager::SI& si )
193 const std::string& mt = si.mimetype();
204 StringMultiMap::const_iterator it = options.begin();
205 for( ; it != options.end(); ++it )
217 const std::string& sid = si.id();
219 m_handler->
handleFTRequest( from, to, sid, si.tag1()->findAttribute(
"name" ),
220 atol( si.tag1()->findAttribute(
"size" ).c_str() ),
221 si.tag1()->findAttribute(
"hash" ),
222 si.tag1()->findAttribute(
"date" ),
223 mt.empty() ?
"binary/octet-stream" : mt,
229 const SIManager::SI& si )
248 to ? to : m_parent->
jid(), from, sid );
257 const std::string&
id = m_parent->
getID();
263 m_parent->
send( iq,
this, OOBSent );
virtual void handleIncomingBytestreamRequest(const std::string &sid, const JID &from)
const std::string & sid() const
void removeProfile(const std::string &profile)
void setStreamHosts(StreamHostList hosts)
virtual void handleSIRequestResult(const JID &from, const JID &to, const std::string &sid, const SIManager::SI &si)
const std::string XMLNS_SI_FT
An abstract base class to handle file transfer (FT) requests.
std::multimap< std::string, std::string > StringMultiMap
An implementation of a single In-Band Bytestream (XEP-0047).
An abstraction of an IQ stanza.
virtual void handleOutgoingBytestream(Bytestream *bs)
void addExtension(const StanzaExtension *se)
void declineSI(const JID &to, const std::string &id, SIError reason, const std::string &text=EmptyString)
void cancel(Bytestream *bs)
void acceptSOCKS5Bytestream(const std::string &sid)
const std::string XMLNS_IQ_OOB
void declineFT(const JID &to, const std::string &sid, SIManager::SIError reason, const std::string &text=EmptyString)
void acceptFT(const JID &to, const std::string &sid, StreamType type=FTTypeS5B, const JID &from=JID())
const std::string XMLNS_IBB
virtual void handleFTBytestream(Bytestream *bs)=0
virtual void handleFTRequest(const JID &from, const JID &to, const std::string &sid, const std::string &name, long size, const std::string &hash, const std::string &date, const std::string &mimetype, const std::string &desc, int stypes)=0
An SOCKS5BytestreamManager dispatches SOCKS5 Bytestreams.
virtual void handleIqID(const IQ &iq, int context)
std::list< StreamHost > StreamHostList
void setFrom(const JID &from)
void addChild(Tag *child)
void registerProfile(const std::string &profile, SIProfileHandler *sih)
const std::string XMLNS_X_DATA
SIProfileFT(ClientBase *parent, SIProfileFTHandler *sipfth, SIManager *manager=0, SOCKS5BytestreamManager *s5Manager=0)
void addStreamHost(const JID &jid, const std::string &host, int port)
virtual void handleFTRequestError(const IQ &iq, const std::string &sid)=0
const std::string requestSI(SIHandler *sih, const JID &to, const std::string &profile, Tag *child1, Tag *child2=0, const std::string &mimetype="binary/octet-stream", const JID &from=JID(), const std::string &sid=EmptyString)
void setStreamHosts(StreamHostList hosts)
void rejectSOCKS5Bytestream(const std::string &sid, StanzaError reason=StanzaErrorNotAcceptable)
The namespace for the gloox library.
bool dispose(SOCKS5Bytestream *s5b)
This class manages streams initiated using XEP-0095.
void acceptSI(const JID &to, const std::string &id, Tag *child1, Tag *child2=0, const JID &from=JID())
virtual void handleIncomingBytestream(Bytestream *bs)
const std::string cdata() const
void addStreamHost(const JID &jid, const std::string &host, int port)
bool addAttribute(Attribute *attr)
This is an abstraction of a jabber:x:oob namespace element or a jabber:iq:oob namespace element as sp...
const std::string XMLNS_BYTESTREAMS
An abstraction of a single bytestream.
virtual void handleBytestreamError(const IQ &iq, const std::string &sid)
virtual void handleSIRequestError(const IQ &iq, const std::string &sid)
const std::string getID()
const std::string XMLNS_FEATURE_NEG
virtual const std::string handleOOBRequestResult(const JID &from, const JID &to, const std::string &sid)=0
const std::string requestFT(const JID &to, const std::string &name, long size, const std::string &hash=EmptyString, const std::string &desc=EmptyString, const std::string &date=EmptyString, const std::string &mimetype=EmptyString, int streamTypes=FTTypeAll, const JID &from=JID(), const std::string &sid=EmptyString)
virtual void handleSIRequest(const JID &from, const JID &to, const std::string &id, const SIManager::SI &si)
bool requestSOCKS5Bytestream(const JID &to, S5BMode mode, const std::string &sid=EmptyString, const JID &from=JID())
Tag * findChild(const std::string &name) const
const std::string EmptyString
This is the common base class for a Jabber/XMPP Client and a Jabber Component.
This is an abstraction of an XML element.
void dispose(Bytestream *bs)